]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Set virtio channel state sooner
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 5 Jan 2016 10:39:20 +0000 (11:39 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 11 Jan 2016 16:16:29 +0000 (17:16 +0100)
In qemu driver we listen to virtio channel events like an agent
connected to or disconnected from the guest part of socket.
However, with a little exception - when we find out that the
socket in question is the guest agent one, we connect or
disconnect guest agent which is done prior setting new state in
internal structure. Due to a bug in our code it may happen that
we got the event but failed to set it in internal structure
representing the channel.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_driver.c

index e2134ee36bbc042a164949da7df97caa4f028947..8ccf68bbe972aa5d27ffc3c159ce74508f264d73 100644 (file)
@@ -4457,6 +4457,12 @@ processSerialChangedEvent(virQEMUDriverPtr driver,
         dev.data.chr->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO)
         goto endjob;
 
+    dev.data.chr->state = newstate;
+
+    if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
+        VIR_WARN("unable to save status of domain %s after updating state of "
+                 "channel %s", vm->def->name, devAlias);
+
     if (STREQ_NULLABLE(dev.data.chr->target.name, "org.qemu.guest_agent.0")) {
         if (newstate == VIR_DOMAIN_CHR_DEVICE_STATE_CONNECTED) {
             if (!priv->agent) {
@@ -4479,12 +4485,6 @@ processSerialChangedEvent(virQEMUDriverPtr driver,
         qemuDomainEventQueue(driver, event);
     }
 
-    dev.data.chr->state = newstate;
-
-    if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
-        VIR_WARN("unable to save status of domain %s after updating state of "
-                 "channel %s", vm->def->name, devAlias);
-
  endjob:
     qemuDomainObjEndJob(driver, vm);