]> xenbits.xensource.com Git - libvirt.git/commitdiff
numad: Copy 'placement' of <numatune> to <vcpu> by default
authorOsier Yang <jyang@redhat.com>
Tue, 8 May 2012 16:04:35 +0000 (00:04 +0800)
committerEric Blake <eblake@redhat.com>
Tue, 8 May 2012 22:57:36 +0000 (16:57 -0600)
With this patch, one can also fully drive numad by:

  <vcpu>2</vcpu>
  <numatune>
    <memory placement='auto'/>
  </numatune>

New tests are added.

12 files changed:
src/conf/domain_conf.c
tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-cpuset.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-cpuset.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-no-cpuset-and-placement.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-no-cpuset-and-placement.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-numad-static-memory-auto-vcpu.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-numad-static-memory-auto-vcpu.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-numatune-memory.xml
tests/qemuxml2argvtest.c
tests/qemuxml2xmloutdata/qemuxml2xmlout-numad-auto-memory-vcpu-cpuset.xml [new file with mode: 0644]
tests/qemuxml2xmloutdata/qemuxml2xmlout-numad-auto-memory-vcpu-no-cpuset-and-placement.xml [new file with mode: 0644]
tests/qemuxml2xmltest.c

index f684ea16495cec0671785a569fa1762e942e3eee..cd6d73b4c78d4d73092c21133182211de0f07cfd 100644 (file)
@@ -8124,6 +8124,16 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
                     if (placement_mode == VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_AUTO)
                         VIR_FREE(def->numatune.memory.nodemask);
 
+                    /* Copy 'placement' of <numatune> to <vcpu> if its 'placement'
+                     * is not specified and 'placement' of <numatune> is specified.
+                     */
+                    if (def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_DEFAULT &&
+                        placement_mode != VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_DEFAULT) {
+                        if (placement_mode == VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_STATIC)
+                            def->placement_mode = VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC;
+                        else
+                            def->placement_mode = VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO;
+                    }
                     def->numatune.memory.placement_mode = placement_mode;
                 } else {
                     virDomainReportError(VIR_ERR_XML_ERROR,
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-cpuset.args b/tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-cpuset.args
new file mode 100644 (file)
index 0000000..23bcb70
--- /dev/null
@@ -0,0 +1,4 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
+pc -m 214 -smp 2 -nographic -monitor \
+unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda \
+/dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-cpuset.xml b/tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-cpuset.xml
new file mode 100644 (file)
index 0000000..e2507e4
--- /dev/null
@@ -0,0 +1,31 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu cpuset='0-1'>2</vcpu>
+  <numatune>
+    <memory mode='interleave' placement='auto'/>
+  </numatune>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <cpu>
+    <topology sockets='2' cores='1' threads='1'/>
+  </cpu>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='ide' index='0'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-no-cpuset-and-placement.args b/tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-no-cpuset-and-placement.args
new file mode 100644 (file)
index 0000000..23bcb70
--- /dev/null
@@ -0,0 +1,4 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
+pc -m 214 -smp 2 -nographic -monitor \
+unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda \
+/dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-no-cpuset-and-placement.xml b/tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-no-cpuset-and-placement.xml
new file mode 100644 (file)
index 0000000..2988be4
--- /dev/null
@@ -0,0 +1,31 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu>2</vcpu>
+  <numatune>
+    <memory mode='interleave' placement='auto'/>
+  </numatune>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <cpu>
+    <topology sockets='2' cores='1' threads='1'/>
+  </cpu>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='ide' index='0'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-numad-static-memory-auto-vcpu.args b/tests/qemuxml2argvdata/qemuxml2argv-numad-static-memory-auto-vcpu.args
new file mode 100644 (file)
index 0000000..23bcb70
--- /dev/null
@@ -0,0 +1,4 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
+pc -m 214 -smp 2 -nographic -monitor \
+unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda \
+/dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-numad-static-memory-auto-vcpu.xml b/tests/qemuxml2argvdata/qemuxml2argv-numad-static-memory-auto-vcpu.xml
new file mode 100644 (file)
index 0000000..e2507e4
--- /dev/null
@@ -0,0 +1,31 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu cpuset='0-1'>2</vcpu>
+  <numatune>
+    <memory mode='interleave' placement='auto'/>
+  </numatune>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <cpu>
+    <topology sockets='2' cores='1' threads='1'/>
+  </cpu>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='ide' index='0'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
index e91307c3c3892091129ffb7f8f181266ebb014fc..bcc97392325041048ba32be5283e0eede5222007 100644 (file)
@@ -3,7 +3,7 @@
   <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
   <memory unit='KiB'>219136</memory>
   <currentMemory unit='KiB'>219136</currentMemory>
-  <vcpu>2</vcpu>
+  <vcpu cpuset='0-1'>2</vcpu>
   <numatune>
     <memory mode="strict" nodeset="0-5,^4"/>
   </numatune>
index 40471d48098b08cc589b01b389aa321df1b84349..c0734291b0b52a8ae9865de515b621243f2d0700 100644 (file)
@@ -740,6 +740,9 @@ mymain(void)
     DO_TEST("numatune-memory", false, NONE);
     DO_TEST("numad", false, NONE);
     DO_TEST("numad-auto-vcpu-static-numatune", false, NONE);
+    DO_TEST("numad-auto-memory-vcpu-cpuset", false, NONE);
+    DO_TEST("numad-auto-memory-vcpu-no-cpuset-and-placement", false, NONE);
+    DO_TEST("numad-static-memory-auto-vcpu", false, NONE);
     DO_TEST("blkdeviotune", false, QEMU_CAPS_NAME, QEMU_CAPS_DEVICE,
             QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_IOTUNE);
 
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-numad-auto-memory-vcpu-cpuset.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-numad-auto-memory-vcpu-cpuset.xml
new file mode 100644 (file)
index 0000000..ffca2a9
--- /dev/null
@@ -0,0 +1,32 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu placement='static' cpuset='0-1'>2</vcpu>
+  <numatune>
+    <memory mode='interleave' placement='auto'/>
+  </numatune>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <cpu>
+    <topology sockets='2' cores='1' threads='1'/>
+  </cpu>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='ide' index='0'/>
+    <controller type='usb' index='0'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-numad-auto-memory-vcpu-no-cpuset-and-placement.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-numad-auto-memory-vcpu-no-cpuset-and-placement.xml
new file mode 100644 (file)
index 0000000..28ec59f
--- /dev/null
@@ -0,0 +1,32 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu placement='auto'>2</vcpu>
+  <numatune>
+    <memory mode='interleave' placement='auto'/>
+  </numatune>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <cpu>
+    <topology sockets='2' cores='1' threads='1'/>
+  </cpu>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='ide' index='0'/>
+    <controller type='usb' index='0'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
index 256eed7e39463c4f72e494897dcb3c8cc8eba6f4..5b6a216bb284033158aba51fd61cdf04c089f368 100644 (file)
@@ -230,6 +230,8 @@ mymain(void)
     DO_TEST_DIFFERENT("graphics-listen-network2");
     DO_TEST_DIFFERENT("graphics-spice-timeout");
     DO_TEST_DIFFERENT("numad-auto-vcpu-no-numatune");
+    DO_TEST_DIFFERENT("numad-auto-memory-vcpu-no-cpuset-and-placement");
+    DO_TEST_DIFFERENT("numad-auto-memory-vcpu-cpuset");
 
     DO_TEST_DIFFERENT("metadata");