mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-27 18:03:50 +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
|
static int
|
||||||
lxcDomainAttachDeviceNetLive(virConnectPtr conn,
|
lxcDomainAttachDeviceNetLive(virLXCDriverPtr driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
virDomainNetDefPtr net)
|
virDomainNetDefPtr net)
|
||||||
{
|
{
|
||||||
@ -3852,7 +3851,7 @@ lxcDomainAttachDeviceNetLive(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_NET_TYPE_DIRECT: {
|
case VIR_DOMAIN_NET_TYPE_DIRECT: {
|
||||||
if (!(veth = virLXCProcessSetupInterfaceDirect(conn, vm->def, net)))
|
if (!(veth = virLXCProcessSetupInterfaceDirect(driver, vm->def, net)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} break;
|
} break;
|
||||||
case VIR_DOMAIN_NET_TYPE_USER:
|
case VIR_DOMAIN_NET_TYPE_USER:
|
||||||
@ -4219,8 +4218,7 @@ lxcDomainAttachDeviceHostdevLive(virLXCDriverPtr driver,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
lxcDomainAttachDeviceLive(virConnectPtr conn,
|
lxcDomainAttachDeviceLive(virLXCDriverPtr driver,
|
||||||
virLXCDriverPtr driver,
|
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
virDomainDeviceDefPtr dev)
|
virDomainDeviceDefPtr dev)
|
||||||
{
|
{
|
||||||
@ -4234,7 +4232,7 @@ lxcDomainAttachDeviceLive(virConnectPtr conn,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_DEVICE_NET:
|
case VIR_DOMAIN_DEVICE_NET:
|
||||||
ret = lxcDomainAttachDeviceNetLive(conn, vm,
|
ret = lxcDomainAttachDeviceNetLive(driver, vm,
|
||||||
dev->data.net);
|
dev->data.net);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
dev->data.net = NULL;
|
dev->data.net = NULL;
|
||||||
@ -4718,7 +4716,7 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr dom,
|
|||||||
true) < 0)
|
true) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if ((ret = lxcDomainAttachDeviceLive(dom->conn, driver, vm, dev_copy)) < 0)
|
if ((ret = lxcDomainAttachDeviceLive(driver, vm, dev_copy)) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
/*
|
/*
|
||||||
* update domain status forcibly because the domain status may be
|
* update domain status forcibly because the domain status may be
|
||||||
|
@ -326,13 +326,13 @@ virLXCProcessSetupInterfaceTap(virDomainDefPtr vm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *virLXCProcessSetupInterfaceDirect(virConnectPtr conn,
|
char *
|
||||||
virDomainDefPtr def,
|
virLXCProcessSetupInterfaceDirect(virLXCDriverPtr driver,
|
||||||
virDomainNetDefPtr net)
|
virDomainDefPtr def,
|
||||||
|
virDomainNetDefPtr net)
|
||||||
{
|
{
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
char *res_ifname = NULL;
|
char *res_ifname = NULL;
|
||||||
virLXCDriverPtr driver = conn->privateData;
|
|
||||||
const virNetDevBandwidth *bw;
|
const virNetDevBandwidth *bw;
|
||||||
const virNetDevVPortProfile *prof;
|
const virNetDevVPortProfile *prof;
|
||||||
virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
|
virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
|
||||||
@ -392,9 +392,10 @@ static const char *nsInfoLocal[VIR_LXC_DOMAIN_NAMESPACE_LAST] = {
|
|||||||
[VIR_LXC_DOMAIN_NAMESPACE_SHAREUTS] = "uts",
|
[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;
|
int fd = -1;
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
virLXCDomainObjPrivatePtr priv;
|
virLXCDomainObjPrivatePtr priv;
|
||||||
@ -474,7 +475,7 @@ static int virLXCProcessSetupNamespaceNet(int ns_type, const char *name)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* virLXCProcessSetupNamespaces:
|
* virLXCProcessSetupNamespaces:
|
||||||
* @conn: pointer to connection
|
* @driver: pointer to driver structure
|
||||||
* @def: pointer to virtual machines namespaceData
|
* @def: pointer to virtual machines namespaceData
|
||||||
* @nsFDs: out parameter to store the namespace FD
|
* @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
|
* Returns 0 on success or -1 in case of error
|
||||||
*/
|
*/
|
||||||
static int virLXCProcessSetupNamespaces(virConnectPtr conn,
|
static int
|
||||||
lxcDomainDefPtr lxcDef,
|
virLXCProcessSetupNamespaces(virLXCDriverPtr driver,
|
||||||
int *nsFDs)
|
lxcDomainDefPtr lxcDef,
|
||||||
|
int *nsFDs)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
@ -500,7 +502,8 @@ static int virLXCProcessSetupNamespaces(virConnectPtr conn,
|
|||||||
case VIR_LXC_DOMAIN_NAMESPACE_SOURCE_NONE:
|
case VIR_LXC_DOMAIN_NAMESPACE_SOURCE_NONE:
|
||||||
continue;
|
continue;
|
||||||
case VIR_LXC_DOMAIN_NAMESPACE_SOURCE_NAME:
|
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;
|
return -1;
|
||||||
break;
|
break;
|
||||||
case VIR_LXC_DOMAIN_NAMESPACE_SOURCE_PID:
|
case VIR_LXC_DOMAIN_NAMESPACE_SOURCE_PID:
|
||||||
@ -519,7 +522,7 @@ static int virLXCProcessSetupNamespaces(virConnectPtr conn,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* virLXCProcessSetupInterfaces:
|
* virLXCProcessSetupInterfaces:
|
||||||
* @conn: pointer to connection
|
* @driver: pointer to driver structure
|
||||||
* @def: pointer to virtual machine structure
|
* @def: pointer to virtual machine structure
|
||||||
* @veths: string list of interface names
|
* @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
|
* Returns 0 on success or -1 in case of error
|
||||||
*/
|
*/
|
||||||
static int virLXCProcessSetupInterfaces(virConnectPtr conn,
|
static int
|
||||||
virDomainDefPtr def,
|
virLXCProcessSetupInterfaces(virLXCDriverPtr driver,
|
||||||
char ***veths)
|
virDomainDefPtr def,
|
||||||
|
char ***veths)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -585,7 +589,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_NET_TYPE_DIRECT:
|
case VIR_DOMAIN_NET_TYPE_DIRECT:
|
||||||
if (!(veth = virLXCProcessSetupInterfaceDirect(conn, def, net)))
|
if (!(veth = virLXCProcessSetupInterfaceDirect(driver, def, net)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1344,11 +1348,11 @@ int virLXCProcessStart(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
VIR_DEBUG("Setting up Interfaces");
|
VIR_DEBUG("Setting up Interfaces");
|
||||||
if (virLXCProcessSetupInterfaces(conn, vm->def, &veths) < 0)
|
if (virLXCProcessSetupInterfaces(driver, vm->def, &veths) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
VIR_DEBUG("Setting up namespaces if any");
|
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;
|
goto cleanup;
|
||||||
|
|
||||||
VIR_DEBUG("Preparing to launch");
|
VIR_DEBUG("Preparing to launch");
|
||||||
|
@ -50,6 +50,6 @@ int virLXCProcessValidateInterface(virDomainNetDefPtr net);
|
|||||||
char *virLXCProcessSetupInterfaceTap(virDomainDefPtr vm,
|
char *virLXCProcessSetupInterfaceTap(virDomainDefPtr vm,
|
||||||
virDomainNetDefPtr net,
|
virDomainNetDefPtr net,
|
||||||
const char *brname);
|
const char *brname);
|
||||||
char *virLXCProcessSetupInterfaceDirect(virConnectPtr conn,
|
char *virLXCProcessSetupInterfaceDirect(virLXCDriverPtr driver,
|
||||||
virDomainDefPtr def,
|
virDomainDefPtr def,
|
||||||
virDomainNetDefPtr net);
|
virDomainNetDefPtr net);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user