From 2f50445537f9e1f39e484831489a6ac6f9951ce0 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Tue, 5 Jan 2016 11:39:20 +0100 Subject: [PATCH] qemu: Set virtio channel state sooner 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 --- src/qemu/qemu_driver.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e2134ee36b..8ccf68bbe9 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -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);