|
|
9119d9 |
From 24725c889ba8a2a8e445dfa7f3d3aa1a9cbbe03c Mon Sep 17 00:00:00 2001
|
|
|
9119d9 |
Message-Id: <24725c889ba8a2a8e445dfa7f3d3aa1a9cbbe03c@dist-git>
|
|
|
9119d9 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
9119d9 |
Date: Mon, 24 Nov 2014 17:51:20 +0100
|
|
|
9119d9 |
Subject: [PATCH] qemu: Emit the guest agent lifecycle event
|
|
|
9119d9 |
|
|
|
9119d9 |
https://bugzilla.redhat.com/show_bug.cgi?id=1146944
|
|
|
9119d9 |
|
|
|
9119d9 |
Add code to emit the event on change of the channel state and reconnect
|
|
|
9119d9 |
to the qemu process.
|
|
|
9119d9 |
|
|
|
9119d9 |
(cherry picked from commit b29f2436ac80030f77428dcac746ccfa4e95f6cb)
|
|
|
9119d9 |
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
---
|
|
|
9119d9 |
src/qemu/qemu_driver.c | 6 ++++++
|
|
|
9119d9 |
src/qemu/qemu_process.c | 22 ++++++++++++++++++----
|
|
|
9119d9 |
2 files changed, 24 insertions(+), 4 deletions(-)
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
9119d9 |
index fe498b9..e096cee 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_driver.c
|
|
|
9119d9 |
+++ b/src/qemu/qemu_driver.c
|
|
|
9119d9 |
@@ -4347,6 +4347,7 @@ processSerialChangedEvent(virQEMUDriverPtr driver,
|
|
|
9119d9 |
{
|
|
|
9119d9 |
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
|
|
9119d9 |
virDomainChrDeviceState newstate;
|
|
|
9119d9 |
+ virObjectEventPtr event = NULL;
|
|
|
9119d9 |
virDomainDeviceDef dev;
|
|
|
9119d9 |
|
|
|
9119d9 |
if (connected)
|
|
|
9119d9 |
@@ -4374,6 +4375,11 @@ processSerialChangedEvent(virQEMUDriverPtr driver,
|
|
|
9119d9 |
dev.data.chr->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO)
|
|
|
9119d9 |
goto endjob;
|
|
|
9119d9 |
|
|
|
9119d9 |
+ if (STREQ_NULLABLE(dev.data.chr->target.name, "org.qemu.guest_agent.0") &&
|
|
|
9119d9 |
+ (event = virDomainEventAgentLifecycleNewFromObj(vm, newstate,
|
|
|
9119d9 |
+ VIR_CONNECT_DOMAIN_EVENT_AGENT_LIFECYCLE_REASON_CHANNEL)))
|
|
|
9119d9 |
+ qemuDomainEventQueue(driver, event);
|
|
|
9119d9 |
+
|
|
|
9119d9 |
dev.data.chr->state = newstate;
|
|
|
9119d9 |
|
|
|
9119d9 |
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
|
|
|
9119d9 |
index e68d9c6..f384b33 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_process.c
|
|
|
9119d9 |
+++ b/src/qemu/qemu_process.c
|
|
|
9119d9 |
@@ -2065,13 +2065,20 @@ qemuProcessFindCharDevicePTYs(virDomainObjPtr vm,
|
|
|
9119d9 |
|
|
|
9119d9 |
|
|
|
9119d9 |
static int
|
|
|
9119d9 |
-qemuProcessRefreshChannelVirtioState(virDomainObjPtr vm,
|
|
|
9119d9 |
- virHashTablePtr info)
|
|
|
9119d9 |
+qemuProcessRefreshChannelVirtioState(virQEMUDriverPtr driver,
|
|
|
9119d9 |
+ virDomainObjPtr vm,
|
|
|
9119d9 |
+ virHashTablePtr info,
|
|
|
9119d9 |
+ int booted)
|
|
|
9119d9 |
{
|
|
|
9119d9 |
size_t i;
|
|
|
9119d9 |
+ int agentReason = VIR_CONNECT_DOMAIN_EVENT_AGENT_LIFECYCLE_REASON_CHANNEL;
|
|
|
9119d9 |
qemuMonitorChardevInfoPtr entry;
|
|
|
9119d9 |
+ virObjectEventPtr event = NULL;
|
|
|
9119d9 |
char id[32];
|
|
|
9119d9 |
|
|
|
9119d9 |
+ if (booted)
|
|
|
9119d9 |
+ agentReason = VIR_CONNECT_DOMAIN_EVENT_AGENT_LIFECYCLE_REASON_DOMAIN_STARTED;
|
|
|
9119d9 |
+
|
|
|
9119d9 |
for (i = 0; i < vm->def->nchannels; i++) {
|
|
|
9119d9 |
virDomainChrDefPtr chr = vm->def->channels[i];
|
|
|
9119d9 |
if (chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO) {
|
|
|
9119d9 |
@@ -2088,6 +2095,12 @@ qemuProcessRefreshChannelVirtioState(virDomainObjPtr vm,
|
|
|
9119d9 |
!entry->state)
|
|
|
9119d9 |
continue;
|
|
|
9119d9 |
|
|
|
9119d9 |
+ if (entry->state != VIR_DOMAIN_CHR_DEVICE_STATE_DEFAULT &&
|
|
|
9119d9 |
+ STREQ_NULLABLE(chr->target.name, "org.qemu.guest_agent.0") &&
|
|
|
9119d9 |
+ (event = virDomainEventAgentLifecycleNewFromObj(vm, entry->state,
|
|
|
9119d9 |
+ agentReason)))
|
|
|
9119d9 |
+ qemuDomainEventQueue(driver, event);
|
|
|
9119d9 |
+
|
|
|
9119d9 |
chr->state = entry->state;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
}
|
|
|
9119d9 |
@@ -2111,7 +2124,7 @@ qemuProcessReconnectRefreshChannelVirtioState(virQEMUDriverPtr driver,
|
|
|
9119d9 |
if (ret < 0)
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
|
|
|
9119d9 |
- ret = qemuProcessRefreshChannelVirtioState(vm, info);
|
|
|
9119d9 |
+ ret = qemuProcessRefreshChannelVirtioState(driver, vm, info, false);
|
|
|
9119d9 |
|
|
|
9119d9 |
cleanup:
|
|
|
9119d9 |
virHashFree(info);
|
|
|
9119d9 |
@@ -2167,7 +2180,8 @@ qemuProcessWaitForMonitor(virQEMUDriverPtr driver,
|
|
|
9119d9 |
info)) < 0)
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
|
|
|
9119d9 |
- if ((ret = qemuProcessRefreshChannelVirtioState(vm, info)) < 0)
|
|
|
9119d9 |
+ if ((ret = qemuProcessRefreshChannelVirtioState(driver, vm, info,
|
|
|
9119d9 |
+ true)) < 0)
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
--
|
|
|
9119d9 |
2.1.3
|
|
|
9119d9 |
|