@@ -130,6 +130,7 @@ extern QEMUClockType rtc_clock;
#define MAX_NODES 64
#define MAX_CPUMASK_BITS 255
extern int nb_numa_nodes;
+extern int nb_numa_mem_nodes;
typedef struct node_info {
uint64_t node_mem;
DECLARE_BITMAP(node_cpu, MAX_CPUMASK_BITS);
@@ -74,6 +74,31 @@ static int numa_node_parse(NumaNodeOptions *opts)
return 0;
}
+static int numa_mem_parse(NumaMemOptions *opts)
+{
+ uint16_t nodenr;
+ uint64_t mem_size;
+
+ if (opts->has_nodeid) {
+ nodenr = opts->nodeid;
+ } else {
+ nodenr = nb_numa_mem_nodes;
+ }
+
+ if (nodenr >= MAX_NODES) {
+ fprintf(stderr, "qemu: Max number of NUMA nodes reached: %"
+ PRIu16 "\n", nodenr);
+ return -1;
+ }
+
+ if (opts->has_size) {
+ mem_size = opts->size;
+ numa_info[nodenr].node_mem = mem_size;
+ }
+
+ return 0;
+}
+
int numa_init_func(QemuOpts *opts, void *opaque)
{
NumaOptions *object = NULL;
@@ -101,6 +126,13 @@ int numa_init_func(QemuOpts *opts, void *opaque)
}
nb_numa_nodes++;
break;
+ case NUMA_OPTIONS_KIND_MEM:
+ ret = numa_mem_parse(object->mem);
+ if (ret) {
+ goto error;
+ }
+ nb_numa_mem_nodes++;
+ break;
default:
fprintf(stderr, "qemu: Invalid NUMA options type.\n");
ret = -1;
@@ -119,6 +151,10 @@ error:
void set_numa_nodes(void)
{
+ if (nb_numa_mem_nodes > nb_numa_nodes) {
+ nb_numa_nodes = nb_numa_mem_nodes;
+ }
+
if (nb_numa_nodes > 0) {
int i;
@@ -95,11 +95,13 @@ specifies the maximum number of hotpluggable CPUs.
ETEXI
DEF("numa", HAS_ARG, QEMU_OPTION_numa,
- "-numa node[,mem=size][,cpus=cpu[-cpu]][,nodeid=node]\n", QEMU_ARCH_ALL)
+ "-numa node[,nodeid=node][,cpus=cpu[-cpu]]\n"
+ "-numa mem[,nodeid=node][,size=size]\n"
+ , QEMU_ARCH_ALL)
STEXI
@item -numa @var{opts}
@findex -numa
-Simulate a multi node NUMA system. If mem and cpus are omitted, resources
+Simulate a multi node NUMA system. If @var{size} and @var{cpus} are omitted, resources
are split equally.
ETEXI
@@ -250,6 +250,7 @@ static QTAILQ_HEAD(, FWBootEntry) fw_boot_order =
QTAILQ_HEAD_INITIALIZER(fw_boot_order);
int nb_numa_nodes;
+int nb_numa_mem_nodes;
NodeInfo numa_info[MAX_NODES];
uint8_t qemu_uuid[16];
@@ -2890,6 +2891,7 @@ int main(int argc, char **argv, char **envp)
}
nb_numa_nodes = 0;
+ nb_numa_mem_nodes = 0;
nb_nics = 0;
bdrv_init_with_whitelist();