]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuDomainOpenGraphics: Start job early
authorJiri Denemark <jdenemar@redhat.com>
Tue, 20 Sep 2016 13:25:06 +0000 (15:25 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 21 Sep 2016 12:11:26 +0000 (14:11 +0200)
Checking if a domain's definition or if it is active before we got a job
is pointless since the domain might have changed in the meantime.

Luckily libvirtd didn't crash when the API tried to talk to an inactive
domain:

debug : qemuDomainObjBeginJobInternal:2914 : Started job: modify
    (async=none vm=0x7f8f340140c0 name=ble)
debug : qemuDomainObjEnterMonitorInternal:3137 : Entering monitor
    (mon=(nil) vm=0x7f8f340140c0 name=ble)
warning : virObjectLock:319 : Object (nil) ((unknown)) is not a
    virObjectLockable instance
debug : qemuMonitorOpenGraphics:3505 : protocol=spice fd=27
    fdname=graphicsfd skipauth=1
error : qemuMonitorOpenGraphics:3508 : invalid argument: monitor must
    not be NULL
debug : qemuDomainObjExitMonitorInternal:3160 : Exited monitor
    (mon=(nil) vm=0x7f8f340140c0 name=ble)
debug : qemuDomainObjEndJob:3068 : Stopping job: modify (async=none
    vm=0x7f8f340140c0 name=ble)

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
src/qemu/qemu_driver.c

index e29180da4e75c6ae194ff0b81d640c2e44dc8014..4c45fc3b4fbdcea4f1ff952f0bd587b7c4945b1d 100644 (file)
@@ -17118,10 +17118,13 @@ qemuDomainOpenGraphics(virDomainPtr dom,
     if (virDomainOpenGraphicsEnsureACL(dom->conn, vm->def) < 0)
         goto cleanup;
 
+    if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
+        goto cleanup;
+
     if (!virDomainObjIsActive(vm)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
                        "%s", _("domain is not running"));
-        goto cleanup;
+        goto endjob;
     }
 
     priv = vm->privateData;
@@ -17129,7 +17132,7 @@ qemuDomainOpenGraphics(virDomainPtr dom,
     if (idx >= vm->def->ngraphics) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("No graphics backend with index %d"), idx);
-        goto cleanup;
+        goto endjob;
     }
     switch (vm->def->graphics[idx]->type) {
     case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
@@ -17142,20 +17145,20 @@ qemuDomainOpenGraphics(virDomainPtr dom,
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("Can only open VNC or SPICE graphics backends, not %s"),
                        virDomainGraphicsTypeToString(vm->def->graphics[idx]->type));
-        goto cleanup;
+        goto endjob;
     }
 
     if (virSecurityManagerSetImageFDLabel(driver->securityManager, vm->def,
                                           fd) < 0)
-        goto cleanup;
+        goto endjob;
 
-    if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
-        goto cleanup;
     qemuDomainObjEnterMonitor(driver, vm);
     ret = qemuMonitorOpenGraphics(priv->mon, protocol, fd, "graphicsfd",
                                   (flags & VIR_DOMAIN_OPEN_GRAPHICS_SKIPAUTH) != 0);
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
         ret = -1;
+
+ endjob:
     qemuDomainObjEndJob(driver, vm);
 
  cleanup: