From: Marc-André Lureau <marcandre.lureau(a)redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau(a)redhat.com>
---
src/qemu/qemu_command.c | 61 +++++++++++++++++++++++++++++------------
1 file changed, 43 insertions(+), 18 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c9e3a91e32..97cfc8a18d 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3113,6 +3113,24 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd,
return ret;
}
+static int
+qemuBuildMemoryBackendPropsShare(virJSONValuePtr props,
+ virDomainMemoryAccess memAccess)
+{
+ switch (memAccess) {
+ case VIR_DOMAIN_MEMORY_ACCESS_SHARED:
+ return virJSONValueObjectAdd(props, "b:share", true, NULL);
+
+ case VIR_DOMAIN_MEMORY_ACCESS_PRIVATE:
+ return virJSONValueObjectAdd(props, "b:share", false, NULL);
+
+ case VIR_DOMAIN_MEMORY_ACCESS_DEFAULT:
+ case VIR_DOMAIN_MEMORY_ACCESS_LAST:
+ break;
+ }
+
+ return 0;
+}
/**
* qemuBuildMemoryBackendProps:
@@ -3259,7 +3277,23 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
if (!(props = virJSONValueNewObject()))
return -1;
- if (useHugepage || mem->nvdimmPath || memAccess ||
+ if (!mem->nvdimmPath &&
+ def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_ANONYMOUS &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_MEMFD) &&
+ (!useHugepage || virQEMUCapsGet(qemuCaps,
QEMU_CAPS_OBJECT_MEMORY_MEMFD_HUGETLB))) {
+ backendType = "memory-backend-memfd";
+
+ if (useHugepage &&
+ (virJSONValueObjectAdd(props, "b:hugetlb", useHugepage, NULL) <
0 ||
+ virJSONValueObjectAdd(props, "U:hugetlbsize", pagesize <<
10, NULL) < 0)) {
+ goto cleanup;
+ }
+
+ if (qemuBuildMemoryBackendPropsShare(props, memAccess) < 0) {
+ goto cleanup;
+ }
+
+ } else if (useHugepage || mem->nvdimmPath || memAccess ||
def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) {
if (mem->nvdimmPath) {
@@ -3297,20 +3331,8 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
goto cleanup;
}
- switch (memAccess) {
- case VIR_DOMAIN_MEMORY_ACCESS_SHARED:
- if (virJSONValueObjectAdd(props, "b:share", true, NULL) < 0)
- goto cleanup;
- break;
-
- case VIR_DOMAIN_MEMORY_ACCESS_PRIVATE:
- if (virJSONValueObjectAdd(props, "b:share", false, NULL) < 0)
- goto cleanup;
- break;
-
- case VIR_DOMAIN_MEMORY_ACCESS_DEFAULT:
- case VIR_DOMAIN_MEMORY_ACCESS_LAST:
- break;
+ if (qemuBuildMemoryBackendPropsShare(props, memAccess) < 0) {
+ goto cleanup;
}
} else {
backendType = "memory-backend-ram";
@@ -7609,7 +7631,8 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
if (virDomainNumatuneHasPerNodeBinding(def->numa) &&
!(virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM) ||
- virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE))) {
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE) ||
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_MEMFD))) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Per-node memory binding is not supported "
"with this QEMU"));
@@ -7618,7 +7641,8 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
if (def->mem.nhugepages &&
def->mem.hugepages[0].size != system_page_size &&
- !virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE)) {
+ !(virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE) ||
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_MEMFD_HUGETLB))) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("huge pages per NUMA node are not "
"supported with this QEMU"));
@@ -7635,7 +7659,8 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
* need to check which approach to use */
for (i = 0; i < ncells; i++) {
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM) ||
- virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE)) {
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE) ||
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_MEMFD)) {
if ((rc = qemuBuildMemoryCellBackendStr(def, cfg, i, priv,
&nodeBackends[i])) < 0)
--
2.19.0.rc1