提交 41c2aa72 编写于 作者: M Martin Kletzander

qemu: Use memory-backing-file only when needed

We are using memory-backing-file even when it's not needed, for example
if user requests hugepages for memory backing, but does not specify any
pagesize or memory node pinning.  This causes migrations to fail when
migrating from older libvirt that did not do this.  So similarly to
commit 7832fac8 which does it for
memory-backend-ram, this commit makes is more generic and
backend-agnostic, so the backend is not used if there is no specific
pagesize of hugepages requested, no nodeset the memory node should be
bound to, no memory access change required, and so on.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1266856Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
上级 a2dba3ce
...@@ -5120,12 +5120,6 @@ qemuBuildMemoryBackendStr(unsigned long long size, ...@@ -5120,12 +5120,6 @@ qemuBuildMemoryBackendStr(unsigned long long size,
} }
if (pagesize || hugepage) { if (pagesize || hugepage) {
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("this qemu doesn't support hugepage memory backing"));
goto cleanup;
}
if (pagesize) { if (pagesize) {
/* Now lets see, if the huge page we want to use is even mounted /* Now lets see, if the huge page we want to use is even mounted
* and ready to use */ * and ready to use */
...@@ -5204,29 +5198,32 @@ qemuBuildMemoryBackendStr(unsigned long long size, ...@@ -5204,29 +5198,32 @@ qemuBuildMemoryBackendStr(unsigned long long size,
goto cleanup; goto cleanup;
} }
if (!hugepage && !pagesize) { /* If none of the following is requested... */
if (!pagesize && !userNodeset && !memAccess && !nodeSpecified && !force) {
if ((userNodeset || nodeSpecified || force) && /* report back that using the new backend is not necessary
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM)) { * to achieve the desired configuration */
ret = 1;
} else {
/* otherwise check the required capability */
if (STREQ(*backendType, "memory-backend-file") &&
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("this qemu doesn't support the "
"memory-backend-file object"));
goto cleanup;
} else if (STREQ(*backendType, "memory-backend-ram") &&
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("this qemu doesn't support the " _("this qemu doesn't support the "
"memory-backend-ram object")); "memory-backend-ram object"));
goto cleanup; goto cleanup;
} }
/* report back that using the new backend is not necessary to achieve ret = 0;
* the desired configuration */
if (!userNodeset && !nodeSpecified) {
*backendProps = props;
props = NULL;
ret = 1;
goto cleanup;
}
} }
*backendProps = props; *backendProps = props;
props = NULL; props = NULL;
ret = 0;
cleanup: cleanup:
virJSONValueFree(props); virJSONValueFree(props);
......
...@@ -4,9 +4,9 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=spice \ ...@@ -4,9 +4,9 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=spice \
-M pc-i440fx-2.3 \ -M pc-i440fx-2.3 \
-m size=1048576k,slots=16,maxmem=1099511627776k \ -m size=1048576k,slots=16,maxmem=1099511627776k \
-smp 2 \ -smp 2 \
-object memory-backend-file,id=ram-node0,prealloc=yes,\ -mem-prealloc \
mem-path=/dev/hugepages2M/libvirt/qemu,size=1073741824 \ -mem-path /dev/hugepages2M/libvirt/qemu \
-numa node,nodeid=0,cpus=0-1,memdev=ram-node0 \ -numa node,nodeid=0,cpus=0-1,mem=1024 \
-object memory-backend-file,id=memdimm0,prealloc=yes,\ -object memory-backend-file,id=memdimm0,prealloc=yes,\
mem-path=/dev/hugepages1G/libvirt/qemu,size=1073741824,host-nodes=1-3,policy=bind \ mem-path=/dev/hugepages1G/libvirt/qemu,size=1073741824,host-nodes=1-3,policy=bind \
-device pc-dimm,node=0,memdev=memdimm0,id=dimm0 \ -device pc-dimm,node=0,memdev=memdimm0,id=dimm0 \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册