On Wed, Oct 14, 2026 at 10:41:46AM -0600, Jim Fehlig via Devel wrote:
> Thanks for the review Michal! Before pushing, I'd like to get opinions on an
> idea Claudio and I discussed off-list: a new
> VIR_DOMAIN_EVENT_UNDEFINED_MIGRATED detail for the UNDEFINED event.
>
> On 10/14/26 7:26 AM, Michal Prívozník wrote:
> > On 10/13/26 22:47, Jim Fehlig via Devel wrote:
> > > From: Jim Fehlig <[email protected]>
> > >
> > > When migrating with VIR_MIGRATE_UNDEFINE_SOURCE, qemuMigrationSrcConfirm()
> > > and qemuMigrationSrcPerformJob() delete the domain's persistent config on
> > > the source host but never emit a VIR_DOMAIN_EVENT_UNDEFINED lifecycle
> > > event. Applications relying solely on domain events never learn the domain
> > > was undefined on the source. Emit the event, reusing the existing
> > > VIR_DOMAIN_EVENT_UNDEFINED_REMOVED detail since the semantics match
> > > virDomainUndefine().
>
> While the semantics are the same within libvirt (virDomainDeleteConfig;
> vm->persistent=0;), the distinction between UNDEFINED_REMOVED and
> UNDEFINED_MIGRATED could be important to a platform using libvirt events for
> state synchronization. If agreed, I'll respin a V2 adding the new detail.
Yes, I think it deserves a new constant.
The "reason" should always reflect the API call or operation that
/caused/ the lifecycle change to take place.
IMHO "UNDEFINED_REMOVED" corresponds to the explicit virDomainUndefine
API call/operation.
We use "MIGRATED" as a reason for most other lifecycle events:
$ grep _MIGRATED include/libvirt/libvirt-domain.h
VIR_DOMAIN_RUNNING_MIGRATED = 2, /* migrated from another host
(Since: 0.9.2) */
VIR_DOMAIN_SHUTOFF_MIGRATED = 4, /* migrated to another host (Since:
0.9.2) */
VIR_DOMAIN_EVENT_STARTED_MIGRATED = 1, /* Incoming migration from another
host (Since: 0.5.0) */
VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED = 1, /* Suspended for offline migration
(Since: 0.5.0) */
VIR_DOMAIN_EVENT_RESUMED_MIGRATED = 1, /* Resumed for completion of
migration (Since: 0.5.0) */
VIR_DOMAIN_EVENT_STOPPED_MIGRATED = 3, /* Migrated off to another host
(Since: 0.5.0) */
and both EVENT_DEFINED and EVENT_UNDEFINED could justify doing
the same.
With regards,
Daniel
--
|: https://berrange.com ~~ https://hachyderm.io/@berrange :|
|: https://libvirt.org ~~ https://entangle-photo.org :|
|: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|