]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Validate memory hotplug in domainValidateCallback instead of cmd line generator
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 28 Jul 2020 08:51:32 +0000 (10:51 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 1 Sep 2020 07:30:27 +0000 (09:30 +0200)
When editing a domain with hotplug enabled, I removed the only
NUMA node it had and got no error. I got the error later though,
when starting the domain. This is not as user friendly as it can
be. Move the validation call out from command line generator and
into domain validator (which is called prior to starting cmd line
generation anyway).

When doing this, I had to remove memory-hotplug-nonuma xml2xml
test case because there is no way the test case can succeed,
obviously.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/qemu/qemu_command.c
src/qemu/qemu_domain.c
src/qemu/qemu_validate.c
tests/qemuxml2argvtest.c
tests/qemuxml2xmloutdata/memory-hotplug-nonuma.xml [deleted file]
tests/qemuxml2xmltest.c

index 6798febf8d0650badcb41d1fd31ed6a9d449482d..bd98b0a97cb95bb5dc90e1f3d809796edf8aaff3 100644 (file)
@@ -7123,9 +7123,6 @@ qemuBuildMemCommandLine(virCommandPtr cmd,
                         virQEMUCapsPtr qemuCaps,
                         qemuDomainObjPrivatePtr priv)
 {
-    if (qemuDomainDefValidateMemoryHotplug(def, qemuCaps, NULL) < 0)
-        return -1;
-
     virCommandAddArg(cmd, "-m");
 
     if (virDomainDefHasMemoryHotplug(def)) {
index 21f24fceedc69f3a3c1d7d3036408b9943ca6400..aa0f5c1a2d0cc9fcd38d355fe0339ad105d4ad17 100644 (file)
@@ -8468,6 +8468,8 @@ qemuCheckMemoryDimmConflict(const virDomainDef *def,
 
     return false;
 }
+
+
 static int
 qemuDomainDefValidateMemoryHotplugDevice(const virDomainMemoryDef *mem,
                                          const virDomainDef *def)
index c4b86326ad73cd6e17c6510a93d7fefc04e15427..6f3fee542791e54e676544c96b59cb48f758a97b 100644 (file)
@@ -916,6 +916,9 @@ qemuValidateDomainDef(const virDomainDef *def,
         }
     }
 
+    if (qemuDomainDefValidateMemoryHotplug(def, qemuCaps, NULL) < 0)
+        return -1;
+
     if (qemuValidateDomainDefClockTimers(def, qemuCaps) < 0)
         return -1;
 
index 01839cb88c52bab20370f65fb2d96444a76bf1b2..e93948e3fc62ed7cb18dd7b57d84534d881f9936 100644 (file)
@@ -2931,7 +2931,7 @@ mymain(void)
     DO_TEST("cpu-host-passthrough-features", QEMU_CAPS_KVM);
 
     DO_TEST_FAILURE("memory-align-fail", NONE);
-    DO_TEST_FAILURE("memory-hotplug-nonuma", QEMU_CAPS_DEVICE_PC_DIMM);
+    DO_TEST_PARSE_ERROR("memory-hotplug-nonuma", QEMU_CAPS_DEVICE_PC_DIMM);
     DO_TEST("memory-hotplug", NONE);
     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,
diff --git a/tests/qemuxml2xmloutdata/memory-hotplug-nonuma.xml b/tests/qemuxml2xmloutdata/memory-hotplug-nonuma.xml
deleted file mode 100644 (file)
index 7c277f0..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<domain type='qemu'>
-  <name>QEMUGuest1</name>
-  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-  <maxMemory slots='9' unit='KiB'>1233456789</maxMemory>
-  <memory unit='KiB'>219136</memory>
-  <currentMemory unit='KiB'>219136</currentMemory>
-  <vcpu placement='static'>1</vcpu>
-  <os>
-    <type arch='i686' machine='pc'>hvm</type>
-    <boot dev='hd'/>
-  </os>
-  <clock offset='utc'/>
-  <on_poweroff>destroy</on_poweroff>
-  <on_reboot>restart</on_reboot>
-  <on_crash>destroy</on_crash>
-  <devices>
-    <emulator>/usr/bin/qemu-system-i386</emulator>
-    <controller type='usb' index='0'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
-    </controller>
-    <controller type='pci' index='0' model='pci-root'/>
-    <input type='mouse' bus='ps2'/>
-    <input type='keyboard' bus='ps2'/>
-    <memballoon model='virtio'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
-    </memballoon>
-  </devices>
-</domain>
index a07e2b7553f09f729a148d5add9a3ca682a1c29e..6eb008c8d21c82e28f7a44287b4d82ac0c312b56 100644 (file)
@@ -303,18 +303,21 @@ mymain(void)
 
     DO_TEST("pages-discard", NONE);
     DO_TEST("pages-discard-hugepages", QEMU_CAPS_OBJECT_MEMORY_FILE);
-    DO_TEST("pages-dimm-discard", NONE);
+    DO_TEST("pages-dimm-discard", QEMU_CAPS_DEVICE_PC_DIMM);
     DO_TEST("hugepages-default", QEMU_CAPS_OBJECT_MEMORY_FILE);
     DO_TEST("hugepages-default-2M", QEMU_CAPS_OBJECT_MEMORY_FILE);
     DO_TEST("hugepages-default-system-size", QEMU_CAPS_OBJECT_MEMORY_FILE);
     DO_TEST("hugepages-nodeset", QEMU_CAPS_OBJECT_MEMORY_FILE);
     DO_TEST("hugepages-numa-default-2M", QEMU_CAPS_OBJECT_MEMORY_FILE);
-    DO_TEST("hugepages-numa-default-dimm", QEMU_CAPS_OBJECT_MEMORY_FILE);
+    DO_TEST("hugepages-numa-default-dimm", QEMU_CAPS_DEVICE_PC_DIMM,
+            QEMU_CAPS_OBJECT_MEMORY_FILE);
     DO_TEST("hugepages-numa-nodeset", QEMU_CAPS_OBJECT_MEMORY_FILE);
     DO_TEST("hugepages-numa-nodeset-part", QEMU_CAPS_OBJECT_MEMORY_FILE);
     DO_TEST("hugepages-shared", QEMU_CAPS_OBJECT_MEMORY_FILE);
-    DO_TEST("hugepages-memaccess", QEMU_CAPS_OBJECT_MEMORY_FILE);
-    DO_TEST("hugepages-memaccess2", QEMU_CAPS_OBJECT_MEMORY_FILE);
+    DO_TEST("hugepages-memaccess", QEMU_CAPS_DEVICE_PC_DIMM,
+            QEMU_CAPS_OBJECT_MEMORY_FILE);
+    DO_TEST("hugepages-memaccess2", QEMU_CAPS_DEVICE_PC_DIMM,
+            QEMU_CAPS_OBJECT_MEMORY_FILE);
     DO_TEST("hugepages-nvdimm", QEMU_CAPS_DEVICE_NVDIMM,
             QEMU_CAPS_OBJECT_MEMORY_FILE);
     DO_TEST("nosharepages", NONE);
@@ -1260,8 +1263,7 @@ mymain(void)
     DO_TEST_CAPS_ARCH_LATEST("aarch64-features-sve", "aarch64");
 
     DO_TEST("memory-hotplug", NONE);
-    DO_TEST("memory-hotplug-nonuma", NONE);
-    DO_TEST("memory-hotplug-dimm", NONE);
+    DO_TEST("memory-hotplug-dimm", QEMU_CAPS_DEVICE_PC_DIMM);
     DO_TEST("memory-hotplug-nvdimm", QEMU_CAPS_DEVICE_NVDIMM);
     DO_TEST("memory-hotplug-nvdimm-access", QEMU_CAPS_DEVICE_NVDIMM);
     DO_TEST("memory-hotplug-nvdimm-label", QEMU_CAPS_DEVICE_NVDIMM);