With this patch, one can also fully drive numad by: <vcpu>2</vcpu> <numatune> <memory placement='auto'/> </numatune> New tests are added, and s/"/'/ on tests (*.xml) added in previous patch. --- docs/formatdomain.html.in | 16 +++++----- src/conf/domain_conf.c | 12 +++++++- ...qemuxml2argv-numad-auto-memory-vcpu-cpuset.args | 4 ++ .../qemuxml2argv-numad-auto-memory-vcpu-cpuset.xml | 31 +++++++++++++++++++ ...d-auto-memory-vcpu-no-cpuset-and-placement.args | 4 ++ ...ad-auto-memory-vcpu-no-cpuset-and-placement.xml | 31 +++++++++++++++++++ ...emuxml2argv-numad-auto-vcpu-static-numatune.xml | 2 +- ...qemuxml2argv-numad-static-memory-auto-vcpu.args | 4 ++ .../qemuxml2argv-numad-static-memory-auto-vcpu.xml | 31 +++++++++++++++++++ .../qemuxml2argv-numatune-memory.xml | 2 +- tests/qemuxml2argvtest.c | 3 ++ ...emuxml2xmlout-numad-auto-memory-vcpu-cpuset.xml | 32 ++++++++++++++++++++ ...ad-auto-memory-vcpu-no-cpuset-and-placement.xml | 32 ++++++++++++++++++++ tests/qemuxml2xmltest.c | 2 + 14 files changed, 195 insertions(+), 11 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-cpuset.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-cpuset.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-no-cpuset-and-placement.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-no-cpuset-and-placement.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-numad-static-memory-auto-vcpu.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-numad-static-memory-auto-vcpu.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-numad-auto-memory-vcpu-cpuset.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-numad-auto-memory-vcpu-no-cpuset-and-placement.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 6049d99..c3412f4 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -362,14 +362,14 @@ 0.9.11 (QEMU and KVM only)</span>, the optional attribute <code>placement</code> can be used to indicate the CPU placement mode for domain process, its value can be either "static" or - "auto", defaults to "static" if <code>cpuset</code> is specified, - "auto" indicates the domain process will be pinned to the advisory - nodeset from querying numad, and the value of attribute - <code>cpuset</code> will be ignored if it's specified. If both - <code>cpuset</code> and <code>placement</code> are not specified, - or if <code>placement</code> is "static", but no <code>cpuset</code> - is specified, the domain process will be pinned to all the - available physical CPUs. + "auto", defaults to <code>placement</code> of <code>numatune</code>, + or "static" if <code>cpuset</code> is specified. "auto" indicates + the domain process will be pinned to the advisory nodeset from querying + numad, and the value of attribute <code>cpuset</code> will be ignored + if it's specified. If both <code>cpuset</code> and <code>placement</code> + are not specified, or if <code>placement</code> is "static", but no + <code>cpuset</code> is specified, the domain process will be pinned to + all the available physical CPUs. </dd> </dl> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e9c9db7..14b94d3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7958,9 +7958,9 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, if (virDomainCpuSetParse(set, 0, def->cpumask, def->cpumasklen) < 0) goto error; - VIR_FREE(tmp); if (def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_DEFAULT) def->placement_mode = VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC; + VIR_FREE(tmp); } } @@ -8107,6 +8107,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 0000000..23bcb70 --- /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 0000000..e2507e4 --- /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 0000000..23bcb70 --- /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 0000000..2988be4 --- /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-auto-vcpu-static-numatune.xml b/tests/qemuxml2argvdata/qemuxml2argv-numad-auto-vcpu-static-numatune.xml index 0577f86..c5757f4 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-numad-auto-vcpu-static-numatune.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-numad-auto-vcpu-static-numatune.xml @@ -5,7 +5,7 @@ <currentMemory unit='KiB'>219136</currentMemory> <vcpu placement='auto'>2</vcpu> <numatune> - <memory mode="interleave" nodeset='0'/> + <memory mode='interleave' nodeset='0'/> </numatune> <os> <type arch='i686' machine='pc'>hvm</type> 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 0000000..23bcb70 --- /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 0000000..e2507e4 --- /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 e91307c..bcc9739 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 29369c6..03cc5fc 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -734,6 +734,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 0000000..ffca2a9 --- /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 0000000..28ec59f --- /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 256eed7..5b6a216 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"); -- 1.7.7.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list