]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: command: move NVDIMM validation to qemu_domain.c
authorDaniel Henrique Barboza <danielhb413@gmail.com>
Wed, 18 Dec 2019 00:36:00 +0000 (21:36 -0300)
committerCole Robinson <crobinso@redhat.com>
Wed, 18 Dec 2019 17:54:56 +0000 (12:54 -0500)
Move the NVDIMM validation from qemuBuildMachineCommandLine()
to a new function in qemu_domain.c, qemuDomainDeviceDefValidateMemory(),
which is called by qemuDomainDeviceDefValidate(). This allows
NVDIMM validation to occur in domain define time.

It also increments memory hotplug validation, which can be seen
by the failures in the hotplug tests in qemuxml2xmltest.c that
needed to be adjusted after the move.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/qemu/qemu_command.c
src/qemu/qemu_domain.c
tests/qemuxml2xmltest.c

index 0cee8dcd859724eee5048b4316e1ba814b80c048..b5bf93172d72b691ff83b252cd26f4ce282f78c7 100644 (file)
@@ -6982,11 +6982,6 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
 
     for (i = 0; i < def->nmems; i++) {
         if (def->mems[i]->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM) {
-            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_NVDIMM)) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("nvdimm isn't supported by this QEMU binary"));
-                return -1;
-            }
             virBufferAddLit(&buf, ",nvdimm=on");
             break;
         }
index 20a96297608bf1c55d381b720a103c4845961791..83964db595524f02be3d521215239d5823cb5ed7 100644 (file)
@@ -5637,6 +5637,19 @@ qemuDomainDeviceDefValidateSound(virDomainSoundDefPtr sound,
     return 0;
 }
 
+static int
+qemuDomainDeviceDefValidateMemory(virDomainMemoryDefPtr mem,
+                                  virQEMUCapsPtr qemuCaps)
+{
+    if (mem->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM &&
+        !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_NVDIMM)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("nvdimm isn't supported by this QEMU binary"));
+        return -1;
+    }
+
+    return 0;
+}
 
 static int
 qemuDomainDefValidate(const virDomainDef *def,
@@ -8365,9 +8378,12 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
         ret = qemuDomainDeviceDefValidateSound(dev->data.sound, qemuCaps);
         break;
 
+    case VIR_DOMAIN_DEVICE_MEMORY:
+        ret = qemuDomainDeviceDefValidateMemory(dev->data.memory, qemuCaps);
+        break;
+
     case VIR_DOMAIN_DEVICE_LEASE:
     case VIR_DOMAIN_DEVICE_SHMEM:
-    case VIR_DOMAIN_DEVICE_MEMORY:
     case VIR_DOMAIN_DEVICE_PANIC:
     case VIR_DOMAIN_DEVICE_NONE:
     case VIR_DOMAIN_DEVICE_LAST:
index 55bbd924fb0c3030c171241117864b9f8da6db07..60ae68c58c05e47eb97e3c1459aee578ac6273a5 100644 (file)
@@ -1221,12 +1221,12 @@ mymain(void)
     DO_TEST("memory-hotplug", NONE);
     DO_TEST("memory-hotplug-nonuma", NONE);
     DO_TEST("memory-hotplug-dimm", NONE);
-    DO_TEST("memory-hotplug-nvdimm", NONE);
-    DO_TEST("memory-hotplug-nvdimm-access", NONE);
-    DO_TEST("memory-hotplug-nvdimm-label", NONE);
-    DO_TEST("memory-hotplug-nvdimm-align", NONE);
-    DO_TEST("memory-hotplug-nvdimm-pmem", NONE);
-    DO_TEST("memory-hotplug-nvdimm-readonly", NONE);
+    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);
+    DO_TEST("memory-hotplug-nvdimm-align", QEMU_CAPS_DEVICE_NVDIMM);
+    DO_TEST("memory-hotplug-nvdimm-pmem", QEMU_CAPS_DEVICE_NVDIMM);
+    DO_TEST("memory-hotplug-nvdimm-readonly", QEMU_CAPS_DEVICE_NVDIMM);
     DO_TEST("net-udp", NONE);
 
     DO_TEST("video-virtio-gpu-device", QEMU_CAPS_DEVICE_VIRTIO_GPU);