aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOsier Yang <jyang@redhat.com>2012-05-09 00:04:35 +0800
committerEric Blake <eblake@redhat.com>2012-05-08 16:57:36 -0600
commit8d26a7fd4e3f1f3410d9bd5eef071351190068ca (patch)
tree120cd0bdf2130ab154e2945121ba93a16a687666
parentnumad: Set memory policy from numad advisory nodeset (diff)
downloadlibvirt-8d26a7fd4e3f1f3410d9bd5eef071351190068ca.tar.gz
libvirt-8d26a7fd4e3f1f3410d9bd5eef071351190068ca.tar.bz2
libvirt-8d26a7fd4e3f1f3410d9bd5eef071351190068ca.zip
numad: Copy 'placement' of <numatune> to <vcpu> by default
With this patch, one can also fully drive numad by: <vcpu>2</vcpu> <numatune> <memory placement='auto'/> </numatune> New tests are added.
-rw-r--r--src/conf/domain_conf.c10
-rw-r--r--tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-cpuset.args4
-rw-r--r--tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-cpuset.xml31
-rw-r--r--tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-no-cpuset-and-placement.args4
-rw-r--r--tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-no-cpuset-and-placement.xml31
-rw-r--r--tests/qemuxml2argvdata/qemuxml2argv-numad-static-memory-auto-vcpu.args4
-rw-r--r--tests/qemuxml2argvdata/qemuxml2argv-numad-static-memory-auto-vcpu.xml31
-rw-r--r--tests/qemuxml2argvdata/qemuxml2argv-numatune-memory.xml2
-rw-r--r--tests/qemuxml2argvtest.c3
-rw-r--r--tests/qemuxml2xmloutdata/qemuxml2xmlout-numad-auto-memory-vcpu-cpuset.xml32
-rw-r--r--tests/qemuxml2xmloutdata/qemuxml2xmlout-numad-auto-memory-vcpu-no-cpuset-and-placement.xml32
-rw-r--r--tests/qemuxml2xmltest.c2
12 files changed, 185 insertions, 1 deletions
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f684ea164..cd6d73b4c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -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
index 000000000..23bcb7000
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-cpuset.args
@@ -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
index 000000000..e2507e4b7
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-cpuset.xml
@@ -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
index 000000000..23bcb7000
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-no-cpuset-and-placement.args
@@ -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
index 000000000..2988be468
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-no-cpuset-and-placement.xml
@@ -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
index 000000000..23bcb7000
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-numad-static-memory-auto-vcpu.args
@@ -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
index 000000000..e2507e4b7
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-numad-static-memory-auto-vcpu.xml
@@ -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-numatune-memory.xml b/tests/qemuxml2argvdata/qemuxml2argv-numatune-memory.xml
index e91307c3c..bcc973923 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-numatune-memory.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-numatune-memory.xml
@@ -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>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 40471d480..c0734291b 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -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
index 000000000..ffca2a919
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-numad-auto-memory-vcpu-cpuset.xml
@@ -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
index 000000000..28ec59fde
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-numad-auto-memory-vcpu-no-cpuset-and-placement.xml
@@ -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>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 256eed7e3..5b6a216bb 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -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");