mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
driver: introduce a driver method for probing default URIs
Currently the virDrvConnectOpen method is supposed to handle both opening an explicit URI and auto-probing a driver if no URI is given. Introduce a dedicated virDrvConnectURIProbe method to enable the probing functionality to be split from the driver opening functionality. It is still possible for NULL to be passed to the virDrvConnectOpen method after this change, because the remote driver needs special handling to enable probing of the URI against a remote libvirtd daemon. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
a2fd657b86
commit
20ad55a8fd
@ -184,7 +184,7 @@ foreach my $drivertable (@drivertable) {
|
|||||||
my $api;
|
my $api;
|
||||||
if (exists $apis{"vir$name"}) {
|
if (exists $apis{"vir$name"}) {
|
||||||
$api = "vir$name";
|
$api = "vir$name";
|
||||||
} elsif ($name =~ /\w+(Open|Close)/) {
|
} elsif ($name =~ /\w+(Open|Close|URIProbe)/) {
|
||||||
next;
|
next;
|
||||||
} else {
|
} else {
|
||||||
die "driver $name does not have a public API";
|
die "driver $name does not have a public API";
|
||||||
@ -241,12 +241,12 @@ foreach my $src (@srcs) {
|
|||||||
|
|
||||||
next if $api eq "no" || $api eq "name";
|
next if $api eq "no" || $api eq "name";
|
||||||
|
|
||||||
die "Method $meth in $src is missing version" unless defined $vers;
|
die "Method $meth in $src is missing version" unless defined $vers || $api eq "connectURIProbe";
|
||||||
|
|
||||||
die "Driver method for $api is NULL in $src" if $meth eq "NULL";
|
die "Driver method for $api is NULL in $src" if $meth eq "NULL";
|
||||||
|
|
||||||
if (!exists($groups{$ingrp}->{apis}->{$api})) {
|
if (!exists($groups{$ingrp}->{apis}->{$api})) {
|
||||||
next if $api =~ /\w(Open|Close)/;
|
next if $api =~ /\w(Open|Close|URIProbe)/;
|
||||||
|
|
||||||
die "Found unexpected method $api in $ingrp\n";
|
die "Found unexpected method $api in $ingrp\n";
|
||||||
}
|
}
|
||||||
|
@ -180,6 +180,17 @@ bhyveDomObjFromDomain(virDomainPtr domain)
|
|||||||
return vm;
|
return vm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
bhyveConnectURIProbe(char **uri)
|
||||||
|
{
|
||||||
|
if (bhyve_driver == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return VIR_STRDUP(*uri, "bhyve:///system");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static virDrvOpenStatus
|
static virDrvOpenStatus
|
||||||
bhyveConnectOpen(virConnectPtr conn,
|
bhyveConnectOpen(virConnectPtr conn,
|
||||||
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
||||||
@ -189,11 +200,7 @@ bhyveConnectOpen(virConnectPtr conn,
|
|||||||
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
||||||
|
|
||||||
if (conn->uri == NULL) {
|
if (conn->uri == NULL) {
|
||||||
if (bhyve_driver == NULL)
|
return VIR_DRV_OPEN_DECLINED;
|
||||||
return VIR_DRV_OPEN_DECLINED;
|
|
||||||
|
|
||||||
if (!(conn->uri = virURIParse("bhyve:///system")))
|
|
||||||
return VIR_DRV_OPEN_ERROR;
|
|
||||||
} else {
|
} else {
|
||||||
if (!conn->uri->scheme || STRNEQ(conn->uri->scheme, "bhyve"))
|
if (!conn->uri->scheme || STRNEQ(conn->uri->scheme, "bhyve"))
|
||||||
return VIR_DRV_OPEN_DECLINED;
|
return VIR_DRV_OPEN_DECLINED;
|
||||||
@ -1673,6 +1680,7 @@ bhyveConnectGetDomainCapabilities(virConnectPtr conn,
|
|||||||
|
|
||||||
static virHypervisorDriver bhyveHypervisorDriver = {
|
static virHypervisorDriver bhyveHypervisorDriver = {
|
||||||
.name = "bhyve",
|
.name = "bhyve",
|
||||||
|
.connectURIProbe = bhyveConnectURIProbe,
|
||||||
.connectOpen = bhyveConnectOpen, /* 1.2.2 */
|
.connectOpen = bhyveConnectOpen, /* 1.2.2 */
|
||||||
.connectClose = bhyveConnectClose, /* 1.2.2 */
|
.connectClose = bhyveConnectClose, /* 1.2.2 */
|
||||||
.connectGetVersion = bhyveConnectGetVersion, /* 1.2.2 */
|
.connectGetVersion = bhyveConnectGetVersion, /* 1.2.2 */
|
||||||
|
@ -59,6 +59,7 @@ my %whitelist = (
|
|||||||
"storageClose" => 1,
|
"storageClose" => 1,
|
||||||
"interfaceOpen" => 1,
|
"interfaceOpen" => 1,
|
||||||
"interfaceClose" => 1,
|
"interfaceClose" => 1,
|
||||||
|
"connectURIProbe" => 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
# Temp hack - remove it once xen driver is fixed
|
# Temp hack - remove it once xen driver is fixed
|
||||||
|
@ -25,6 +25,9 @@
|
|||||||
# error "Don't include this file directly, only use driver.h"
|
# error "Don't include this file directly, only use driver.h"
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
typedef int
|
||||||
|
(*virDrvConnectURIProbe)(char **uri);
|
||||||
|
|
||||||
typedef virDrvOpenStatus
|
typedef virDrvOpenStatus
|
||||||
(*virDrvConnectOpen)(virConnectPtr conn,
|
(*virDrvConnectOpen)(virConnectPtr conn,
|
||||||
virConnectAuthPtr auth,
|
virConnectAuthPtr auth,
|
||||||
@ -1300,6 +1303,7 @@ typedef virHypervisorDriver *virHypervisorDriverPtr;
|
|||||||
*/
|
*/
|
||||||
struct _virHypervisorDriver {
|
struct _virHypervisorDriver {
|
||||||
const char *name; /* the name of the driver */
|
const char *name; /* the name of the driver */
|
||||||
|
virDrvConnectURIProbe connectURIProbe;
|
||||||
virDrvConnectOpen connectOpen;
|
virDrvConnectOpen connectOpen;
|
||||||
virDrvConnectClose connectClose;
|
virDrvConnectClose connectClose;
|
||||||
virDrvConnectSupportsFeature connectSupportsFeature;
|
virDrvConnectSupportsFeature connectSupportsFeature;
|
||||||
|
@ -975,6 +975,19 @@ virConnectOpenInternal(const char *name,
|
|||||||
} else {
|
} else {
|
||||||
if (virConnectGetDefaultURI(conf, &uristr) < 0)
|
if (virConnectGetDefaultURI(conf, &uristr) < 0)
|
||||||
goto failed;
|
goto failed;
|
||||||
|
|
||||||
|
if (uristr == NULL) {
|
||||||
|
VIR_DEBUG("Trying to probe for default URI");
|
||||||
|
for (i = 0; i < virConnectDriverTabCount && uristr == NULL; i++) {
|
||||||
|
if (virConnectDriverTab[i]->hypervisorDriver->connectURIProbe) {
|
||||||
|
if (virConnectDriverTab[i]->hypervisorDriver->connectURIProbe(&uristr) < 0)
|
||||||
|
goto failed;
|
||||||
|
VIR_DEBUG("%s driver URI probe returned '%s'",
|
||||||
|
virConnectDriverTab[i]->hypervisorDriver->name,
|
||||||
|
uristr ? uristr : "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uristr) {
|
if (uristr) {
|
||||||
|
@ -827,6 +827,16 @@ libxlStateReload(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
libxlConnectURIProbe(char **uri)
|
||||||
|
{
|
||||||
|
if (libxl_driver == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return VIR_STRDUP(*uri, "xen:///system");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static virDrvOpenStatus
|
static virDrvOpenStatus
|
||||||
libxlConnectOpen(virConnectPtr conn,
|
libxlConnectOpen(virConnectPtr conn,
|
||||||
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
||||||
@ -836,11 +846,7 @@ libxlConnectOpen(virConnectPtr conn,
|
|||||||
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
||||||
|
|
||||||
if (conn->uri == NULL) {
|
if (conn->uri == NULL) {
|
||||||
if (libxl_driver == NULL)
|
return VIR_DRV_OPEN_DECLINED;
|
||||||
return VIR_DRV_OPEN_DECLINED;
|
|
||||||
|
|
||||||
if (!(conn->uri = virURIParse("xen:///system")))
|
|
||||||
return VIR_DRV_OPEN_ERROR;
|
|
||||||
} else {
|
} else {
|
||||||
/* Only xen scheme */
|
/* Only xen scheme */
|
||||||
if (conn->uri->scheme == NULL || STRNEQ(conn->uri->scheme, "xen"))
|
if (conn->uri->scheme == NULL || STRNEQ(conn->uri->scheme, "xen"))
|
||||||
@ -6466,6 +6472,7 @@ libxlConnectBaselineCPU(virConnectPtr conn,
|
|||||||
|
|
||||||
static virHypervisorDriver libxlHypervisorDriver = {
|
static virHypervisorDriver libxlHypervisorDriver = {
|
||||||
.name = LIBXL_DRIVER_NAME,
|
.name = LIBXL_DRIVER_NAME,
|
||||||
|
.connectURIProbe = libxlConnectURIProbe,
|
||||||
.connectOpen = libxlConnectOpen, /* 0.9.0 */
|
.connectOpen = libxlConnectOpen, /* 0.9.0 */
|
||||||
.connectClose = libxlConnectClose, /* 0.9.0 */
|
.connectClose = libxlConnectClose, /* 0.9.0 */
|
||||||
.connectGetType = libxlConnectGetType, /* 0.9.0 */
|
.connectGetType = libxlConnectGetType, /* 0.9.0 */
|
||||||
|
@ -152,6 +152,16 @@ lxcDomObjFromDomain(virDomainPtr domain)
|
|||||||
|
|
||||||
/* Functions */
|
/* Functions */
|
||||||
|
|
||||||
|
static int
|
||||||
|
lxcConnectURIProbe(char **uri)
|
||||||
|
{
|
||||||
|
if (lxc_driver == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return VIR_STRDUP(*uri, "lxc:///system");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static virDrvOpenStatus lxcConnectOpen(virConnectPtr conn,
|
static virDrvOpenStatus lxcConnectOpen(virConnectPtr conn,
|
||||||
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
||||||
virConfPtr conf ATTRIBUTE_UNUSED,
|
virConfPtr conf ATTRIBUTE_UNUSED,
|
||||||
@ -161,11 +171,7 @@ static virDrvOpenStatus lxcConnectOpen(virConnectPtr conn,
|
|||||||
|
|
||||||
/* Verify uri was specified */
|
/* Verify uri was specified */
|
||||||
if (conn->uri == NULL) {
|
if (conn->uri == NULL) {
|
||||||
if (lxc_driver == NULL)
|
return VIR_DRV_OPEN_DECLINED;
|
||||||
return VIR_DRV_OPEN_DECLINED;
|
|
||||||
|
|
||||||
if (!(conn->uri = virURIParse("lxc:///system")))
|
|
||||||
return VIR_DRV_OPEN_ERROR;
|
|
||||||
} else {
|
} else {
|
||||||
if (conn->uri->scheme == NULL ||
|
if (conn->uri->scheme == NULL ||
|
||||||
STRNEQ(conn->uri->scheme, "lxc"))
|
STRNEQ(conn->uri->scheme, "lxc"))
|
||||||
@ -5537,6 +5543,7 @@ lxcDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags)
|
|||||||
/* Function Tables */
|
/* Function Tables */
|
||||||
static virHypervisorDriver lxcHypervisorDriver = {
|
static virHypervisorDriver lxcHypervisorDriver = {
|
||||||
.name = LXC_DRIVER_NAME,
|
.name = LXC_DRIVER_NAME,
|
||||||
|
.connectURIProbe = lxcConnectURIProbe,
|
||||||
.connectOpen = lxcConnectOpen, /* 0.4.2 */
|
.connectOpen = lxcConnectOpen, /* 0.4.2 */
|
||||||
.connectClose = lxcConnectClose, /* 0.4.2 */
|
.connectClose = lxcConnectClose, /* 0.4.2 */
|
||||||
.connectSupportsFeature = lxcConnectSupportsFeature, /* 1.2.2 */
|
.connectSupportsFeature = lxcConnectSupportsFeature, /* 1.2.2 */
|
||||||
|
@ -1331,6 +1331,20 @@ openvzDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus)
|
|||||||
return openvzDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_AFFECT_LIVE);
|
return openvzDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_AFFECT_LIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
openvzConnectURIProbe(char **uri)
|
||||||
|
{
|
||||||
|
if (!virFileExists("/proc/vz"))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (access("/proc/vz", W_OK) < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return VIR_STRDUP(*uri, "openvz:///system");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static virDrvOpenStatus openvzConnectOpen(virConnectPtr conn,
|
static virDrvOpenStatus openvzConnectOpen(virConnectPtr conn,
|
||||||
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
||||||
virConfPtr conf ATTRIBUTE_UNUSED,
|
virConfPtr conf ATTRIBUTE_UNUSED,
|
||||||
@ -1341,14 +1355,7 @@ static virDrvOpenStatus openvzConnectOpen(virConnectPtr conn,
|
|||||||
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
||||||
|
|
||||||
if (conn->uri == NULL) {
|
if (conn->uri == NULL) {
|
||||||
if (!virFileExists("/proc/vz"))
|
return VIR_DRV_OPEN_DECLINED;
|
||||||
return VIR_DRV_OPEN_DECLINED;
|
|
||||||
|
|
||||||
if (access("/proc/vz", W_OK) < 0)
|
|
||||||
return VIR_DRV_OPEN_DECLINED;
|
|
||||||
|
|
||||||
if (!(conn->uri = virURIParse("openvz:///system")))
|
|
||||||
return VIR_DRV_OPEN_ERROR;
|
|
||||||
} else {
|
} else {
|
||||||
/* If scheme isn't 'openvz', then its for another driver */
|
/* If scheme isn't 'openvz', then its for another driver */
|
||||||
if (conn->uri->scheme == NULL ||
|
if (conn->uri->scheme == NULL ||
|
||||||
@ -2450,6 +2457,7 @@ openvzDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags)
|
|||||||
|
|
||||||
static virHypervisorDriver openvzHypervisorDriver = {
|
static virHypervisorDriver openvzHypervisorDriver = {
|
||||||
.name = "OPENVZ",
|
.name = "OPENVZ",
|
||||||
|
.connectURIProbe = openvzConnectURIProbe,
|
||||||
.connectOpen = openvzConnectOpen, /* 0.3.1 */
|
.connectOpen = openvzConnectOpen, /* 0.3.1 */
|
||||||
.connectClose = openvzConnectClose, /* 0.3.1 */
|
.connectClose = openvzConnectClose, /* 0.3.1 */
|
||||||
.connectGetType = openvzConnectGetType, /* 0.3.1 */
|
.connectGetType = openvzConnectGetType, /* 0.3.1 */
|
||||||
|
@ -1115,6 +1115,25 @@ qemuStateCleanup(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuConnectURIProbe(char **uri)
|
||||||
|
{
|
||||||
|
virQEMUDriverConfigPtr cfg = NULL;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
if (qemu_driver == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
cfg = virQEMUDriverGetConfig(qemu_driver);
|
||||||
|
if (VIR_STRDUP(*uri, cfg->uri) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
cleanup:
|
||||||
|
virObjectUnref(cfg);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static virDrvOpenStatus qemuConnectOpen(virConnectPtr conn,
|
static virDrvOpenStatus qemuConnectOpen(virConnectPtr conn,
|
||||||
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
||||||
virConfPtr conf ATTRIBUTE_UNUSED,
|
virConfPtr conf ATTRIBUTE_UNUSED,
|
||||||
@ -1125,15 +1144,7 @@ static virDrvOpenStatus qemuConnectOpen(virConnectPtr conn,
|
|||||||
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
||||||
|
|
||||||
if (conn->uri == NULL) {
|
if (conn->uri == NULL) {
|
||||||
if (qemu_driver == NULL) {
|
return VIR_DRV_OPEN_DECLINED;
|
||||||
ret = VIR_DRV_OPEN_DECLINED;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg = virQEMUDriverGetConfig(qemu_driver);
|
|
||||||
|
|
||||||
if (!(conn->uri = virURIParse(cfg->uri)))
|
|
||||||
goto cleanup;
|
|
||||||
} else {
|
} else {
|
||||||
/* If URI isn't 'qemu' its definitely not for us */
|
/* If URI isn't 'qemu' its definitely not for us */
|
||||||
if (conn->uri->scheme == NULL ||
|
if (conn->uri->scheme == NULL ||
|
||||||
@ -21336,6 +21347,7 @@ qemuDomainSetLifecycleAction(virDomainPtr dom,
|
|||||||
|
|
||||||
static virHypervisorDriver qemuHypervisorDriver = {
|
static virHypervisorDriver qemuHypervisorDriver = {
|
||||||
.name = QEMU_DRIVER_NAME,
|
.name = QEMU_DRIVER_NAME,
|
||||||
|
.connectURIProbe = qemuConnectURIProbe,
|
||||||
.connectOpen = qemuConnectOpen, /* 0.2.0 */
|
.connectOpen = qemuConnectOpen, /* 0.2.0 */
|
||||||
.connectClose = qemuConnectClose, /* 0.2.0 */
|
.connectClose = qemuConnectClose, /* 0.2.0 */
|
||||||
.connectSupportsFeature = qemuConnectSupportsFeature, /* 0.5.0 */
|
.connectSupportsFeature = qemuConnectSupportsFeature, /* 0.5.0 */
|
||||||
|
@ -1185,6 +1185,17 @@ static void umlShutdownVMDaemon(struct uml_driver *driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int umlConnectURIProbe(char **uri)
|
||||||
|
{
|
||||||
|
if (uml_driver == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return VIR_STRDUP(*uri, uml_driver->privileged ?
|
||||||
|
"uml:///system" :
|
||||||
|
"uml:///session");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static virDrvOpenStatus umlConnectOpen(virConnectPtr conn,
|
static virDrvOpenStatus umlConnectOpen(virConnectPtr conn,
|
||||||
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
||||||
virConfPtr conf ATTRIBUTE_UNUSED,
|
virConfPtr conf ATTRIBUTE_UNUSED,
|
||||||
@ -1193,13 +1204,7 @@ static virDrvOpenStatus umlConnectOpen(virConnectPtr conn,
|
|||||||
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
||||||
|
|
||||||
if (conn->uri == NULL) {
|
if (conn->uri == NULL) {
|
||||||
if (uml_driver == NULL)
|
return VIR_DRV_OPEN_DECLINED;
|
||||||
return VIR_DRV_OPEN_DECLINED;
|
|
||||||
|
|
||||||
if (!(conn->uri = virURIParse(uml_driver->privileged ?
|
|
||||||
"uml:///system" :
|
|
||||||
"uml:///session")))
|
|
||||||
return VIR_DRV_OPEN_ERROR;
|
|
||||||
} else {
|
} else {
|
||||||
if (conn->uri->scheme == NULL ||
|
if (conn->uri->scheme == NULL ||
|
||||||
STRNEQ(conn->uri->scheme, "uml"))
|
STRNEQ(conn->uri->scheme, "uml"))
|
||||||
@ -2947,6 +2952,7 @@ umlDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags)
|
|||||||
|
|
||||||
static virHypervisorDriver umlHypervisorDriver = {
|
static virHypervisorDriver umlHypervisorDriver = {
|
||||||
.name = "UML",
|
.name = "UML",
|
||||||
|
.connectURIProbe = umlConnectURIProbe,
|
||||||
.connectOpen = umlConnectOpen, /* 0.5.0 */
|
.connectOpen = umlConnectOpen, /* 0.5.0 */
|
||||||
.connectClose = umlConnectClose, /* 0.5.0 */
|
.connectClose = umlConnectClose, /* 0.5.0 */
|
||||||
.connectGetType = umlConnectGetType, /* 0.5.0 */
|
.connectGetType = umlConnectGetType, /* 0.5.0 */
|
||||||
|
@ -499,6 +499,13 @@ vboxAttachStorageControllers(virDomainDefPtr def,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
vboxConnectURIProbe(char **uri)
|
||||||
|
{
|
||||||
|
return VIR_STRDUP(*uri, geteuid() ? "vbox:///session" : "vbox:///system");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static virDrvOpenStatus
|
static virDrvOpenStatus
|
||||||
vboxConnectOpen(virConnectPtr conn,
|
vboxConnectOpen(virConnectPtr conn,
|
||||||
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
||||||
@ -510,9 +517,8 @@ vboxConnectOpen(virConnectPtr conn,
|
|||||||
|
|
||||||
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
||||||
|
|
||||||
if (conn->uri == NULL &&
|
if (conn->uri == NULL)
|
||||||
!(conn->uri = virURIParse(uid ? "vbox:///session" : "vbox:///system")))
|
return VIR_DRV_OPEN_DECLINED;
|
||||||
return VIR_DRV_OPEN_ERROR;
|
|
||||||
|
|
||||||
if (conn->uri->scheme == NULL ||
|
if (conn->uri->scheme == NULL ||
|
||||||
STRNEQ(conn->uri->scheme, "vbox"))
|
STRNEQ(conn->uri->scheme, "vbox"))
|
||||||
@ -7980,6 +7986,7 @@ vboxDomainSendKey(virDomainPtr dom,
|
|||||||
|
|
||||||
static virHypervisorDriver vboxCommonDriver = {
|
static virHypervisorDriver vboxCommonDriver = {
|
||||||
.name = "VBOX",
|
.name = "VBOX",
|
||||||
|
.connectURIProbe = vboxConnectURIProbe,
|
||||||
.connectOpen = vboxConnectOpen, /* 0.6.3 */
|
.connectOpen = vboxConnectOpen, /* 0.6.3 */
|
||||||
.connectClose = vboxConnectClose, /* 0.6.3 */
|
.connectClose = vboxConnectClose, /* 0.6.3 */
|
||||||
.connectGetVersion = vboxConnectGetVersion, /* 0.6.3 */
|
.connectGetVersion = vboxConnectGetVersion, /* 0.6.3 */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user