mirror of https://gitee.com/openkylin/libvirt.git
Remove use of nwfilterPrivateData from nwfilter driver
The nwfilter driver can rely on its global state instead of the connect private data.
This commit is contained in:
parent
04101f23d0
commit
7b1ba9566b
|
@ -38,12 +38,11 @@ virDomainConfNWFilterRegister(virDomainConfNWFilterDriverPtr driver)
|
|||
}
|
||||
|
||||
int
|
||||
virDomainConfNWFilterInstantiate(virConnectPtr conn,
|
||||
const unsigned char *vmuuid,
|
||||
virDomainConfNWFilterInstantiate(const unsigned char *vmuuid,
|
||||
virDomainNetDefPtr net)
|
||||
{
|
||||
if (nwfilterDriver != NULL)
|
||||
return nwfilterDriver->instantiateFilter(conn, vmuuid, net);
|
||||
return nwfilterDriver->instantiateFilter(vmuuid, net);
|
||||
/* driver module not available -- don't indicate failure */
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
#ifndef DOMAIN_NWFILTER_H
|
||||
# define DOMAIN_NWFILTER_H
|
||||
|
||||
typedef int (*virDomainConfInstantiateNWFilter)(virConnectPtr conn,
|
||||
const unsigned char *vmuuid,
|
||||
typedef int (*virDomainConfInstantiateNWFilter)(const unsigned char *vmuuid,
|
||||
virDomainNetDefPtr net);
|
||||
typedef void (*virDomainConfTeardownNWFilter)(virDomainNetDefPtr net);
|
||||
|
||||
|
@ -36,8 +35,7 @@ typedef virDomainConfNWFilterDriver *virDomainConfNWFilterDriverPtr;
|
|||
|
||||
void virDomainConfNWFilterRegister(virDomainConfNWFilterDriverPtr driver);
|
||||
|
||||
int virDomainConfNWFilterInstantiate(virConnectPtr conn,
|
||||
const unsigned char *vmuuid,
|
||||
int virDomainConfNWFilterInstantiate(const unsigned char *vmuuid,
|
||||
virDomainNetDefPtr net);
|
||||
void virDomainConfNWFilterTeardown(virDomainNetDefPtr net);
|
||||
void virDomainConfVMNWFilterTeardown(virDomainObjPtr vm);
|
||||
|
|
|
@ -4189,8 +4189,7 @@ lxcDomainAttachDeviceNetLive(virConnectPtr conn,
|
|||
_("No bridge name specified"));
|
||||
goto cleanup;
|
||||
}
|
||||
if (!(veth = virLXCProcessSetupInterfaceBridged(conn,
|
||||
vm->def,
|
||||
if (!(veth = virLXCProcessSetupInterfaceBridged(vm->def,
|
||||
net,
|
||||
brname)))
|
||||
goto cleanup;
|
||||
|
|
|
@ -239,8 +239,7 @@ static void virLXCProcessCleanup(virLXCDriverPtr driver,
|
|||
}
|
||||
|
||||
|
||||
char *virLXCProcessSetupInterfaceBridged(virConnectPtr conn,
|
||||
virDomainDefPtr vm,
|
||||
char *virLXCProcessSetupInterfaceBridged(virDomainDefPtr vm,
|
||||
virDomainNetDefPtr net,
|
||||
const char *brname)
|
||||
{
|
||||
|
@ -274,7 +273,7 @@ char *virLXCProcessSetupInterfaceBridged(virConnectPtr conn,
|
|||
goto cleanup;
|
||||
|
||||
if (net->filter &&
|
||||
virDomainConfNWFilterInstantiate(conn, vm->uuid, net) < 0)
|
||||
virDomainConfNWFilterInstantiate(vm->uuid, net) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = containerVeth;
|
||||
|
@ -391,8 +390,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
|
|||
_("No bridge name specified"));
|
||||
goto cleanup;
|
||||
}
|
||||
if (!(veth = virLXCProcessSetupInterfaceBridged(conn,
|
||||
def,
|
||||
if (!(veth = virLXCProcessSetupInterfaceBridged(def,
|
||||
net,
|
||||
brname)))
|
||||
goto cleanup;
|
||||
|
|
|
@ -47,8 +47,7 @@ void virLXCProcessAutostartAll(virLXCDriverPtr driver);
|
|||
int virLXCProcessReconnectAll(virLXCDriverPtr driver,
|
||||
virDomainObjListPtr doms);
|
||||
|
||||
char *virLXCProcessSetupInterfaceBridged(virConnectPtr conn,
|
||||
virDomainDefPtr vm,
|
||||
char *virLXCProcessSetupInterfaceBridged(virDomainDefPtr vm,
|
||||
virDomainNetDefPtr net,
|
||||
const char *brname);
|
||||
char *virLXCProcessSetupInterfaceDirect(virConnectPtr conn,
|
||||
|
|
|
@ -64,17 +64,17 @@ VIR_LOG_INIT("nwfilter.nwfilter_driver");
|
|||
",member='Reloaded'"
|
||||
|
||||
|
||||
static virNWFilterDriverStatePtr driverState;
|
||||
static virNWFilterDriverStatePtr driver;
|
||||
|
||||
static int nwfilterStateCleanup(void);
|
||||
|
||||
static int nwfilterStateReload(void);
|
||||
|
||||
static void nwfilterDriverLock(virNWFilterDriverStatePtr driver)
|
||||
static void nwfilterDriverLock(void)
|
||||
{
|
||||
virMutexLock(&driver->lock);
|
||||
}
|
||||
static void nwfilterDriverUnlock(virNWFilterDriverStatePtr driver)
|
||||
static void nwfilterDriverUnlock(void)
|
||||
{
|
||||
virMutexUnlock(&driver->lock);
|
||||
}
|
||||
|
@ -183,17 +183,17 @@ nwfilterStateInitialize(bool privileged,
|
|||
!(sysbus = virDBusGetSystemBus()))
|
||||
return -1;
|
||||
|
||||
if (VIR_ALLOC(driverState) < 0)
|
||||
if (VIR_ALLOC(driver) < 0)
|
||||
return -1;
|
||||
|
||||
if (virMutexInit(&driverState->lock) < 0)
|
||||
if (virMutexInit(&driver->lock) < 0)
|
||||
goto err_free_driverstate;
|
||||
|
||||
/* remember that we are going to use firewalld */
|
||||
driverState->watchingFirewallD = (sysbus != NULL);
|
||||
driverState->privileged = privileged;
|
||||
driver->watchingFirewallD = (sysbus != NULL);
|
||||
driver->privileged = privileged;
|
||||
|
||||
nwfilterDriverLock(driverState);
|
||||
nwfilterDriverLock();
|
||||
|
||||
if (virNWFilterIPAddrMapInit() < 0)
|
||||
goto err_free_driverstate;
|
||||
|
@ -206,7 +206,7 @@ nwfilterStateInitialize(bool privileged,
|
|||
goto err_dhcpsnoop_shutdown;
|
||||
|
||||
if (virNWFilterConfLayerInit(virNWFilterDomainFWUpdateCB,
|
||||
driverState) < 0)
|
||||
driver) < 0)
|
||||
goto err_techdrivers_shutdown;
|
||||
|
||||
/*
|
||||
|
@ -231,23 +231,23 @@ nwfilterStateInitialize(bool privileged,
|
|||
if (VIR_STRDUP(base, SYSCONFDIR "/libvirt") < 0)
|
||||
goto error;
|
||||
|
||||
if (virAsprintf(&driverState->configDir,
|
||||
if (virAsprintf(&driver->configDir,
|
||||
"%s/nwfilter", base) == -1)
|
||||
goto error;
|
||||
|
||||
VIR_FREE(base);
|
||||
|
||||
if (virNWFilterLoadAllConfigs(&driverState->nwfilters,
|
||||
driverState->configDir) < 0)
|
||||
if (virNWFilterLoadAllConfigs(&driver->nwfilters,
|
||||
driver->configDir) < 0)
|
||||
goto error;
|
||||
|
||||
nwfilterDriverUnlock(driverState);
|
||||
nwfilterDriverUnlock();
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
VIR_FREE(base);
|
||||
nwfilterDriverUnlock(driverState);
|
||||
nwfilterDriverUnlock();
|
||||
nwfilterStateCleanup();
|
||||
|
||||
return -1;
|
||||
|
@ -262,7 +262,7 @@ nwfilterStateInitialize(bool privileged,
|
|||
virNWFilterIPAddrMapShutdown();
|
||||
|
||||
err_free_driverstate:
|
||||
VIR_FREE(driverState);
|
||||
VIR_FREE(driver);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -276,26 +276,26 @@ nwfilterStateInitialize(bool privileged,
|
|||
static int
|
||||
nwfilterStateReload(void)
|
||||
{
|
||||
if (!driverState)
|
||||
if (!driver)
|
||||
return -1;
|
||||
|
||||
if (!driverState->privileged)
|
||||
if (!driver->privileged)
|
||||
return 0;
|
||||
|
||||
virNWFilterDHCPSnoopEnd(NULL);
|
||||
/* shut down all threads -- they will be restarted if necessary */
|
||||
virNWFilterLearnThreadsTerminate(true);
|
||||
|
||||
nwfilterDriverLock(driverState);
|
||||
nwfilterDriverLock();
|
||||
virNWFilterWriteLockFilterUpdates();
|
||||
virNWFilterCallbackDriversLock();
|
||||
|
||||
virNWFilterLoadAllConfigs(&driverState->nwfilters,
|
||||
driverState->configDir);
|
||||
virNWFilterLoadAllConfigs(&driver->nwfilters,
|
||||
driver->configDir);
|
||||
|
||||
virNWFilterCallbackDriversUnlock();
|
||||
virNWFilterUnlockFilterUpdates();
|
||||
nwfilterDriverUnlock(driverState);
|
||||
nwfilterDriverUnlock();
|
||||
|
||||
virNWFilterInstFiltersOnAllVMs();
|
||||
|
||||
|
@ -313,10 +313,10 @@ nwfilterStateReload(void)
|
|||
bool
|
||||
virNWFilterDriverIsWatchingFirewallD(void)
|
||||
{
|
||||
if (!driverState)
|
||||
if (!driver)
|
||||
return false;
|
||||
|
||||
return driverState->watchingFirewallD;
|
||||
return driver->watchingFirewallD;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -327,29 +327,29 @@ virNWFilterDriverIsWatchingFirewallD(void)
|
|||
static int
|
||||
nwfilterStateCleanup(void)
|
||||
{
|
||||
if (!driverState)
|
||||
if (!driver)
|
||||
return -1;
|
||||
|
||||
if (driverState->privileged) {
|
||||
if (driver->privileged) {
|
||||
virNWFilterConfLayerShutdown();
|
||||
virNWFilterDHCPSnoopShutdown();
|
||||
virNWFilterLearnShutdown();
|
||||
virNWFilterIPAddrMapShutdown();
|
||||
virNWFilterTechDriversShutdown();
|
||||
|
||||
nwfilterDriverLock(driverState);
|
||||
nwfilterDriverLock();
|
||||
|
||||
nwfilterDriverRemoveDBusMatches();
|
||||
|
||||
/* free inactive nwfilters */
|
||||
virNWFilterObjListFree(&driverState->nwfilters);
|
||||
virNWFilterObjListFree(&driver->nwfilters);
|
||||
|
||||
VIR_FREE(driverState->configDir);
|
||||
nwfilterDriverUnlock(driverState);
|
||||
VIR_FREE(driver->configDir);
|
||||
nwfilterDriverUnlock();
|
||||
}
|
||||
|
||||
virMutexDestroy(&driverState->lock);
|
||||
VIR_FREE(driverState);
|
||||
virMutexDestroy(&driver->lock);
|
||||
VIR_FREE(driver);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -359,13 +359,12 @@ static virNWFilterPtr
|
|||
nwfilterLookupByUUID(virConnectPtr conn,
|
||||
const unsigned char *uuid)
|
||||
{
|
||||
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
|
||||
virNWFilterObjPtr nwfilter;
|
||||
virNWFilterPtr ret = NULL;
|
||||
|
||||
nwfilterDriverLock(driver);
|
||||
nwfilterDriverLock();
|
||||
nwfilter = virNWFilterObjFindByUUID(&driver->nwfilters, uuid);
|
||||
nwfilterDriverUnlock(driver);
|
||||
nwfilterDriverUnlock();
|
||||
|
||||
if (!nwfilter) {
|
||||
virReportError(VIR_ERR_NO_NWFILTER,
|
||||
|
@ -389,13 +388,12 @@ static virNWFilterPtr
|
|||
nwfilterLookupByName(virConnectPtr conn,
|
||||
const char *name)
|
||||
{
|
||||
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
|
||||
virNWFilterObjPtr nwfilter;
|
||||
virNWFilterPtr ret = NULL;
|
||||
|
||||
nwfilterDriverLock(driver);
|
||||
nwfilterDriverLock();
|
||||
nwfilter = virNWFilterObjFindByName(&driver->nwfilters, name);
|
||||
nwfilterDriverUnlock(driver);
|
||||
nwfilterDriverUnlock();
|
||||
|
||||
if (!nwfilter) {
|
||||
virReportError(VIR_ERR_NO_NWFILTER,
|
||||
|
@ -416,24 +414,22 @@ nwfilterLookupByName(virConnectPtr conn,
|
|||
|
||||
|
||||
static virDrvOpenStatus
|
||||
nwfilterOpen(virConnectPtr conn,
|
||||
nwfilterOpen(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
||||
unsigned int flags)
|
||||
{
|
||||
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
||||
|
||||
if (!driverState)
|
||||
if (!driver)
|
||||
return VIR_DRV_OPEN_DECLINED;
|
||||
|
||||
conn->nwfilterPrivateData = driverState;
|
||||
return VIR_DRV_OPEN_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
nwfilterClose(virConnectPtr conn)
|
||||
nwfilterClose(virConnectPtr conn ATTRIBUTE_UNUSED)
|
||||
{
|
||||
conn->nwfilterPrivateData = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -441,7 +437,6 @@ nwfilterClose(virConnectPtr conn)
|
|||
static int
|
||||
nwfilterConnectNumOfNWFilters(virConnectPtr conn)
|
||||
{
|
||||
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
|
||||
size_t i;
|
||||
int n;
|
||||
|
||||
|
@ -466,14 +461,13 @@ nwfilterConnectListNWFilters(virConnectPtr conn,
|
|||
char **const names,
|
||||
int nnames)
|
||||
{
|
||||
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
|
||||
int got = 0;
|
||||
size_t i;
|
||||
|
||||
if (virConnectListNWFiltersEnsureACL(conn) < 0)
|
||||
return -1;
|
||||
|
||||
nwfilterDriverLock(driver);
|
||||
nwfilterDriverLock();
|
||||
for (i = 0; i < driver->nwfilters.count && got < nnames; i++) {
|
||||
virNWFilterObjPtr obj = driver->nwfilters.objs[i];
|
||||
virNWFilterObjLock(obj);
|
||||
|
@ -486,11 +480,11 @@ nwfilterConnectListNWFilters(virConnectPtr conn,
|
|||
}
|
||||
virNWFilterObjUnlock(obj);
|
||||
}
|
||||
nwfilterDriverUnlock(driver);
|
||||
nwfilterDriverUnlock();
|
||||
return got;
|
||||
|
||||
cleanup:
|
||||
nwfilterDriverUnlock(driver);
|
||||
nwfilterDriverUnlock();
|
||||
for (i = 0; i < got; i++)
|
||||
VIR_FREE(names[i]);
|
||||
memset(names, 0, nnames * sizeof(*names));
|
||||
|
@ -503,7 +497,6 @@ nwfilterConnectListAllNWFilters(virConnectPtr conn,
|
|||
virNWFilterPtr **filters,
|
||||
unsigned int flags)
|
||||
{
|
||||
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
|
||||
virNWFilterPtr *tmp_filters = NULL;
|
||||
int nfilters = 0;
|
||||
virNWFilterPtr filter = NULL;
|
||||
|
@ -516,7 +509,7 @@ nwfilterConnectListAllNWFilters(virConnectPtr conn,
|
|||
if (virConnectListAllNWFiltersEnsureACL(conn) < 0)
|
||||
return -1;
|
||||
|
||||
nwfilterDriverLock(driver);
|
||||
nwfilterDriverLock();
|
||||
|
||||
if (!filters) {
|
||||
ret = driver->nwfilters.count;
|
||||
|
@ -545,7 +538,7 @@ nwfilterConnectListAllNWFilters(virConnectPtr conn,
|
|||
ret = nfilters;
|
||||
|
||||
cleanup:
|
||||
nwfilterDriverUnlock(driver);
|
||||
nwfilterDriverUnlock();
|
||||
if (tmp_filters) {
|
||||
for (i = 0; i < nfilters; i ++)
|
||||
virObjectUnref(tmp_filters[i]);
|
||||
|
@ -559,12 +552,11 @@ static virNWFilterPtr
|
|||
nwfilterDefineXML(virConnectPtr conn,
|
||||
const char *xml)
|
||||
{
|
||||
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
|
||||
virNWFilterDefPtr def;
|
||||
virNWFilterObjPtr nwfilter = NULL;
|
||||
virNWFilterPtr ret = NULL;
|
||||
|
||||
nwfilterDriverLock(driver);
|
||||
nwfilterDriverLock();
|
||||
virNWFilterWriteLockFilterUpdates();
|
||||
virNWFilterCallbackDriversLock();
|
||||
|
||||
|
@ -593,7 +585,7 @@ nwfilterDefineXML(virConnectPtr conn,
|
|||
|
||||
virNWFilterCallbackDriversUnlock();
|
||||
virNWFilterUnlockFilterUpdates();
|
||||
nwfilterDriverUnlock(driver);
|
||||
nwfilterDriverUnlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -601,11 +593,10 @@ nwfilterDefineXML(virConnectPtr conn,
|
|||
static int
|
||||
nwfilterUndefine(virNWFilterPtr obj)
|
||||
{
|
||||
virNWFilterDriverStatePtr driver = obj->conn->nwfilterPrivateData;
|
||||
virNWFilterObjPtr nwfilter;
|
||||
int ret = -1;
|
||||
|
||||
nwfilterDriverLock(driver);
|
||||
nwfilterDriverLock();
|
||||
virNWFilterWriteLockFilterUpdates();
|
||||
virNWFilterCallbackDriversLock();
|
||||
|
||||
|
@ -641,7 +632,7 @@ nwfilterUndefine(virNWFilterPtr obj)
|
|||
|
||||
virNWFilterCallbackDriversUnlock();
|
||||
virNWFilterUnlockFilterUpdates();
|
||||
nwfilterDriverUnlock(driver);
|
||||
nwfilterDriverUnlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -650,15 +641,14 @@ static char *
|
|||
nwfilterGetXMLDesc(virNWFilterPtr obj,
|
||||
unsigned int flags)
|
||||
{
|
||||
virNWFilterDriverStatePtr driver = obj->conn->nwfilterPrivateData;
|
||||
virNWFilterObjPtr nwfilter;
|
||||
char *ret = NULL;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
|
||||
nwfilterDriverLock(driver);
|
||||
nwfilterDriverLock();
|
||||
nwfilter = virNWFilterObjFindByUUID(&driver->nwfilters, obj->uuid);
|
||||
nwfilterDriverUnlock(driver);
|
||||
nwfilterDriverUnlock();
|
||||
|
||||
if (!nwfilter) {
|
||||
virReportError(VIR_ERR_NO_NWFILTER,
|
||||
|
@ -679,11 +669,10 @@ nwfilterGetXMLDesc(virNWFilterPtr obj,
|
|||
|
||||
|
||||
static int
|
||||
nwfilterInstantiateFilter(virConnectPtr conn,
|
||||
const unsigned char *vmuuid,
|
||||
nwfilterInstantiateFilter(const unsigned char *vmuuid,
|
||||
virDomainNetDefPtr net)
|
||||
{
|
||||
return virNWFilterInstantiateFilter(conn->nwfilterPrivateData, vmuuid, net);
|
||||
return virNWFilterInstantiateFilter(driver, vmuuid, net);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -285,7 +285,6 @@ static int qemuCreateInBridgePortWithHelper(virQEMUDriverConfigPtr cfg,
|
|||
*/
|
||||
int
|
||||
qemuNetworkIfaceConnect(virDomainDefPtr def,
|
||||
virConnectPtr conn,
|
||||
virQEMUDriverPtr driver,
|
||||
virDomainNetDefPtr net,
|
||||
virQEMUCapsPtr qemuCaps,
|
||||
|
@ -368,7 +367,7 @@ qemuNetworkIfaceConnect(virDomainDefPtr def,
|
|||
goto cleanup;
|
||||
|
||||
if (net->filter &&
|
||||
virDomainConfNWFilterInstantiate(conn, def->uuid, net) < 0) {
|
||||
virDomainConfNWFilterInstantiate(def->uuid, net) < 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -7420,7 +7419,6 @@ qemuBuildVhostuserCommandLine(virCommandPtr cmd,
|
|||
static int
|
||||
qemuBuildInterfaceCommandLine(virCommandPtr cmd,
|
||||
virQEMUDriverPtr driver,
|
||||
virConnectPtr conn,
|
||||
virDomainDefPtr def,
|
||||
virDomainNetDefPtr net,
|
||||
virQEMUCapsPtr qemuCaps,
|
||||
|
@ -7476,7 +7474,7 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
|
|||
|
||||
memset(tapfd, -1, tapfdSize * sizeof(tapfd[0]));
|
||||
|
||||
if (qemuNetworkIfaceConnect(def, conn, driver, net,
|
||||
if (qemuNetworkIfaceConnect(def, driver, net,
|
||||
qemuCaps, tapfd, &tapfdSize) < 0)
|
||||
goto cleanup;
|
||||
} else if (actualType == VIR_DOMAIN_NET_TYPE_DIRECT) {
|
||||
|
@ -8933,7 +8931,7 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|||
else
|
||||
vlan = i;
|
||||
|
||||
if (qemuBuildInterfaceCommandLine(cmd, driver, conn, def, net,
|
||||
if (qemuBuildInterfaceCommandLine(cmd, driver, def, net,
|
||||
qemuCaps, vlan, bootNet, vmop,
|
||||
standalone) < 0)
|
||||
goto error;
|
||||
|
|
|
@ -190,7 +190,6 @@ char *qemuBuildRedirdevDevStr(virDomainDefPtr def,
|
|||
virDomainRedirdevDefPtr dev,
|
||||
virQEMUCapsPtr qemuCaps);
|
||||
int qemuNetworkIfaceConnect(virDomainDefPtr def,
|
||||
virConnectPtr conn,
|
||||
virQEMUDriverPtr driver,
|
||||
virDomainNetDefPtr net,
|
||||
virQEMUCapsPtr qemuCaps,
|
||||
|
|
|
@ -7177,7 +7177,7 @@ qemuDomainUpdateDeviceLive(virConnectPtr conn,
|
|||
ret = qemuDomainChangeGraphics(driver, vm, dev->data.graphics);
|
||||
break;
|
||||
case VIR_DOMAIN_DEVICE_NET:
|
||||
ret = qemuDomainChangeNet(driver, vm, dom, dev);
|
||||
ret = qemuDomainChangeNet(driver, vm, dev);
|
||||
break;
|
||||
case VIR_DOMAIN_DEVICE_FS:
|
||||
case VIR_DOMAIN_DEVICE_INPUT:
|
||||
|
|
|
@ -914,7 +914,7 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
|
|||
if (VIR_ALLOC_N(vhostfd, vhostfdSize) < 0)
|
||||
goto cleanup;
|
||||
memset(vhostfd, -1, sizeof(*vhostfd) * vhostfdSize);
|
||||
if (qemuNetworkIfaceConnect(vm->def, conn, driver, net,
|
||||
if (qemuNetworkIfaceConnect(vm->def, driver, net,
|
||||
priv->qemuCaps, tapfd, &tapfdSize) < 0)
|
||||
goto cleanup;
|
||||
iface_connected = true;
|
||||
|
@ -1830,8 +1830,7 @@ qemuDomainChangeNetBridge(virDomainObjPtr vm,
|
|||
}
|
||||
|
||||
static int
|
||||
qemuDomainChangeNetFilter(virConnectPtr conn,
|
||||
virDomainObjPtr vm,
|
||||
qemuDomainChangeNetFilter(virDomainObjPtr vm,
|
||||
virDomainNetDefPtr olddev,
|
||||
virDomainNetDefPtr newdev)
|
||||
{
|
||||
|
@ -1851,7 +1850,7 @@ qemuDomainChangeNetFilter(virConnectPtr conn,
|
|||
virDomainConfNWFilterTeardown(olddev);
|
||||
|
||||
if (newdev->filter &&
|
||||
virDomainConfNWFilterInstantiate(conn, vm->def->uuid, newdev) < 0) {
|
||||
virDomainConfNWFilterInstantiate(vm->def->uuid, newdev) < 0) {
|
||||
virErrorPtr errobj;
|
||||
|
||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||
|
@ -1859,7 +1858,7 @@ qemuDomainChangeNetFilter(virConnectPtr conn,
|
|||
"- attempting to restore old rules"),
|
||||
olddev->ifname);
|
||||
errobj = virSaveLastError();
|
||||
ignore_value(virDomainConfNWFilterInstantiate(conn, vm->def->uuid, olddev));
|
||||
ignore_value(virDomainConfNWFilterInstantiate(vm->def->uuid, olddev));
|
||||
virSetError(errobj);
|
||||
virFreeError(errobj);
|
||||
return -1;
|
||||
|
@ -1902,7 +1901,6 @@ int qemuDomainChangeNetLinkState(virQEMUDriverPtr driver,
|
|||
int
|
||||
qemuDomainChangeNet(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
virDomainPtr dom,
|
||||
virDomainDeviceDefPtr dev)
|
||||
{
|
||||
virDomainNetDefPtr newdev = dev->data.net;
|
||||
|
@ -2230,7 +2228,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
|
|||
}
|
||||
|
||||
if (needFilterChange) {
|
||||
if (qemuDomainChangeNetFilter(dom->conn, vm, olddev, newdev) < 0)
|
||||
if (qemuDomainChangeNetFilter(vm, olddev, newdev) < 0)
|
||||
goto cleanup;
|
||||
/* we successfully switched to the new filter, and we've
|
||||
* determined that the rest of newdev is equivalent to olddev,
|
||||
|
|
|
@ -68,7 +68,6 @@ int qemuDomainChangeGraphicsPasswords(virQEMUDriverPtr driver,
|
|||
int asyncJob);
|
||||
int qemuDomainChangeNet(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
virDomainPtr dom,
|
||||
virDomainDeviceDefPtr dev);
|
||||
int qemuDomainChangeNetLinkState(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
|
|
|
@ -3331,18 +3331,14 @@ qemuProcessNotifyNets(virDomainDefPtr def)
|
|||
}
|
||||
|
||||
static int
|
||||
qemuProcessFiltersInstantiate(virConnectPtr conn,
|
||||
virDomainDefPtr def)
|
||||
qemuProcessFiltersInstantiate(virDomainDefPtr def)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (!conn)
|
||||
return 1;
|
||||
|
||||
for (i = 0; i < def->nnets; i++) {
|
||||
virDomainNetDefPtr net = def->nets[i];
|
||||
if ((net->filter) && (net->ifname)) {
|
||||
if (virDomainConfNWFilterInstantiate(conn, def->uuid, net) < 0)
|
||||
if (virDomainConfNWFilterInstantiate(def->uuid, net) < 0)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -3800,7 +3796,7 @@ qemuProcessReconnect(void *opaque)
|
|||
if (qemuProcessNotifyNets(obj->def) < 0)
|
||||
goto error;
|
||||
|
||||
if (qemuProcessFiltersInstantiate(conn, obj->def))
|
||||
if (qemuProcessFiltersInstantiate(obj->def))
|
||||
goto error;
|
||||
|
||||
if (qemuDomainCheckEjectableMedia(driver, obj, QEMU_ASYNC_JOB_NONE) < 0)
|
||||
|
|
|
@ -105,8 +105,7 @@ virCapsPtr umlCapsInit(void)
|
|||
|
||||
|
||||
static int
|
||||
umlConnectTapDevice(virConnectPtr conn,
|
||||
virDomainDefPtr vm,
|
||||
umlConnectTapDevice(virDomainDefPtr vm,
|
||||
virDomainNetDefPtr net,
|
||||
const char *bridge)
|
||||
{
|
||||
|
@ -135,7 +134,7 @@ umlConnectTapDevice(virConnectPtr conn,
|
|||
}
|
||||
|
||||
if (net->filter) {
|
||||
if (virDomainConfNWFilterInstantiate(conn, vm->uuid, net) < 0) {
|
||||
if (virDomainConfNWFilterInstantiate(vm->uuid, net) < 0) {
|
||||
if (template_ifname)
|
||||
VIR_FREE(net->ifname);
|
||||
goto error;
|
||||
|
@ -217,7 +216,7 @@ umlBuildCommandLineNet(virConnectPtr conn,
|
|||
if (bridge == NULL)
|
||||
goto error;
|
||||
|
||||
if (umlConnectTapDevice(conn, vm, def, bridge) < 0) {
|
||||
if (umlConnectTapDevice(vm, def, bridge) < 0) {
|
||||
VIR_FREE(bridge);
|
||||
goto error;
|
||||
}
|
||||
|
@ -228,7 +227,7 @@ umlBuildCommandLineNet(virConnectPtr conn,
|
|||
}
|
||||
|
||||
case VIR_DOMAIN_NET_TYPE_BRIDGE:
|
||||
if (umlConnectTapDevice(conn, vm, def,
|
||||
if (umlConnectTapDevice(vm, def,
|
||||
def->data.bridge.brname) < 0)
|
||||
goto error;
|
||||
|
||||
|
|
Loading…
Reference in New Issue