[libvirt] [RFC v3 3/4] nvdimm: update qemu command-line generating for NVDIMM memory
Luyao Zhong
luyao.zhong at intel.com
Fri Dec 14 08:31:07 UTC 2018
On 2018/12/14 上午9:10, John Ferlan wrote:
>
>
> On 12/12/18 7:53 AM, Luyao Zhong wrote:
>> According to the result parsing from xml, add corresponding properties
>> into QEMU command line, including 'align', 'pmem' and 'unarmed'.
>>
>> Signed-off-by: Luyao Zhong <luyao.zhong at intel.com>
>> ---
>> src/qemu/qemu_command.c | 32 ++++++++++++++++++++++
>> .../memory-hotplug-nvdimm-align.args | 31 +++++++++++++++++++++
>> .../memory-hotplug-nvdimm-pmem.args | 31 +++++++++++++++++++++
>> .../memory-hotplug-nvdimm-unarmed.args | 31 +++++++++++++++++++++
>> tests/qemuxml2argvtest.c | 11 ++++++++
>> 5 files changed, 136 insertions(+)
>> create mode 100644 tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.args
>> create mode 100644 tests/qemuxml2argvdata/memory-hotplug-nvdimm-pmem.args
>> create mode 100644 tests/qemuxml2argvdata/memory-hotplug-nvdimm-unarmed.args
>>
>
> Again 3 different changes.... and of course using the *CAPS_LATEST* for
> each like I described in the response to the cover.
>
Got it.
>> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
>> index 32ed83f..73600b7 100644
>> --- a/src/qemu/qemu_command.c
>> +++ b/src/qemu/qemu_command.c
>> @@ -3400,6 +3400,34 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
>> if (virJSONValueObjectAdd(props, "U:size", mem->size * 1024, NULL) < 0)
>> goto cleanup;
>>
>> + if (mem->alignsize) {
>> + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE_ALIGN)) {
>
> A recent change passes priv, so use priv->qemuCaps
>
Got it.
>> + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
>> + _("align property is not available "
>> + "with this QEMU binary"));
>> + goto cleanup;
>> + }
>> + if (virJSONValueObjectAdd(props,
>> + "U:align",
>> + mem->alignsize * 1024,
>> + NULL) < 0)
>> + goto cleanup;
>> + }
>> +
>> + if (mem->nvdimmPmem) {
>> + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE_PMEM)) {
>
> same here priv->qemuCaps
>
Got it.
> John
>
Thank you for your comments.
Luyao Zhong
>> + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
>> + _("pmem property is not available "
>> + "with this QEMU binary"));
>> + goto cleanup;
>> + }
>> + if (virJSONValueObjectAdd(props,
>> + "s:pmem",
>> + mem->nvdimmPmem ? "on" : "off",
>> + NULL) < 0)
>> + goto cleanup;
>> + }
>> +
>> if (mem->sourceNodes) {
>> nodemask = mem->sourceNodes;
>> } else {
>> @@ -3569,6 +3597,10 @@ qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem)
>> if (mem->labelsize)
>> virBufferAsprintf(&buf, "label-size=%llu,", mem->labelsize * 1024);
>>
>> + if (mem->nvdimmUnarmed)
>> + virBufferAsprintf(&buf, "unarmed=%s,",
>> + mem->nvdimmUnarmed ? "on" : "off");
>> +
>> virBufferAsprintf(&buf, "memdev=mem%s,id=%s",
>> mem->info.alias, mem->info.alias);
>>
>> diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.args b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.args
>> new file mode 100644
>> index 0000000..432f622
>> --- /dev/null
>> +++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.args
>> @@ -0,0 +1,31 @@
>> +LC_ALL=C \
>> +PATH=/bin \
>> +HOME=/home/test \
>> +USER=test \
>> +LOGNAME=test \
>> +QEMU_AUDIO_DRV=none \
>> +/usr/bin/qemu-system-i686 \
>> +-name QEMUGuest1 \
>> +-S \
>> +-machine pc,accel=tcg,usb=off,dump-guest-core=off,nvdimm=on \
>> +-m size=219136k,slots=16,maxmem=1099511627776k \
>> +-smp 2,sockets=2,cores=1,threads=1 \
>> +-numa node,nodeid=0,cpus=0-1,mem=214 \
>> +-object memory-backend-file,id=memnvdimm0,prealloc=yes,mem-path=/tmp/nvdimm,\
>> +share=no,size=536870912,align=2097152 \
>> +-device nvdimm,node=0,memdev=memnvdimm0,id=nvdimm0,slot=0 \
>> +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
>> +-display none \
>> +-no-user-config \
>> +-nodefaults \
>> +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
>> +server,nowait \
>> +-mon chardev=charmonitor,id=monitor,mode=control \
>> +-rtc base=utc \
>> +-no-shutdown \
>> +-no-acpi \
>> +-usb \
>> +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
>> +-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,\
>> +bootindex=1 \
>> +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
>> diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-pmem.args b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-pmem.args
>> new file mode 100644
>> index 0000000..d34ac5b
>> --- /dev/null
>> +++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-pmem.args
>> @@ -0,0 +1,31 @@
>> +LC_ALL=C \
>> +PATH=/bin \
>> +HOME=/home/test \
>> +USER=test \
>> +LOGNAME=test \
>> +QEMU_AUDIO_DRV=none \
>> +/usr/bin/qemu-system-i686 \
>> +-name QEMUGuest1 \
>> +-S \
>> +-machine pc,accel=tcg,usb=off,dump-guest-core=off,nvdimm=on \
>> +-m size=219136k,slots=16,maxmem=1099511627776k \
>> +-smp 2,sockets=2,cores=1,threads=1 \
>> +-numa node,nodeid=0,cpus=0-1,mem=214 \
>> +-object memory-backend-file,id=memnvdimm0,prealloc=yes,mem-path=/tmp/nvdimm,\
>> +share=no,size=536870912,pmem=on \
>> +-device nvdimm,node=0,memdev=memnvdimm0,id=nvdimm0,slot=0 \
>> +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
>> +-display none \
>> +-no-user-config \
>> +-nodefaults \
>> +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
>> +server,nowait \
>> +-mon chardev=charmonitor,id=monitor,mode=control \
>> +-rtc base=utc \
>> +-no-shutdown \
>> +-no-acpi \
>> +-usb \
>> +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
>> +-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,\
>> +bootindex=1 \
>> +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
>> diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-unarmed.args b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-unarmed.args
>> new file mode 100644
>> index 0000000..64dcc5a
>> --- /dev/null
>> +++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-unarmed.args
>> @@ -0,0 +1,31 @@
>> +LC_ALL=C \
>> +PATH=/bin \
>> +HOME=/home/test \
>> +USER=test \
>> +LOGNAME=test \
>> +QEMU_AUDIO_DRV=none \
>> +/usr/bin/qemu-system-i686 \
>> +-name QEMUGuest1 \
>> +-S \
>> +-machine pc,accel=tcg,usb=off,dump-guest-core=off,nvdimm=on \
>> +-m size=219136k,slots=16,maxmem=1099511627776k \
>> +-smp 2,sockets=2,cores=1,threads=1 \
>> +-numa node,nodeid=0,cpus=0-1,mem=214 \
>> +-object memory-backend-file,id=memnvdimm0,prealloc=yes,mem-path=/tmp/nvdimm,\
>> +share=no,size=536870912 \
>> +-device nvdimm,node=0,unarmed=on,memdev=memnvdimm0,id=nvdimm0,slot=0 \
>> +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
>> +-display none \
>> +-no-user-config \
>> +-nodefaults \
>> +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
>> +server,nowait \
>> +-mon chardev=charmonitor,id=monitor,mode=control \
>> +-rtc base=utc \
>> +-no-shutdown \
>> +-no-acpi \
>> +-usb \
>> +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
>> +-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,\
>> +bootindex=1 \
>> +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
>> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
>> index e17709e..8be62a0 100644
>> --- a/tests/qemuxml2argvtest.c
>> +++ b/tests/qemuxml2argvtest.c
>> @@ -2757,6 +2757,17 @@ mymain(void)
>> DO_TEST("memory-hotplug-nvdimm-label",
>> QEMU_CAPS_DEVICE_NVDIMM,
>> QEMU_CAPS_NUMA, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
>> + DO_TEST("memory-hotplug-nvdimm-align",
>> + QEMU_CAPS_DEVICE_NVDIMM,
>> + QEMU_CAPS_NUMA, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE,
>> + QEMU_CAPS_OBJECT_MEMORY_FILE_ALIGN);
>> + DO_TEST("memory-hotplug-nvdimm-pmem",
>> + QEMU_CAPS_DEVICE_NVDIMM,
>> + QEMU_CAPS_NUMA, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE,
>> + QEMU_CAPS_OBJECT_MEMORY_FILE_PMEM);
>> + DO_TEST("memory-hotplug-nvdimm-unarmed",
>> + QEMU_CAPS_DEVICE_NVDIMM,
>> + QEMU_CAPS_NUMA, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
>>
>> DO_TEST("machine-aeskeywrap-on-caps",
>> QEMU_CAPS_AES_KEY_WRAP,
>>
More information about the libvir-list
mailing list