mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
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@redhat.com>
This commit is contained in:
parent
74d7c51815
commit
2870419eb9
30
src/driver.c
30
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");
|
||||
}
|
||||
|
@ -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__ */
|
||||
|
@ -1183,6 +1183,15 @@ virStorageVolClass;
|
||||
virStreamClass;
|
||||
|
||||
|
||||
# driver.h
|
||||
virGetConnectInterface;
|
||||
virGetConnectNetwork;
|
||||
virGetConnectNodeDev;
|
||||
virGetConnectNWFilter;
|
||||
virGetConnectSecret;
|
||||
virGetConnectStorage;
|
||||
|
||||
|
||||
# libvirt_internal.h
|
||||
virConnectSupportsFeature;
|
||||
virDomainMigrateBegin3;
|
||||
|
Loading…
x
Reference in New Issue
Block a user