]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Close the agent connection only on agent channel events
authorPeter Krempa <pkrempa@redhat.com>
Tue, 30 Jun 2015 08:46:50 +0000 (10:46 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 30 Jun 2015 11:18:02 +0000 (13:18 +0200)
processSerialChangedEvent processes events for all channels. Commit
2af51483 broke all agent interaction if a channel other than the agent
closes since it did not check that the event actually originated from
the guest agent channel.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1236924
Fixes up: https://bugzilla.redhat.com/show_bug.cgi?id=890648

src/qemu/qemu_driver.c

index bdf9b15df95c5b0451fee249f90389adc3e7ab58..3c8ccd21f68f97a2991fa8721b01aa540d56e15f 100644 (file)
@@ -4448,10 +4448,20 @@ processSerialChangedEvent(virQEMUDriverPtr driver,
 
     if (newstate == VIR_DOMAIN_CHR_DEVICE_STATE_DISCONNECTED &&
         virDomainObjIsActive(vm) && priv->agent) {
-        /* Close agent monitor early, so that other threads
-         * waiting for the agent to reply can finish and our
-         * job we acquire below can succeed. */
-       qemuAgentNotifyClose(priv->agent);
+        /* peek into the domain definition to find the channel */
+        if (virDomainDefFindDevice(vm->def, devAlias, &dev, true) == 0 &&
+            dev.type == VIR_DOMAIN_DEVICE_CHR &&
+            dev.data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL &&
+            dev.data.chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO &&
+            STREQ_NULLABLE(dev.data.chr->target.name, "org.qemu.guest_agent.0"))
+            /* Close agent monitor early, so that other threads
+             * waiting for the agent to reply can finish and our
+             * job we acquire below can succeed. */
+            qemuAgentNotifyClose(priv->agent);
+
+        /* now discard the data, since it may possibly change once we unlock
+         * while entering the job */
+        memset(&dev, 0, sizeof(dev));
     }
 
     if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)