]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: check for active domain after agent interaction
authorEric Blake <eblake@redhat.com>
Wed, 20 Aug 2014 21:29:44 +0000 (15:29 -0600)
committerEric Blake <eblake@redhat.com>
Fri, 22 Aug 2014 20:30:52 +0000 (14:30 -0600)
Commit b606bbb41 reminded me that any time we drop locks to run
back-to-back guest interaction commands, we have to check that
the guest didn't disappear in between the two commands.  A quick
audit found a couple of spots that were missing this check.

* src/qemu/qemu_driver.c (qemuDomainShutdownFlags)
(qemuDomainSetVcpusFlags): Check that domain is still up.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/qemu/qemu_driver.c

index fa0ad5ac9d68077734724be61c7f165041b793b1..ad75bd9896396cd4eae1948733fe1e3ae3cd66f0 100644 (file)
@@ -1921,6 +1921,13 @@ static int qemuDomainShutdownFlags(virDomainPtr dom, unsigned int flags)
         (ret < 0 && (acpiRequested || !flags))) {
         qemuDomainSetFakeReboot(driver, vm, isReboot);
 
+        /* Even if agent failed, we have to check if guest went away
+         * by itself while our locks were down.  */
+        if (useAgent && !virDomainObjIsActive(vm)) {
+            ret = 0;
+            goto endjob;
+        }
+
         qemuDomainObjEnterMonitor(driver, vm);
         ret = qemuMonitorSystemPowerdown(priv->mon);
         qemuDomainObjExitMonitor(driver, vm);
@@ -4360,6 +4367,12 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
         if (ncpuinfo < 0)
             goto endjob;
 
+        if (!virDomainObjIsActive(vm)) {
+            virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                           _("domain is not running"));
+            goto endjob;
+        }
+
         if (qemuAgentUpdateCPUInfo(nvcpus, cpuinfo, ncpuinfo) < 0)
             goto endjob;