
On 9/10/24 21:22, Praveen K Paladugu wrote:
From: Praveen K Paladugu <prapal@linux.microsoft.com>
Enable callbacks for define, undefine, started, booted, stopped, destroyed events of ch guests.
Signed-off-by: Praveen K Paladugu <praveenkpaladugu@gmail.com> --- src/ch/ch_conf.h | 4 +++ src/ch/ch_driver.c | 82 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 84 insertions(+), 2 deletions(-)
diff --git a/src/ch/ch_conf.h b/src/ch/ch_conf.h index a77cad7a2a..97c6c24aa5 100644 --- a/src/ch/ch_conf.h +++ b/src/ch/ch_conf.h @@ -24,6 +24,7 @@ #include "virthread.h" #include "ch_capabilities.h" #include "virebtables.h" +#include "object_event.h"
#define CH_DRIVER_NAME "CH" #define CH_CMD "cloud-hypervisor" @@ -75,6 +76,9 @@ struct _virCHDriver * then lockless thereafter */ virCHDriverConfig *config;
+ /* Immutable pointer, self-locking APIs */ + virObjectEventState *domainEventState; + /* pid file FD, ensures two copies of the driver can't use the same root */ int lockFD;
diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index dab025edc1..d18f266387 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -28,6 +28,7 @@ #include "ch_monitor.h" #include "ch_process.h" #include "domain_cgroup.h" +#include "domain_event.h" #include "datatypes.h" #include "driver.h" #include "viraccessapicheck.h" @@ -263,6 +264,7 @@ chDomainCreateWithFlags(virDomainPtr dom, unsigned int flags) virCHDriver *driver = dom->conn->privateData; virDomainObj *vm; virCHDomainObjPrivate *priv; + virObjectEvent *event; g_autofree char *managed_save_path = NULL; int ret = -1;
@@ -304,6 +306,14 @@ chDomainCreateWithFlags(virDomainPtr dom, unsigned int flags) ret = virCHProcessStart(driver, vm, VIR_DOMAIN_RUNNING_BOOTED); }
+ if (ret == 0) { + event = virDomainEventLifecycleNewFromObj(vm, + VIR_DOMAIN_EVENT_STARTED, + VIR_DOMAIN_EVENT_STARTED_BOOTED); + if (event) + virObjectEventStateQueue(driver->domainEventState, event);
No need to check for event != NULL; virObjectEventStateQueue() already does that. Speaking of the variable - it's sufficient to declare it inside the this block. Reviewed-by: Michal Privoznik <mprivozn@redhat.com> and merged. Michal