[libvirt] [PATCH 5/5] tests: add qemuxml2argv memfd-memory-numa test
Marc-André Lureau
marcandre.lureau at redhat.com
Wed Sep 12 13:12:29 UTC 2018
Hi
On Wed, Sep 12, 2018 at 4:01 AM, John Ferlan <jferlan at redhat.com> wrote:
>
>
> On 09/11/2018 04:48 AM, Marc-André Lureau wrote:
>> Hi
>>
>> On Tue, Sep 11, 2018 at 2:57 AM, John Ferlan <jferlan at redhat.com> wrote:
>>>
>>>
>>> On 09/07/2018 07:32 AM, marcandre.lureau at redhat.com wrote:
>>>> From: Marc-André Lureau <marcandre.lureau at redhat.com>
>>>>
>>>> Check anonymous memory is backed by memfd if qemu is capable.
>>>>
>>>> Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
>>>> ---
>>>> tests/qemuxml2argvdata/memfd-memory-numa.args | 28 +++++++++++++++
>>>> tests/qemuxml2argvdata/memfd-memory-numa.xml | 36 +++++++++++++++++++
>>>> tests/qemuxml2argvtest.c | 5 +++
>>>> 3 files changed, 69 insertions(+)
>>>> create mode 100644 tests/qemuxml2argvdata/memfd-memory-numa.args
>>>> create mode 100644 tests/qemuxml2argvdata/memfd-memory-numa.xml
>>>>
>>>> diff --git a/tests/qemuxml2argvdata/memfd-memory-numa.args b/tests/qemuxml2argvdata/memfd-memory-numa.args
>>>> new file mode 100644
>>>> index 0000000000..b26c476196
>>>> --- /dev/null
>>>> +++ b/tests/qemuxml2argvdata/memfd-memory-numa.args
>>>> @@ -0,0 +1,28 @@
>>>> +LC_ALL=C \
>>>> +PATH=/bin \
>>>> +HOME=/home/test \
>>>> +USER=test \
>>>> +LOGNAME=test \
>>>> +QEMU_AUDIO_DRV=none \
>>>> +/usr/bin/qemu-system-x86_64 \
>>>> +-name instance-00000092 \
>>>> +-S \
>>>> +-machine pc-i440fx-wily,accel=kvm,usb=off,dump-guest-core=off \
>>>> +-m 14336 \
>>>> +-mem-prealloc \
>>>> +-smp 20,sockets=1,cores=8,threads=1 \
>>>> +-object memory-backend-memfd,id=ram-node0,hugetlb=yes,hugetlbsize=2097152,share=yes,\
>>>> +size=15032385536,host-nodes=3,policy=preferred \
>>>
>>> Another syntax-check error here, needed to move the "share=yes," to the
>>> subsequent line.
>>>
>>
>> ok
>>
>>>> +-numa node,nodeid=0,cpus=0-7,memdev=ram-node0 \
>>>> +-uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \
>>>> +-display none \
>>>> +-no-user-config \
>>>> +-nodefaults \
>>>> +-chardev socket,id=charmonitor,\
>>>> +path=/tmp/lib/domain--1-instance-00000092/monitor.sock,server,nowait \
>>>> +-mon chardev=charmonitor,id=monitor,mode=control \
>>>> +-rtc base=utc \
>>>> +-no-shutdown \
>>>> +-no-acpi \
>>>> +-usb \
>>>> +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
>>>> diff --git a/tests/qemuxml2argvdata/memfd-memory-numa.xml b/tests/qemuxml2argvdata/memfd-memory-numa.xml
>>>> new file mode 100644
>>>> index 0000000000..abe93e8c4b
>>>> --- /dev/null
>>>> +++ b/tests/qemuxml2argvdata/memfd-memory-numa.xml
>>>> @@ -0,0 +1,36 @@
>>>> + <domain type='kvm' id='56'>
>>>> + <name>instance-00000092</name>
>>>> + <uuid>126f2720-6f8e-45ab-a886-ec9277079a67</uuid>
>>>> + <memory unit='KiB'>14680064</memory>
>>>> + <currentMemory unit='KiB'>14680064</currentMemory>
>>>> + <memoryBacking>
>>>> + <hugepages>
>>>> + <page size="2" unit="M"/>
>>>> + </hugepages>
>>>> + <source type='anonymous'/>
>>>> + <access mode='shared'/>
>>>> + <allocation mode='immediate'/>
>>>> + </memoryBacking>
>>>> + <numatune>
>>>> + <memnode cellid='0' mode='preferred' nodeset='3'/>
>>>> + </numatune>
>>>> + <vcpu placement='static'>20</vcpu>
>>>> + <os>
>>>> + <type arch='x86_64' machine='pc-i440fx-wily'>hvm</type>>> + <boot dev='hd'/>
>>>> + </os>
>>>> + <cpu>
>>>> + <topology sockets='1' cores='8' threads='1'/>
>>>> + <numa>
>>>> + <cell id='0' cpus='0-7' memory='14680064' unit='KiB'/>
>>>> + </numa>
>>>> + </cpu>
>>>> + <clock offset='utc'/>
>>>> + <on_poweroff>destroy</on_poweroff>
>>>> + <on_reboot>restart</on_reboot>
>>>> + <on_crash>destroy</on_crash>
>>>> + <devices>
>>>> + <emulator>/usr/bin/qemu-system-x86_64</emulator>
>>>> + <memballoon model='virtio'/>
>>>> + </devices>
>>>> + </domain>
>>>> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
>>>> index 35df63b2ac..76008a8d07 100644
>>>> --- a/tests/qemuxml2argvtest.c
>>>> +++ b/tests/qemuxml2argvtest.c
>>>> @@ -2928,6 +2928,11 @@ mymain(void)
>>>> DO_TEST("fd-memory-no-numa-topology", QEMU_CAPS_OBJECT_MEMORY_FILE,
>>>> QEMU_CAPS_KVM);
>>>>
>>>> + DO_TEST("memfd-memory-numa",
>>>> + QEMU_CAPS_OBJECT_MEMORY_MEMFD,
>>>> + QEMU_CAPS_OBJECT_MEMORY_MEMFD_HUGETLB,
>>>> + QEMU_CAPS_KVM);
>>>> +
>>>
>>> Theoretically, if we have 3.1 capabilties to test against, then this
>>> would use a DO_TEST_CAPS_LATEST, while a "pre-3.1" would still be using
>>> -ramfd, right? That is, using DO_TEST_CAPS_VER w/ "3.0.0" would
>>> generate different results.
>>>
>>> I'm conflicted if we should wait for someone to generate the 3.1 caps or
>>> not. For whatever reason, when I post them they're not quite right for
>>> someone else's tastes...
>>>
>>> Let's see if anyone else has strong feelings one way or another.
>>>
>>
>> -memfd is available since 2.12. After patch 1 & 2 are applied, we
>> should probably switch to use DO_TEST_CAPS_LATEST.
>>
>
> hrmph - tried using CAPS_LATEST, and got the error
>
> "CPU topology doesn't match maximum vcpu count"
>
> well *that's* helpful /-|...
>
> The only libvirt test that cares about it currently is
> cpu-hotplug-startup and yes, the maxvcpus matches the cpu topology
> calculation...
>
> So, as long as I change vcpu count from 20 to 8, rename the
> tests/qemuxml2argvdata/memfd-memory-numa.args to
> memfd-memory-numa.x86_64-latest.args, and regenerate the output to:
>
> LC_ALL=C \
> PATH=/bin \
> HOME=/home/test \
> USER=test \
> LOGNAME=test \
> QEMU_AUDIO_DRV=none \
> /usr/bin/qemu-system-x86_64 \
> -name guest=instance-00000092,debug-threads=on \
> -S \
> -object secret,id=masterKey0,format=raw,\
> file=/tmp/lib/domain--1-instance-00000092/master-key.aes \
> -machine pc-i440fx-wily,accel=kvm,usb=off,dump-guest-core=off \
> -m 14336 \
> -mem-prealloc \
> -realtime mlock=off \
> -smp 8,sockets=1,cores=8,threads=1 \
> -object memory-backend-memfd,id=ram-node0,hugetlb=yes,hugetlbsize=2097152,\
> share=yes,size=15032385536,host-nodes=3,policy=preferred \
> -numa node,nodeid=0,cpus=0-7,memdev=ram-node0 \
> -uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \
> -display none \
> -no-user-config \
> -nodefaults \
> -chardev socket,id=charmonitor,fd=1729,server,nowait \
> -mon chardev=charmonitor,id=monitor,mode=control \
> -rtc base=utc \
> -no-shutdown \
> -no-acpi \
> -boot strict=on \
> -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
> -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
> -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
> resourcecontrol=deny \
> -msg timestamp=on
>
> Then, the test is happy. The memory-backend-memfd object doesn't change.
ok
>
> So all that's "left":
>
> 1. "Add" a check in qemuDomainABIStabilityCheck to ensure we're not
> changing from memory-backend-ram to memory-backend-memfd. We already
> check that "(src->mem.source != dst->mem.source)" - so we know we're
> already anonymous or not.
>
> Any suggestions? If source is anonymous, then what? I think we can use
> the qemuDomainObjPrivatePtr in some way to determine that we were
> started with -memfd (or not started that way).
No idea how we could save that information across various restarts /
version changes.
Tbh, I would try to migrate, and let qemu fail if something is
incompatible (such as incompatible memory backends or memory region
name mismatch). See also my qemu series "[PATCH 0/9] hostmem-ram: use
whole path for region name with >= 3.1". It feels like libvirt
duplicates some qemu logic/error otherwise.
>
> 2. Get the patches I posted today to cleanup/move the memory backing
> checks from domain_conf to qemu_domain:
>
> https://www.redhat.com/archives/libvir-list/2018-September/msg00463.html
>
> reviewed and pushed so that patch4 can use the qemu_domain API to alter
> it's hugepages check.
done
feel free to update & resend my series, or else I will rebase and resend it
thanks
>
> John
>
>> Before 2.12 (or if the capabilities are not exposed by the host qemu)
>> the argv will use -file. This is already covered by existing tests,
>> like hugepages-shared.
>>
>> thanks
>>
>>> John
>>>
>>>> DO_TEST("cpu-check-none", QEMU_CAPS_KVM);
>>>> DO_TEST("cpu-check-partial", QEMU_CAPS_KVM);
>>>> DO_TEST("cpu-check-full", QEMU_CAPS_KVM);
>>>>
More information about the libvir-list
mailing list