diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index b7f82c5acc..5ccfcdd154 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -334,12 +334,7 @@ static void daemonInitialize(void) * priority when calling virStateInitialize. We must register the * network, storage and nodedev drivers before any stateful domain * driver, since their resources must be auto-started before any - * domains can be auto-started. Moreover, some stateless drivers - * implement their own subdrivers (e.g. the vbox driver has its - * own network and storage subdriers) which need to have higher - * priority. Otherwise, when connecting to such driver the generic - * subdriver may be opened instead of the one corresponding to the - * stateless driver. + * domains can be auto-started. */ #ifdef WITH_DRIVER_MODULES /* We don't care if any of these fail, because the whole point @@ -347,18 +342,12 @@ static void daemonInitialize(void) * If they try to open a connection for a module that * is not loaded they'll get a suitable error at that point */ -# ifdef WITH_VBOX - virDriverLoadModule("vbox_network"); -# endif # ifdef WITH_NETWORK virDriverLoadModule("network"); # endif # ifdef WITH_INTERFACE virDriverLoadModule("interface"); # endif -# ifdef WITH_VBOX - virDriverLoadModule("vbox_storage"); -# endif # ifdef WITH_STORAGE virDriverLoadModule("storage"); # endif @@ -393,18 +382,12 @@ static void daemonInitialize(void) virDriverLoadModule("bhyve"); # endif #else -# ifdef WITH_VBOX - vboxNetworkRegister(); -# endif # ifdef WITH_NETWORK networkRegister(); # endif # ifdef WITH_INTERFACE interfaceRegister(); # endif -# ifdef WITH_VBOX - vboxStorageRegister(); -# endif # ifdef WITH_STORAGE storageRegister(); # endif diff --git a/src/Makefile.am b/src/Makefile.am index 1e2127919c..b41c6d4236 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -539,8 +539,6 @@ DRIVER_SOURCE_FILES = \ $(TEST_DRIVER_SOURCES) \ $(UML_DRIVER_SOURCES) \ $(VBOX_DRIVER_SOURCES) \ - $(VBOX_NETWORK_DRIVER_SOURCES) \ - $(VBOX_STORAGE_DRIVER_SOURCES) \ vbox/vbox_tmpl.c \ $(VMWARE_DRIVER_SOURCES) \ $(XEN_DRIVER_SOURCES) \ @@ -701,15 +699,9 @@ VBOX_DRIVER_SOURCES = \ vbox/vbox_V4_3_4.c vbox/vbox_CAPI_v4_3_4.h \ vbox/vbox_common.c vbox/vbox_common.h \ vbox/vbox_uniformed_api.h \ - vbox/vbox_get_driver.h - -VBOX_NETWORK_DRIVER_SOURCES = \ - vbox/vbox_driver.c vbox/vbox_driver.h \ - vbox/vbox_network.c vbox/vbox_get_driver.h - -VBOX_STORAGE_DRIVER_SOURCES = \ - vbox/vbox_driver.c vbox/vbox_driver.h \ - vbox/vbox_storage.c vbox/vbox_get_driver.h + vbox/vbox_get_driver.h \ + vbox/vbox_network.c \ + vbox/vbox_storage.c VBOX_DRIVER_EXTRA_DIST = \ vbox/vbox_tmpl.c vbox/README \ @@ -760,10 +752,7 @@ ESX_DRIVER_SOURCES = \ esx/esx_storage_driver.c esx/esx_storage_driver.h \ esx/esx_storage_backend_vmfs.c esx/esx_storage_backend_vmfs.h \ esx/esx_storage_backend_iscsi.c esx/esx_storage_backend_iscsi.h \ - esx/esx_device_monitor.c esx/esx_device_monitor.h \ - esx/esx_secret_driver.c esx/esx_secret_driver.h \ esx/esx_stream.c esx/esx_stream.h \ - esx/esx_nwfilter_driver.c esx/esx_nwfilter_driver.h \ esx/esx_util.c esx/esx_util.h \ esx/esx_vi.c esx/esx_vi.h \ esx/esx_vi_methods.c esx/esx_vi_methods.h \ @@ -791,12 +780,6 @@ ESX_DRIVER_EXTRA_DIST = \ HYPERV_DRIVER_SOURCES = \ hyperv/hyperv_private.h \ hyperv/hyperv_driver.c hyperv/hyperv_driver.h \ - hyperv/hyperv_interface_driver.c hyperv/hyperv_interface_driver.h \ - hyperv/hyperv_network_driver.c hyperv/hyperv_network_driver.h \ - hyperv/hyperv_storage_driver.c hyperv/hyperv_storage_driver.h \ - hyperv/hyperv_device_monitor.c hyperv/hyperv_device_monitor.h \ - hyperv/hyperv_secret_driver.c hyperv/hyperv_secret_driver.h \ - hyperv/hyperv_nwfilter_driver.c hyperv/hyperv_nwfilter_driver.h \ hyperv/hyperv_util.c hyperv/hyperv_util.h \ hyperv/hyperv_wmi.c hyperv/hyperv_wmi.h \ hyperv/hyperv_wmi_classes.c hyperv/hyperv_wmi_classes.h \ @@ -1180,33 +1163,19 @@ endif WITH_VMWARE if WITH_VBOX noinst_LTLIBRARIES += \ - libvirt_driver_vbox_impl.la \ - libvirt_driver_vbox_network_impl.la \ - libvirt_driver_vbox_storage_impl.la + libvirt_driver_vbox_impl.la libvirt_driver_vbox_la_SOURCES = libvirt_driver_vbox_la_LIBADD = libvirt_driver_vbox_impl.la -libvirt_driver_vbox_network_la_SOURCES = -libvirt_driver_vbox_network_la_LIBADD = libvirt_driver_vbox_network_impl.la -libvirt_driver_vbox_storage_la_SOURCES = -libvirt_driver_vbox_storage_la_LIBADD = libvirt_driver_vbox_storage_impl.la if WITH_DRIVER_MODULES mod_LTLIBRARIES += \ - libvirt_driver_vbox.la \ - libvirt_driver_vbox_network.la \ - libvirt_driver_vbox_storage.la + libvirt_driver_vbox.la libvirt_driver_vbox_la_LIBADD += ../gnulib/lib/libgnu.la libvirt_driver_vbox_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS) -libvirt_driver_vbox_network_la_LIBADD += ../gnulib/lib/libgnu.la -libvirt_driver_vbox_network_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS) -libvirt_driver_vbox_storage_la_LIBADD += ../gnulib/lib/libgnu.la -libvirt_driver_vbox_storage_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS) else ! WITH_DRIVER_MODULES noinst_LTLIBRARIES += libvirt_driver_vbox.la # GPLv2-only license requries that it be linked into # libvirtd and *not* libvirt.so #libvirt_la_BUILT_LIBADD += libvirt_driver_vbox.la -libvirt_driver_vbox_la_LIBADD += libvirt_driver_vbox_network_impl.la \ - libvirt_driver_vbox_storage_impl.la endif ! WITH_DRIVER_MODULES libvirt_driver_vbox_impl_la_CFLAGS = \ @@ -1218,28 +1187,6 @@ libvirt_driver_vbox_impl_la_LIBADD = $(DLOPEN_LIBS) \ $(MSCOM_LIBS) \ $(LIBXML_LIBS) libvirt_driver_vbox_impl_la_SOURCES = $(VBOX_DRIVER_SOURCES) - -libvirt_driver_vbox_network_impl_la_CFLAGS = \ - -I$(srcdir)/conf \ - $(AM_CFLAGS) \ - -DVBOX_NETWORK_DRIVER -libvirt_driver_vbox_network_impl_la_LDFLAGS = $(AM_LDFLAGS) -libvirt_driver_vbox_network_impl_la_LIBADD = $(DLOPEN_LIBS) \ - $(MSCOM_LIBS) \ - $(LIBXML_LIBS) \ - libvirt_driver_vbox_impl.la -libvirt_driver_vbox_network_impl_la_SOURCES = $(VBOX_NETWORK_DRIVER_SOURCES) - -libvirt_driver_vbox_storage_impl_la_CFLAGS = \ - -I$(srcdir)/conf \ - $(AM_CFLAGS) \ - -DVBOX_STORAGE_DRIVER -libvirt_driver_vbox_storage_impl_la_LDFLAGS = $(AM_LDFLAGS) -libvirt_driver_vbox_storage_impl_la_LIBADD = $(DLOPEN_LIBS) \ - $(MSCOM_LIBS) \ - $(LIBXML_LIBS) \ - libvirt_driver_vbox_impl.la -libvirt_driver_vbox_storage_impl_la_SOURCES = $(VBOX_STORAGE_DRIVER_SOURCES) endif WITH_VBOX if WITH_XENAPI diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 8264ad8db7..56cc8abd16 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -1430,8 +1430,7 @@ bhyveConnectDomainEventDeregisterAny(virConnectPtr conn, return 0; } -static virHypervisorDriver bhyveDriver = { - .no = VIR_DRV_BHYVE, +static virHypervisorDriver bhyveHypervisorDriver = { .name = "bhyve", .connectOpen = bhyveConnectOpen, /* 1.2.2 */ .connectClose = bhyveConnectClose, /* 1.2.2 */ @@ -1480,6 +1479,10 @@ static virHypervisorDriver bhyveDriver = { }; +static virConnectDriver bhyveConnectDriver = { + .hypervisorDriver = &bhyveHypervisorDriver, +}; + static virStateDriver bhyveStateDriver = { .name = "bhyve", .stateInitialize = bhyveStateInitialize, @@ -1490,9 +1493,10 @@ static virStateDriver bhyveStateDriver = { int bhyveRegister(void) { - if (virRegisterHypervisorDriver(&bhyveDriver) < 0) + if (virRegisterConnectDriver(&bhyveConnectDriver, + true) < 0) return -1; - if (virRegisterStateDriver(&bhyveStateDriver) < 0) + if (virRegisterStateDriver(&bhyveStateDriver) < 0) return -1; - return 0; + return 0; } diff --git a/src/check-driverimpls.pl b/src/check-driverimpls.pl index 17e2b481a3..e32055835a 100755 --- a/src/check-driverimpls.pl +++ b/src/check-driverimpls.pl @@ -69,7 +69,8 @@ while (<>) { } } elsif (/^(?:static\s+)?(vir(?:\w+)?Driver)\s+/) { next if $1 eq "virNWFilterCallbackDriver" || - $1 eq "virNWFilterTechDriver"; + $1 eq "virNWFilterTechDriver" || + $1 eq "virConnectDriver"; $intable = 1; $table = $1; } diff --git a/src/datatypes.c b/src/datatypes.c index b4f67653de..1afaf00f61 100644 --- a/src/datatypes.c +++ b/src/datatypes.c @@ -138,18 +138,6 @@ virConnectDispose(void *obj) { virConnectPtr conn = obj; - if (conn->networkDriver) - conn->networkDriver->networkClose(conn); - if (conn->interfaceDriver) - conn->interfaceDriver->interfaceClose(conn); - if (conn->storageDriver) - conn->storageDriver->storageClose(conn); - if (conn->nodeDeviceDriver) - conn->nodeDeviceDriver->nodeDeviceClose(conn); - if (conn->secretDriver) - conn->secretDriver->secretClose(conn); - if (conn->nwfilterDriver) - conn->nwfilterDriver->nwfilterClose(conn); if (conn->driver) conn->driver->connectClose(conn); diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index a1d2a0aec2..a1198adeec 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -33,7 +33,6 @@ typedef virDrvOpenStatus typedef int (*virDrvConnectClose)(virConnectPtr conn); - typedef int (*virDrvConnectSupportsFeature)(virConnectPtr conn, int feature); @@ -1185,13 +1184,11 @@ typedef virHypervisorDriver *virHypervisorDriverPtr; * entry points for it. * * All drivers must support the following fields/methods: - * - no * - name * - open * - close */ struct _virHypervisorDriver { - int no; /* the number virDrvNo */ const char *name; /* the name of the driver */ virDrvConnectOpen connectOpen; virDrvConnectClose connectClose; diff --git a/src/driver-interface.h b/src/driver-interface.h index eb9b1adde6..3f05a93325 100644 --- a/src/driver-interface.h +++ b/src/driver-interface.h @@ -25,9 +25,6 @@ # error "Don't include this file directly, only use driver.h" # endif -typedef virDrvConnectOpen virDrvInterfaceOpen; -typedef virDrvConnectClose virDrvInterfaceClose; - typedef int (*virDrvConnectNumOfInterfaces)(virConnectPtr conn); @@ -100,15 +97,9 @@ typedef virInterfaceDriver *virInterfaceDriverPtr; * * Structure associated to a network interface driver, defining the various * entry points for it. - * - * All drivers must support the following fields/methods: - * - open - * - close */ struct _virInterfaceDriver { const char *name; /* the name of the driver */ - virDrvInterfaceOpen interfaceOpen; - virDrvInterfaceClose interfaceClose; virDrvConnectNumOfInterfaces connectNumOfInterfaces; virDrvConnectListInterfaces connectListInterfaces; virDrvConnectNumOfDefinedInterfaces connectNumOfDefinedInterfaces; diff --git a/src/driver-network.h b/src/driver-network.h index 9ede53c47d..e65117c49a 100644 --- a/src/driver-network.h +++ b/src/driver-network.h @@ -25,9 +25,6 @@ # error "Don't include this file directly, only use driver.h" # endif -typedef virDrvConnectOpen virDrvNetworkOpen; -typedef virDrvConnectClose virDrvNetworkClose; - typedef int (*virDrvConnectNumOfNetworks)(virConnectPtr conn); @@ -129,15 +126,9 @@ typedef virNetworkDriver *virNetworkDriverPtr; * * Structure associated to a network virtualization driver, defining the various * entry points for it. - * - * All drivers must support the following fields/methods: - * - open - * - close */ struct _virNetworkDriver { - const char * name; /* the name of the driver */ - virDrvNetworkOpen networkOpen; - virDrvNetworkClose networkClose; + const char *name; /* the name of the driver */ virDrvConnectNumOfNetworks connectNumOfNetworks; virDrvConnectListNetworks connectListNetworks; virDrvConnectNumOfDefinedNetworks connectNumOfDefinedNetworks; diff --git a/src/driver-nodedev.h b/src/driver-nodedev.h index 8d1c8a93ad..e846612d31 100644 --- a/src/driver-nodedev.h +++ b/src/driver-nodedev.h @@ -25,10 +25,6 @@ # error "Don't include this file directly, only use driver.h" # endif -typedef virDrvConnectOpen virDrvNodeDeviceOpen; -typedef virDrvConnectClose virDrvNodeDeviceClose; - - typedef int (*virDrvNodeNumOfDevices)(virConnectPtr conn, const char *cap, @@ -92,9 +88,7 @@ typedef virNodeDeviceDriver *virNodeDeviceDriverPtr; * */ struct _virNodeDeviceDriver { - const char * name; /* the name of the driver */ - virDrvNodeDeviceOpen nodeDeviceOpen; - virDrvNodeDeviceClose nodeDeviceClose; + const char *name; /* the name of the driver */ virDrvNodeNumOfDevices nodeNumOfDevices; virDrvNodeListDevices nodeListDevices; virDrvConnectListAllNodeDevices connectListAllNodeDevices; diff --git a/src/driver-nwfilter.h b/src/driver-nwfilter.h index 502700f638..cb49542f92 100644 --- a/src/driver-nwfilter.h +++ b/src/driver-nwfilter.h @@ -25,11 +25,6 @@ # error "Don't include this file directly, only use driver.h" # endif - -typedef virDrvConnectOpen virDrvNWFilterOpen; -typedef virDrvConnectClose virDrvNWFilterClose; - - typedef int (*virDrvConnectNumOfNWFilters)(virConnectPtr conn); @@ -71,15 +66,9 @@ typedef virNWFilterDriver *virNWFilterDriverPtr; * * Structure associated to a network filter driver, defining the various * entry points for it. - * - * All drivers must support the following fields/methods: - * - open - * - close */ struct _virNWFilterDriver { - const char * name; /* the name of the driver */ - virDrvNWFilterOpen nwfilterOpen; - virDrvNWFilterClose nwfilterClose; + const char *name; /* the name of the driver */ virDrvConnectNumOfNWFilters connectNumOfNWFilters; virDrvConnectListNWFilters connectListNWFilters; virDrvConnectListAllNWFilters connectListAllNWFilters; diff --git a/src/driver-secret.h b/src/driver-secret.h index d82e7df817..c39e0d797c 100644 --- a/src/driver-secret.h +++ b/src/driver-secret.h @@ -31,10 +31,6 @@ enum { VIR_SECRET_GET_VALUE_INTERNAL_CALL = 1 << 0, }; -typedef virDrvConnectOpen virDrvSecretOpen; -typedef virDrvConnectClose virDrvSecretClose; - - typedef virSecretPtr (*virDrvSecretLookupByUUID)(virConnectPtr conn, const unsigned char *uuid); @@ -89,15 +85,9 @@ typedef virSecretDriver *virSecretDriverPtr; * * Structure associated to a driver for storing secrets, defining the various * entry points for it. - * - * All drivers must support the following fields/methods: - * - open - * - close */ struct _virSecretDriver { - const char *name; - virDrvSecretOpen secretOpen; - virDrvSecretClose secretClose; + const char *name; /* the name of the driver */ virDrvConnectNumOfSecrets connectNumOfSecrets; virDrvConnectListSecrets connectListSecrets; virDrvConnectListAllSecrets connectListAllSecrets; diff --git a/src/driver-storage.h b/src/driver-storage.h index 4848dd3d1a..0489647a91 100644 --- a/src/driver-storage.h +++ b/src/driver-storage.h @@ -25,10 +25,6 @@ # error "Don't include this file directly, only use driver.h" # endif -typedef virDrvConnectOpen virDrvStorageOpen; -typedef virDrvConnectClose virDrvStorageClose; - - typedef int (*virDrvConnectNumOfStoragePools)(virConnectPtr conn); @@ -210,15 +206,9 @@ typedef virStorageDriver *virStorageDriverPtr; * * Structure associated to a storage driver, defining the various * entry points for it. - * - * All drivers must support the following fields/methods: - * - open - * - close */ struct _virStorageDriver { - const char * name; /* the name of the driver */ - virDrvStorageOpen storageOpen; - virDrvStorageClose storageClose; + const char *name; /* the name of the driver */ virDrvConnectNumOfStoragePools connectNumOfStoragePools; virDrvConnectListStoragePools connectListStoragePools; virDrvConnectNumOfDefinedStoragePools connectNumOfDefinedStoragePools; diff --git a/src/driver.h b/src/driver.h index 5b7862bd9e..e4e382b634 100644 --- a/src/driver.h +++ b/src/driver.h @@ -27,28 +27,6 @@ # include "internal.h" # include "libvirt_internal.h" # include "viruri.h" -/* - * List of registered drivers numbers - */ -typedef enum { - VIR_DRV_XEN_UNIFIED = 1, - VIR_DRV_TEST = 2, - VIR_DRV_QEMU = 3, - VIR_DRV_REMOTE = 4, - VIR_DRV_OPENVZ = 5, - VIR_DRV_LXC = 6, - VIR_DRV_UML = 7, - VIR_DRV_VBOX = 8, - VIR_DRV_ONE = 9, - VIR_DRV_ESX = 10, - VIR_DRV_PHYP = 11, - VIR_DRV_XENAPI = 12, - VIR_DRV_VMWARE = 13, - VIR_DRV_LIBXL = 14, - VIR_DRV_HYPERV = 15, - VIR_DRV_PARALLELS = 16, - VIR_DRV_BHYVE = 17, -} virDrvNo; /* Status codes returned from driver open call. */ @@ -97,15 +75,29 @@ typedef enum { # undef __VIR_DRIVER_H_INCLUDES___ -int virRegisterHypervisorDriver(virHypervisorDriverPtr) ATTRIBUTE_RETURN_CHECK; -int virRegisterNetworkDriver(virNetworkDriverPtr) ATTRIBUTE_RETURN_CHECK; -int virRegisterInterfaceDriver(virInterfaceDriverPtr) ATTRIBUTE_RETURN_CHECK; -int virRegisterNetworkDriver(virNetworkDriverPtr) ATTRIBUTE_RETURN_CHECK; -int virRegisterNodeDeviceDriver(virNodeDeviceDriverPtr) ATTRIBUTE_RETURN_CHECK; -int virRegisterNWFilterDriver(virNWFilterDriverPtr) ATTRIBUTE_RETURN_CHECK; -int virRegisterSecretDriver(virSecretDriverPtr) ATTRIBUTE_RETURN_CHECK; -int virRegisterStateDriver(virStateDriverPtr) ATTRIBUTE_RETURN_CHECK; -int virRegisterStorageDriver(virStorageDriverPtr) ATTRIBUTE_RETURN_CHECK; +typedef struct _virConnectDriver virConnectDriver; +typedef virConnectDriver *virConnectDriverPtr; + +struct _virConnectDriver { + virHypervisorDriverPtr hypervisorDriver; + virInterfaceDriverPtr interfaceDriver; + virNetworkDriverPtr networkDriver; + virNodeDeviceDriverPtr nodeDeviceDriver; + virNWFilterDriverPtr nwfilterDriver; + virSecretDriverPtr secretDriver; + virStorageDriverPtr storageDriver; +}; + +int virRegisterConnectDriver(virConnectDriverPtr driver, + bool setSharedDrivers) ATTRIBUTE_RETURN_CHECK; +int virRegisterStateDriver(virStateDriverPtr driver) ATTRIBUTE_RETURN_CHECK; + +int virSetSharedInterfaceDriver(virInterfaceDriverPtr driver) ATTRIBUTE_RETURN_CHECK; +int virSetSharedNetworkDriver(virNetworkDriverPtr driver) ATTRIBUTE_RETURN_CHECK; +int virSetSharedNodeDeviceDriver(virNodeDeviceDriverPtr driver) ATTRIBUTE_RETURN_CHECK; +int virSetSharedNWFilterDriver(virNWFilterDriverPtr driver) ATTRIBUTE_RETURN_CHECK; +int virSetSharedSecretDriver(virSecretDriverPtr driver) ATTRIBUTE_RETURN_CHECK; +int virSetSharedStorageDriver(virStorageDriverPtr driver) ATTRIBUTE_RETURN_CHECK; void *virDriverLoadModule(const char *name); diff --git a/src/esx/esx_device_monitor.c b/src/esx/esx_device_monitor.c deleted file mode 100644 index bf71145a61..0000000000 --- a/src/esx/esx_device_monitor.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * esx_device_monitor.c: device monitor functions for managing VMware ESX - * host devices - * - * Copyright (C) 2010-2011 Red Hat, Inc. - * Copyright (C) 2010 Matthias Bolte - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - * - */ - -#include - -#include "internal.h" -#include "viralloc.h" -#include "viruuid.h" -#include "esx_private.h" -#include "esx_device_monitor.h" -#include "esx_vi.h" -#include "esx_vi_methods.h" -#include "esx_util.h" - -#define VIR_FROM_THIS VIR_FROM_ESX - - - -static virDrvOpenStatus -esxNodeDeviceOpen(virConnectPtr conn, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (conn->driver->no != VIR_DRV_ESX) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - - - -static int -esxNodeDeviceClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - - - -static virNodeDeviceDriver esxNodeDeviceDriver = { - .name = "ESX", - .nodeDeviceOpen = esxNodeDeviceOpen, /* 0.7.6 */ - .nodeDeviceClose = esxNodeDeviceClose, /* 0.7.6 */ -}; - - - -int -esxDeviceRegister(void) -{ - return virRegisterNodeDeviceDriver(&esxNodeDeviceDriver); -} diff --git a/src/esx/esx_device_monitor.h b/src/esx/esx_device_monitor.h deleted file mode 100644 index 1b2795e5b2..0000000000 --- a/src/esx/esx_device_monitor.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * esx_device_monitor.h: device monitor methods for managing VMware ESX - * host devices - * - * Copyright (C) 2010 Matthias Bolte - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - * - */ - -#ifndef __ESX_DEVICE_MONITOR_H__ -# define __ESX_DEVICE_MONITOR_H__ - -int esxDeviceRegister(void); - -#endif /* __ESX_DEVICE_MONITOR_H__ */ diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index bfa1d79fa7..6b9965f8a5 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -37,9 +37,6 @@ #include "esx_interface_driver.h" #include "esx_network_driver.h" #include "esx_storage_driver.h" -#include "esx_device_monitor.h" -#include "esx_secret_driver.h" -#include "esx_nwfilter_driver.h" #include "esx_private.h" #include "esx_vi.h" #include "esx_vi_methods.h" @@ -5151,8 +5148,7 @@ esxConnectListAllDomains(virConnectPtr conn, #undef MATCH -static virHypervisorDriver esxDriver = { - .no = VIR_DRV_ESX, +static virHypervisorDriver esxHypervisorDriver = { .name = "ESX", .connectOpen = esxConnectOpen, /* 0.7.0 */ .connectClose = esxConnectClose, /* 0.7.0 */ @@ -5233,19 +5229,16 @@ static virHypervisorDriver esxDriver = { }; +static virConnectDriver esxConnectDriver = { + .hypervisorDriver = &esxHypervisorDriver, + .interfaceDriver = &esxInterfaceDriver, + .networkDriver = &esxNetworkDriver, + .storageDriver = &esxStorageDriver, +}; int esxRegister(void) { - if (virRegisterHypervisorDriver(&esxDriver) < 0 || - esxInterfaceRegister() < 0 || - esxNetworkRegister() < 0 || - esxStorageRegister() < 0 || - esxDeviceRegister() < 0 || - esxSecretRegister() < 0 || - esxNWFilterRegister() < 0) { - return -1; - } - - return 0; + return virRegisterConnectDriver(&esxConnectDriver, + false); } diff --git a/src/esx/esx_interface_driver.c b/src/esx/esx_interface_driver.c index 20c93614b4..58096e84cf 100644 --- a/src/esx/esx_interface_driver.c +++ b/src/esx/esx_interface_driver.c @@ -38,30 +38,6 @@ #define VIR_FROM_THIS VIR_FROM_ESX - -static virDrvOpenStatus -esxInterfaceOpen(virConnectPtr conn, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (conn->driver->no != VIR_DRV_ESX) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - - - -static int -esxInterfaceClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - - - static int esxConnectNumOfInterfaces(virConnectPtr conn) { @@ -282,10 +258,7 @@ esxInterfaceIsActive(virInterfacePtr iface ATTRIBUTE_UNUSED) -static virInterfaceDriver esxInterfaceDriver = { - .name = "ESX", - .interfaceOpen = esxInterfaceOpen, /* 0.7.6 */ - .interfaceClose = esxInterfaceClose, /* 0.7.6 */ +virInterfaceDriver esxInterfaceDriver = { .connectNumOfInterfaces = esxConnectNumOfInterfaces, /* 0.10.0 */ .connectListInterfaces = esxConnectListInterfaces, /* 0.10.0 */ .connectNumOfDefinedInterfaces = esxConnectNumOfDefinedInterfaces, /* 0.10.0 */ @@ -295,11 +268,3 @@ static virInterfaceDriver esxInterfaceDriver = { .interfaceGetXMLDesc = esxInterfaceGetXMLDesc, /* 0.10.0 */ .interfaceIsActive = esxInterfaceIsActive, /* 0.10.0 */ }; - - - -int -esxInterfaceRegister(void) -{ - return virRegisterInterfaceDriver(&esxInterfaceDriver); -} diff --git a/src/esx/esx_interface_driver.h b/src/esx/esx_interface_driver.h index cf0c4bd326..dfe245bb89 100644 --- a/src/esx/esx_interface_driver.h +++ b/src/esx/esx_interface_driver.h @@ -23,6 +23,8 @@ #ifndef __ESX_INTERFACE_DRIVER_H__ # define __ESX_INTERFACE_DRIVER_H__ -int esxInterfaceRegister(void); +# include "driver.h" + +extern virInterfaceDriver esxInterfaceDriver; #endif /* __ESX_INTERFACE_DRIVER_H__ */ diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c index 8defcd60c1..6793b809ee 100644 --- a/src/esx/esx_network_driver.c +++ b/src/esx/esx_network_driver.c @@ -44,30 +44,6 @@ verify(MD5_DIGEST_SIZE == VIR_UUID_BUFLEN); - -static virDrvOpenStatus -esxNetworkOpen(virConnectPtr conn, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (conn->driver->no != VIR_DRV_ESX) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - - - -static int -esxNetworkClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - - - static int esxConnectNumOfNetworks(virConnectPtr conn) { @@ -881,10 +857,7 @@ esxNetworkIsPersistent(virNetworkPtr network ATTRIBUTE_UNUSED) -static virNetworkDriver esxNetworkDriver = { - .name = "ESX", - .networkOpen = esxNetworkOpen, /* 0.7.6 */ - .networkClose = esxNetworkClose, /* 0.7.6 */ +virNetworkDriver esxNetworkDriver = { .connectNumOfNetworks = esxConnectNumOfNetworks, /* 0.10.0 */ .connectListNetworks = esxConnectListNetworks, /* 0.10.0 */ .connectNumOfDefinedNetworks = esxConnectNumOfDefinedNetworks, /* 0.10.0 */ @@ -899,11 +872,3 @@ static virNetworkDriver esxNetworkDriver = { .networkIsActive = esxNetworkIsActive, /* 0.10.0 */ .networkIsPersistent = esxNetworkIsPersistent, /* 0.10.0 */ }; - - - -int -esxNetworkRegister(void) -{ - return virRegisterNetworkDriver(&esxNetworkDriver); -} diff --git a/src/esx/esx_network_driver.h b/src/esx/esx_network_driver.h index 7a8a225f9f..d5bf0dd952 100644 --- a/src/esx/esx_network_driver.h +++ b/src/esx/esx_network_driver.h @@ -23,6 +23,8 @@ #ifndef __ESX_NETWORK_DRIVER_H__ # define __ESX_NETWORK_DRIVER_H__ -int esxNetworkRegister(void); +# include "driver.h" + +extern virNetworkDriver esxNetworkDriver; #endif /* __ESX_NETWORK_DRIVER_H__ */ diff --git a/src/esx/esx_nwfilter_driver.c b/src/esx/esx_nwfilter_driver.c deleted file mode 100644 index 705035c73f..0000000000 --- a/src/esx/esx_nwfilter_driver.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * esx_nwfilter_driver.c: nwfilter driver functions for managing VMware ESX - * firewall rules - * - * Copyright (C) 2011 Red Hat, Inc. - * Copyright (C) 2010 Matthias Bolte - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - * - */ - -#include - -#include "internal.h" -#include "viralloc.h" -#include "viruuid.h" -#include "esx_private.h" -#include "esx_nwfilter_driver.h" -#include "esx_vi.h" -#include "esx_vi_methods.h" -#include "esx_util.h" - -#define VIR_FROM_THIS VIR_FROM_ESX - - - -static virDrvOpenStatus -esxNWFilterOpen(virConnectPtr conn, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (conn->driver->no != VIR_DRV_ESX) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - - - -static int -esxNWFilterClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - - - -static virNWFilterDriver esxNWFilterDriver = { - .name = "ESX", - .nwfilterOpen = esxNWFilterOpen, /* 0.8.1 */ - .nwfilterClose = esxNWFilterClose, /* 0.8.1 */ -}; - - - -int -esxNWFilterRegister(void) -{ - return virRegisterNWFilterDriver(&esxNWFilterDriver); -} diff --git a/src/esx/esx_nwfilter_driver.h b/src/esx/esx_nwfilter_driver.h deleted file mode 100644 index 4fa88c3107..0000000000 --- a/src/esx/esx_nwfilter_driver.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * esx_nwfilter_driver.h: nwfilter driver functions for managing VMware ESX - * firewall rules - * - * Copyright (C) 2010 Matthias Bolte - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - * - */ - -#ifndef __ESX_NWFILTER_DRIVER_H__ -# define __ESX_NWFILTER_DRIVER_H__ - -int esxNWFilterRegister(void); - -#endif /* __ESX_NWFILTER_DRIVER_H__ */ diff --git a/src/esx/esx_secret_driver.c b/src/esx/esx_secret_driver.c deleted file mode 100644 index de398af98c..0000000000 --- a/src/esx/esx_secret_driver.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * esx_secret_driver.c: secret driver functions for VMware ESX secret manipulation - * - * Copyright (C) 2010-2011 Red Hat, Inc. - * Copyright (C) 2010 Matthias Bolte - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - * - */ - -#include - -#include "internal.h" -#include "viralloc.h" -#include "viruuid.h" -#include "esx_private.h" -#include "esx_secret_driver.h" -#include "esx_vi.h" -#include "esx_vi_methods.h" -#include "esx_util.h" - -#define VIR_FROM_THIS VIR_FROM_ESX - - - -static virDrvOpenStatus -esxSecretOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (conn->driver->no != VIR_DRV_ESX) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - - - -static int -esxSecretClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - - - -static virSecretDriver esxSecretDriver = { - .name = "ESX", - .secretOpen = esxSecretOpen, /* 0.7.6 */ - .secretClose = esxSecretClose, /* 0.7.6 */ -}; - - - -int -esxSecretRegister(void) -{ - return virRegisterSecretDriver(&esxSecretDriver); -} diff --git a/src/esx/esx_secret_driver.h b/src/esx/esx_secret_driver.h deleted file mode 100644 index 07f8b13ed3..0000000000 --- a/src/esx/esx_secret_driver.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * esx_secret_driver.h: secret driver functions for VMware ESX secret manipulation - * - * Copyright (C) 2010 Matthias Bolte - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - * - */ - -#ifndef __ESX_SECRET_DRIVER_H__ -# define __ESX_SECRET_DRIVER_H__ - -int esxSecretRegister(void); - -#endif /* __ESX_SECRET_DRIVER_H__ */ diff --git a/src/esx/esx_storage_driver.c b/src/esx/esx_storage_driver.c index b8e2fdae25..e692e8644d 100644 --- a/src/esx/esx_storage_driver.c +++ b/src/esx/esx_storage_driver.c @@ -52,30 +52,6 @@ static virStorageDriverPtr backends[] = { }; - -static virDrvOpenStatus -esxStorageOpen(virConnectPtr conn, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (conn->driver->no != VIR_DRV_ESX) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - - - -static int -esxStorageClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - - - static int esxConnectNumOfStoragePools(virConnectPtr conn) { @@ -541,10 +517,7 @@ esxStoragePoolIsPersistent(virStoragePoolPtr pool ATTRIBUTE_UNUSED) -static virStorageDriver esxStorageDriver = { - .name = "ESX", - .storageOpen = esxStorageOpen, /* 0.7.6 */ - .storageClose = esxStorageClose, /* 0.7.6 */ +virStorageDriver esxStorageDriver = { .connectNumOfStoragePools = esxConnectNumOfStoragePools, /* 0.8.2 */ .connectListStoragePools = esxConnectListStoragePools, /* 0.8.2 */ .connectNumOfDefinedStoragePools = esxConnectNumOfDefinedStoragePools, /* 0.8.2 */ @@ -572,11 +545,3 @@ static virStorageDriver esxStorageDriver = { .storagePoolIsActive = esxStoragePoolIsActive, /* 0.8.2 */ .storagePoolIsPersistent = esxStoragePoolIsPersistent, /* 0.8.2 */ }; - - - -int -esxStorageRegister(void) -{ - return virRegisterStorageDriver(&esxStorageDriver); -} diff --git a/src/esx/esx_storage_driver.h b/src/esx/esx_storage_driver.h index 871e59c3f3..eee3c5c51e 100644 --- a/src/esx/esx_storage_driver.h +++ b/src/esx/esx_storage_driver.h @@ -23,6 +23,8 @@ #ifndef __ESX_STORAGE_DRIVER_H__ # define __ESX_STORAGE_DRIVER_H__ -int esxStorageRegister(void); +# include "driver.h" + +extern virStorageDriver esxStorageDriver; #endif /* __ESX_STORAGE_DRIVER_H__ */ diff --git a/src/hyperv/hyperv_device_monitor.c b/src/hyperv/hyperv_device_monitor.c deleted file mode 100644 index c24c384d82..0000000000 --- a/src/hyperv/hyperv_device_monitor.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * hyperv_device_monitor.c: device monitor functions for managing - * Microsoft Hyper-V host devices - * - * Copyright (C) 2011 Matthias Bolte - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - * - */ - -#include - -#include "internal.h" -#include "virerror.h" -#include "datatypes.h" -#include "viralloc.h" -#include "viruuid.h" -#include "hyperv_device_monitor.h" - -#define VIR_FROM_THIS VIR_FROM_HYPERV - - - -static virDrvOpenStatus -hypervNodeDeviceOpen(virConnectPtr conn, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (conn->driver->no != VIR_DRV_HYPERV) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - - - -static int -hypervNodeDeviceClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - - - -static virNodeDeviceDriver hypervNodeDeviceDriver = { - "Hyper-V", - .nodeDeviceOpen = hypervNodeDeviceOpen, /* 0.9.5 */ - .nodeDeviceClose = hypervNodeDeviceClose, /* 0.9.5 */ -}; - - - -int -hypervDeviceRegister(void) -{ - return virRegisterNodeDeviceDriver(&hypervNodeDeviceDriver); -} diff --git a/src/hyperv/hyperv_device_monitor.h b/src/hyperv/hyperv_device_monitor.h deleted file mode 100644 index 36459b6258..0000000000 --- a/src/hyperv/hyperv_device_monitor.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * hyperv_device_monitor.h: device monitor functions for managing - * Microsoft Hyper-V host devices - * - * Copyright (C) 2011 Matthias Bolte - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - * - */ - -#ifndef __HYPERV_DEVICE_MONITOR_H__ -# define __HYPERV_DEVICE_MONITOR_H__ - -int hypervDeviceRegister(void); - -#endif /* __HYPERV_DEVICE_MONITOR_H__ */ diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index be379e9a95..906c6032f2 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -30,12 +30,6 @@ #include "virlog.h" #include "viruuid.h" #include "hyperv_driver.h" -#include "hyperv_interface_driver.h" -#include "hyperv_network_driver.h" -#include "hyperv_storage_driver.h" -#include "hyperv_device_monitor.h" -#include "hyperv_secret_driver.h" -#include "hyperv_nwfilter_driver.h" #include "hyperv_private.h" #include "hyperv_util.h" #include "hyperv_wmi.h" @@ -1326,8 +1320,7 @@ hypervConnectListAllDomains(virConnectPtr conn, -static virHypervisorDriver hypervDriver = { - .no = VIR_DRV_HYPERV, +static virHypervisorDriver hypervHypervisorDriver = { .name = "Hyper-V", .connectOpen = hypervConnectOpen, /* 0.9.5 */ .connectClose = hypervConnectClose, /* 0.9.5 */ @@ -1386,22 +1379,16 @@ hypervDebugHandler(const char *message, debug_level_e level, } +static virConnectDriver hypervConnectDriver = { + .hypervisorDriver = &hypervHypervisorDriver, +}; int hypervRegister(void) { - if (virRegisterHypervisorDriver(&hypervDriver) < 0 || - hypervInterfaceRegister() < 0 || - hypervNetworkRegister() < 0 || - hypervStorageRegister() < 0 || - hypervDeviceRegister() < 0 || - hypervSecretRegister() < 0 || - hypervNWFilterRegister() < 0) { - return -1; - } - /* Forward openwsman errors and warnings to libvirt's logging */ debug_add_handler(hypervDebugHandler, DEBUG_LEVEL_WARNING, NULL); - return 0; + return virRegisterConnectDriver(&hypervConnectDriver, + false); } diff --git a/src/hyperv/hyperv_interface_driver.c b/src/hyperv/hyperv_interface_driver.c deleted file mode 100644 index 6529e3705f..0000000000 --- a/src/hyperv/hyperv_interface_driver.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * hyperv_interface_driver.c: interface driver functions for managing - * Microsoft Hyper-V host interfaces - * - * Copyright (C) 2011 Matthias Bolte - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - * - */ - -#include - -#include "internal.h" -#include "virerror.h" -#include "datatypes.h" -#include "viralloc.h" -#include "viruuid.h" -#include "hyperv_interface_driver.h" - -#define VIR_FROM_THIS VIR_FROM_HYPERV - - - -static virDrvOpenStatus -hypervInterfaceOpen(virConnectPtr conn, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (conn->driver->no != VIR_DRV_HYPERV) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - - - -static int -hypervInterfaceClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - - - -static virInterfaceDriver hypervInterfaceDriver = { - .name = "Hyper-V", - .interfaceOpen = hypervInterfaceOpen, /* 0.9.5 */ - .interfaceClose = hypervInterfaceClose, /* 0.9.5 */ -}; - - - -int -hypervInterfaceRegister(void) -{ - return virRegisterInterfaceDriver(&hypervInterfaceDriver); -} diff --git a/src/hyperv/hyperv_interface_driver.h b/src/hyperv/hyperv_interface_driver.h deleted file mode 100644 index 2ab022530b..0000000000 --- a/src/hyperv/hyperv_interface_driver.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * hyperv_interface_driver.h: interface driver functions for managing - * Microsoft Hyper-V host interfaces - * - * Copyright (C) 2011 Matthias Bolte - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - * - */ - -#ifndef __HYPERV_INTERFACE_DRIVER_H__ -# define __HYPERV_INTERFACE_DRIVER_H__ - -int hypervInterfaceRegister(void); - -#endif /* __HYPERV_INTERFACE_DRIVER_H__ */ diff --git a/src/hyperv/hyperv_network_driver.c b/src/hyperv/hyperv_network_driver.c deleted file mode 100644 index 93f37183c3..0000000000 --- a/src/hyperv/hyperv_network_driver.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * hyperv_network_driver.c: network driver functions for managing - * Microsoft Hyper-V host networks - * - * Copyright (C) 2011 Matthias Bolte - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - * - */ - -#include - -#include "internal.h" -#include "virerror.h" -#include "datatypes.h" -#include "viralloc.h" -#include "viruuid.h" -#include "hyperv_network_driver.h" - -#define VIR_FROM_THIS VIR_FROM_HYPERV - - - -static virDrvOpenStatus -hypervNetworkOpen(virConnectPtr conn, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (conn->driver->no != VIR_DRV_HYPERV) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - - - -static int -hypervNetworkClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - - - -static virNetworkDriver hypervNetworkDriver = { - .name = "Hyper-V", - .networkOpen = hypervNetworkOpen, /* 0.9.5 */ - .networkClose = hypervNetworkClose, /* 0.9.5 */ -}; - - - -int -hypervNetworkRegister(void) -{ - return virRegisterNetworkDriver(&hypervNetworkDriver); -} diff --git a/src/hyperv/hyperv_network_driver.h b/src/hyperv/hyperv_network_driver.h deleted file mode 100644 index 231d94bc68..0000000000 --- a/src/hyperv/hyperv_network_driver.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * hyperv_network_driver.h: network driver functions for managing - * Microsoft Hyper-V host networks - * - * Copyright (C) 2011 Matthias Bolte - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - * - */ - -#ifndef __HYPERV_NETWORK_DRIVER_H__ -# define __HYPERV_NETWORK_DRIVER_H__ - -int hypervNetworkRegister(void); - -#endif /* __HYPERV_NETWORK_DRIVER_H__ */ diff --git a/src/hyperv/hyperv_nwfilter_driver.c b/src/hyperv/hyperv_nwfilter_driver.c deleted file mode 100644 index fc6ae19745..0000000000 --- a/src/hyperv/hyperv_nwfilter_driver.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * hyperv_nwfilter_driver.c: nwfilter driver functions for managing - * Microsoft Hyper-V firewall rules - * - * Copyright (C) 2011 Matthias Bolte - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - * - */ - -#include - -#include "internal.h" -#include "virerror.h" -#include "datatypes.h" -#include "viralloc.h" -#include "viruuid.h" -#include "hyperv_nwfilter_driver.h" - -#define VIR_FROM_THIS VIR_FROM_HYPERV - - - -static virDrvOpenStatus -hypervNWFilterOpen(virConnectPtr conn, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (conn->driver->no != VIR_DRV_HYPERV) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - - - -static int -hypervNWFilterClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - - - -static virNWFilterDriver hypervNWFilterDriver = { - .name = "Hyper-V", - .nwfilterOpen = hypervNWFilterOpen, /* 0.9.5 */ - .nwfilterClose = hypervNWFilterClose, /* 0.9.5 */ -}; - - - -int -hypervNWFilterRegister(void) -{ - return virRegisterNWFilterDriver(&hypervNWFilterDriver); -} diff --git a/src/hyperv/hyperv_nwfilter_driver.h b/src/hyperv/hyperv_nwfilter_driver.h deleted file mode 100644 index d5918cb9b0..0000000000 --- a/src/hyperv/hyperv_nwfilter_driver.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * hyperv_nwfilter_driver.h: nwfilter driver functions for managing - * Microsoft Hyper-V firewall rules - * - * Copyright (C) 2011 Matthias Bolte - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - * - */ - -#ifndef __HYPERV_NWFILTER_DRIVER_H__ -# define __HYPERV_NWFILTER_DRIVER_H__ - -int hypervNWFilterRegister(void); - -#endif /* __HYPERV_NWFILTER_DRIVER_H__ */ diff --git a/src/hyperv/hyperv_secret_driver.c b/src/hyperv/hyperv_secret_driver.c deleted file mode 100644 index 31cf915128..0000000000 --- a/src/hyperv/hyperv_secret_driver.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * hyperv_secret_driver.c: secret driver functions for Microsoft Hyper-V - * secret manipulation - * - * Copyright (C) 2011 Matthias Bolte - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - * - */ - -#include - -#include "internal.h" -#include "virerror.h" -#include "datatypes.h" -#include "viralloc.h" -#include "viruuid.h" -#include "hyperv_secret_driver.h" - -#define VIR_FROM_THIS VIR_FROM_HYPERV - - - -static virDrvOpenStatus -hypervSecretOpen(virConnectPtr conn, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (conn->driver->no != VIR_DRV_HYPERV) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - - - -static int -hypervSecretClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - - - -static virSecretDriver hypervSecretDriver = { - .name = "Hyper-V", - .secretOpen = hypervSecretOpen, /* 0.9.5 */ - .secretClose = hypervSecretClose, /* 0.9.5 */ -}; - - - -int -hypervSecretRegister(void) -{ - return virRegisterSecretDriver(&hypervSecretDriver); -} diff --git a/src/hyperv/hyperv_secret_driver.h b/src/hyperv/hyperv_secret_driver.h deleted file mode 100644 index 40bb3ada4c..0000000000 --- a/src/hyperv/hyperv_secret_driver.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * hyperv_secret_driver.h: secret driver functions for Microsoft Hyper-V - * secret manipulation - * - * Copyright (C) 2011 Matthias Bolte - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - * - */ - -#ifndef __HYPERV_SECRET_DRIVER_H__ -# define __HYPERV_SECRET_DRIVER_H__ - -int hypervSecretRegister(void); - -#endif /* __HYPERV_SECRET_DRIVER_H__ */ diff --git a/src/hyperv/hyperv_storage_driver.c b/src/hyperv/hyperv_storage_driver.c deleted file mode 100644 index 8fa1343d21..0000000000 --- a/src/hyperv/hyperv_storage_driver.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * hyperv_storage_driver.c: storage driver functions for managing - * Microsoft Hyper-V host storage - * - * Copyright (C) 2011 Matthias Bolte - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - * - */ - -#include - -#include "internal.h" -#include "virerror.h" -#include "datatypes.h" -#include "viralloc.h" -#include "viruuid.h" -#include "hyperv_storage_driver.h" - -#define VIR_FROM_THIS VIR_FROM_HYPERV - - - -static virDrvOpenStatus -hypervStorageOpen(virConnectPtr conn, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (conn->driver->no != VIR_DRV_HYPERV) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - - - -static int -hypervStorageClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - - - -static virStorageDriver hypervStorageDriver = { - .name = "Hyper-V", - .storageOpen = hypervStorageOpen, /* 0.9.5*/ - .storageClose = hypervStorageClose, /* 0.9.5 */ -}; - - - -int -hypervStorageRegister(void) -{ - return virRegisterStorageDriver(&hypervStorageDriver); -} diff --git a/src/hyperv/hyperv_storage_driver.h b/src/hyperv/hyperv_storage_driver.h deleted file mode 100644 index 651fb51926..0000000000 --- a/src/hyperv/hyperv_storage_driver.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * hyperv_storage_driver.h: storage driver methods for managing - * Microsoft Hyper-V host storage - * - * Copyright (C) 2011 Matthias Bolte - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - * - */ - -#ifndef __HYPERV_STORAGE_DRIVER_H__ -# define __HYPERV_STORAGE_DRIVER_H__ - -int hypervStorageRegister(void); - -#endif /* __HYPERV_STORAGE_DRIVER_H__ */ diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interface_backend_netcf.c index 116d84e210..947f1e2d0d 100644 --- a/src/interface/interface_backend_netcf.c +++ b/src/interface/interface_backend_netcf.c @@ -264,25 +264,6 @@ netcfInterfaceObjIsActive(struct netcf_if *iface, return ret; } -static virDrvOpenStatus -netcfInterfaceOpen(virConnectPtr conn ATTRIBUTE_UNUSED, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (!driver) - return VIR_DRV_OPEN_ERROR; - - return VIR_DRV_OPEN_SUCCESS; -} - -static int -netcfInterfaceClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - static int netcfConnectNumOfInterfacesImpl(virConnectPtr conn, int status, virInterfaceObjListFilter filter) @@ -1136,8 +1117,6 @@ static int netcfInterfaceChangeRollback(virConnectPtr conn, unsigned int flags) static virInterfaceDriver interfaceDriver = { .name = INTERFACE_DRIVER_NAME, - .interfaceOpen = netcfInterfaceOpen, /* 0.7.0 */ - .interfaceClose = netcfInterfaceClose, /* 0.7.0 */ .connectNumOfInterfaces = netcfConnectNumOfInterfaces, /* 0.7.0 */ .connectListInterfaces = netcfConnectListInterfaces, /* 0.7.0 */ .connectNumOfDefinedInterfaces = netcfConnectNumOfDefinedInterfaces, /* 0.7.0 */ @@ -1167,11 +1146,8 @@ static virStateDriver interfaceStateDriver = { int netcfIfaceRegister(void) { - if (virRegisterInterfaceDriver(&interfaceDriver) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("failed to register netcf interface driver")); + if (virSetSharedInterfaceDriver(&interfaceDriver) < 0) return -1; - } if (virRegisterStateDriver(&interfaceStateDriver) < 0) return -1; return 0; diff --git a/src/interface/interface_backend_udev.c b/src/interface/interface_backend_udev.c index b027de0f2e..27a772dc03 100644 --- a/src/interface/interface_backend_udev.c +++ b/src/interface/interface_backend_udev.c @@ -135,25 +135,6 @@ udevGetDevices(struct udev *udev, virUdevStatus status) return enumerate; } -static virDrvOpenStatus -udevInterfaceOpen(virConnectPtr conn ATTRIBUTE_UNUSED, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (!driver) - return VIR_DRV_OPEN_ERROR; - - return VIR_DRV_OPEN_SUCCESS; -} - -static int -udevInterfaceClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - static int udevNumOfInterfacesByStatus(virConnectPtr conn, virUdevStatus status, virInterfaceObjListFilter filter) @@ -1212,9 +1193,7 @@ udevStateCleanup(void) static virInterfaceDriver udevIfaceDriver = { - "udev", - .interfaceOpen = udevInterfaceOpen, /* 1.0.0 */ - .interfaceClose = udevInterfaceClose, /* 1.0.0 */ + .name = "udev", .connectNumOfInterfaces = udevConnectNumOfInterfaces, /* 1.0.0 */ .connectListInterfaces = udevConnectListInterfaces, /* 1.0.0 */ .connectNumOfDefinedInterfaces = udevConnectNumOfDefinedInterfaces, /* 1.0.0 */ @@ -1235,7 +1214,7 @@ static virStateDriver interfaceStateDriver = { int udevIfaceRegister(void) { - if (virRegisterInterfaceDriver(&udevIfaceDriver) < 0) { + if (virSetSharedInterfaceDriver(&udevIfaceDriver) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to register udev interface driver")); return -1; diff --git a/src/libvirt.c b/src/libvirt.c index 43eb95ca37..c8a58341ae 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -111,33 +111,18 @@ VIR_LOG_INIT("libvirt"); #define MAX_DRIVERS 20 -#define virDriverCheckTabMaxReturn(count, ret) \ - do { \ - if ((count) >= MAX_DRIVERS) { \ - virReportError(VIR_ERR_INTERNAL_ERROR, \ - _("Too many drivers, cannot register %s"), \ - driver->name); \ - return ret; \ - } \ - } while (0) - -static virHypervisorDriverPtr virHypervisorDriverTab[MAX_DRIVERS]; -static int virHypervisorDriverTabCount; -static virNetworkDriverPtr virNetworkDriverTab[MAX_DRIVERS]; -static int virNetworkDriverTabCount; -static virInterfaceDriverPtr virInterfaceDriverTab[MAX_DRIVERS]; -static int virInterfaceDriverTabCount; -static virStorageDriverPtr virStorageDriverTab[MAX_DRIVERS]; -static int virStorageDriverTabCount; -static virNodeDeviceDriverPtr virNodeDeviceDriverTab[MAX_DRIVERS]; -static int virNodeDeviceDriverTabCount; -static virSecretDriverPtr virSecretDriverTab[MAX_DRIVERS]; -static int virSecretDriverTabCount; -static virNWFilterDriverPtr virNWFilterDriverTab[MAX_DRIVERS]; -static int virNWFilterDriverTabCount; +static virConnectDriverPtr virConnectDriverTab[MAX_DRIVERS]; +static int virConnectDriverTabCount; static virStateDriverPtr virStateDriverTab[MAX_DRIVERS]; static int virStateDriverTabCount; +static virNetworkDriverPtr virSharedNetworkDriver; +static virInterfaceDriverPtr virSharedInterfaceDriver; +static virStorageDriverPtr virSharedStorageDriver; +static virNodeDeviceDriverPtr virSharedNodeDeviceDriver; +static virSecretDriverPtr virSharedSecretDriver; +static virNWFilterDriverPtr virSharedNWFilterDriver; + #if defined(POLKIT_AUTH) static int @@ -533,29 +518,33 @@ DllMain(HINSTANCE instance ATTRIBUTE_UNUSED, /** - * virRegisterNetworkDriver: + * virSetSharedNetworkDriver: * @driver: pointer to a network driver block * * Register a network virtualization driver * - * Returns the driver priority or -1 in case of error. + * Returns 0 on success, or -1 in case of error. */ int -virRegisterNetworkDriver(virNetworkDriverPtr driver) +virSetSharedNetworkDriver(virNetworkDriverPtr driver) { virCheckNonNullArgReturn(driver, -1); - virDriverCheckTabMaxReturn(virNetworkDriverTabCount, -1); - VIR_DEBUG("registering %s as network driver %d", - driver->name, virNetworkDriverTabCount); + if (virSharedNetworkDriver) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("A network driver is already registered")); + return -1; + } - virNetworkDriverTab[virNetworkDriverTabCount] = driver; - return virNetworkDriverTabCount++; + VIR_DEBUG("registering %s as network driver", driver->name); + + virSharedNetworkDriver = driver; + return 0; } /** - * virRegisterInterfaceDriver: + * virSetSharedInterfaceDriver: * @driver: pointer to an interface driver block * * Register an interface virtualization driver @@ -563,21 +552,25 @@ virRegisterNetworkDriver(virNetworkDriverPtr driver) * Returns the driver priority or -1 in case of error. */ int -virRegisterInterfaceDriver(virInterfaceDriverPtr driver) +virSetSharedInterfaceDriver(virInterfaceDriverPtr driver) { virCheckNonNullArgReturn(driver, -1); - virDriverCheckTabMaxReturn(virInterfaceDriverTabCount, -1); - VIR_DEBUG("registering %s as interface driver %d", - driver->name, virInterfaceDriverTabCount); + if (virSharedInterfaceDriver) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("A interface driver is already registered")); + return -1; + } - virInterfaceDriverTab[virInterfaceDriverTabCount] = driver; - return virInterfaceDriverTabCount++; + VIR_DEBUG("registering %s as interface driver", driver->name); + + virSharedInterfaceDriver = driver; + return 0; } /** - * virRegisterStorageDriver: + * virSetSharedStorageDriver: * @driver: pointer to a storage driver block * * Register a storage virtualization driver @@ -585,21 +578,25 @@ virRegisterInterfaceDriver(virInterfaceDriverPtr driver) * Returns the driver priority or -1 in case of error. */ int -virRegisterStorageDriver(virStorageDriverPtr driver) +virSetSharedStorageDriver(virStorageDriverPtr driver) { virCheckNonNullArgReturn(driver, -1); - virDriverCheckTabMaxReturn(virStorageDriverTabCount, -1); - VIR_DEBUG("registering %s as storage driver %d", - driver->name, virStorageDriverTabCount); + if (virSharedStorageDriver) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("A storage driver is already registered")); + return -1; + } - virStorageDriverTab[virStorageDriverTabCount] = driver; - return virStorageDriverTabCount++; + VIR_DEBUG("registering %s as storage driver", driver->name); + + virSharedStorageDriver = driver; + return 0; } /** - * virRegisterNodeDeviceDriver: + * virSetSharedNodeDeviceDriver: * @driver: pointer to a device monitor block * * Register a device monitor @@ -607,21 +604,25 @@ virRegisterStorageDriver(virStorageDriverPtr driver) * Returns the driver priority or -1 in case of error. */ int -virRegisterNodeDeviceDriver(virNodeDeviceDriverPtr driver) +virSetSharedNodeDeviceDriver(virNodeDeviceDriverPtr driver) { virCheckNonNullArgReturn(driver, -1); - virDriverCheckTabMaxReturn(virNodeDeviceDriverTabCount, -1); - VIR_DEBUG("registering %s as device driver %d", - driver->name, virNodeDeviceDriverTabCount); + if (virSharedNodeDeviceDriver) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("A node device driver is already registered")); + return -1; + } - virNodeDeviceDriverTab[virNodeDeviceDriverTabCount] = driver; - return virNodeDeviceDriverTabCount++; + VIR_DEBUG("registering %s as device driver", driver->name); + + virSharedNodeDeviceDriver = driver; + return 0; } /** - * virRegisterSecretDriver: + * virSetSharedSecretDriver: * @driver: pointer to a secret driver block * * Register a secret driver @@ -629,21 +630,25 @@ virRegisterNodeDeviceDriver(virNodeDeviceDriverPtr driver) * Returns the driver priority or -1 in case of error. */ int -virRegisterSecretDriver(virSecretDriverPtr driver) +virSetSharedSecretDriver(virSecretDriverPtr driver) { virCheckNonNullArgReturn(driver, -1); - virDriverCheckTabMaxReturn(virSecretDriverTabCount, -1); - VIR_DEBUG("registering %s as secret driver %d", - driver->name, virSecretDriverTabCount); + if (virSharedSecretDriver) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("A secret driver is already registered")); + return -1; + } - virSecretDriverTab[virSecretDriverTabCount] = driver; - return virSecretDriverTabCount++; + VIR_DEBUG("registering %s as secret driver", driver->name); + + virSharedSecretDriver = driver; + return 0; } /** - * virRegisterNWFilterDriver: + * virSetSharedNWFilterDriver: * @driver: pointer to a network filter driver block * * Register a network filter virtualization driver @@ -651,41 +656,68 @@ virRegisterSecretDriver(virSecretDriverPtr driver) * Returns the driver priority or -1 in case of error. */ int -virRegisterNWFilterDriver(virNWFilterDriverPtr driver) +virSetSharedNWFilterDriver(virNWFilterDriverPtr driver) { virCheckNonNullArgReturn(driver, -1); - virDriverCheckTabMaxReturn(virNWFilterDriverTabCount, -1); - VIR_DEBUG("registering %s as network filter driver %d", - driver->name, virNWFilterDriverTabCount); + if (virSharedNWFilterDriver) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("A network filter driver is already registered")); + return -1; + } - virNWFilterDriverTab[virNWFilterDriverTabCount] = driver; - return virNWFilterDriverTabCount++; + VIR_DEBUG("registering %s as network filter driver", driver->name); + + virSharedNWFilterDriver = driver; + return 0; } /** - * virRegisterHypervisorDriver: + * virRegisterConnectDriver: * @driver: pointer to a driver block + * @setSharedDrivers: populate shared drivers * - * Register a virtualization driver + * Register a virtualization driver, optionally filling in + * any empty pointers for shared secondary drivers * * Returns the driver priority or -1 in case of error. */ int -virRegisterHypervisorDriver(virHypervisorDriverPtr driver) +virRegisterConnectDriver(virConnectDriverPtr driver, + bool setSharedDrivers) { VIR_DEBUG("driver=%p name=%s", driver, - driver ? NULLSTR(driver->name) : "(null)"); + driver ? NULLSTR(driver->hypervisorDriver->name) : "(null)"); virCheckNonNullArgReturn(driver, -1); - virDriverCheckTabMaxReturn(virHypervisorDriverTabCount, -1); + if (virConnectDriverTabCount >= MAX_DRIVERS) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Too many drivers, cannot register %s"), + driver->hypervisorDriver->name); + return -1; + } VIR_DEBUG("registering %s as driver %d", - driver->name, virHypervisorDriverTabCount); + driver->hypervisorDriver->name, virConnectDriverTabCount); - virHypervisorDriverTab[virHypervisorDriverTabCount] = driver; - return virHypervisorDriverTabCount++; + if (setSharedDrivers) { + if (driver->interfaceDriver == NULL) + driver->interfaceDriver = virSharedInterfaceDriver; + if (driver->networkDriver == NULL) + driver->networkDriver = virSharedNetworkDriver; + if (driver->nodeDeviceDriver == NULL) + driver->nodeDeviceDriver = virSharedNodeDeviceDriver; + if (driver->nwfilterDriver == NULL) + driver->nwfilterDriver = virSharedNWFilterDriver; + if (driver->secretDriver == NULL) + driver->secretDriver = virSharedSecretDriver; + if (driver->storageDriver == NULL) + driver->storageDriver = virSharedStorageDriver; + } + + virConnectDriverTab[virConnectDriverTabCount] = driver; + return virConnectDriverTabCount++; } @@ -701,7 +733,13 @@ int virRegisterStateDriver(virStateDriverPtr driver) { virCheckNonNullArgReturn(driver, -1); - virDriverCheckTabMaxReturn(virStateDriverTabCount, -1); + + if (virStateDriverTabCount >= MAX_DRIVERS) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Too many drivers, cannot register %s"), + driver->name); + return -1; + } virStateDriverTab[virStateDriverTabCount] = driver; return virStateDriverTabCount++; @@ -1101,7 +1139,7 @@ do_open(const char *name, /* Cleansing flags */ ret->flags = flags & VIR_CONNECT_RO; - for (i = 0; i < virHypervisorDriverTabCount; i++) { + for (i = 0; i < virConnectDriverTabCount; 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. @@ -1109,7 +1147,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 (virHypervisorDriverTab[i]->no == VIR_DRV_REMOTE && + if (STREQ(virConnectDriverTab[i]->hypervisorDriver->name, "remote") && ret->uri != NULL && ret->uri->scheme != NULL && ( #ifndef WITH_PHYP @@ -1137,22 +1175,37 @@ do_open(const char *name, goto failed; } - VIR_DEBUG("trying driver %zu (%s) ...", i, virHypervisorDriverTab[i]->name); - ret->driver = virHypervisorDriverTab[i]; - res = virHypervisorDriverTab[i]->connectOpen(ret, auth, flags); + VIR_DEBUG("trying driver %zu (%s) ...", + i, virConnectDriverTab[i]->hypervisorDriver->name); + + ret->driver = virConnectDriverTab[i]->hypervisorDriver; + ret->interfaceDriver = virConnectDriverTab[i]->interfaceDriver; + ret->networkDriver = virConnectDriverTab[i]->networkDriver; + ret->nodeDeviceDriver = virConnectDriverTab[i]->nodeDeviceDriver; + ret->nwfilterDriver = virConnectDriverTab[i]->nwfilterDriver; + ret->secretDriver = virConnectDriverTab[i]->secretDriver; + ret->storageDriver = virConnectDriverTab[i]->storageDriver; + + res = virConnectDriverTab[i]->hypervisorDriver->connectOpen(ret, auth, flags); VIR_DEBUG("driver %zu %s returned %s", - i, virHypervisorDriverTab[i]->name, + i, virConnectDriverTab[i]->hypervisorDriver->name, res == VIR_DRV_OPEN_SUCCESS ? "SUCCESS" : (res == VIR_DRV_OPEN_DECLINED ? "DECLINED" : (res == VIR_DRV_OPEN_ERROR ? "ERROR" : "unknown status"))); if (res == VIR_DRV_OPEN_SUCCESS) { break; - } else if (res == VIR_DRV_OPEN_ERROR) { - ret->driver = NULL; - goto failed; } else { ret->driver = NULL; + ret->interfaceDriver = NULL; + ret->networkDriver = NULL; + ret->nodeDeviceDriver = NULL; + ret->nwfilterDriver = NULL; + ret->secretDriver = NULL; + ret->storageDriver = NULL; + + if (res == VIR_DRV_OPEN_ERROR) + goto failed; } } @@ -1162,106 +1215,6 @@ do_open(const char *name, goto failed; } - for (i = 0; i < virNetworkDriverTabCount; i++) { - res = virNetworkDriverTab[i]->networkOpen(ret, auth, flags); - VIR_DEBUG("network driver %zu %s returned %s", - i, virNetworkDriverTab[i]->name, - res == VIR_DRV_OPEN_SUCCESS ? "SUCCESS" : - (res == VIR_DRV_OPEN_DECLINED ? "DECLINED" : - (res == VIR_DRV_OPEN_ERROR ? "ERROR" : "unknown status"))); - - if (res == VIR_DRV_OPEN_SUCCESS) { - ret->networkDriver = virNetworkDriverTab[i]; - break; - } else if (res == VIR_DRV_OPEN_ERROR) { - break; - } - } - - for (i = 0; i < virInterfaceDriverTabCount; i++) { - res = virInterfaceDriverTab[i]->interfaceOpen(ret, auth, flags); - VIR_DEBUG("interface driver %zu %s returned %s", - i, virInterfaceDriverTab[i]->name, - res == VIR_DRV_OPEN_SUCCESS ? "SUCCESS" : - (res == VIR_DRV_OPEN_DECLINED ? "DECLINED" : - (res == VIR_DRV_OPEN_ERROR ? "ERROR" : "unknown status"))); - - if (res == VIR_DRV_OPEN_SUCCESS) { - ret->interfaceDriver = virInterfaceDriverTab[i]; - break; - } else if (res == VIR_DRV_OPEN_ERROR) { - break; - } - } - - /* Secondary driver for storage. Optional */ - for (i = 0; i < virStorageDriverTabCount; i++) { - res = virStorageDriverTab[i]->storageOpen(ret, auth, flags); - VIR_DEBUG("storage driver %zu %s returned %s", - i, virStorageDriverTab[i]->name, - res == VIR_DRV_OPEN_SUCCESS ? "SUCCESS" : - (res == VIR_DRV_OPEN_DECLINED ? "DECLINED" : - (res == VIR_DRV_OPEN_ERROR ? "ERROR" : "unknown status"))); - - if (res == VIR_DRV_OPEN_SUCCESS) { - ret->storageDriver = virStorageDriverTab[i]; - break; - } else if (res == VIR_DRV_OPEN_ERROR) { - break; - } - } - - /* Node driver (optional) */ - for (i = 0; i < virNodeDeviceDriverTabCount; i++) { - res = virNodeDeviceDriverTab[i]->nodeDeviceOpen(ret, auth, flags); - VIR_DEBUG("node driver %zu %s returned %s", - i, virNodeDeviceDriverTab[i]->name, - res == VIR_DRV_OPEN_SUCCESS ? "SUCCESS" : - (res == VIR_DRV_OPEN_DECLINED ? "DECLINED" : - (res == VIR_DRV_OPEN_ERROR ? "ERROR" : "unknown status"))); - - if (res == VIR_DRV_OPEN_SUCCESS) { - ret->nodeDeviceDriver = virNodeDeviceDriverTab[i]; - break; - } else if (res == VIR_DRV_OPEN_ERROR) { - break; - } - } - - /* Secret manipulation driver. Optional */ - for (i = 0; i < virSecretDriverTabCount; i++) { - res = virSecretDriverTab[i]->secretOpen(ret, auth, flags); - VIR_DEBUG("secret driver %zu %s returned %s", - i, virSecretDriverTab[i]->name, - res == VIR_DRV_OPEN_SUCCESS ? "SUCCESS" : - (res == VIR_DRV_OPEN_DECLINED ? "DECLINED" : - (res == VIR_DRV_OPEN_ERROR ? "ERROR" : "unknown status"))); - - if (res == VIR_DRV_OPEN_SUCCESS) { - ret->secretDriver = virSecretDriverTab[i]; - break; - } else if (res == VIR_DRV_OPEN_ERROR) { - break; - } - } - - /* Network filter driver. Optional */ - for (i = 0; i < virNWFilterDriverTabCount; i++) { - res = virNWFilterDriverTab[i]->nwfilterOpen(ret, auth, flags); - VIR_DEBUG("nwfilter driver %zu %s returned %s", - i, virNWFilterDriverTab[i]->name, - res == VIR_DRV_OPEN_SUCCESS ? "SUCCESS" : - (res == VIR_DRV_OPEN_DECLINED ? "DECLINED" : - (res == VIR_DRV_OPEN_ERROR ? "ERROR" : "unknown status"))); - - if (res == VIR_DRV_OPEN_SUCCESS) { - ret->nwfilterDriver = virNWFilterDriverTab[i]; - break; - } else if (res == VIR_DRV_OPEN_ERROR) { - break; - } - } - virConfFree(conf); return ret; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 1b72055748..75a6d83e3d 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -883,14 +883,14 @@ virDomainMigratePrepare3Params; virDomainMigratePrepareTunnel; virDomainMigratePrepareTunnel3; virDomainMigratePrepareTunnel3Params; -virRegisterHypervisorDriver; -virRegisterInterfaceDriver; -virRegisterNetworkDriver; -virRegisterNodeDeviceDriver; -virRegisterNWFilterDriver; -virRegisterSecretDriver; +virRegisterConnectDriver; virRegisterStateDriver; -virRegisterStorageDriver; +virSetSharedInterfaceDriver; +virSetSharedNetworkDriver; +virSetSharedNodeDeviceDriver; +virSetSharedNWFilterDriver; +virSetSharedSecretDriver; +virSetSharedStorageDriver; virStateCleanup; virStateInitialize; virStateReload; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index cd56cbcd7b..c95b3879d2 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -4749,8 +4749,7 @@ libxlDomainMigrateConfirm3Params(virDomainPtr domain, } -static virHypervisorDriver libxlDriver = { - .no = VIR_DRV_LIBXL, +static virHypervisorDriver libxlHypervisorDriver = { .name = LIBXL_DRIVER_NAME, .connectOpen = libxlConnectOpen, /* 0.9.0 */ .connectClose = libxlConnectClose, /* 0.9.0 */ @@ -4846,6 +4845,10 @@ static virHypervisorDriver libxlDriver = { .domainMigrateConfirm3Params = libxlDomainMigrateConfirm3Params, /* 1.2.6 */ }; +static virConnectDriver libxlConnectDriver = { + .hypervisorDriver = &libxlHypervisorDriver, +}; + static virStateDriver libxlStateDriver = { .name = "LIBXL", .stateInitialize = libxlStateInitialize, @@ -4858,7 +4861,8 @@ static virStateDriver libxlStateDriver = { int libxlRegister(void) { - if (virRegisterHypervisorDriver(&libxlDriver) < 0) + if (virRegisterConnectDriver(&libxlConnectDriver, + true) < 0) return -1; if (virRegisterStateDriver(&libxlStateDriver) < 0) return -1; diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index a0bc9719ce..487e2a2518 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -5727,8 +5727,7 @@ lxcNodeAllocPages(virConnectPtr conn, /* Function Tables */ -static virHypervisorDriver lxcDriver = { - .no = VIR_DRV_LXC, +static virHypervisorDriver lxcHypervisorDriver = { .name = LXC_DRIVER_NAME, .connectOpen = lxcConnectOpen, /* 0.4.2 */ .connectClose = lxcConnectClose, /* 0.4.2 */ @@ -5821,6 +5820,10 @@ static virHypervisorDriver lxcDriver = { .nodeAllocPages = lxcNodeAllocPages, /* 1.2.9 */ }; +static virConnectDriver lxcConnectDriver = { + .hypervisorDriver = &lxcHypervisorDriver, +}; + static virStateDriver lxcStateDriver = { .name = LXC_DRIVER_NAME, .stateInitialize = lxcStateInitialize, @@ -5831,7 +5834,8 @@ static virStateDriver lxcStateDriver = { int lxcRegister(void) { - if (virRegisterHypervisorDriver(&lxcDriver) < 0) + if (virRegisterConnectDriver(&lxcConnectDriver, + true) < 0) return -1; if (virRegisterStateDriver(&lxcStateDriver) < 0) return -1; diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 94e32ecad2..c56e8f2a38 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -2514,23 +2514,6 @@ static virNetworkPtr networkLookupByName(virConnectPtr conn, return ret; } -static virDrvOpenStatus networkOpen(virConnectPtr conn ATTRIBUTE_UNUSED, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (!driver) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - -static int networkClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - static int networkConnectNumOfNetworks(virConnectPtr conn) { int nactive = 0; @@ -3670,9 +3653,7 @@ networkGetDHCPLeases(virNetworkPtr network, static virNetworkDriver networkDriver = { - "Network", - .networkOpen = networkOpen, /* 0.2.0 */ - .networkClose = networkClose, /* 0.2.0 */ + .name = "bridge", .connectNumOfNetworks = networkConnectNumOfNetworks, /* 0.2.0 */ .connectListNetworks = networkConnectListNetworks, /* 0.2.0 */ .connectNumOfDefinedNetworks = networkConnectNumOfDefinedNetworks, /* 0.2.0 */ @@ -3698,7 +3679,7 @@ static virNetworkDriver networkDriver = { }; static virStateDriver networkStateDriver = { - .name = "Network", + .name = "bridge", .stateInitialize = networkStateInitialize, .stateAutoStart = networkStateAutoStart, .stateCleanup = networkStateCleanup, @@ -3707,7 +3688,7 @@ static virStateDriver networkStateDriver = { int networkRegister(void) { - if (virRegisterNetworkDriver(&networkDriver) < 0) + if (virSetSharedNetworkDriver(&networkDriver) < 0) return -1; if (virRegisterStateDriver(&networkStateDriver) < 0) return -1; diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index b1f17f4d4b..c1ad3cd7e2 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -616,17 +616,11 @@ nodeDeviceDestroy(virNodeDevicePtr dev) int nodedevRegister(void) { -#if defined(WITH_HAL) && defined(WITH_UDEV) - /* Register only one of these two - they conflict */ - if (udevNodeRegister() == -1) - return halNodeRegister(); - return 0; +#ifdef WITH_UDEV + return udevNodeRegister(); #else # ifdef WITH_HAL return halNodeRegister(); # endif -# ifdef WITH_UDEV - return udevNodeRegister(); -# endif #endif } diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c index 2885bd35d3..fa37787dd6 100644 --- a/src/node_device/node_device_hal.c +++ b/src/node_device/node_device_hal.c @@ -777,30 +777,8 @@ nodeStateReload(void) } -static virDrvOpenStatus -nodeDeviceOpen(virConnectPtr conn ATTRIBUTE_UNUSED, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (driver == NULL) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - -static int -nodeDeviceClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - - static virNodeDeviceDriver halNodeDeviceDriver = { - .name = "halNodeDeviceDriver", - .nodeDeviceOpen = nodeDeviceOpen, /* 0.5.0 */ - .nodeDeviceClose = nodeDeviceClose, /* 0.5.0 */ + .name = "HAL", .nodeNumOfDevices = nodeNumOfDevices, /* 0.5.0 */ .nodeListDevices = nodeListDevices, /* 0.5.0 */ .connectListAllNodeDevices = nodeConnectListAllNodeDevices, /* 0.10.2 */ @@ -825,7 +803,7 @@ static virStateDriver halStateDriver = { int halNodeRegister(void) { - if (virRegisterNodeDeviceDriver(&halNodeDeviceDriver) < 0) + if (virSetSharedNodeDeviceDriver(&halNodeDeviceDriver) < 0) return -1; return virRegisterStateDriver(&halStateDriver); } diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 115a92bf9a..03c7a0b7b1 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1821,27 +1821,8 @@ static int nodeStateReload(void) } -static virDrvOpenStatus nodeDeviceOpen(virConnectPtr conn ATTRIBUTE_UNUSED, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (driver == NULL) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - -static int nodeDeviceClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - static virNodeDeviceDriver udevNodeDeviceDriver = { - .name = "udevNodeDeviceDriver", - .nodeDeviceOpen = nodeDeviceOpen, /* 0.7.3 */ - .nodeDeviceClose = nodeDeviceClose, /* 0.7.3 */ + .name = "udev", .nodeNumOfDevices = nodeNumOfDevices, /* 0.7.3 */ .nodeListDevices = nodeListDevices, /* 0.7.3 */ .connectListAllNodeDevices = nodeConnectListAllNodeDevices, /* 0.10.2 */ @@ -1866,7 +1847,7 @@ int udevNodeRegister(void) { VIR_DEBUG("Registering udev node device backend"); - if (virRegisterNodeDeviceDriver(&udevNodeDeviceDriver) < 0) + if (virSetSharedNodeDeviceDriver(&udevNodeDeviceDriver) < 0) return -1; return virRegisterStateDriver(&udevStateDriver); diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index 225ae14d9d..8e3db43959 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -413,27 +413,6 @@ nwfilterLookupByName(virConnectPtr conn, } -static virDrvOpenStatus -nwfilterOpen(virConnectPtr conn ATTRIBUTE_UNUSED, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (!driver) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - - -static int -nwfilterClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - - static int nwfilterConnectNumOfNWFilters(virConnectPtr conn) { @@ -686,8 +665,6 @@ nwfilterTeardownFilter(virDomainNetDefPtr net) static virNWFilterDriver nwfilterDriver = { .name = "nwfilter", - .nwfilterOpen = nwfilterOpen, /* 0.8.0 */ - .nwfilterClose = nwfilterClose, /* 0.8.0 */ .connectNumOfNWFilters = nwfilterConnectNumOfNWFilters, /* 0.8.0 */ .connectListNWFilters = nwfilterConnectListNWFilters, /* 0.8.0 */ .connectListAllNWFilters = nwfilterConnectListAllNWFilters, /* 0.10.2 */ @@ -715,7 +692,7 @@ static virDomainConfNWFilterDriver domainNWFilterDriver = { int nwfilterRegister(void) { - if (virRegisterNWFilterDriver(&nwfilterDriver) < 0) + if (virSetSharedNWFilterDriver(&nwfilterDriver) < 0) return -1; if (virRegisterStateDriver(&stateDriver) < 0) return -1; diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index bdab1c34c9..556f6267b2 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -2568,8 +2568,7 @@ openvzDomainMigrateConfirm3Params(virDomainPtr domain, } -static virHypervisorDriver openvzDriver = { - .no = VIR_DRV_OPENVZ, +static virHypervisorDriver openvzHypervisorDriver = { .name = "OPENVZ", .connectOpen = openvzConnectOpen, /* 0.3.1 */ .connectClose = openvzConnectClose, /* 0.3.1 */ @@ -2635,9 +2634,12 @@ static virHypervisorDriver openvzDriver = { .domainMigrateConfirm3Params = openvzDomainMigrateConfirm3Params, /* 1.2.8 */ }; +static virConnectDriver openvzConnectDriver = { + .hypervisorDriver = &openvzHypervisorDriver, +}; + int openvzRegister(void) { - if (virRegisterHypervisorDriver(&openvzDriver) < 0) - return -1; - return 0; + return virRegisterConnectDriver(&openvzConnectDriver, + false); } diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index 5531d6df0d..b569160dbf 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -262,7 +262,9 @@ parallelsConnectOpen(virConnectPtr conn, return VIR_DRV_OPEN_ERROR; } - if ((ret = parallelsOpenDefault(conn)) != VIR_DRV_OPEN_SUCCESS) + if ((ret = parallelsOpenDefault(conn)) != VIR_DRV_OPEN_SUCCESS || + (ret = parallelsStorageOpen(conn, flags)) != VIR_DRV_OPEN_SUCCESS || + (ret = parallelsNetworkOpen(conn, flags)) != VIR_DRV_OPEN_SUCCESS) return ret; return VIR_DRV_OPEN_SUCCESS; @@ -273,6 +275,9 @@ parallelsConnectClose(virConnectPtr conn) { parallelsConnPtr privconn = conn->privateData; + parallelsNetworkClose(conn); + parallelsStorageClose(conn); + parallelsDriverLock(privconn); prlsdkUnsubscribeFromPCSEvents(privconn); virObjectUnref(privconn->caps); @@ -952,7 +957,6 @@ parallelsDomainUndefine(virDomainPtr domain) } static virHypervisorDriver parallelsDriver = { - .no = VIR_DRV_PARALLELS, .name = "Parallels", .connectOpen = parallelsConnectOpen, /* 0.10.0 */ .connectClose = parallelsConnectClose, /* 0.10.0 */ @@ -995,6 +999,12 @@ static virHypervisorDriver parallelsDriver = { .connectIsAlive = parallelsConnectIsAlive, /* 1.2.5 */ }; +static virConnectDriver parallelsConnectDriver = { + .hypervisorDriver = ¶llelsDriver, + .storageDriver = ¶llelsStorageDriver, + .networkDriver = ¶llelsNetworkDriver, +}; + /** * parallelsRegister: * @@ -1013,11 +1023,7 @@ parallelsRegister(void) VIR_FREE(prlctl_path); - if (virRegisterHypervisorDriver(¶llelsDriver) < 0) - return -1; - if (parallelsStorageRegister()) - return -1; - if (parallelsNetworkRegister()) + if (virRegisterConnectDriver(¶llelsConnectDriver, false) < 0) return -1; return 0; diff --git a/src/parallels/parallels_network.c b/src/parallels/parallels_network.c index 90217df774..3e7087dbbf 100644 --- a/src/parallels/parallels_network.c +++ b/src/parallels/parallels_network.c @@ -318,9 +318,8 @@ static int parallelsLoadNetworks(parallelsConnPtr privconn) return ret; } -static virDrvOpenStatus +virDrvOpenStatus parallelsNetworkOpen(virConnectPtr conn, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, unsigned int flags) { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); @@ -334,7 +333,7 @@ parallelsNetworkOpen(virConnectPtr conn, return VIR_DRV_OPEN_SUCCESS; } -static int parallelsNetworkClose(virConnectPtr conn) +int parallelsNetworkClose(virConnectPtr conn) { parallelsConnPtr privconn = conn->privateData; parallelsDriverLock(privconn); @@ -597,10 +596,9 @@ static int parallelsNetworkGetAutostart(virNetworkPtr net, virNetworkObjUnlock(network); return ret; } -static virNetworkDriver parallelsNetworkDriver = { - "Parallels", - .networkOpen = parallelsNetworkOpen, /* 1.0.1 */ - .networkClose = parallelsNetworkClose, /* 1.0.1 */ + +virNetworkDriver parallelsNetworkDriver = { + .name = "Parallels", .connectNumOfNetworks = parallelsConnectNumOfNetworks, /* 1.0.1 */ .connectListNetworks = parallelsConnectListNetworks, /* 1.0.1 */ .connectNumOfDefinedNetworks = parallelsConnectNumOfDefinedNetworks, /* 1.0.1 */ @@ -613,12 +611,3 @@ static virNetworkDriver parallelsNetworkDriver = { .networkIsActive = parallelsNetworkIsActive, /* 1.0.1 */ .networkIsPersistent = parallelsNetworkIsPersistent, /* 1.0.1 */ }; - -int -parallelsNetworkRegister(void) -{ - if (virRegisterNetworkDriver(¶llelsNetworkDriver) < 0) - return -1; - - return 0; -} diff --git a/src/parallels/parallels_storage.c b/src/parallels/parallels_storage.c index e916e0f741..d2c5bf20ee 100644 --- a/src/parallels/parallels_storage.c +++ b/src/parallels/parallels_storage.c @@ -67,7 +67,7 @@ parallelsStorageUnlock(virStorageDriverStatePtr driver) virMutexUnlock(&driver->lock); } -static int +int parallelsStorageClose(virConnectPtr conn) { parallelsConnPtr privconn = conn->privateData; @@ -456,9 +456,8 @@ static int parallelsLoadPools(virConnectPtr conn) return -1; } -static virDrvOpenStatus +virDrvOpenStatus parallelsStorageOpen(virConnectPtr conn, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, unsigned int flags) { parallelsConnPtr privconn = conn->privateData; @@ -1612,10 +1611,8 @@ parallelsStorageVolGetPath(virStorageVolPtr vol) return ret; } -static virStorageDriver parallelsStorageDriver = { +virStorageDriver parallelsStorageDriver = { .name = "Parallels", - .storageOpen = parallelsStorageOpen, /* 0.10.0 */ - .storageClose = parallelsStorageClose, /* 0.10.0 */ .connectNumOfStoragePools = parallelsConnectNumOfStoragePools, /* 0.10.0 */ .connectListStoragePools = parallelsConnectListStoragePools, /* 0.10.0 */ @@ -1648,12 +1645,3 @@ static virStorageDriver parallelsStorageDriver = { .storagePoolIsActive = parallelsStoragePoolIsActive, /* 0.10.0 */ .storagePoolIsPersistent = parallelsStoragePoolIsPersistent, /* 0.10.0 */ }; - -int -parallelsStorageRegister(void) -{ - if (virRegisterStorageDriver(¶llelsStorageDriver) < 0) - return -1; - - return 0; -} diff --git a/src/parallels/parallels_utils.h b/src/parallels/parallels_utils.h index b5aa209e1c..bebf8417fb 100644 --- a/src/parallels/parallels_utils.h +++ b/src/parallels/parallels_utils.h @@ -75,8 +75,13 @@ struct parallelsDomObj { typedef struct parallelsDomObj *parallelsDomObjPtr; -int parallelsStorageRegister(void); -int parallelsNetworkRegister(void); +virDrvOpenStatus parallelsStorageOpen(virConnectPtr conn, unsigned int flags); +int parallelsStorageClose(virConnectPtr conn); +extern virStorageDriver parallelsStorageDriver; + +virDrvOpenStatus parallelsNetworkOpen(virConnectPtr conn, unsigned int flags); +int parallelsNetworkClose(virConnectPtr conn); +extern virNetworkDriver parallelsNetworkDriver; virJSONValuePtr parallelsParseOutput(const char *binary, ...) ATTRIBUTE_NONNULL(1) ATTRIBUTE_SENTINEL; diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 17859b000b..6c5a91e304 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -3669,46 +3669,7 @@ phypDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) return phypDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_VCPU_LIVE); } -static virDrvOpenStatus -phypStorageOpen(virConnectPtr conn, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (conn->driver->no != VIR_DRV_PHYP) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - -static int -phypStorageClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - -static virDrvOpenStatus -phypInterfaceOpen(virConnectPtr conn, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (conn->driver->no != VIR_DRV_PHYP) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - -static int -phypInterfaceClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - -static virHypervisorDriver phypDriver = { - .no = VIR_DRV_PHYP, +static virHypervisorDriver phypHypervisorDriver = { .name = "PHYP", .connectOpen = phypConnectOpen, /* 0.7.0 */ .connectClose = phypConnectClose, /* 0.7.0 */ @@ -3740,10 +3701,6 @@ static virHypervisorDriver phypDriver = { }; static virStorageDriver phypStorageDriver = { - .name = "PHYP", - .storageOpen = phypStorageOpen, /* 0.8.2 */ - .storageClose = phypStorageClose, /* 0.8.2 */ - .connectNumOfStoragePools = phypConnectNumOfStoragePools, /* 0.8.2 */ .connectListStoragePools = phypConnectListStoragePools, /* 0.8.2 */ .storagePoolLookupByName = phypStoragePoolLookupByName, /* 0.8.2 */ @@ -3762,9 +3719,6 @@ static virStorageDriver phypStorageDriver = { }; static virInterfaceDriver phypInterfaceDriver = { - .name = "PHYP", - .interfaceOpen = phypInterfaceOpen, /* 0.9.1 */ - .interfaceClose = phypInterfaceClose, /* 0.9.1 */ .connectNumOfInterfaces = phypConnectNumOfInterfaces, /* 0.9.1 */ .connectListInterfaces = phypConnectListInterfaces, /* 0.9.1 */ .interfaceLookupByName = phypInterfaceLookupByName, /* 0.9.1 */ @@ -3773,15 +3727,15 @@ static virInterfaceDriver phypInterfaceDriver = { .interfaceIsActive = phypInterfaceIsActive /* 0.9.1 */ }; +static virConnectDriver phypConnectDriver = { + .hypervisorDriver = &phypHypervisorDriver, + .interfaceDriver = &phypInterfaceDriver, + .storageDriver = &phypStorageDriver, +}; + int phypRegister(void) { - if (virRegisterHypervisorDriver(&phypDriver) < 0) - return -1; - if (virRegisterStorageDriver(&phypStorageDriver) < 0) - return -1; - if (virRegisterInterfaceDriver(&phypInterfaceDriver) < 0) - return -1; - - return 0; + return virRegisterConnectDriver(&phypConnectDriver, + false); } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 901f3f0a48..ee5e4f5c8e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18934,8 +18934,7 @@ qemuDomainGetFSInfo(virDomainPtr dom, } -static virHypervisorDriver qemuDriver = { - .no = VIR_DRV_QEMU, +static virHypervisorDriver qemuHypervisorDriver = { .name = QEMU_DRIVER_NAME, .connectOpen = qemuConnectOpen, /* 0.2.0 */ .connectClose = qemuConnectClose, /* 0.2.0 */ @@ -19139,6 +19138,10 @@ static virHypervisorDriver qemuDriver = { }; +static virConnectDriver qemuConnectDriver = { + .hypervisorDriver = &qemuHypervisorDriver, +}; + static virStateDriver qemuStateDriver = { .name = QEMU_DRIVER_NAME, .stateInitialize = qemuStateInitialize, @@ -19150,7 +19153,8 @@ static virStateDriver qemuStateDriver = { int qemuRegister(void) { - if (virRegisterHypervisorDriver(&qemuDriver) < 0) + if (virRegisterConnectDriver(&qemuConnectDriver, + true) < 0) return -1; if (virRegisterStateDriver(&qemuStateDriver) < 0) return -1; diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 0ad05313fd..d4fd658089 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -3527,69 +3527,6 @@ remoteConnectListAllSecrets(virConnectPtr conn, /*----------------------------------------------------------------------*/ -static virDrvOpenStatus ATTRIBUTE_NONNULL(1) -remoteGenericOpen(virConnectPtr conn) -{ - if (inside_daemon) - return VIR_DRV_OPEN_DECLINED; - - if (conn->driver && - STREQ(conn->driver->name, "remote")) { - return VIR_DRV_OPEN_SUCCESS; - } - - return VIR_DRV_OPEN_DECLINED; -} - -static virDrvOpenStatus ATTRIBUTE_NONNULL(1) -remoteNetworkOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - return remoteGenericOpen(conn); -} - -static int -remoteNetworkClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - -/*----------------------------------------------------------------------*/ - -static virDrvOpenStatus ATTRIBUTE_NONNULL(1) -remoteInterfaceOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - return remoteGenericOpen(conn); -} - -static int -remoteInterfaceClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - -/*----------------------------------------------------------------------*/ - -static virDrvOpenStatus ATTRIBUTE_NONNULL(1) -remoteStorageOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - return remoteGenericOpen(conn); -} - -static int -remoteStorageClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - static char * remoteConnectFindStoragePoolSources(virConnectPtr conn, const char *type, @@ -3757,21 +3694,6 @@ remoteStoragePoolListAllVolumes(virStoragePoolPtr pool, /*----------------------------------------------------------------------*/ -static virDrvOpenStatus ATTRIBUTE_NONNULL(1) -remoteNodeDeviceOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - return remoteGenericOpen(conn); -} - -static int -remoteNodeDeviceClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - static int remoteNodeDeviceDettach(virNodeDevicePtr dev) { @@ -3870,22 +3792,6 @@ remoteNodeDeviceReset(virNodeDevicePtr dev) return rv; } -/* ------------------------------------------------------------- */ - -static virDrvOpenStatus ATTRIBUTE_NONNULL(1) -remoteNWFilterOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - return remoteGenericOpen(conn); -} - -static int -remoteNWFilterClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} /*----------------------------------------------------------------------*/ @@ -5551,21 +5457,6 @@ remoteDomainBuildQemuMonitorEvent(virNetClientProgramPtr prog ATTRIBUTE_UNUSED, } -static virDrvOpenStatus ATTRIBUTE_NONNULL(1) -remoteSecretOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - return remoteGenericOpen(conn); -} - -static int -remoteSecretClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - static unsigned char * remoteSecretGetValue(virSecretPtr secret, size_t *value_size, unsigned int flags, unsigned int internalFlags) @@ -8074,7 +7965,6 @@ unsigned long remoteVersion(void) } static virHypervisorDriver hypervisor_driver = { - .no = VIR_DRV_REMOTE, .name = "remote", .connectOpen = remoteConnectOpen, /* 0.3.0 */ .connectClose = remoteConnectClose, /* 0.3.0 */ @@ -8287,9 +8177,6 @@ static virHypervisorDriver hypervisor_driver = { }; static virNetworkDriver network_driver = { - .name = "remote", - .networkOpen = remoteNetworkOpen, /* 0.3.0 */ - .networkClose = remoteNetworkClose, /* 0.3.0 */ .connectNumOfNetworks = remoteConnectNumOfNetworks, /* 0.3.0 */ .connectListNetworks = remoteConnectListNetworks, /* 0.3.0 */ .connectNumOfDefinedNetworks = remoteConnectNumOfDefinedNetworks, /* 0.3.0 */ @@ -8315,9 +8202,6 @@ static virNetworkDriver network_driver = { }; static virInterfaceDriver interface_driver = { - .name = "remote", - .interfaceOpen = remoteInterfaceOpen, /* 0.7.2 */ - .interfaceClose = remoteInterfaceClose, /* 0.7.2 */ .connectNumOfInterfaces = remoteConnectNumOfInterfaces, /* 0.7.2 */ .connectListInterfaces = remoteConnectListInterfaces, /* 0.7.2 */ .connectNumOfDefinedInterfaces = remoteConnectNumOfDefinedInterfaces, /* 0.7.2 */ @@ -8337,9 +8221,6 @@ static virInterfaceDriver interface_driver = { }; static virStorageDriver storage_driver = { - .name = "remote", - .storageOpen = remoteStorageOpen, /* 0.4.1 */ - .storageClose = remoteStorageClose, /* 0.4.1 */ .connectNumOfStoragePools = remoteConnectNumOfStoragePools, /* 0.4.1 */ .connectListStoragePools = remoteConnectListStoragePools, /* 0.4.1 */ .connectNumOfDefinedStoragePools = remoteConnectNumOfDefinedStoragePools, /* 0.4.1 */ @@ -8384,9 +8265,6 @@ static virStorageDriver storage_driver = { }; static virSecretDriver secret_driver = { - .name = "remote", - .secretOpen = remoteSecretOpen, /* 0.7.1 */ - .secretClose = remoteSecretClose, /* 0.7.1 */ .connectNumOfSecrets = remoteConnectNumOfSecrets, /* 0.7.1 */ .connectListSecrets = remoteConnectListSecrets, /* 0.7.1 */ .connectListAllSecrets = remoteConnectListAllSecrets, /* 0.10.2 */ @@ -8400,9 +8278,6 @@ static virSecretDriver secret_driver = { }; static virNodeDeviceDriver node_device_driver = { - .name = "remote", - .nodeDeviceOpen = remoteNodeDeviceOpen, /* 0.5.0 */ - .nodeDeviceClose = remoteNodeDeviceClose, /* 0.5.0 */ .nodeNumOfDevices = remoteNodeNumOfDevices, /* 0.5.0 */ .nodeListDevices = remoteNodeListDevices, /* 0.5.0 */ .connectListAllNodeDevices = remoteConnectListAllNodeDevices, /* 0.10.2 */ @@ -8417,9 +8292,6 @@ static virNodeDeviceDriver node_device_driver = { }; static virNWFilterDriver nwfilter_driver = { - .name = "remote", - .nwfilterOpen = remoteNWFilterOpen, /* 0.8.0 */ - .nwfilterClose = remoteNWFilterClose, /* 0.8.0 */ .nwfilterLookupByUUID = remoteNWFilterLookupByUUID, /* 0.8.0 */ .nwfilterLookupByName = remoteNWFilterLookupByName, /* 0.8.0 */ .nwfilterGetXMLDesc = remoteNWFilterGetXMLDesc, /* 0.8.0 */ @@ -8430,6 +8302,15 @@ static virNWFilterDriver nwfilter_driver = { .connectListAllNWFilters = remoteConnectListAllNWFilters, /* 0.10.2 */ }; +static virConnectDriver connect_driver = { + .hypervisorDriver = &hypervisor_driver, + .interfaceDriver = &interface_driver, + .networkDriver = &network_driver, + .nodeDeviceDriver = &node_device_driver, + .nwfilterDriver = &nwfilter_driver, + .secretDriver = &secret_driver, + .storageDriver = &storage_driver, +}; static virStateDriver state_driver = { .name = "Remote", @@ -8446,19 +8327,8 @@ static virStateDriver state_driver = { int remoteRegister(void) { - if (virRegisterHypervisorDriver(&hypervisor_driver) < 0) - return -1; - if (virRegisterNetworkDriver(&network_driver) < 0) - return -1; - if (virRegisterInterfaceDriver(&interface_driver) < 0) - return -1; - if (virRegisterStorageDriver(&storage_driver) < 0) - return -1; - if (virRegisterNodeDeviceDriver(&node_device_driver) < 0) - return -1; - if (virRegisterSecretDriver(&secret_driver) < 0) - return -1; - if (virRegisterNWFilterDriver(&nwfilter_driver) < 0) + if (virRegisterConnectDriver(&connect_driver, + false) < 0) return -1; if (virRegisterStateDriver(&state_driver) < 0) return -1; diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c index 26a23ac03c..fcdff1b1fd 100644 --- a/src/secret/secret_driver.c +++ b/src/secret/secret_driver.c @@ -514,25 +514,6 @@ loadSecrets(virSecretEntryPtr *dest) /* Driver functions */ -static virDrvOpenStatus -secretOpen(virConnectPtr conn ATTRIBUTE_UNUSED, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (driver == NULL) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - -static int -secretClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - static int secretConnectNumOfSecrets(virConnectPtr conn) { @@ -1152,8 +1133,6 @@ secretStateReload(void) static virSecretDriver secretDriver = { .name = "secret", - .secretOpen = secretOpen, /* 0.7.1 */ - .secretClose = secretClose, /* 0.7.1 */ .connectNumOfSecrets = secretConnectNumOfSecrets, /* 0.7.1 */ .connectListSecrets = secretConnectListSecrets, /* 0.7.1 */ .connectListAllSecrets = secretConnectListAllSecrets, /* 0.10.2 */ @@ -1167,7 +1146,7 @@ static virSecretDriver secretDriver = { }; static virStateDriver stateDriver = { - .name = "Secret", + .name = "secret", .stateInitialize = secretStateInitialize, .stateCleanup = secretStateCleanup, .stateReload = secretStateReload, @@ -1176,7 +1155,7 @@ static virStateDriver stateDriver = { int secretRegister(void) { - if (virRegisterSecretDriver(&secretDriver) < 0) + if (virSetSharedSecretDriver(&secretDriver) < 0) return -1; if (virRegisterStateDriver(&stateDriver) < 0) return -1; diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 66dc99495b..3fc09ce96b 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -355,25 +355,6 @@ storagePoolLookupByVolume(virStorageVolPtr vol) return ret; } -static virDrvOpenStatus -storageOpen(virConnectPtr conn ATTRIBUTE_UNUSED, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (!driver) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - -static int -storageClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - static int storageConnectNumOfStoragePools(virConnectPtr conn) { @@ -2389,8 +2370,6 @@ storageConnectListAllStoragePools(virConnectPtr conn, static virStorageDriver storageDriver = { .name = "storage", - .storageOpen = storageOpen, /* 0.4.0 */ - .storageClose = storageClose, /* 0.4.0 */ .connectNumOfStoragePools = storageConnectNumOfStoragePools, /* 0.4.0 */ .connectListStoragePools = storageConnectListStoragePools, /* 0.4.0 */ .connectNumOfDefinedStoragePools = storageConnectNumOfDefinedStoragePools, /* 0.4.0 */ @@ -2437,7 +2416,7 @@ static virStorageDriver storageDriver = { static virStateDriver stateDriver = { - .name = "Storage", + .name = "storage", .stateInitialize = storageStateInitialize, .stateAutoStart = storageStateAutoStart, .stateCleanup = storageStateCleanup, @@ -2446,7 +2425,7 @@ static virStateDriver stateDriver = { int storageRegister(void) { - if (virRegisterStorageDriver(&storageDriver) < 0) + if (virSetSharedStorageDriver(&storageDriver) < 0) return -1; if (virRegisterStateDriver(&stateDriver) < 0) return -1; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 777ef3a6bc..a386270655 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -3485,23 +3485,6 @@ static int testDomainInterfaceStats(virDomainPtr domain, return ret; } -static virDrvOpenStatus testNetworkOpen(virConnectPtr conn, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (STRNEQ(conn->driver->name, "Test")) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - -static int testNetworkClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - static virNetworkPtr testNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid) @@ -4043,23 +4026,6 @@ static int testNetworkSetAutostart(virNetworkPtr network, * Physical host interface routines */ -static virDrvOpenStatus testInterfaceOpen(virConnectPtr conn, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (STRNEQ(conn->driver->name, "Test")) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - -static int testInterfaceClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - static int testConnectNumOfInterfaces(virConnectPtr conn) { @@ -4478,23 +4444,6 @@ static int testStoragePoolObjSetDefaults(virStoragePoolObjPtr pool) return VIR_STRDUP(pool->configFile, ""); } -static virDrvOpenStatus testStorageOpen(virConnectPtr conn, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (STRNEQ(conn->driver->name, "Test")) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - -static int testStorageClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - static virStoragePoolPtr testStoragePoolLookupByUUID(virConnectPtr conn, @@ -5816,22 +5765,6 @@ testStorageVolGetPath(virStorageVolPtr vol) /* Node device implementations */ -static virDrvOpenStatus testNodeDeviceOpen(virConnectPtr conn, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (STRNEQ(conn->driver->name, "Test")) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - -static int testNodeDeviceClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} static int testNodeNumOfDevices(virConnectPtr conn, @@ -6281,41 +6214,6 @@ static void testObjectEventQueue(testConnPtr driver, virObjectEventStateQueue(driver->eventState, event); } -static virDrvOpenStatus testSecretOpen(virConnectPtr conn, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (STRNEQ(conn->driver->name, "Test")) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - -static int testSecretClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - - -static virDrvOpenStatus testNWFilterOpen(virConnectPtr conn, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (STRNEQ(conn->driver->name, "Test")) - return VIR_DRV_OPEN_DECLINED; - - return VIR_DRV_OPEN_SUCCESS; -} - -static int testNWFilterClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - static int testConnectListAllDomains(virConnectPtr conn, virDomainPtr **domains, @@ -7344,8 +7242,7 @@ testDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, -static virHypervisorDriver testDriver = { - .no = VIR_DRV_TEST, +static virHypervisorDriver testHypervisorDriver = { .name = "Test", .connectOpen = testConnectOpen, /* 0.1.1 */ .connectClose = testConnectClose, /* 0.1.1 */ @@ -7444,9 +7341,6 @@ static virHypervisorDriver testDriver = { }; static virNetworkDriver testNetworkDriver = { - "Test", - .networkOpen = testNetworkOpen, /* 0.3.2 */ - .networkClose = testNetworkClose, /* 0.3.2 */ .connectNumOfNetworks = testConnectNumOfNetworks, /* 0.3.2 */ .connectListNetworks = testConnectListNetworks, /* 0.3.2 */ .connectNumOfDefinedNetworks = testConnectNumOfDefinedNetworks, /* 0.3.2 */ @@ -7471,9 +7365,6 @@ static virNetworkDriver testNetworkDriver = { }; static virInterfaceDriver testInterfaceDriver = { - "Test", /* name */ - .interfaceOpen = testInterfaceOpen, /* 0.7.0 */ - .interfaceClose = testInterfaceClose, /* 0.7.0 */ .connectNumOfInterfaces = testConnectNumOfInterfaces, /* 0.7.0 */ .connectListInterfaces = testConnectListInterfaces, /* 0.7.0 */ .connectNumOfDefinedInterfaces = testConnectNumOfDefinedInterfaces, /* 0.7.0 */ @@ -7493,10 +7384,6 @@ static virInterfaceDriver testInterfaceDriver = { static virStorageDriver testStorageDriver = { - .name = "Test", - .storageOpen = testStorageOpen, /* 0.4.1 */ - .storageClose = testStorageClose, /* 0.4.1 */ - .connectNumOfStoragePools = testConnectNumOfStoragePools, /* 0.5.0 */ .connectListStoragePools = testConnectListStoragePools, /* 0.5.0 */ .connectNumOfDefinedStoragePools = testConnectNumOfDefinedStoragePools, /* 0.5.0 */ @@ -7536,10 +7423,6 @@ static virStorageDriver testStorageDriver = { }; static virNodeDeviceDriver testNodeDeviceDriver = { - .name = "Test", - .nodeDeviceOpen = testNodeDeviceOpen, /* 0.6.0 */ - .nodeDeviceClose = testNodeDeviceClose, /* 0.6.0 */ - .nodeNumOfDevices = testNodeNumOfDevices, /* 0.7.2 */ .nodeListDevices = testNodeListDevices, /* 0.7.2 */ .nodeDeviceLookupByName = testNodeDeviceLookupByName, /* 0.7.2 */ @@ -7551,17 +7434,14 @@ static virNodeDeviceDriver testNodeDeviceDriver = { .nodeDeviceDestroy = testNodeDeviceDestroy, /* 0.7.3 */ }; -static virSecretDriver testSecretDriver = { - .name = "Test", - .secretOpen = testSecretOpen, /* 0.7.1 */ - .secretClose = testSecretClose, /* 0.7.1 */ -}; - - -static virNWFilterDriver testNWFilterDriver = { - .name = "Test", - .nwfilterOpen = testNWFilterOpen, /* 0.8.0 */ - .nwfilterClose = testNWFilterClose, /* 0.8.0 */ +static virConnectDriver testConnectDriver = { + .hypervisorDriver = &testHypervisorDriver, + .interfaceDriver = &testInterfaceDriver, + .networkDriver = &testNetworkDriver, + .nodeDeviceDriver = &testNodeDeviceDriver, + .nwfilterDriver = NULL, + .secretDriver = NULL, + .storageDriver = &testStorageDriver, }; /** @@ -7572,20 +7452,6 @@ static virNWFilterDriver testNWFilterDriver = { int testRegister(void) { - if (virRegisterHypervisorDriver(&testDriver) < 0) - return -1; - if (virRegisterNetworkDriver(&testNetworkDriver) < 0) - return -1; - if (virRegisterInterfaceDriver(&testInterfaceDriver) < 0) - return -1; - if (virRegisterStorageDriver(&testStorageDriver) < 0) - return -1; - if (virRegisterNodeDeviceDriver(&testNodeDeviceDriver) < 0) - return -1; - if (virRegisterSecretDriver(&testSecretDriver) < 0) - return -1; - if (virRegisterNWFilterDriver(&testNWFilterDriver) < 0) - return -1; - - return 0; + return virRegisterConnectDriver(&testConnectDriver, + false); } diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index d5bc8abb74..6ca038ae1f 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -2943,8 +2943,7 @@ umlNodeAllocPages(virConnectPtr conn, } -static virHypervisorDriver umlDriver = { - .no = VIR_DRV_UML, +static virHypervisorDriver umlHypervisorDriver = { .name = "UML", .connectOpen = umlConnectOpen, /* 0.5.0 */ .connectClose = umlConnectClose, /* 0.5.0 */ @@ -3009,6 +3008,10 @@ static virHypervisorDriver umlDriver = { .nodeAllocPages = umlNodeAllocPages, /* 1.2.9 */ }; +static virConnectDriver umlConnectDriver = { + .hypervisorDriver = ¨HypervisorDriver, +}; + static virStateDriver umlStateDriver = { .name = "UML", .stateInitialize = umlStateInitialize, @@ -3019,7 +3022,8 @@ static virStateDriver umlStateDriver = { int umlRegister(void) { - if (virRegisterHypervisorDriver(¨Driver) < 0) + if (virRegisterConnectDriver(¨ConnectDriver, + true) < 0) return -1; if (virRegisterStateDriver(¨StateDriver) < 0) return -1; diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index e020f8347d..bd3f50ce92 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -7594,7 +7594,6 @@ vboxNodeAllocPages(virConnectPtr conn ATTRIBUTE_UNUSED, */ virHypervisorDriver vboxCommonDriver = { - .no = VIR_DRV_VBOX, .name = "VBOX", .connectOpen = vboxConnectOpen, /* 0.6.3 */ .connectClose = vboxConnectClose, /* 0.6.3 */ diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c index b2e35e9544..d363fef590 100644 --- a/src/vbox/vbox_driver.c +++ b/src/vbox/vbox_driver.c @@ -50,36 +50,6 @@ VIR_LOG_INIT("vbox.vbox_driver"); #define VIR_FROM_THIS VIR_FROM_VBOX -#if !defined(WITH_DRIVER_MODULES) || defined(VBOX_NETWORK_DRIVER) -int vboxNetworkRegister(void) -{ - virNetworkDriverPtr networkDriver = NULL; - uint32_t uVersion; - - if (VBoxCGlueInit(&uVersion) == 0) - networkDriver = vboxGetNetworkDriver(uVersion); - - if (networkDriver && virRegisterNetworkDriver(networkDriver) < 0) - return -1; - return 0; -} -#endif - -#if !defined(WITH_DRIVER_MODULES) || defined(VBOX_STORAGE_DRIVER) -int vboxStorageRegister(void) -{ - virStorageDriverPtr storageDriver = NULL; - uint32_t uVersion; - - if (VBoxCGlueInit(&uVersion) == 0) - storageDriver = vboxGetStorageDriver(uVersion); - - if (storageDriver && virRegisterStorageDriver(storageDriver) < 0) - return -1; - return 0; -} -#endif - #if !defined(WITH_DRIVER_MODULES) || defined(VBOX_DRIVER) static virDrvOpenStatus dummyConnectOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED, @@ -122,23 +92,28 @@ static virDrvOpenStatus dummyConnectOpen(virConnectPtr conn, } static virHypervisorDriver vboxDriverDummy = { - VIR_DRV_VBOX, "VBOX", .connectOpen = dummyConnectOpen, /* 0.6.3 */ }; +static virConnectDriver vboxConnectDriver; + int vboxRegister(void) { - virHypervisorDriverPtr driver = NULL; uint32_t uVersion; if (VBoxCGlueInit(&uVersion) == 0) - driver = vboxGetHypervisorDriver(uVersion); + vboxConnectDriver.hypervisorDriver = vboxGetHypervisorDriver(uVersion); - if (!driver) - driver = &vboxDriverDummy; + if (vboxConnectDriver.hypervisorDriver) { + vboxConnectDriver.networkDriver = vboxGetNetworkDriver(uVersion); + vboxConnectDriver.storageDriver = vboxGetStorageDriver(uVersion); + } else { + vboxConnectDriver.hypervisorDriver = &vboxDriverDummy; + } - if (virRegisterHypervisorDriver(driver) < 0) + if (virRegisterConnectDriver(&vboxConnectDriver, + false) < 0) return -1; return 0; } diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c index a6079b4561..ee409e3e53 100644 --- a/src/vbox/vbox_network.c +++ b/src/vbox/vbox_network.c @@ -86,35 +86,6 @@ static vboxUniformedAPI gVBoxAPI; * The Network Functions here on */ -static virDrvOpenStatus -vboxNetworkOpen(virConnectPtr conn, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - vboxGlobalData *data = conn->privateData; - - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (STRNEQ(conn->driver->name, "VBOX")) - goto cleanup; - - if (!data->pFuncs || !data->vboxObj || !data->vboxSession) - goto cleanup; - - VIR_DEBUG("network initialized"); - - return VIR_DRV_OPEN_SUCCESS; - - cleanup: - return VIR_DRV_OPEN_DECLINED; -} - -static int vboxNetworkClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - VIR_DEBUG("network uninitialized"); - - return 0; -} static int vboxConnectNumOfNetworks(virConnectPtr conn) { @@ -998,9 +969,6 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr network, unsigned int flags) } virNetworkDriver vboxNetworkDriver = { - "VBOX", - .networkOpen = vboxNetworkOpen, /* 0.6.4 */ - .networkClose = vboxNetworkClose, /* 0.6.4 */ .connectNumOfNetworks = vboxConnectNumOfNetworks, /* 0.6.4 */ .connectListNetworks = vboxConnectListNetworks, /* 0.6.4 */ .connectNumOfDefinedNetworks = vboxConnectNumOfDefinedNetworks, /* 0.6.4 */ diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c index 3af5f940f5..599f9175a3 100644 --- a/src/vbox/vbox_storage.c +++ b/src/vbox/vbox_storage.c @@ -42,33 +42,6 @@ static vboxUniformedAPI gVBoxAPI; * The Storage Functions here on */ -static virDrvOpenStatus -vboxStorageOpen(virConnectPtr conn, - virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags) -{ - vboxGlobalData *data = conn->privateData; - - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - - if (STRNEQ(conn->driver->name, "VBOX")) - return VIR_DRV_OPEN_DECLINED; - - if ((!data->pFuncs) || (!data->vboxObj) || (!data->vboxSession)) - return VIR_DRV_OPEN_ERROR; - - VIR_DEBUG("vbox storage initialized"); - - return VIR_DRV_OPEN_SUCCESS; -} - -static int vboxStorageClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - VIR_DEBUG("vbox storage uninitialized"); - - return 0; -} - static int vboxConnectNumOfStoragePools(virConnectPtr conn ATTRIBUTE_UNUSED) { @@ -894,9 +867,6 @@ static char *vboxStorageVolGetPath(virStorageVolPtr vol) */ virStorageDriver vboxStorageDriver = { - .name = "VBOX", - .storageOpen = vboxStorageOpen, /* 0.7.1 */ - .storageClose = vboxStorageClose, /* 0.7.1 */ .connectNumOfStoragePools = vboxConnectNumOfStoragePools, /* 0.7.1 */ .connectListStoragePools = vboxConnectListStoragePools, /* 0.7.1 */ .storagePoolLookupByName = vboxStoragePoolLookupByName, /* 0.7.1 */ diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index d04599355a..2d7ba045fe 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -1197,8 +1197,7 @@ vmwareConnectListAllDomains(virConnectPtr conn, -static virHypervisorDriver vmwareDriver = { - .no = VIR_DRV_VMWARE, +static virHypervisorDriver vmwareHypervisorDriver = { .name = "VMWARE", .connectOpen = vmwareConnectOpen, /* 0.8.7 */ .connectClose = vmwareConnectClose, /* 0.8.7 */ @@ -1236,10 +1235,13 @@ static virHypervisorDriver vmwareDriver = { .connectIsAlive = vmwareConnectIsAlive, /* 0.9.8 */ }; +static virConnectDriver vmwareConnectDriver = { + .hypervisorDriver = &vmwareHypervisorDriver, +}; + int vmwareRegister(void) { - if (virRegisterHypervisorDriver(&vmwareDriver) < 0) - return -1; - return 0; + return virRegisterConnectDriver(&vmwareConnectDriver, + false); } diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 65dc24f62d..5e6ef68d69 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -2759,8 +2759,7 @@ xenUnifiedNodeSuspendForDuration(virConnectPtr conn, /*----- Register with libvirt.c, and initialize Xen drivers. -----*/ /* The interface which we export upwards to libvirt.c. */ -static virHypervisorDriver xenUnifiedDriver = { - .no = VIR_DRV_XEN_UNIFIED, +static virHypervisorDriver xenUnifiedHypervisorDriver = { .name = "Xen", .connectOpen = xenUnifiedConnectOpen, /* 0.0.3 */ .connectClose = xenUnifiedConnectClose, /* 0.0.3 */ @@ -2856,6 +2855,11 @@ static virHypervisorDriver xenUnifiedDriver = { .nodeSetMemoryParameters = xenUnifiedNodeSetMemoryParameters, /* 0.10.2 */ }; + +static virConnectDriver xenUnifiedConnectDriver = { + .hypervisorDriver = &xenUnifiedHypervisorDriver, +}; + /** * xenRegister: * @@ -2868,7 +2872,8 @@ xenRegister(void) { if (virRegisterStateDriver(&state_driver) == -1) return -1; - return virRegisterHypervisorDriver(&xenUnifiedDriver); + return virRegisterConnectDriver(&xenUnifiedConnectDriver, + true); } /** diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index cef53eccba..0902f9a2a4 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -1978,8 +1978,7 @@ xenapiConnectIsAlive(virConnectPtr conn) } /* The interface which we export upwards to libvirt.c. */ -static virHypervisorDriver xenapiDriver = { - .no = VIR_DRV_XENAPI, +static virHypervisorDriver xenapiHypervisorDriver = { .name = "XenAPI", .connectOpen = xenapiConnectOpen, /* 0.8.0 */ .connectClose = xenapiConnectClose, /* 0.8.0 */ @@ -2032,6 +2031,11 @@ static virHypervisorDriver xenapiDriver = { .connectIsAlive = xenapiConnectIsAlive, /* 0.9.8 */ }; + +static virConnectDriver xenapiConnectDriver = { + .hypervisorDriver = &xenapiHypervisorDriver, +}; + /** * xenapiRegister: * @@ -2041,7 +2045,8 @@ static virHypervisorDriver xenapiDriver = { int xenapiRegister(void) { - return virRegisterHypervisorDriver(&xenapiDriver); + return virRegisterConnectDriver(&xenapiConnectDriver, + false); } /* diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index d1a95c5692..3d79759da6 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -58,16 +58,7 @@ fakeSecretLookupByUsage(virConnectPtr conn, return virGetSecret(conn, uuid, usageType, usageID); } -static int -fakeSecretClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - static virSecretDriver fakeSecretDriver = { - .name = "fake_secret", - .secretOpen = NULL, - .secretClose = fakeSecretClose, .connectNumOfSecrets = NULL, .connectListSecrets = NULL, .secretLookupByUUID = NULL, @@ -212,12 +203,6 @@ fakeStoragePoolGetXMLDesc(virStoragePoolPtr pool, return xmlbuf; } -static int -fakeStorageClose(virConnectPtr conn ATTRIBUTE_UNUSED) -{ - return 0; -} - static int fakeStoragePoolIsActive(virStoragePoolPtr pool) { @@ -244,8 +229,6 @@ fakeStoragePoolIsActive(virStoragePoolPtr pool) * type is assumed. */ static virStorageDriver fakeStorageDriver = { - .name = "fake_storage", - .storageClose = fakeStorageClose, .storagePoolLookupByName = fakeStoragePoolLookupByName, .storageVolLookupByName = fakeStorageVolLookupByName, .storagePoolGetXMLDesc = fakeStoragePoolGetXMLDesc, diff --git a/tests/virdrivermoduletest.c b/tests/virdrivermoduletest.c index d823ad9737..6fb842e42e 100644 --- a/tests/virdrivermoduletest.c +++ b/tests/virdrivermoduletest.c @@ -30,23 +30,12 @@ VIR_LOG_INIT("tests.drivermoduletest"); -struct testDriverData { - const char *name; - const char *dep1; -}; - - static int testDriverModule(const void *args) { - const struct testDriverData *data = args; + const char *name = args; /* coverity[leaked_storage] */ - if (data->dep1 && - !virDriverLoadModule(data->dep1)) - return -1; - - /* coverity[leaked_storage] */ - if (!virDriverLoadModule(data->name)) + if (!virDriverLoadModule(name)) return -1; return 0; @@ -60,8 +49,7 @@ mymain(void) #define TEST(name, dep1) \ do { \ - const struct testDriverData data = { name, dep1 }; \ - if (virtTestRun("Test driver " # name, testDriverModule, &data) < 0) \ + if (virtTestRun("Test driver " # name, testDriverModule, name) < 0) \ ret = -1; \ } while (0)