1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-30 18:50:18 +03:00

qemu: Emit NIC_MAC_CHANGE event

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://issues.redhat.com/browse/RHEL-7035
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Michal Privoznik 2023-06-27 13:32:55 +02:00
parent 057872df2d
commit 50981052a5
4 changed files with 24 additions and 6 deletions

View File

@ -11088,7 +11088,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;
@ -11145,6 +11146,19 @@ qemuDomainSyncRxFilter(virDomainObj *vm,
oldMac = &def->mac;
if (virMacAddrCmp(oldMac, &guestFilter->mac)) {
if (event) {
char oldMACStr[VIR_MAC_STRING_BUFLEN] = { 0 };
char newMACStr[VIR_MAC_STRING_BUFLEN] = { 0 };
virMacAddrFormat(oldMac, oldMACStr);
virMacAddrFormat(&guestFilter->mac, newMACStr);
*event = virDomainEventNICMACChangeNewFromObj(vm,
def->info.alias,
oldMACStr,
newMACStr);
}
/* Reflect changed MAC address in the domain XML. */
if (virMacAddrCmp(&def->mac, &guestFilter->mac)) {
if (!def->currentAddress) {

View File

@ -1132,7 +1132,8 @@ qemuDomainRefreshStatsSchema(virDomainObj *dom);
int
qemuDomainSyncRxFilter(virDomainObj *vm,
virDomainNetDef *def,
virDomainAsyncJob asyncJob);
virDomainAsyncJob asyncJob,
virObjectEvent **event);
int
qemuDomainSchedCoreStart(virQEMUDriverConfig *cfg,

View File

@ -3679,9 +3679,11 @@ processNetdevStreamDisconnectedEvent(virDomainObj *vm,
static void
processNicRxFilterChangedEvent(virDomainObj *vm,
processNicRxFilterChangedEvent(virQEMUDriver *driver,
virDomainObj *vm,
const char *devAlias)
{
virObjectEvent *event = NULL;
virDomainDeviceDef dev;
virDomainNetDef *def;
@ -3726,11 +3728,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);
}
@ -4074,7 +4077,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,

View File

@ -8362,7 +8362,7 @@ qemuProcessRefreshRxFilters(virDomainObj *vm,
continue;
}
if (qemuDomainSyncRxFilter(vm, def, asyncJob) < 0)
if (qemuDomainSyncRxFilter(vm, def, asyncJob, NULL) < 0)
return -1;
}