]> xenbits.xensource.com Git - libvirt.git/commitdiff
Check for balloon model in qemuDomainSetMemoryStatsPeriod
authorJán Tomko <jtomko@redhat.com>
Wed, 3 Jun 2015 14:52:57 +0000 (16:52 +0200)
committerJán Tomko <jtomko@redhat.com>
Fri, 5 Jun 2015 14:17:49 +0000 (16:17 +0200)
There's no point in calling the monitor if there is no balloon.

src/qemu/qemu_driver.c

index 4690406196a1fa5930150054fa9f46d25de9ce68..34e558160484c1ae1b6990c9dd3f3c96c4c86c4b 100644 (file)
@@ -2459,6 +2459,14 @@ static int qemuDomainSetMemoryStatsPeriod(virDomainPtr dom, int period,
     priv = vm->privateData;
 
     if (def) {
+        if (!def->memballoon ||
+            def->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("Memory balloon model must be virtio to set the"
+                             " collection period"));
+            goto endjob;
+        }
+
         qemuDomainObjEnterMonitor(driver, vm);
         r = qemuMonitorSetMemoryStatsPeriod(priv->mon, period);
         if (qemuDomainObjExitMonitor(driver, vm) < 0)
@@ -2475,6 +2483,13 @@ static int qemuDomainSetMemoryStatsPeriod(virDomainPtr dom, int period,
     }
 
     if (persistentDef) {
+        if (!persistentDef->memballoon ||
+            persistentDef->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("Memory balloon model must be virtio to set the"
+                             " collection period"));
+            goto endjob;
+        }
         persistentDef->memballoon->period = period;
         ret = virDomainSaveConfig(cfg->configDir, persistentDef);
         goto endjob;