]> git.proxmox.com Git - qemu-server.git/commitdiff
add numa options v3
authorAlexandre Derumier <aderumier@odiso.com>
Wed, 3 Dec 2014 15:23:47 +0000 (16:23 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 4 Dec 2014 12:01:47 +0000 (13:01 +0100)
This enable numa support inside the guest, and share the memory and cores across the sockets numa nodes.

numa: 0|1

example:
-------
sockets:2
cores:2
memory:4096
numa: 1

qemu command line
-----------------
-object memory-backend-ram,size=2048,id=ram-node0
-numa node,nodeid=0,cpus=0-1,memdev=ram-node0
-object memory-backend-ram,size=2048,id=ram-node1
-numa node,nodeid=1,cpus=2-3,memdev=ram-node1

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
PVE/QemuServer.pm

index 5a40944518a6cc4d815cec3eb87099f0560aa37f..16c70d7bcc4c53bec938ccd537de6b2d60b1d757 100644 (file)
@@ -306,6 +306,12 @@ EODESC
        minimum => 1,
        default => 1,
     },
+    numa => {
+       optional => 1,
+       type => 'boolean',
+       description => "Enable/disable Numa.",
+       default => 0,
+    },
     maxcpus => {
        optional => 1,
        type => 'integer',
@@ -2686,8 +2692,29 @@ sub config_to_command {
     # push @$cmd, '-cpu', "$cpu,enforce";
     push @$cmd, '-cpu', $cpu;
 
+    my $memory =  $conf->{memory} || $defaults->{memory};    
+    push @$cmd, '-m', $memory;
+
+    if($conf->{numa}){
+
+       my $numa_memory = ($memory / $sockets)."M";
+
+       for (my $i = 0; $i < $sockets; $i++)  {
+
+           my $cpustart = ($cores * $i);
+           my $cpuend = ($cpustart + $cores - 1) if $cores && $cores > 1;
+           my $cpus = $cpustart;
+           $cpus .= "-$cpuend" if $cpuend;
+
+           push @$cmd, '-object', "memory-backend-ram,size=$numa_memory,id=ram-node$i";
+           push @$cmd, '-numa', "node,nodeid=$i,cpus=$cpus,memdev=ram-node$i";
+       }
+    }
+
     push @$cmd, '-S' if $conf->{freeze};
 
+
+
     # set keyboard layout
     my $kb = $conf->{keyboard} || $defaults->{keyboard};
     push @$cmd, '-k', $kb if $kb;
@@ -2798,8 +2825,6 @@ sub config_to_command {
        push @$devices, '-device', print_drivedevice_full($storecfg, $conf, $vmid, $drive, $bridges);
     });
 
-    push @$cmd, '-m', $conf->{memory} || $defaults->{memory};
-
     for (my $i = 0; $i < $MAX_NETS; $i++) {
          next if !$conf->{"net$i"};
          my $d = parse_net($conf->{"net$i"});