mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 09:53:10 +00:00
rename "struct interface_driver" to virNetcfDriverState
This better fits the modern naming scheme in libvirt, and anticipates an upcoming change where a single instance of this state will be maintained by a separate state driver, and every instance of the netcf driver will share the same state.
This commit is contained in:
parent
75235a52bc
commit
4c5fa43097
@ -2,7 +2,7 @@
|
|||||||
* interface_driver.c: backend driver methods to handle physical
|
* interface_driver.c: backend driver methods to handle physical
|
||||||
* interface configuration using the netcf library.
|
* interface configuration using the netcf library.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2012 Red Hat, Inc.
|
* Copyright (C) 2006-2013 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -36,20 +36,22 @@
|
|||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_INTERFACE
|
#define VIR_FROM_THIS VIR_FROM_INTERFACE
|
||||||
|
|
||||||
|
#define INTERFACE_DRIVER_NAME "netcf"
|
||||||
|
|
||||||
/* Main driver state */
|
/* Main driver state */
|
||||||
struct interface_driver
|
typedef struct
|
||||||
{
|
{
|
||||||
virMutex lock;
|
virMutex lock;
|
||||||
struct netcf *netcf;
|
struct netcf *netcf;
|
||||||
};
|
} virNetcfDriverState, *virNetcfDriverStatePtr;
|
||||||
|
|
||||||
|
|
||||||
static void interfaceDriverLock(struct interface_driver *driver)
|
static void interfaceDriverLock(virNetcfDriverStatePtr driver)
|
||||||
{
|
{
|
||||||
virMutexLock(&driver->lock);
|
virMutexLock(&driver->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void interfaceDriverUnlock(struct interface_driver *driver)
|
static void interfaceDriverUnlock(virNetcfDriverStatePtr driver)
|
||||||
{
|
{
|
||||||
virMutexUnlock(&driver->lock);
|
virMutexUnlock(&driver->lock);
|
||||||
}
|
}
|
||||||
@ -150,7 +152,7 @@ static virDrvOpenStatus netcfInterfaceOpen(virConnectPtr conn,
|
|||||||
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
struct interface_driver *driverState;
|
virNetcfDriverStatePtr driverState;
|
||||||
|
|
||||||
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
||||||
|
|
||||||
@ -191,7 +193,7 @@ static int netcfInterfaceClose(virConnectPtr conn)
|
|||||||
|
|
||||||
if (conn->interfacePrivateData != NULL)
|
if (conn->interfacePrivateData != NULL)
|
||||||
{
|
{
|
||||||
struct interface_driver *driver = conn->interfacePrivateData;
|
virNetcfDriverStatePtr driver = conn->interfacePrivateData;
|
||||||
|
|
||||||
/* close netcf instance */
|
/* close netcf instance */
|
||||||
ncf_close(driver->netcf);
|
ncf_close(driver->netcf);
|
||||||
@ -208,7 +210,7 @@ static int netcfConnectNumOfInterfacesImpl(virConnectPtr conn,
|
|||||||
int status,
|
int status,
|
||||||
virInterfaceObjListFilter filter)
|
virInterfaceObjListFilter filter)
|
||||||
{
|
{
|
||||||
struct interface_driver *driver = conn->interfacePrivateData;
|
virNetcfDriverStatePtr driver = conn->interfacePrivateData;
|
||||||
int count;
|
int count;
|
||||||
int want = 0;
|
int want = 0;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -302,7 +304,7 @@ static int netcfConnectListInterfacesImpl(virConnectPtr conn,
|
|||||||
char **const names, int nnames,
|
char **const names, int nnames,
|
||||||
virInterfaceObjListFilter filter)
|
virInterfaceObjListFilter filter)
|
||||||
{
|
{
|
||||||
struct interface_driver *driver = conn->interfacePrivateData;
|
virNetcfDriverStatePtr driver = conn->interfacePrivateData;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int want = 0;
|
int want = 0;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -401,7 +403,7 @@ cleanup:
|
|||||||
static int netcfConnectNumOfInterfaces(virConnectPtr conn)
|
static int netcfConnectNumOfInterfaces(virConnectPtr conn)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
struct interface_driver *driver = conn->interfacePrivateData;
|
virNetcfDriverStatePtr driver = conn->interfacePrivateData;
|
||||||
|
|
||||||
if (virConnectNumOfInterfacesEnsureACL(conn) < 0)
|
if (virConnectNumOfInterfacesEnsureACL(conn) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -416,7 +418,7 @@ static int netcfConnectNumOfInterfaces(virConnectPtr conn)
|
|||||||
|
|
||||||
static int netcfConnectListInterfaces(virConnectPtr conn, char **const names, int nnames)
|
static int netcfConnectListInterfaces(virConnectPtr conn, char **const names, int nnames)
|
||||||
{
|
{
|
||||||
struct interface_driver *driver = conn->interfacePrivateData;
|
virNetcfDriverStatePtr driver = conn->interfacePrivateData;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
if (virConnectListInterfacesEnsureACL(conn) < 0)
|
if (virConnectListInterfacesEnsureACL(conn) < 0)
|
||||||
@ -435,7 +437,7 @@ static int netcfConnectListInterfaces(virConnectPtr conn, char **const names, in
|
|||||||
static int netcfConnectNumOfDefinedInterfaces(virConnectPtr conn)
|
static int netcfConnectNumOfDefinedInterfaces(virConnectPtr conn)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
struct interface_driver *driver = conn->interfacePrivateData;
|
virNetcfDriverStatePtr driver = conn->interfacePrivateData;
|
||||||
|
|
||||||
if (virConnectNumOfDefinedInterfacesEnsureACL(conn) < 0)
|
if (virConnectNumOfDefinedInterfacesEnsureACL(conn) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -450,7 +452,7 @@ static int netcfConnectNumOfDefinedInterfaces(virConnectPtr conn)
|
|||||||
|
|
||||||
static int netcfConnectListDefinedInterfaces(virConnectPtr conn, char **const names, int nnames)
|
static int netcfConnectListDefinedInterfaces(virConnectPtr conn, char **const names, int nnames)
|
||||||
{
|
{
|
||||||
struct interface_driver *driver = conn->interfacePrivateData;
|
virNetcfDriverStatePtr driver = conn->interfacePrivateData;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
if (virConnectListDefinedInterfacesEnsureACL(conn) < 0)
|
if (virConnectListDefinedInterfacesEnsureACL(conn) < 0)
|
||||||
@ -472,7 +474,7 @@ netcfConnectListAllInterfaces(virConnectPtr conn,
|
|||||||
virInterfacePtr **ifaces,
|
virInterfacePtr **ifaces,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
struct interface_driver *driver = conn->interfacePrivateData;
|
virNetcfDriverStatePtr driver = conn->interfacePrivateData;
|
||||||
int count;
|
int count;
|
||||||
size_t i;
|
size_t i;
|
||||||
struct netcf_if *iface = NULL;
|
struct netcf_if *iface = NULL;
|
||||||
@ -627,7 +629,7 @@ cleanup:
|
|||||||
static virInterfacePtr netcfInterfaceLookupByName(virConnectPtr conn,
|
static virInterfacePtr netcfInterfaceLookupByName(virConnectPtr conn,
|
||||||
const char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
struct interface_driver *driver = conn->interfacePrivateData;
|
virNetcfDriverStatePtr driver = conn->interfacePrivateData;
|
||||||
struct netcf_if *iface;
|
struct netcf_if *iface;
|
||||||
virInterfacePtr ret = NULL;
|
virInterfacePtr ret = NULL;
|
||||||
virInterfaceDefPtr def = NULL;
|
virInterfaceDefPtr def = NULL;
|
||||||
@ -667,7 +669,7 @@ cleanup:
|
|||||||
static virInterfacePtr netcfInterfaceLookupByMACString(virConnectPtr conn,
|
static virInterfacePtr netcfInterfaceLookupByMACString(virConnectPtr conn,
|
||||||
const char *macstr)
|
const char *macstr)
|
||||||
{
|
{
|
||||||
struct interface_driver *driver = conn->interfacePrivateData;
|
virNetcfDriverStatePtr driver = conn->interfacePrivateData;
|
||||||
struct netcf_if *iface;
|
struct netcf_if *iface;
|
||||||
int niface;
|
int niface;
|
||||||
virInterfacePtr ret = NULL;
|
virInterfacePtr ret = NULL;
|
||||||
@ -716,7 +718,7 @@ cleanup:
|
|||||||
static char *netcfInterfaceGetXMLDesc(virInterfacePtr ifinfo,
|
static char *netcfInterfaceGetXMLDesc(virInterfacePtr ifinfo,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
struct interface_driver *driver = ifinfo->conn->interfacePrivateData;
|
virNetcfDriverStatePtr driver = ifinfo->conn->interfacePrivateData;
|
||||||
struct netcf_if *iface = NULL;
|
struct netcf_if *iface = NULL;
|
||||||
char *xmlstr = NULL;
|
char *xmlstr = NULL;
|
||||||
virInterfaceDefPtr ifacedef = NULL;
|
virInterfaceDefPtr ifacedef = NULL;
|
||||||
@ -774,7 +776,7 @@ static virInterfacePtr netcfInterfaceDefineXML(virConnectPtr conn,
|
|||||||
const char *xml,
|
const char *xml,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
struct interface_driver *driver = conn->interfacePrivateData;
|
virNetcfDriverStatePtr driver = conn->interfacePrivateData;
|
||||||
struct netcf_if *iface = NULL;
|
struct netcf_if *iface = NULL;
|
||||||
char *xmlstr = NULL;
|
char *xmlstr = NULL;
|
||||||
virInterfaceDefPtr ifacedef = NULL;
|
virInterfaceDefPtr ifacedef = NULL;
|
||||||
@ -821,7 +823,7 @@ cleanup:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int netcfInterfaceUndefine(virInterfacePtr ifinfo) {
|
static int netcfInterfaceUndefine(virInterfacePtr ifinfo) {
|
||||||
struct interface_driver *driver = ifinfo->conn->interfacePrivateData;
|
virNetcfDriverStatePtr driver = ifinfo->conn->interfacePrivateData;
|
||||||
struct netcf_if *iface = NULL;
|
struct netcf_if *iface = NULL;
|
||||||
virInterfaceDefPtr def = NULL;
|
virInterfaceDefPtr def = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -862,7 +864,7 @@ cleanup:
|
|||||||
static int netcfInterfaceCreate(virInterfacePtr ifinfo,
|
static int netcfInterfaceCreate(virInterfacePtr ifinfo,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
struct interface_driver *driver = ifinfo->conn->interfacePrivateData;
|
virNetcfDriverStatePtr driver = ifinfo->conn->interfacePrivateData;
|
||||||
struct netcf_if *iface = NULL;
|
struct netcf_if *iface = NULL;
|
||||||
virInterfaceDefPtr def = NULL;
|
virInterfaceDefPtr def = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -905,7 +907,7 @@ cleanup:
|
|||||||
static int netcfInterfaceDestroy(virInterfacePtr ifinfo,
|
static int netcfInterfaceDestroy(virInterfacePtr ifinfo,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
struct interface_driver *driver = ifinfo->conn->interfacePrivateData;
|
virNetcfDriverStatePtr driver = ifinfo->conn->interfacePrivateData;
|
||||||
struct netcf_if *iface = NULL;
|
struct netcf_if *iface = NULL;
|
||||||
virInterfaceDefPtr def = NULL;
|
virInterfaceDefPtr def = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -947,7 +949,7 @@ cleanup:
|
|||||||
|
|
||||||
static int netcfInterfaceIsActive(virInterfacePtr ifinfo)
|
static int netcfInterfaceIsActive(virInterfacePtr ifinfo)
|
||||||
{
|
{
|
||||||
struct interface_driver *driver = ifinfo->conn->interfacePrivateData;
|
virNetcfDriverStatePtr driver = ifinfo->conn->interfacePrivateData;
|
||||||
struct netcf_if *iface = NULL;
|
struct netcf_if *iface = NULL;
|
||||||
unsigned int flags = 0;
|
unsigned int flags = 0;
|
||||||
virInterfaceDefPtr def = NULL;
|
virInterfaceDefPtr def = NULL;
|
||||||
@ -990,7 +992,7 @@ cleanup:
|
|||||||
#ifdef HAVE_NETCF_TRANSACTIONS
|
#ifdef HAVE_NETCF_TRANSACTIONS
|
||||||
static int netcfInterfaceChangeBegin(virConnectPtr conn, unsigned int flags)
|
static int netcfInterfaceChangeBegin(virConnectPtr conn, unsigned int flags)
|
||||||
{
|
{
|
||||||
struct interface_driver *driver = conn->interfacePrivateData;
|
virNetcfDriverStatePtr driver = conn->interfacePrivateData;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
virCheckFlags(0, -1); /* currently flags must be 0 */
|
virCheckFlags(0, -1); /* currently flags must be 0 */
|
||||||
@ -1016,7 +1018,7 @@ static int netcfInterfaceChangeBegin(virConnectPtr conn, unsigned int flags)
|
|||||||
|
|
||||||
static int netcfInterfaceChangeCommit(virConnectPtr conn, unsigned int flags)
|
static int netcfInterfaceChangeCommit(virConnectPtr conn, unsigned int flags)
|
||||||
{
|
{
|
||||||
struct interface_driver *driver = conn->interfacePrivateData;
|
virNetcfDriverStatePtr driver = conn->interfacePrivateData;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
virCheckFlags(0, -1); /* currently flags must be 0 */
|
virCheckFlags(0, -1); /* currently flags must be 0 */
|
||||||
@ -1042,7 +1044,7 @@ static int netcfInterfaceChangeCommit(virConnectPtr conn, unsigned int flags)
|
|||||||
|
|
||||||
static int netcfInterfaceChangeRollback(virConnectPtr conn, unsigned int flags)
|
static int netcfInterfaceChangeRollback(virConnectPtr conn, unsigned int flags)
|
||||||
{
|
{
|
||||||
struct interface_driver *driver = conn->interfacePrivateData;
|
virNetcfDriverStatePtr driver = conn->interfacePrivateData;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
virCheckFlags(0, -1); /* currently flags must be 0 */
|
virCheckFlags(0, -1); /* currently flags must be 0 */
|
||||||
|
Loading…
Reference in New Issue
Block a user