]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu: conf: Reject memory device if it would exceed configured max size
authorPeter Krempa <pkrempa@redhat.com>
Tue, 28 Apr 2015 14:23:05 +0000 (16:23 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 29 Apr 2015 07:40:16 +0000 (09:40 +0200)
If the added memory device would exceed the maximum memory size, reject
it.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1216046

src/conf/domain_conf.c

index fc48ed5a5f6da0da775423cbc995f854c8c447b6..7e4f0af25d09817a224ac57db739d37d78c9f56f 100644 (file)
@@ -21661,6 +21661,17 @@ virDomainDefCompatibleDevice(virDomainDefPtr def,
             return -1;
     }
 
+    if (dev->type == VIR_DOMAIN_DEVICE_MEMORY) {
+        unsigned long long sz = dev->data.memory->size;
+
+        if ((virDomainDefGetMemoryActual(def) + sz) > def->mem.max_memory) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("Attaching memory device with size '%llu' would "
+                             "exceed domain's maxMemory config"), sz);
+            return -1;
+        }
+    }
+
     return 0;
 }