There are couple of scenarios where we need to reflect MAC change
done in the guest:
1) domain restore from a file (here, we don't store updated MAC
in the save file and thus on restore create the macvtap with
the original MAC),
2) reconnecting to a running domain (here, the guest might have
changed the MAC while we were not running),
3) migration (here, guest might change the MAC address but we
fail to respond to it,
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_domain.c | 9 ++++++---
src/qemu/qemu_domain.h | 3 ++-
src/qemu/qemu_driver.c | 2 +-
src/qemu/qemu_process.c | 27 +++++++++++++++++++++++++++
4 files changed, 36 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 1b93ebe579..b408ec0607 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -11975,14 +11975,17 @@ syncNicRxFilterMulticast(char *ifname,
int
qemuDomainSyncRxFilter(virDomainObj *vm,
- virDomainNetDef *def)
+ virDomainNetDef *def,
+ virDomainAsyncJob asyncJob)
{
qemuDomainObjPrivate *priv = vm->privateData;
g_autoptr(virNetDevRxFilter) guestFilter = NULL;
g_autoptr(virNetDevRxFilter) hostFilter = NULL;
int rc;
- qemuDomainObjEnterMonitor(vm);
+ if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0)
+ return -1;
+
rc = qemuMonitorQueryRxFilter(priv->mon, def->info.alias, &guestFilter);
qemuDomainObjExitMonitor(vm);
if (rc < 0)
@@ -11990,7 +11993,7 @@ qemuDomainSyncRxFilter(virDomainObj *vm,
if (virDomainNetGetActualType(def) == VIR_DOMAIN_NET_TYPE_DIRECT) {
if (virNetDevGetRxFilter(def->ifname, &hostFilter)) {
- VIR_WARN("Couldn't get current RX filter for device %s while
responding to NIC_RX_FILTER_CHANGED",
+ VIR_WARN("Couldn't get current RX filter for device %s",
def->ifname);
return -1;
}
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index f436861efc..37e0a90452 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -1101,4 +1101,5 @@ qemuDomainObjWait(virDomainObj *vm);
int
qemuDomainSyncRxFilter(virDomainObj *vm,
- virDomainNetDef *def);
+ virDomainNetDef *def,
+ virDomainAsyncJob asyncJob);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d5fb2913be..803d2c1771 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3662,7 +3662,7 @@ 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) < 0)
+ if (qemuDomainSyncRxFilter(vm, def, VIR_ASYNC_JOB_NONE) < 0)
goto endjob;
endjob:
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 1a9175f40f..fe98601fce 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -7756,6 +7756,26 @@ qemuProcessLaunch(virConnectPtr conn,
}
+static int
+qemuProcessRefreshRxFilters(virDomainObj *vm,
+ virDomainAsyncJob asyncJob)
+{
+ size_t i;
+
+ for (i = 0; i < vm->def->nnets; i++) {
+ virDomainNetDef *def = vm->def->nets[i];
+
+ if (!virDomainNetGetActualTrustGuestRxFilters(def))
+ continue;
+
+ if (qemuDomainSyncRxFilter(vm, def, asyncJob) < 0)
+ return -1;
+ }
+
+ return 0;
+}
+
+
/**
* qemuProcessRefreshState:
* @driver: qemu driver data
@@ -7787,6 +7807,10 @@ qemuProcessRefreshState(virQEMUDriver *driver,
if (qemuProcessRefreshDisks(vm, asyncJob) < 0)
return -1;
+ VIR_DEBUG("Updating rx-filter data");
+ if (qemuProcessRefreshRxFilters(vm, asyncJob) < 0)
+ return -1;
+
return 0;
}
@@ -8807,6 +8831,9 @@ qemuProcessReconnect(void *opaque)
if (qemuSecurityReserveLabel(driver->securityManager, obj->def, obj->pid)
< 0)
goto error;
+ if (qemuProcessRefreshRxFilters(obj, VIR_ASYNC_JOB_NONE) < 0)
+ goto error;
+
qemuProcessNotifyNets(obj->def);
qemuProcessFiltersInstantiate(obj->def);
--
2.37.3