There are some functions which pass virConnectPtr around for one
reason and one reason only: to obtain virLXCDriverPtr in the end.
Might replace the argument and pass a pointer to the driver right
from the start.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/lxc/lxc_driver.c | 12 +++++-------
src/lxc/lxc_process.c | 40 ++++++++++++++++++++++------------------
src/lxc/lxc_process.h | 2 +-
3 files changed, 28 insertions(+), 26 deletions(-)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 826bf074e3..e4be45fca2 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -3803,9 +3803,8 @@ lxcDomainAttachDeviceDiskLive(virLXCDriverPtr driver,
}
-/* XXX conn required for network -> bridge resolution */
static int
-lxcDomainAttachDeviceNetLive(virConnectPtr conn,
+lxcDomainAttachDeviceNetLive(virLXCDriverPtr driver,
virDomainObjPtr vm,
virDomainNetDefPtr net)
{
@@ -3866,7 +3865,7 @@ lxcDomainAttachDeviceNetLive(virConnectPtr conn,
goto cleanup;
break;
case VIR_DOMAIN_NET_TYPE_DIRECT: {
- if (!(veth = virLXCProcessSetupInterfaceDirect(conn, vm->def, net)))
+ if (!(veth = virLXCProcessSetupInterfaceDirect(driver, vm->def, net)))
goto cleanup;
} break;
case VIR_DOMAIN_NET_TYPE_USER:
@@ -4233,8 +4232,7 @@ lxcDomainAttachDeviceHostdevLive(virLXCDriverPtr driver,
static int
-lxcDomainAttachDeviceLive(virConnectPtr conn,
- virLXCDriverPtr driver,
+lxcDomainAttachDeviceLive(virLXCDriverPtr driver,
virDomainObjPtr vm,
virDomainDeviceDefPtr dev)
{
@@ -4248,7 +4246,7 @@ lxcDomainAttachDeviceLive(virConnectPtr conn,
break;
case VIR_DOMAIN_DEVICE_NET:
- ret = lxcDomainAttachDeviceNetLive(conn, vm,
+ ret = lxcDomainAttachDeviceNetLive(driver, vm,
dev->data.net);
if (!ret)
dev->data.net = NULL;
@@ -4736,7 +4734,7 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr dom,
true) < 0)
goto endjob;
- if ((ret = lxcDomainAttachDeviceLive(dom->conn, driver, vm, dev_copy)) <
0)
+ if ((ret = lxcDomainAttachDeviceLive(driver, vm, dev_copy)) < 0)
goto endjob;
/*
* update domain status forcibly because the domain status may be
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index 9b62a93096..f5d2fb0145 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -326,13 +326,13 @@ virLXCProcessSetupInterfaceTap(virDomainDefPtr vm,
}
-char *virLXCProcessSetupInterfaceDirect(virConnectPtr conn,
- virDomainDefPtr def,
- virDomainNetDefPtr net)
+char *
+virLXCProcessSetupInterfaceDirect(virLXCDriverPtr driver,
+ virDomainDefPtr def,
+ virDomainNetDefPtr net)
{
char *ret = NULL;
char *res_ifname = NULL;
- virLXCDriverPtr driver = conn->privateData;
const virNetDevBandwidth *bw;
const virNetDevVPortProfile *prof;
virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
@@ -392,9 +392,10 @@ static const char *nsInfoLocal[VIR_LXC_DOMAIN_NAMESPACE_LAST] = {
[VIR_LXC_DOMAIN_NAMESPACE_SHAREUTS] = "uts",
};
-static int virLXCProcessSetupNamespaceName(virConnectPtr conn, int ns_type, const char
*name)
+static int virLXCProcessSetupNamespaceName(virLXCDriverPtr driver,
+ int ns_type,
+ const char *name)
{
- virLXCDriverPtr driver = conn->privateData;
int fd = -1;
virDomainObjPtr vm;
virLXCDomainObjPrivatePtr priv;
@@ -474,7 +475,7 @@ static int virLXCProcessSetupNamespaceNet(int ns_type, const char
*name)
/**
* virLXCProcessSetupNamespaces:
- * @conn: pointer to connection
+ * @driver: pointer to driver structure
* @def: pointer to virtual machines namespaceData
* @nsFDs: out parameter to store the namespace FD
*
@@ -483,9 +484,10 @@ static int virLXCProcessSetupNamespaceNet(int ns_type, const char
*name)
*
* Returns 0 on success or -1 in case of error
*/
-static int virLXCProcessSetupNamespaces(virConnectPtr conn,
- lxcDomainDefPtr lxcDef,
- int *nsFDs)
+static int
+virLXCProcessSetupNamespaces(virLXCDriverPtr driver,
+ lxcDomainDefPtr lxcDef,
+ int *nsFDs)
{
size_t i;
@@ -500,7 +502,8 @@ static int virLXCProcessSetupNamespaces(virConnectPtr conn,
case VIR_LXC_DOMAIN_NAMESPACE_SOURCE_NONE:
continue;
case VIR_LXC_DOMAIN_NAMESPACE_SOURCE_NAME:
- if ((nsFDs[i] = virLXCProcessSetupNamespaceName(conn, i,
lxcDef->ns_val[i])) < 0)
+ if ((nsFDs[i] = virLXCProcessSetupNamespaceName(driver, i,
+ lxcDef->ns_val[i])) <
0)
return -1;
break;
case VIR_LXC_DOMAIN_NAMESPACE_SOURCE_PID:
@@ -519,7 +522,7 @@ static int virLXCProcessSetupNamespaces(virConnectPtr conn,
/**
* virLXCProcessSetupInterfaces:
- * @conn: pointer to connection
+ * @driver: pointer to driver structure
* @def: pointer to virtual machine structure
* @veths: string list of interface names
*
@@ -529,9 +532,10 @@ static int virLXCProcessSetupNamespaces(virConnectPtr conn,
*
* Returns 0 on success or -1 in case of error
*/
-static int virLXCProcessSetupInterfaces(virConnectPtr conn,
- virDomainDefPtr def,
- char ***veths)
+static int
+virLXCProcessSetupInterfaces(virLXCDriverPtr driver,
+ virDomainDefPtr def,
+ char ***veths)
{
int ret = -1;
size_t i;
@@ -585,7 +589,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
goto cleanup;
break;
case VIR_DOMAIN_NET_TYPE_DIRECT:
- if (!(veth = virLXCProcessSetupInterfaceDirect(conn, def, net)))
+ if (!(veth = virLXCProcessSetupInterfaceDirect(driver, def, net)))
goto cleanup;
break;
@@ -1344,11 +1348,11 @@ int virLXCProcessStart(virConnectPtr conn,
}
VIR_DEBUG("Setting up Interfaces");
- if (virLXCProcessSetupInterfaces(conn, vm->def, &veths) < 0)
+ if (virLXCProcessSetupInterfaces(driver, vm->def, &veths) < 0)
goto cleanup;
VIR_DEBUG("Setting up namespaces if any");
- if (virLXCProcessSetupNamespaces(conn, vm->def->namespaceData, nsInheritFDs)
< 0)
+ if (virLXCProcessSetupNamespaces(driver, vm->def->namespaceData, nsInheritFDs)
< 0)
goto cleanup;
VIR_DEBUG("Preparing to launch");
diff --git a/src/lxc/lxc_process.h b/src/lxc/lxc_process.h
index 1bf359b229..383f6f714d 100644
--- a/src/lxc/lxc_process.h
+++ b/src/lxc/lxc_process.h
@@ -50,6 +50,6 @@ int virLXCProcessValidateInterface(virDomainNetDefPtr net);
char *virLXCProcessSetupInterfaceTap(virDomainDefPtr vm,
virDomainNetDefPtr net,
const char *brname);
-char *virLXCProcessSetupInterfaceDirect(virConnectPtr conn,
+char *virLXCProcessSetupInterfaceDirect(virLXCDriverPtr driver,
virDomainDefPtr def,
virDomainNetDefPtr net);
--
2.23.0