So far, we only process NIC_RX_FILTER_CHANGED event when the corresponding device has 'trustGuestRxFilters' enabled. And the event is emitted only for virtio model. IOW, this is fairly limited situation and other scenarios don't emit any event (e.g. change of MAC address on a PCI passthrough device). Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2025303 Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/qemu/qemu_domain.c | 16 +++++++++++++++- src/qemu/qemu_domain.h | 3 ++- src/qemu/qemu_driver.c | 9 ++++++--- src/qemu/qemu_process.c | 2 +- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 5e5789a28c..51e5db6631 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -12498,7 +12498,8 @@ syncNicRxFilterMulticast(char *ifname, int qemuDomainSyncRxFilter(virDomainObj *vm, virDomainNetDef *def, - virDomainAsyncJob asyncJob) + virDomainAsyncJob asyncJob, + virObjectEvent **event) { qemuDomainObjPrivate *priv = vm->privateData; g_autoptr(virNetDevRxFilter) guestFilter = NULL; @@ -12550,6 +12551,19 @@ qemuDomainSyncRxFilter(virDomainObj *vm, /* Reflect changed MAC address in the domain XML. */ if (virMacAddrCmp(&def->mac, &guestFilter->mac)) { + if (event) { + char oldMAC[VIR_MAC_STRING_BUFLEN] = { 0 }; + char newMAC[VIR_MAC_STRING_BUFLEN] = { 0 }; + + virMacAddrFormat(&def->mac, oldMAC); + virMacAddrFormat(&guestFilter->mac, newMAC); + + *event = virDomainEventNICMACChangeNewFromObj(vm, + def->info.alias, + oldMAC, + newMAC); + } + virMacAddrSet(&def->mac, &guestFilter->mac); } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 999190e381..3021208c4c 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1127,7 +1127,8 @@ qemuDomainRefreshStatsSchema(virDomainObj *dom); int qemuDomainSyncRxFilter(virDomainObj *vm, virDomainNetDef *def, - virDomainAsyncJob asyncJob); + virDomainAsyncJob asyncJob, + virObjectEvent **event); int qemuDomainSchedCoreStart(virQEMUDriverConfig *cfg, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ccf653d201..f713bff6ab 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3702,9 +3702,11 @@ processNetdevStreamDisconnectedEvent(virDomainObj *vm, static void -processNicRxFilterChangedEvent(virDomainObj *vm, +processNicRxFilterChangedEvent(virQEMUDriver *driver, + virDomainObj *vm, const char *devAlias) { + virObjectEvent *event = NULL; virDomainDeviceDef dev; virDomainNetDef *def; @@ -3749,11 +3751,12 @@ processNicRxFilterChangedEvent(virDomainObj *vm, VIR_DEBUG("process NIC_RX_FILTER_CHANGED event for network " "device %s in domain %s", def->info.alias, vm->def->name); - if (qemuDomainSyncRxFilter(vm, def, VIR_ASYNC_JOB_NONE) < 0) + if (qemuDomainSyncRxFilter(vm, def, VIR_ASYNC_JOB_NONE, &event) < 0) goto endjob; endjob: virDomainObjEndJob(vm); + virObjectEventStateQueue(driver->domainEventState, event); } @@ -4054,7 +4057,7 @@ static void qemuProcessEventHandler(void *data, void *opaque) processNetdevStreamDisconnectedEvent(vm, processEvent->data); break; case QEMU_PROCESS_EVENT_NIC_RX_FILTER_CHANGED: - processNicRxFilterChangedEvent(vm, processEvent->data); + processNicRxFilterChangedEvent(driver, vm, processEvent->data); break; case QEMU_PROCESS_EVENT_SERIAL_CHANGED: processSerialChangedEvent(driver, vm, processEvent->data, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index db06991450..61c1a75639 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7925,7 +7925,7 @@ qemuProcessRefreshRxFilters(virDomainObj *vm, if (!virDomainNetGetActualTrustGuestRxFilters(def)) continue; - if (qemuDomainSyncRxFilter(vm, def, asyncJob) < 0) + if (qemuDomainSyncRxFilter(vm, def, asyncJob, NULL) < 0) return -1; } -- 2.39.3