On Mon, Jan 29, 2018 at 11:58:11AM +0100, Peter Krempa wrote:
> Daniel P. Berrangé (10):
> storage: move driver registration back to end of the file
> storage: allow opening with storage:///system and storage:///session
> URIs
> network: move driver registration back to end of the file
> network: allow opening with network:///system and network:///session
> URIs
> nwfilter: allow opening with nwfilter:///system URI
> interface: allow opening with interface:///system and
> interface:///session URIs
> nodedev: allow opening with nodedev:///system and nodedev:///session
> URIs
> secret: allow opening with secret:///system and secret:///session URIs
All of the patches above copy-paste code which has wrong coding style,
so all need to be fixed.
Yes will fix.
> storage: open secret driver connection at time of use
> storage: remove virConnectPtr from all backend functions
And the opening of the helper connection really needs a helper function.
I'm putting in this patch just before those two:
commit 409e665f3b1cb3049c588116713ffd37dd287e29
Author: Daniel P. Berrangé <berrange(a)redhat.com>
Date: Wed Jan 31 18:21:52 2018 +0000
driver: add some helpers for opening secondary driver connections
Various parts of libvirt will want to open connections to secondary
drivers. The right URI to use will depend on the context, so rather than
duplicating that logic in various places, use some helper APIs. This
will also make it easier for us to later pre-open/cache connections to
avoid repeated opening & closing the same connectiong during autostart.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
diff --git a/src/driver.c b/src/driver.c
index 04dd0a4431..a6a7ff925a 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -167,3 +167,33 @@ virDriverLoadModule(const char *name,
/* XXX unload modules, but we can't until we can unregister libvirt drivers */
+
+virConnectPtr virGetConnectInterface(void)
+{
+ return virConnectOpen(geteuid() == 0 ? "interface:///system" :
"interface:///session");
+}
+
+virConnectPtr virGetConnectNetwork(void)
+{
+ return virConnectOpen(geteuid() == 0 ? "network:///system" :
"network:///session");
+}
+
+virConnectPtr virGetConnectNWFilter(void)
+{
+ return virConnectOpen(geteuid() == 0 ? "nwfilter:///system" :
"nwfilter:///session");
+}
+
+virConnectPtr virGetConnectNodeDev(void)
+{
+ return virConnectOpen(geteuid() == 0 ? "nodedev:///system" :
"nodedev:///session");
+}
+
+virConnectPtr virGetConnectSecret(void)
+{
+ return virConnectOpen(geteuid() == 0 ? "secret:///system" :
"secret:///session");
+}
+
+virConnectPtr virGetConnectStorage(void)
+{
+ return virConnectOpen(geteuid() == 0 ? "storage:///system" :
"storage:///session");
+}
diff --git a/src/driver.h b/src/driver.h
index 936c981603..fe0cec0923 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -105,4 +105,11 @@ int virDriverLoadModuleFull(const char *name,
const char *regfunc,
void **handle);
+virConnectPtr virGetConnectInterface(void);
+virConnectPtr virGetConnectNetwork(void);
+virConnectPtr virGetConnectNWFilter(void);
+virConnectPtr virGetConnectNodeDev(void);
+virConnectPtr virGetConnectSecret(void);
+virConnectPtr virGetConnectStorage(void);
+
#endif /* __VIR_DRIVER_H__ */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 43deca9a52..c6e59e889a 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1183,6 +1183,15 @@ virStorageVolClass;
virStreamClass;
+# driver.h
+virGetConnectInterface;
+virGetConnectNetwork;
+virGetConnectNWFilter;
+virGetConnectNodeDev;
+virGetConnectSecret;
+virGetConnectStorage;
+
+
# libvirt_internal.h
virConnectSupportsFeature;
virDomainMigrateBegin3;
Regards,
Daniel
--
|:
https://berrange.com -o-
https://www.flickr.com/photos/dberrange :|
|:
https://libvirt.org -o-
https://fstop138.berrange.com :|
|:
https://entangle-photo.org -o-
https://www.instagram.com/dberrange :|