Allow drivers to be run against a different virtual root directory.
The intent here is to allow the virt drivers to be run directly embedded
in an arbitrary process without interfering with libvirtd.
This can be useful for doing testing of the virt drivers in "make check"
without interfering with the user's own libvirtd instances.
It can also be used for an application like libguestfs which doesn't
want its VMs to show up in the main libvirtd VM list.
XXX make drivers reject root != "" until they are ported to support it.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/driver-state.h | 1 +
src/interface/interface_backend_netcf.c | 1 +
src/interface/interface_backend_udev.c | 1 +
src/libvirt.c | 2 ++
src/libvirt_internal.h | 1 +
src/libxl/libxl_driver.c | 1 +
src/lxc/lxc_driver.c | 2 ++
src/network/bridge_driver.c | 1 +
src/node_device/node_device_hal.c | 1 +
src/node_device/node_device_udev.c | 1 +
src/nwfilter/nwfilter_driver.c | 1 +
src/qemu/qemu_driver.c | 1 +
src/remote/remote_daemon.c | 1 +
src/remote/remote_driver.c | 1 +
src/secret/secret_driver.c | 1 +
src/storage/storage_driver.c | 1 +
src/vz/vz_driver.c | 1 +
17 files changed, 19 insertions(+)
diff --git a/src/driver-state.h b/src/driver-state.h
index a8595662af..68bbf75e06 100644
--- a/src/driver-state.h
+++ b/src/driver-state.h
@@ -27,6 +27,7 @@
typedef int
(*virDrvStateInitialize)(bool privileged,
+ const char *root,
virStateInhibitCallback callback,
void *opaque);
diff --git a/src/interface/interface_backend_netcf.c
b/src/interface/interface_backend_netcf.c
index cf8eb9488d..e9a0fee606 100644
--- a/src/interface/interface_backend_netcf.c
+++ b/src/interface/interface_backend_netcf.c
@@ -76,6 +76,7 @@ virNetcfDriverStateDispose(void *obj)
static int
netcfStateInitialize(bool privileged,
+ const char *root ATTRIBUTE_UNUSED,
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
diff --git a/src/interface/interface_backend_udev.c
b/src/interface/interface_backend_udev.c
index 1373356246..7c315c315a 100644
--- a/src/interface/interface_backend_udev.c
+++ b/src/interface/interface_backend_udev.c
@@ -1159,6 +1159,7 @@ udevInterfaceIsActive(virInterfacePtr ifinfo)
static int
udevStateInitialize(bool privileged,
+ const char *root ATTRIBUTE_UNUSED,
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
diff --git a/src/libvirt.c b/src/libvirt.c
index 7e665b6cba..677f1cef5f 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -638,6 +638,7 @@ virRegisterStateDriver(virStateDriverPtr driver)
*/
int
virStateInitialize(bool privileged,
+ const char *root,
virStateInhibitCallback callback,
void *opaque)
{
@@ -651,6 +652,7 @@ virStateInitialize(bool privileged,
VIR_DEBUG("Running global init for %s state driver",
virStateDriverTab[i]->name);
if (virStateDriverTab[i]->stateInitialize(privileged,
+ root,
callback,
opaque) < 0) {
VIR_ERROR(_("Initialization of %s state driver failed: %s"),
diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h
index 8be1257814..c3964d4c38 100644
--- a/src/libvirt_internal.h
+++ b/src/libvirt_internal.h
@@ -31,6 +31,7 @@ typedef void (*virStateInhibitCallback)(bool inhibit,
void *opaque);
int virStateInitialize(bool privileged,
+ const char *root,
virStateInhibitCallback inhibit,
void *opaque);
int virStateCleanup(void);
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 2b9c6f1866..59e0d7229d 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -633,6 +633,7 @@ libxlAddDom0(libxlDriverPrivatePtr driver)
static int
libxlStateInitialize(bool privileged,
+ const char *root ATTRIBUTE_UNUSED,
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 9db2a02dee..6d0d3a8ace 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -85,6 +85,7 @@ VIR_LOG_INIT("lxc.lxc_driver");
static int lxcStateInitialize(bool privileged,
+ const char *root ATTRIBUTE_UNUSED,
virStateInhibitCallback callback,
void *opaque);
static int lxcStateCleanup(void);
@@ -1536,6 +1537,7 @@ lxcSecurityInit(virLXCDriverConfigPtr cfg)
static int lxcStateInitialize(bool privileged,
+ const char *root ATTRIBUTE_UNUSED,
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 26f7f80418..ca9deaab4b 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -588,6 +588,7 @@ firewalld_dbus_filter_bridge(DBusConnection *connection
ATTRIBUTE_UNUSED,
*/
static int
networkStateInitialize(bool privileged,
+ const char *root ATTRIBUTE_UNUSED,
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c
index d1eb6c7851..7b11d4d7f7 100644
--- a/src/node_device/node_device_hal.c
+++ b/src/node_device/node_device_hal.c
@@ -588,6 +588,7 @@ device_prop_modified(LibHalContext *ctx ATTRIBUTE_UNUSED,
static int
nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED,
+ const char *root ATTRIBUTE_UNUSED,
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 5df2fd72f3..2d772d85c3 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1800,6 +1800,7 @@ udevPCITranslateInit(bool privileged ATTRIBUTE_UNUSED)
static int
nodeStateInitialize(bool privileged,
+ const char *root ATTRIBUTE_UNUSED,
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index fdfc6f48fa..58adcdbeb1 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -176,6 +176,7 @@ virNWFilterTriggerRebuildImpl(void *opaque)
*/
static int
nwfilterStateInitialize(bool privileged,
+ const char *root ATTRIBUTE_UNUSED,
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0a425b82e5..659d7b89e1 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -574,6 +574,7 @@ qemuDomainFindMaxID(virDomainObjPtr vm,
*/
static int
qemuStateInitialize(bool privileged,
+ const char *root ATTRIBUTE_UNUSED,
virStateInhibitCallback callback,
void *opaque)
{
diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c
index c3782971f1..2e47263bb9 100644
--- a/src/remote/remote_daemon.c
+++ b/src/remote/remote_daemon.c
@@ -796,6 +796,7 @@ static void daemonRunStateInit(void *opaque)
* we're ready, since it can take a long time and this will
* seriously delay OS bootup process */
if (virStateInitialize(virNetDaemonIsPrivileged(dmn),
+ "",
daemonInhibitCallback,
dmn) < 0) {
VIR_ERROR(_("Driver state initialization failed"));
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 5c4dd41227..244e384607 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -184,6 +184,7 @@ static int remoteSplitURIScheme(virURIPtr uri,
static int
remoteStateInitialize(bool privileged ATTRIBUTE_UNUSED,
+ const char *root ATTRIBUTE_UNUSED,
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c
index ac85f5d195..1b4826e597 100644
--- a/src/secret/secret_driver.c
+++ b/src/secret/secret_driver.c
@@ -444,6 +444,7 @@ secretStateCleanup(void)
static int
secretStateInitialize(bool privileged,
+ const char *root ATTRIBUTE_UNUSED,
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 496d51b1e0..a13eabf134 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -247,6 +247,7 @@ storageDriverAutostart(void)
*/
static int
storageStateInitialize(bool privileged,
+ const char *root ATTRIBUTE_UNUSED,
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index dfd49e7cc7..92a9cfeaac 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -4096,6 +4096,7 @@ vzStateCleanup(void)
static int
vzStateInitialize(bool privileged ATTRIBUTE_UNUSED,
+ const char *root ATTRIBUTE_UNUSED,
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
--
2.21.0