Introduced in QEMU's commit of v2.1.0-rc0~41^2~26 only for Linux,
and later in v3.1.0-rc0~71^2~10 for all POSIX, the
memory-backend-file is going to be present for all QEMU versions
we support (4.2.0, currently). Therefore, we can assume the
capability is always set and thus doesn't need to be checked for.

Signed-off-by: Michal Privoznik <mpriv...@redhat.com>
---
 src/qemu/qemu_capabilities.c                  |  9 ++---
 src/qemu/qemu_command.c                       | 13 ++------
 src/qemu/qemu_validate.c                      | 10 ------
 .../hugepages-default-1G-nodeset-2M.err       |  2 +-
 tests/qemuxml2argvtest.c                      | 33 ++++++-------------
 tests/qemuxml2xmltest.c                       | 26 +++++----------
 6 files changed, 26 insertions(+), 67 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 6e5037762a..329a120237 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1725,7 +1725,7 @@ static struct virQEMUCapsStringFlags 
virQEMUCapsObjectPropsMaxCPU[] = {
 static virQEMUCapsObjectTypeProps virQEMUCapsObjectProps[] = {
     { "memory-backend-file", virQEMUCapsObjectPropsMemoryBackendFile,
       G_N_ELEMENTS(virQEMUCapsObjectPropsMemoryBackendFile),
-      QEMU_CAPS_OBJECT_MEMORY_FILE },
+      -1 },
     { "memory-backend-memfd", virQEMUCapsObjectPropsMemoryBackendMemfd,
       G_N_ELEMENTS(virQEMUCapsObjectPropsMemoryBackendMemfd),
       QEMU_CAPS_OBJECT_MEMORY_MEMFD },
@@ -6096,12 +6096,9 @@ virQEMUCapsFillDomainMemoryBackingCaps(virQEMUCaps 
*qemuCaps,
         VIR_DOMAIN_CAPS_ENUM_SET(memoryBacking->sourceType,
                                  VIR_DOMAIN_MEMORY_SOURCE_MEMFD);
 
-    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE))
-        VIR_DOMAIN_CAPS_ENUM_SET(memoryBacking->sourceType,
-                                 VIR_DOMAIN_MEMORY_SOURCE_FILE);
-
     VIR_DOMAIN_CAPS_ENUM_SET(memoryBacking->sourceType,
-                             VIR_DOMAIN_MEMORY_SOURCE_ANONYMOUS);
+                             VIR_DOMAIN_MEMORY_SOURCE_ANONYMOUS,
+                             VIR_DOMAIN_MEMORY_SOURCE_FILE);
 }
 
 
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 2a7146e6df..bcd30ef4f3 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3472,17 +3472,10 @@ qemuBuildMemoryBackendProps(virJSONValue **backendProps,
         rc = 1;
     } else {
         /* otherwise check the required capability */
-        if (STREQ(backendType, "memory-backend-file") &&
-            !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE)) {
+        if (STREQ(backendType, "memory-backend-memfd") &&
+            !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_MEMORY_MEMFD)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("this qemu doesn't support the "
-                             "memory-backend-file object"));
-            return -1;
-        } else if (STREQ(backendType, "memory-backend-memfd") &&
-                   !virQEMUCapsGet(priv->qemuCaps, 
QEMU_CAPS_OBJECT_MEMORY_MEMFD)) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("this qemu doesn't support the "
-                             "memory-backend-memfd object"));
+                           _("this qemu doesn't support the 
memory-backend-memfd object"));
             return -1;
         }
 
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 5963442397..d4dca018aa 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -966,19 +966,9 @@ static int
 qemuValidateDomainDefNuma(const virDomainDef *def,
                           virQEMUCaps *qemuCaps)
 {
-    const long system_page_size = virGetSystemPageSizeKB();
     size_t ncells = virDomainNumaGetNodeCount(def->numa);
     size_t i;
 
-    if (def->mem.nhugepages &&
-        def->mem.hugepages[0].size != system_page_size &&
-        !virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE)) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("huge pages per NUMA node are not "
-                         "supported with this QEMU"));
-        return -1;
-    }
-
     for (i = 0; i < ncells; i++) {
         virBitmap *cpumask = virDomainNumaGetNodeCpumask(def->numa, i);
 
diff --git a/tests/qemuxml2argvdata/hugepages-default-1G-nodeset-2M.err 
b/tests/qemuxml2argvdata/hugepages-default-1G-nodeset-2M.err
index 8c0706fb8b..b103478bb8 100644
--- a/tests/qemuxml2argvdata/hugepages-default-1G-nodeset-2M.err
+++ b/tests/qemuxml2argvdata/hugepages-default-1G-nodeset-2M.err
@@ -1 +1 @@
-unsupported configuration: huge pages per NUMA node are not supported with 
this QEMU
+two master hugepages detected: 2048 and 1048576
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 4d02b0f97c..bf3465ee15 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1234,8 +1234,7 @@ mymain(void)
     DO_TEST_PARSE_ERROR_NOCAPS("hugepages-memaccess-invalid");
     DO_TEST_CAPS_LATEST("hugepages-memaccess");
     DO_TEST_CAPS_LATEST("hugepages-memaccess2");
-    DO_TEST_PARSE_ERROR("hugepages-memaccess3",
-                        QEMU_CAPS_OBJECT_MEMORY_FILE);
+    DO_TEST_PARSE_ERROR_NOCAPS("hugepages-memaccess3");
     DO_TEST_CAPS_LATEST("hugepages-memaccess3");
     DO_TEST_CAPS_LATEST("hugepages-nvdimm");
     DO_TEST_NOCAPS("nosharepages");
@@ -1907,8 +1906,7 @@ mymain(void)
     DO_TEST_PARSE_ERROR_NOCAPS("cpu-numa3");
     DO_TEST_PARSE_ERROR_NOCAPS("cpu-numa-disjoint");
     DO_TEST("cpu-numa-disjoint", QEMU_CAPS_NUMA);
-    DO_TEST_FAILURE_NOCAPS("cpu-numa-memshared");
-    DO_TEST("cpu-numa-memshared", QEMU_CAPS_OBJECT_MEMORY_FILE);
+    DO_TEST_NOCAPS("cpu-numa-memshared");
     DO_TEST("cpu-host-model",
             QEMU_CAPS_DEVICE_PCI_BRIDGE,
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
@@ -1965,8 +1963,7 @@ mymain(void)
     DO_TEST_PARSE_ERROR_NOCAPS("cputune-vcpusched-overlap");
     DO_TEST("cputune-numatune",
             QEMU_CAPS_KVM,
-            QEMU_CAPS_OBJECT_IOTHREAD,
-            QEMU_CAPS_OBJECT_MEMORY_FILE);
+            QEMU_CAPS_OBJECT_IOTHREAD);
     DO_TEST("vcpu-placement-static",
             QEMU_CAPS_KVM,
             QEMU_CAPS_OBJECT_IOTHREAD);
@@ -1991,8 +1988,7 @@ mymain(void)
     DO_TEST_CAPS_LATEST("numatune-hmat");
 
     DO_TEST_NOCAPS("numatune-auto-nodeset-invalid");
-    DO_TEST("numatune-auto-prefer",
-            QEMU_CAPS_OBJECT_MEMORY_FILE);
+    DO_TEST_NOCAPS("numatune-auto-prefer");
     DO_TEST_FAILURE_NOCAPS("numatune-static-nodeset-exceed-hostnode");
     DO_TEST_PARSE_ERROR_NOCAPS("numatune-memnode-nocpu");
     DO_TEST_PARSE_ERROR_NOCAPS("numatune-memnodes-problematic");
@@ -2637,18 +2633,15 @@ mymain(void)
     DO_TEST_PARSE_ERROR_NOCAPS("memory-hotplug-invalid-targetnode");
     DO_TEST_NOCAPS("memory-hotplug");
     DO_TEST("memory-hotplug", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA);
-    DO_TEST("memory-hotplug-dimm", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
-            QEMU_CAPS_OBJECT_MEMORY_FILE);
+    DO_TEST("memory-hotplug-dimm", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA);
     DO_TEST_CAPS_LATEST("memory-hotplug-dimm-addr");
     DO_TEST("memory-hotplug-ppc64-nonuma", QEMU_CAPS_KVM, 
QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
-            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
-            QEMU_CAPS_OBJECT_MEMORY_FILE);
+            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
     DO_TEST_FULL("memory-hotplug-ppc64-nonuma-abi-update", "",
                  ARG_PARSEFLAGS, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE,
                  ARG_QEMU_CAPS,
                  QEMU_CAPS_KVM, QEMU_CAPS_DEVICE_PC_DIMM,
                  QEMU_CAPS_NUMA, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
-                 QEMU_CAPS_OBJECT_MEMORY_FILE,
                  QEMU_CAPS_LAST,
                  ARG_END);
     DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm");
@@ -2662,13 +2655,11 @@ mymain(void)
     DO_TEST_CAPS_VER("memory-hotplug-nvdimm-readonly", "5.2.0");
     DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-readonly");
     DO_TEST("memory-hotplug-nvdimm-ppc64", 
QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
-                                           QEMU_CAPS_OBJECT_MEMORY_FILE,
                                            QEMU_CAPS_DEVICE_NVDIMM);
     DO_TEST_FULL("memory-hotplug-nvdimm-ppc64-abi-update", "",
                  ARG_PARSEFLAGS, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE,
                  ARG_QEMU_CAPS,
                  QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
-                 QEMU_CAPS_OBJECT_MEMORY_FILE,
                  QEMU_CAPS_DEVICE_NVDIMM,
                  QEMU_CAPS_LAST,
                  ARG_END);
@@ -2840,16 +2831,12 @@ mymain(void)
     DO_TEST_CAPS_LATEST("virtio-options-video-packed");
     DO_TEST_PARSE_ERROR_NOCAPS("virtio-options-memballoon-freepage-reporting");
 
-    DO_TEST("fd-memory-numa-topology", QEMU_CAPS_OBJECT_MEMORY_FILE,
-            QEMU_CAPS_KVM);
-    DO_TEST("fd-memory-numa-topology2", QEMU_CAPS_OBJECT_MEMORY_FILE,
-            QEMU_CAPS_KVM);
-    DO_TEST("fd-memory-numa-topology3", QEMU_CAPS_OBJECT_MEMORY_FILE,
-            QEMU_CAPS_KVM);
+    DO_TEST("fd-memory-numa-topology", QEMU_CAPS_KVM);
+    DO_TEST("fd-memory-numa-topology2", QEMU_CAPS_KVM);
+    DO_TEST("fd-memory-numa-topology3", QEMU_CAPS_KVM);
     DO_TEST_CAPS_LATEST("fd-memory-numa-topology4");
 
-    DO_TEST("fd-memory-no-numa-topology", QEMU_CAPS_OBJECT_MEMORY_FILE,
-            QEMU_CAPS_KVM);
+    DO_TEST("fd-memory-no-numa-topology", QEMU_CAPS_KVM);
 
     DO_TEST_CAPS_LATEST("memfd-memory-numa");
     DO_TEST_CAPS_LATEST("memfd-memory-default-hugepage");
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 7c2f525c68..40763607ba 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -657,7 +657,6 @@ mymain(void)
     DO_TEST_NOCAPS("seclabel-device-multiple");
     DO_TEST_FULL("seclabel-dynamic-none-relabel", "", WHEN_INACTIVE,
                  ARG_QEMU_CAPS, QEMU_CAPS_DEVICE_CIRRUS_VGA,
-                 QEMU_CAPS_OBJECT_MEMORY_FILE,
                  QEMU_CAPS_SPICE, QEMU_CAPS_LAST,
                  ARG_END);
     DO_TEST_NOCAPS("numad-static-vcpu-no-numatune");
@@ -926,11 +925,11 @@ mymain(void)
     DO_TEST_NOCAPS("cpu-numa-no-memory-element");
     DO_TEST_NOCAPS("cpu-numa-disordered");
     DO_TEST("cpu-numa-disjoint", QEMU_CAPS_NUMA);
-    DO_TEST("cpu-numa-memshared", QEMU_CAPS_OBJECT_MEMORY_FILE);
+    DO_TEST_NOCAPS("cpu-numa-memshared");
 
     DO_TEST_NOCAPS("numatune-auto-prefer");
-    DO_TEST("numatune-memnode", QEMU_CAPS_NUMA, QEMU_CAPS_OBJECT_MEMORY_FILE);
-    DO_TEST("numatune-memnode-no-memory", QEMU_CAPS_OBJECT_MEMORY_FILE);
+    DO_TEST("numatune-memnode", QEMU_CAPS_NUMA);
+    DO_TEST_NOCAPS("numatune-memnode-no-memory");
     DO_TEST("numatune-distances", QEMU_CAPS_NUMA);
     DO_TEST("numatune-no-vcpu", QEMU_CAPS_NUMA);
     DO_TEST("numatune-hmat", QEMU_CAPS_NUMA_HMAT);
@@ -1025,14 +1024,13 @@ mymain(void)
     DO_TEST_CAPS_ARCH_LATEST("aarch64-features-sve", "aarch64");
 
     DO_TEST("memory-hotplug-ppc64-nonuma", QEMU_CAPS_KVM, 
QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA,
-            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
-            QEMU_CAPS_OBJECT_MEMORY_FILE);
+            QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
     DO_TEST_FULL("memory-hotplug-ppc64-nonuma-abi-update", "", WHEN_BOTH,
                  ARG_PARSEFLAGS, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE,
                  ARG_QEMU_CAPS,
                  QEMU_CAPS_KVM, QEMU_CAPS_DEVICE_PC_DIMM,
                  QEMU_CAPS_NUMA, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
-                 QEMU_CAPS_OBJECT_MEMORY_FILE, QEMU_CAPS_LAST, ARG_END);
+                 QEMU_CAPS_LAST, ARG_END);
     DO_TEST_NOCAPS("memory-hotplug");
     DO_TEST("memory-hotplug-dimm", QEMU_CAPS_DEVICE_PC_DIMM);
     DO_TEST_CAPS_LATEST("memory-hotplug-dimm-addr");
@@ -1044,13 +1042,11 @@ mymain(void)
     DO_TEST("memory-hotplug-nvdimm-readonly", QEMU_CAPS_DEVICE_NVDIMM,
                                               QEMU_CAPS_DEVICE_NVDIMM_UNARMED);
     DO_TEST("memory-hotplug-nvdimm-ppc64", 
QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
-                                           QEMU_CAPS_OBJECT_MEMORY_FILE,
                                            QEMU_CAPS_DEVICE_NVDIMM);
     DO_TEST_FULL("memory-hotplug-nvdimm-ppc64-abi-update", "", WHEN_BOTH,
                  ARG_PARSEFLAGS, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE,
                  ARG_QEMU_CAPS,
                  QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
-                 QEMU_CAPS_OBJECT_MEMORY_FILE,
                  QEMU_CAPS_DEVICE_NVDIMM,
                  QEMU_CAPS_LAST, ARG_END);
     DO_TEST_CAPS_LATEST("memory-hotplug-virtio-pmem");
@@ -1087,16 +1083,12 @@ mymain(void)
 
     DO_TEST_CAPS_LATEST("virtio-options");
 
-    DO_TEST("fd-memory-numa-topology", QEMU_CAPS_OBJECT_MEMORY_FILE,
-            QEMU_CAPS_KVM);
-    DO_TEST("fd-memory-numa-topology2", QEMU_CAPS_OBJECT_MEMORY_FILE,
-            QEMU_CAPS_KVM);
-    DO_TEST("fd-memory-numa-topology3", QEMU_CAPS_OBJECT_MEMORY_FILE,
-            QEMU_CAPS_KVM);
+    DO_TEST("fd-memory-numa-topology", QEMU_CAPS_KVM);
+    DO_TEST("fd-memory-numa-topology2", QEMU_CAPS_KVM);
+    DO_TEST("fd-memory-numa-topology3", QEMU_CAPS_KVM);
     DO_TEST_CAPS_LATEST("fd-memory-numa-topology4");
 
-    DO_TEST("fd-memory-no-numa-topology", QEMU_CAPS_OBJECT_MEMORY_FILE,
-            QEMU_CAPS_KVM);
+    DO_TEST("fd-memory-no-numa-topology", QEMU_CAPS_KVM);
 
     DO_TEST_CAPS_LATEST("memfd-memory-numa");
     DO_TEST_CAPS_LATEST("memfd-memory-default-hugepage");
-- 
2.37.4

Reply via email to