]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Add check/error for domain supports cold/hotplug
authorJohn Ferlan <jferlan@redhat.com>
Fri, 7 Dec 2018 14:46:48 +0000 (09:46 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 12 Dec 2018 19:34:20 +0000 (14:34 -0500)
https://bugzilla.redhat.com/show_bug.cgi?id=1624336

Add a check during virDomainDefCompatibleDevice whether the
domain supports cold/hotplug of a memory module even though
this duplicates the qemuDomainDefValidateMemoryHotplug check.

Without this check, the cold/hot plug would fail on the
subsequent mem_memory check (since it's 0). Adding a check
for max_memory > 0 would allow the subsequent hotplug check
to fail, but would cause coldplug to fail with the somewhat
opaque message "no free memory device slot available".

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/domain_conf.c

index 89f444b967667494f51b33632d3eddb212f8b6eb..ae8fb5a501e2564ef080c12739eb3e47a3e1cb3f 100644 (file)
@@ -28923,6 +28923,13 @@ virDomainDefCompatibleDevice(virDomainDefPtr def,
     if (dev->type == VIR_DOMAIN_DEVICE_MEMORY) {
         unsigned long long sz = dev->data.memory->size;
 
+        if (!virDomainDefHasMemoryHotplug(def)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("cannot use/hotplug a memory device when domain "
+                             "'maxMemory' is not defined"));
+            return -1;
+        }
+
         if ((virDomainDefGetMemoryTotal(def) + sz) > def->mem.max_memory) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("Attaching memory device with size '%llu' would "