[PATCH 11/11] qemu: Emit the guest agent lifecycle event

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add code to emit the event on change of the channel state and reconnect
to the qemu process.
---
 src/qemu/qemu_driver.c  |  5 +++++
 src/qemu/qemu_process.c | 13 ++++++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 31bf6bb..c489d2f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4342,6 +4342,7 @@ processSerialChangedEvent(virQEMUDriverPtr driver,
 {
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
     virDomainChrDeviceState newstate;
+    virObjectEventPtr event = NULL;
     virDomainDeviceDef dev;

     if (connected)
@@ -4369,6 +4370,10 @@ processSerialChangedEvent(virQEMUDriverPtr driver,
         dev.data.chr->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO)
         goto endjob;

+    if (STREQ_NULLABLE(dev.data.chr->target.name, "org.qemu.guest_agent.0") &&
+        (event = virDomainEventAgentLifecycleNewFromObj(vm, newstate, 0)))
+        qemuDomainEventQueue(driver, event);
+
     dev.data.chr->state = newstate;

     if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 3c3ff66..15dabe3 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2068,11 +2068,13 @@ qemuProcessFindCharDevicePTYs(virDomainObjPtr vm,


 static int
-qemuProcessRefreshChannelVirtioState(virDomainObjPtr vm,
+qemuProcessRefreshChannelVirtioState(virQEMUDriverPtr driver,
+                                     virDomainObjPtr vm,
                                      virHashTablePtr info)
 {
     size_t i;
     qemuMonitorChardevInfoPtr entry;
+    virObjectEventPtr event = NULL;
     char id[32];

     for (i = 0; i < vm->def->nchannels; i++) {
@@ -2090,6 +2092,11 @@ qemuProcessRefreshChannelVirtioState(virDomainObjPtr vm,
             if (!(entry = virHashLookup(info, id)))
                 continue;

+            if (entry->state != VIR_DOMAIN_CHR_DEVICE_STATE_DEFAULT &&
+                STREQ_NULLABLE(chr->target.name, "org.qemu.guest_agent.0") &&
+                (event = virDomainEventAgentLifecycleNewFromObj(vm, entry->state, 0)))
+                qemuDomainEventQueue(driver, event);
+
             chr->state = entry->state;
         }
     }
@@ -2113,7 +2120,7 @@ qemuProcessReconnectRefreshChannelVirtioState(virQEMUDriverPtr driver,
     if (ret < 0)
         goto cleanup;

-    ret = qemuProcessRefreshChannelVirtioState(vm, info);
+    ret = qemuProcessRefreshChannelVirtioState(driver, vm, info);

  cleanup:
     virHashFree(info);
@@ -2170,7 +2177,7 @@ qemuProcessWaitForMonitor(virQEMUDriverPtr driver,
                                                         info)) != 0)
             goto cleanup;

-        if ((ret = qemuProcessRefreshChannelVirtioState(vm, info)) != 0)
+        if ((ret = qemuProcessRefreshChannelVirtioState(driver, vm, info)) != 0)
             goto cleanup;
     }

-- 
2.1.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]