Rename virDriver to virHypervisorDriver

To prepare for introducing a single global driver, rename the
virDriver struct to virHypervisorDriver and the registration
API to virRegisterHypervisorDriver()
This commit is contained in:
Daniel P. Berrange 2014-10-16 10:25:59 +01:00
parent 43b67f2e71
commit 931dff992e
25 changed files with 66 additions and 69 deletions

View File

@ -15,7 +15,7 @@ my $symslxc = "$srcdir/libvirt_lxc.syms";
my $drivertable = "$srcdir/driver.h";
my %groupheaders = (
"virDriver" => "Hypervisor APIs",
"virHypervisorDriver" => "Hypervisor APIs",
"virNetworkDriver" => "Virtual Network APIs",
"virInterfaceDriver" => "Host Interface APIs",
"virNodeDeviceDriver" => "Host Device APIs",

View File

@ -1400,7 +1400,7 @@ bhyveConnectDomainEventDeregisterAny(virConnectPtr conn,
return 0;
}
static virDriver bhyveDriver = {
static virHypervisorDriver bhyveDriver = {
.no = VIR_DRV_BHYVE,
.name = "bhyve",
.connectOpen = bhyveConnectOpen, /* 1.2.2 */
@ -1459,7 +1459,7 @@ static virStateDriver bhyveStateDriver = {
int
bhyveRegister(void)
{
if (virRegisterDriver(&bhyveDriver) < 0)
if (virRegisterHypervisorDriver(&bhyveDriver) < 0)
return -1;
if (virRegisterStateDriver(&bhyveStateDriver) < 0)
return -1;

View File

@ -336,7 +336,7 @@ struct _virConnect {
virURIPtr uri; /* connection URI */
/* The underlying hypervisor driver and network driver. */
virDriverPtr driver;
virHypervisorDriverPtr driver;
virNetworkDriverPtr networkDriver;
virInterfaceDriverPtr interfaceDriver;
virStorageDriverPtr storageDriver;

View File

@ -1221,11 +1221,11 @@ typedef int
unsigned int cellCount,
unsigned int flags);
typedef struct _virDriver virDriver;
typedef virDriver *virDriverPtr;
typedef struct _virHypervisorDriver virHypervisorDriver;
typedef virHypervisorDriver *virHypervisorDriverPtr;
/**
* _virDriver:
* _virHypervisorDriver:
*
* Structure associated to a virtualization driver, defining the various
* entry points for it.
@ -1236,7 +1236,7 @@ typedef virDriver *virDriverPtr;
* - open
* - close
*/
struct _virDriver {
struct _virHypervisorDriver {
int no; /* the number virDrvNo */
const char *name; /* the name of the driver */
virDrvConnectOpen connectOpen;
@ -2241,7 +2241,7 @@ struct _virNWFilterDriver {
* TODO: also need ways to (des)activate a given driver
* lookup based on the URI given in a virConnectOpen(ReadOnly)
*/
int virRegisterDriver(virDriverPtr) ATTRIBUTE_RETURN_CHECK;
int virRegisterHypervisorDriver(virHypervisorDriverPtr) ATTRIBUTE_RETURN_CHECK;
int virRegisterNetworkDriver(virNetworkDriverPtr) ATTRIBUTE_RETURN_CHECK;
int virRegisterInterfaceDriver(virInterfaceDriverPtr) ATTRIBUTE_RETURN_CHECK;
int virRegisterStorageDriver(virStorageDriverPtr) ATTRIBUTE_RETURN_CHECK;

View File

@ -5291,7 +5291,7 @@ esxConnectListAllDomains(virConnectPtr conn,
#undef MATCH
static virDriver esxDriver = {
static virHypervisorDriver esxDriver = {
.no = VIR_DRV_ESX,
.name = "ESX",
.connectOpen = esxConnectOpen, /* 0.7.0 */
@ -5376,7 +5376,7 @@ static virDriver esxDriver = {
int
esxRegister(void)
{
if (virRegisterDriver(&esxDriver) < 0 ||
if (virRegisterHypervisorDriver(&esxDriver) < 0 ||
esxInterfaceRegister() < 0 ||
esxNetworkRegister() < 0 ||
esxStorageRegister() < 0 ||

View File

@ -1354,7 +1354,7 @@ hypervConnectListAllDomains(virConnectPtr conn,
static virDriver hypervDriver = {
static virHypervisorDriver hypervDriver = {
.no = VIR_DRV_HYPERV,
.name = "Hyper-V",
.connectOpen = hypervConnectOpen, /* 0.9.5 */
@ -1418,7 +1418,7 @@ hypervDebugHandler(const char *message, debug_level_e level,
int
hypervRegister(void)
{
if (virRegisterDriver(&hypervDriver) < 0 ||
if (virRegisterHypervisorDriver(&hypervDriver) < 0 ||
hypervInterfaceRegister() < 0 ||
hypervNetworkRegister() < 0 ||
hypervStorageRegister() < 0 ||

View File

@ -122,8 +122,8 @@ VIR_LOG_INIT("libvirt");
} \
} while (0)
static virDriverPtr virDriverTab[MAX_DRIVERS];
static int virDriverTabCount = 0;
static virHypervisorDriverPtr virHypervisorDriverTab[MAX_DRIVERS];
static int virHypervisorDriverTabCount = 0;
static virNetworkDriverPtr virNetworkDriverTab[MAX_DRIVERS];
static int virNetworkDriverTabCount = 0;
static virInterfaceDriverPtr virInterfaceDriverTab[MAX_DRIVERS];
@ -668,7 +668,7 @@ virRegisterNWFilterDriver(virNWFilterDriverPtr driver)
/**
* virRegisterDriver:
* virRegisterHypervisorDriver:
* @driver: pointer to a driver block
*
* Register a virtualization driver
@ -676,19 +676,19 @@ virRegisterNWFilterDriver(virNWFilterDriverPtr driver)
* Returns the driver priority or -1 in case of error.
*/
int
virRegisterDriver(virDriverPtr driver)
virRegisterHypervisorDriver(virHypervisorDriverPtr driver)
{
VIR_DEBUG("driver=%p name=%s", driver,
driver ? NULLSTR(driver->name) : "(null)");
virCheckNonNullArgReturn(driver, -1);
virDriverCheckTabMaxReturn(virDriverTabCount, -1);
virDriverCheckTabMaxReturn(virHypervisorDriverTabCount, -1);
VIR_DEBUG("registering %s as driver %d",
driver->name, virDriverTabCount);
driver->name, virHypervisorDriverTabCount);
virDriverTab[virDriverTabCount] = driver;
return virDriverTabCount++;
virHypervisorDriverTab[virHypervisorDriverTabCount] = driver;
return virHypervisorDriverTabCount++;
}
@ -1106,7 +1106,7 @@ do_open(const char *name,
/* Cleansing flags */
ret->flags = flags & VIR_CONNECT_RO;
for (i = 0; i < virDriverTabCount; i++) {
for (i = 0; i < virHypervisorDriverTabCount; i++) {
/* We're going to probe the remote driver next. So we have already
* probed all other client-side-only driver before, but none of them
* accepted the URI.
@ -1114,7 +1114,7 @@ do_open(const char *name,
* driver then report a useful error, instead of a cryptic one about
* not being able to connect to libvirtd or not being able to find
* certificates. */
if (virDriverTab[i]->no == VIR_DRV_REMOTE &&
if (virHypervisorDriverTab[i]->no == VIR_DRV_REMOTE &&
ret->uri != NULL && ret->uri->scheme != NULL &&
(
#ifndef WITH_PHYP
@ -1142,11 +1142,11 @@ do_open(const char *name,
goto failed;
}
VIR_DEBUG("trying driver %zu (%s) ...", i, virDriverTab[i]->name);
ret->driver = virDriverTab[i];
res = virDriverTab[i]->connectOpen(ret, auth, flags);
VIR_DEBUG("trying driver %zu (%s) ...", i, virHypervisorDriverTab[i]->name);
ret->driver = virHypervisorDriverTab[i];
res = virHypervisorDriverTab[i]->connectOpen(ret, auth, flags);
VIR_DEBUG("driver %zu %s returned %s",
i, virDriverTab[i]->name,
i, virHypervisorDriverTab[i]->name,
res == VIR_DRV_OPEN_SUCCESS ? "SUCCESS" :
(res == VIR_DRV_OPEN_DECLINED ? "DECLINED" :
(res == VIR_DRV_OPEN_ERROR ? "ERROR" : "unknown status")));

View File

@ -857,7 +857,7 @@ virDomainMigratePrepare3Params;
virDomainMigratePrepareTunnel;
virDomainMigratePrepareTunnel3;
virDomainMigratePrepareTunnel3Params;
virRegisterDriver;
virRegisterHypervisorDriver;
virRegisterInterfaceDriver;
virRegisterNetworkDriver;
virRegisterNodeDeviceDriver;

View File

@ -4729,7 +4729,7 @@ libxlDomainMigrateConfirm3Params(virDomainPtr domain,
}
static virDriver libxlDriver = {
static virHypervisorDriver libxlDriver = {
.no = VIR_DRV_LIBXL,
.name = LIBXL_DRIVER_NAME,
.connectOpen = libxlConnectOpen, /* 0.9.0 */
@ -4837,7 +4837,7 @@ static virStateDriver libxlStateDriver = {
int
libxlRegister(void)
{
if (virRegisterDriver(&libxlDriver) < 0)
if (virRegisterHypervisorDriver(&libxlDriver) < 0)
return -1;
if (virRegisterStateDriver(&libxlStateDriver) < 0)
return -1;

View File

@ -5707,7 +5707,7 @@ lxcNodeAllocPages(virConnectPtr conn,
/* Function Tables */
static virDriver lxcDriver = {
static virHypervisorDriver lxcDriver = {
.no = VIR_DRV_LXC,
.name = LXC_DRIVER_NAME,
.connectOpen = lxcConnectOpen, /* 0.4.2 */
@ -5810,7 +5810,7 @@ static virStateDriver lxcStateDriver = {
int lxcRegister(void)
{
if (virRegisterDriver(&lxcDriver) < 0)
if (virRegisterHypervisorDriver(&lxcDriver) < 0)
return -1;
if (virRegisterStateDriver(&lxcStateDriver) < 0)
return -1;

View File

@ -2552,7 +2552,7 @@ openvzDomainMigrateConfirm3Params(virDomainPtr domain,
}
static virDriver openvzDriver = {
static virHypervisorDriver openvzDriver = {
.no = VIR_DRV_OPENVZ,
.name = "OPENVZ",
.connectOpen = openvzConnectOpen, /* 0.3.1 */
@ -2620,7 +2620,7 @@ static virDriver openvzDriver = {
int openvzRegister(void)
{
if (virRegisterDriver(&openvzDriver) < 0)
if (virRegisterHypervisorDriver(&openvzDriver) < 0)
return -1;
return 0;
}

View File

@ -2463,7 +2463,7 @@ parallelsNodeGetCPUMap(virConnectPtr conn ATTRIBUTE_UNUSED,
}
static virDriver parallelsDriver = {
static virHypervisorDriver parallelsDriver = {
.no = VIR_DRV_PARALLELS,
.name = "Parallels",
.connectOpen = parallelsConnectOpen, /* 0.10.0 */
@ -2518,7 +2518,7 @@ parallelsRegister(void)
VIR_FREE(prlctl_path);
if (virRegisterDriver(&parallelsDriver) < 0)
if (virRegisterHypervisorDriver(&parallelsDriver) < 0)
return -1;
if (parallelsStorageRegister())
return -1;

View File

@ -3717,7 +3717,7 @@ phypInterfaceClose(virConnectPtr conn ATTRIBUTE_UNUSED)
return 0;
}
static virDriver phypDriver = {
static virHypervisorDriver phypDriver = {
.no = VIR_DRV_PHYP,
.name = "PHYP",
.connectOpen = phypConnectOpen, /* 0.7.0 */
@ -3786,7 +3786,7 @@ static virInterfaceDriver phypInterfaceDriver = {
int
phypRegister(void)
{
if (virRegisterDriver(&phypDriver) < 0)
if (virRegisterHypervisorDriver(&phypDriver) < 0)
return -1;
if (virRegisterStorageDriver(&phypStorageDriver) < 0)
return -1;

View File

@ -18491,7 +18491,7 @@ qemuNodeAllocPages(virConnectPtr conn,
}
static virDriver qemuDriver = {
static virHypervisorDriver qemuDriver = {
.no = VIR_DRV_QEMU,
.name = QEMU_DRIVER_NAME,
.connectOpen = qemuConnectOpen, /* 0.2.0 */
@ -18705,7 +18705,7 @@ static virStateDriver qemuStateDriver = {
int qemuRegister(void)
{
if (virRegisterDriver(&qemuDriver) < 0)
if (virRegisterHypervisorDriver(&qemuDriver) < 0)
return -1;
if (virRegisterStateDriver(&qemuStateDriver) < 0)
return -1;

View File

@ -78,7 +78,6 @@ VIR_LOG_INIT("remote.remote_driver");
limit, params, nparams)
static bool inside_daemon = false;
static virDriverPtr remoteDriver = NULL;
struct private_data {
virMutex lock;
@ -8030,7 +8029,7 @@ unsigned long remoteVersion(void)
return REMOTE_PROTOCOL_VERSION;
}
static virDriver remote_driver = {
static virHypervisorDriver hypervisor_driver = {
.no = VIR_DRV_REMOTE,
.name = "remote",
.connectOpen = remoteConnectOpen, /* 0.3.0 */
@ -8403,9 +8402,7 @@ static virStateDriver state_driver = {
int
remoteRegister(void)
{
remoteDriver = &remote_driver;
if (virRegisterDriver(&remote_driver) < 0)
if (virRegisterHypervisorDriver(&hypervisor_driver) < 0)
return -1;
if (virRegisterNetworkDriver(&network_driver) < 0)
return -1;

View File

@ -7356,7 +7356,7 @@ testDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
static virDriver testDriver = {
static virHypervisorDriver testDriver = {
.no = VIR_DRV_TEST,
.name = "Test",
.connectOpen = testConnectOpen, /* 0.1.1 */
@ -7583,7 +7583,7 @@ static virNWFilterDriver testNWFilterDriver = {
int
testRegister(void)
{
if (virRegisterDriver(&testDriver) < 0)
if (virRegisterHypervisorDriver(&testDriver) < 0)
return -1;
if (virRegisterNetworkDriver(&testNetworkDriver) < 0)
return -1;

View File

@ -2928,7 +2928,7 @@ umlNodeAllocPages(virConnectPtr conn,
}
static virDriver umlDriver = {
static virHypervisorDriver umlDriver = {
.no = VIR_DRV_UML,
.name = "UML",
.connectOpen = umlConnectOpen, /* 0.5.0 */
@ -3003,7 +3003,7 @@ static virStateDriver umlStateDriver = {
int umlRegister(void)
{
if (virRegisterDriver(&umlDriver) < 0)
if (virRegisterHypervisorDriver(&umlDriver) < 0)
return -1;
if (virRegisterStateDriver(&umlStateDriver) < 0)
return -1;

View File

@ -7468,7 +7468,7 @@ vboxNodeAllocPages(virConnectPtr conn ATTRIBUTE_UNUSED,
* Function Tables
*/
virDriver vboxCommonDriver = {
virHypervisorDriver vboxCommonDriver = {
.no = VIR_DRV_VBOX,
.name = "VBOX",
.connectOpen = vboxConnectOpen, /* 0.6.3 */
@ -7550,7 +7550,7 @@ static void updateDriver(void)
vboxCommonDriver.domainScreenshot = NULL;
}
virDriverPtr vboxGetDriver(uint32_t uVersion)
virHypervisorDriverPtr vboxGetHypervisorDriver(uint32_t uVersion)
{
/* Install gVBoxAPI according to the vbox API version.
* Return -1 for unsupported version.

View File

@ -73,7 +73,7 @@ extern virStorageDriver vbox43_4StorageDriver;
#if !defined(WITH_DRIVER_MODULES) || defined(VBOX_STORAGE_DRIVER)
static void
vboxGetDrivers(virDriverPtr *driver_ret,
vboxGetDrivers(virHypervisorDriverPtr *hypervisorDriver_ret,
virStorageDriverPtr *storageDriver_ret)
{
virStorageDriverPtr storageDriver;
@ -136,8 +136,8 @@ vboxGetDrivers(virDriverPtr *driver_ret,
VIR_DEBUG("VBoxCGlueInit failed, using dummy driver");
}
if (driver_ret)
*driver_ret = NULL;
if (hypervisorDriver_ret)
*hypervisorDriver_ret = NULL;
if (storageDriver_ret)
*storageDriver_ret = storageDriver;
}
@ -212,7 +212,7 @@ static virDrvOpenStatus dummyConnectOpen(virConnectPtr conn,
return VIR_DRV_OPEN_ERROR;
}
static virDriver vboxDriverDummy = {
static virHypervisorDriver vboxDriverDummy = {
VIR_DRV_VBOX,
"VBOX",
.connectOpen = dummyConnectOpen, /* 0.6.3 */
@ -220,16 +220,16 @@ static virDriver vboxDriverDummy = {
int vboxRegister(void)
{
virDriverPtr driver = NULL;
virHypervisorDriverPtr driver = NULL;
uint32_t uVersion;
if (VBoxCGlueInit(&uVersion) == 0)
driver = vboxGetDriver(uVersion);
driver = vboxGetHypervisorDriver(uVersion);
if (!driver)
driver = &vboxDriverDummy;
if (virRegisterDriver(driver) < 0)
if (virRegisterHypervisorDriver(driver) < 0)
return -1;
return 0;
}

View File

@ -21,7 +21,7 @@
# include "internal.h"
virDriverPtr vboxGetDriver(uint32_t uVersion);
virHypervisorDriverPtr vboxGetHypervisorDriver(uint32_t uVersion);
virNetworkDriverPtr vboxGetNetworkDriver(uint32_t uVersion);
#endif /* VBOX_GET_DRIVER_H */

View File

@ -1456,7 +1456,7 @@ _vboxDomainSnapshotRestore(virDomainPtr dom,
/* No Callback support for VirtualBox 4.* series */
static void
_registerDomainEvent(virDriverPtr driver)
_registerDomainEvent(virHypervisorDriverPtr driver)
{
driver->connectDomainEventRegister = NULL;
driver->connectDomainEventDeregister = NULL;
@ -2007,7 +2007,7 @@ vboxConnectDomainEventDeregisterAny(virConnectPtr conn,
}
static void
_registerDomainEvent(virDriverPtr driver)
_registerDomainEvent(virHypervisorDriverPtr driver)
{
driver->connectDomainEventRegister = vboxConnectDomainEventRegister; /* 0.7.0 */
driver->connectDomainEventDeregister = vboxConnectDomainEventDeregister; /* 0.7.0 */

View File

@ -541,7 +541,7 @@ typedef struct {
int (*attachFloppy)(vboxGlobalData *data, IMachine *machine, const char *src);
int (*detachFloppy)(IMachine *machine);
int (*snapshotRestore)(virDomainPtr dom, IMachine *machine, ISnapshot *snapshot);
void (*registerDomainEvent)(virDriverPtr driver);
void (*registerDomainEvent)(virHypervisorDriverPtr driver);
vboxUniformedPFN UPFN;
vboxUniformedIID UIID;
vboxUniformedArray UArray;

View File

@ -1182,7 +1182,7 @@ vmwareConnectListAllDomains(virConnectPtr conn,
static virDriver vmwareDriver = {
static virHypervisorDriver vmwareDriver = {
.no = VIR_DRV_VMWARE,
.name = "VMWARE",
.connectOpen = vmwareConnectOpen, /* 0.8.7 */
@ -1223,7 +1223,7 @@ static virDriver vmwareDriver = {
int
vmwareRegister(void)
{
if (virRegisterDriver(&vmwareDriver) < 0)
if (virRegisterHypervisorDriver(&vmwareDriver) < 0)
return -1;
return 0;
}

View File

@ -2744,7 +2744,7 @@ xenUnifiedNodeSuspendForDuration(virConnectPtr conn,
/*----- Register with libvirt.c, and initialize Xen drivers. -----*/
/* The interface which we export upwards to libvirt.c. */
static virDriver xenUnifiedDriver = {
static virHypervisorDriver xenUnifiedDriver = {
.no = VIR_DRV_XEN_UNIFIED,
.name = "Xen",
.connectOpen = xenUnifiedConnectOpen, /* 0.0.3 */
@ -2852,7 +2852,7 @@ xenRegister(void)
{
if (virRegisterStateDriver(&state_driver) == -1) return -1;
return virRegisterDriver(&xenUnifiedDriver);
return virRegisterHypervisorDriver(&xenUnifiedDriver);
}
/**

View File

@ -1963,7 +1963,7 @@ xenapiConnectIsAlive(virConnectPtr conn)
}
/* The interface which we export upwards to libvirt.c. */
static virDriver xenapiDriver = {
static virHypervisorDriver xenapiDriver = {
.no = VIR_DRV_XENAPI,
.name = "XenAPI",
.connectOpen = xenapiConnectOpen, /* 0.8.0 */
@ -2025,7 +2025,7 @@ static virDriver xenapiDriver = {
int
xenapiRegister(void)
{
return virRegisterDriver(&xenapiDriver);
return virRegisterHypervisorDriver(&xenapiDriver);
}
/*