mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-26 14:03:49 +03:00
lxc: Cleanup virConnectPtr usage
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@redhat.com> Reviewed-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
f1625edc16
commit
dd2fd7d449
@ -3789,9 +3789,8 @@ lxcDomainAttachDeviceDiskLive(virLXCDriverPtr driver,
|
||||
}
|
||||
|
||||
|
||||
/* XXX conn required for network -> bridge resolution */
|
||||
static int
|
||||
lxcDomainAttachDeviceNetLive(virConnectPtr conn,
|
||||
lxcDomainAttachDeviceNetLive(virLXCDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
virDomainNetDefPtr net)
|
||||
{
|
||||
@ -3852,7 +3851,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:
|
||||
@ -4219,8 +4218,7 @@ lxcDomainAttachDeviceHostdevLive(virLXCDriverPtr driver,
|
||||
|
||||
|
||||
static int
|
||||
lxcDomainAttachDeviceLive(virConnectPtr conn,
|
||||
virLXCDriverPtr driver,
|
||||
lxcDomainAttachDeviceLive(virLXCDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
virDomainDeviceDefPtr dev)
|
||||
{
|
||||
@ -4234,7 +4232,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;
|
||||
@ -4718,7 +4716,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
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user