if (conn->uri == NULL) {
return VIR_DRV_OPEN_DECLINED;
} else {
- if (!conn->uri->scheme || STRNEQ(conn->uri->scheme, "bhyve"))
- return VIR_DRV_OPEN_DECLINED;
-
if (STRNEQ_NULLABLE(conn->uri->path, "/system")) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected bhyve URI path '%s', try bhyve:///system"),
static virConnectDriver bhyveConnectDriver = {
.localOnly = true,
+ .uriSchemes = (const char *[]){ "bhyve", NULL },
.hypervisorDriver = &bhyveHypervisorDriver,
};
struct _virConnectDriver {
/* Wether driver permits a server in the URI */
bool localOnly;
+ /*
+ * NULL terminated list of supported URI schemes.
+ * - Single element { NULL } list indicates no supported schemes
+ * - NULL list indicates wildcard supportnig all schemes
+ */
+ const char **uriSchemes;
virHypervisorDriverPtr hypervisorDriver;
virInterfaceDriverPtr interfaceDriver;
virNetworkDriverPtr networkDriver;
unsigned int flags)
{
virDrvOpenStatus result = VIR_DRV_OPEN_ERROR;
- char *plus;
esxPrivate *priv = NULL;
char *potentialVCenterIPAddress = NULL;
char vCenterIPAddress[NI_MAXHOST] = "";
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
/* Decline if the URI is NULL or the scheme is NULL */
- if (!conn->uri || !conn->uri->scheme)
+ if (!conn->uri)
return VIR_DRV_OPEN_DECLINED;
- /* Decline if the scheme is not one of {vpx|esx|gsx} */
- plus = strchr(conn->uri->scheme, '+');
-
- if (!plus) {
- if (STRCASENEQ(conn->uri->scheme, "vpx") &&
- STRCASENEQ(conn->uri->scheme, "esx") &&
- STRCASENEQ(conn->uri->scheme, "gsx")) {
- return VIR_DRV_OPEN_DECLINED;
- }
- } else {
- if (plus - conn->uri->scheme != 3 ||
- (STRCASENEQLEN(conn->uri->scheme, "vpx", 3) &&
- STRCASENEQLEN(conn->uri->scheme, "esx", 3) &&
- STRCASENEQLEN(conn->uri->scheme, "gsx", 3))) {
- return VIR_DRV_OPEN_DECLINED;
- }
-
- virReportError(VIR_ERR_INVALID_ARG,
- _("Transport '%s' in URI scheme is not supported, try again "
- "without the transport part"), plus + 1);
- return VIR_DRV_OPEN_ERROR;
- }
-
if (STRCASENEQ(conn->uri->scheme, "vpx") &&
conn->uri->path && STRNEQ(conn->uri->path, "/")) {
VIR_WARN("Ignoring unexpected path '%s' for non-vpx scheme '%s'",
static virConnectDriver esxConnectDriver = {
+ .uriSchemes = (const char *[]){ "vpx", "esx", "gsx", NULL },
.hypervisorDriver = &esxHypervisorDriver,
.interfaceDriver = &esxInterfaceDriver,
.networkDriver = &esxNetworkDriver,
unsigned int flags)
{
virDrvOpenStatus result = VIR_DRV_OPEN_ERROR;
- char *plus;
hypervPrivate *priv = NULL;
char *username = NULL;
char *password = NULL;
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
/* Decline if the URI is NULL or the scheme is NULL */
- if (conn->uri == NULL || conn->uri->scheme == NULL)
+ if (conn->uri == NULL)
return VIR_DRV_OPEN_DECLINED;
- /* Decline if the scheme is not hyperv */
- plus = strchr(conn->uri->scheme, '+');
-
- if (plus == NULL) {
- if (STRCASENEQ(conn->uri->scheme, "hyperv"))
- return VIR_DRV_OPEN_DECLINED;
- } else {
- if (plus - conn->uri->scheme != 6 ||
- STRCASENEQLEN(conn->uri->scheme, "hyperv", 6)) {
- return VIR_DRV_OPEN_DECLINED;
- }
-
- virReportError(VIR_ERR_INVALID_ARG,
- _("Transport '%s' in URI scheme is not supported, try again "
- "without the transport part"), plus + 1);
- return VIR_DRV_OPEN_ERROR;
- }
-
/* Require server part */
if (conn->uri->server == NULL) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
static virConnectDriver hypervConnectDriver = {
+ .uriSchemes = (const char *[]){ "hyperv", NULL },
.hypervisorDriver = &hypervHypervisorDriver,
};
/* Only hypervisor drivers are permitted to auto-open on NULL uri */
return VIR_DRV_OPEN_DECLINED;
} else {
- if (STRNEQ_NULLABLE(conn->uri->scheme, "interface"))
- return VIR_DRV_OPEN_DECLINED;
-
if (driver == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("interface state driver is not active"));
static virConnectDriver interfaceConnectDriver = {
.localOnly = true,
+ .uriSchemes = (const char *[]){ "interface", NULL },
.hypervisorDriver = &interfaceHypervisorDriver,
.interfaceDriver = &interfaceDriver,
};
/* Only hypervisor drivers are permitted to auto-open on NULL uri */
return VIR_DRV_OPEN_DECLINED;
} else {
- if (STRNEQ_NULLABLE(conn->uri->scheme, "interface"))
- return VIR_DRV_OPEN_DECLINED;
-
if (driver == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("interface state driver is not active"));
static virConnectDriver udevConnectDriver = {
.localOnly = true,
+ .uriSchemes = (const char *[]){ "interface", NULL },
.hypervisorDriver = &udevHypervisorDriver,
.interfaceDriver = &udevIfaceDriver,
};
continue;
}
+ /* Filter drivers based on declared URI schemes */
+ if (virConnectDriverTab[i]->uriSchemes && ret->uri) {
+ bool matchScheme = false;
+ size_t s;
+ if (!ret->uri->scheme) {
+ VIR_DEBUG("No URI scheme, skipping driver with URI whitelist");
+ continue;
+ }
+ VIR_DEBUG("Checking for supported URI schemes");
+ for (s = 0; virConnectDriverTab[i]->uriSchemes[s] != NULL; s++) {
+ if (STREQ(ret->uri->scheme, virConnectDriverTab[i]->uriSchemes[s])) {
+ VIR_DEBUG("Matched URI scheme '%s'", ret->uri->scheme);
+ matchScheme = true;
+ break;
+ }
+ }
+ if (!matchScheme) {
+ VIR_DEBUG("No matching URI scheme");
+ continue;
+ }
+ } else {
+ VIR_DEBUG("Matching any URI scheme for '%s'", ret->uri ? ret->uri->scheme : "");
+ }
+
ret->driver = virConnectDriverTab[i]->hypervisorDriver;
ret->interfaceDriver = virConnectDriverTab[i]->interfaceDriver;
ret->networkDriver = virConnectDriverTab[i]->networkDriver;
if (conn->uri == NULL) {
return VIR_DRV_OPEN_DECLINED;
} else {
- /* Only xen scheme */
- if (conn->uri->scheme == NULL || STRNEQ(conn->uri->scheme, "xen"))
- return VIR_DRV_OPEN_DECLINED;
-
/* Error if xen or libxl scheme specified but driver not started. */
if (libxl_driver == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
static virConnectDriver libxlConnectDriver = {
.localOnly = true,
+ .uriSchemes = (const char *[]){ "xen", NULL },
.hypervisorDriver = &libxlHypervisorDriver,
};
if (conn->uri == NULL) {
return VIR_DRV_OPEN_DECLINED;
} else {
- if (conn->uri->scheme == NULL ||
- STRNEQ(conn->uri->scheme, "lxc"))
- return VIR_DRV_OPEN_DECLINED;
-
/* If path isn't '/' then they typoed, tell them correct path */
if (conn->uri->path != NULL &&
STRNEQ(conn->uri->path, "/") &&
static virConnectDriver lxcConnectDriver = {
.localOnly = true,
+ .uriSchemes = (const char *[]){ "lxc", NULL },
.hypervisorDriver = &lxcHypervisorDriver,
};
/* Only hypervisor drivers are permitted to auto-open on NULL uri */
return VIR_DRV_OPEN_DECLINED;
} else {
- if (STRNEQ_NULLABLE(conn->uri->scheme, "network"))
- return VIR_DRV_OPEN_DECLINED;
-
if (network_driver == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("network state driver is not active"));
static virConnectDriver networkConnectDriver = {
.localOnly = true,
+ .uriSchemes = (const char *[]){ "network", NULL },
.hypervisorDriver = &networkHypervisorDriver,
.networkDriver = &networkDriver,
};
/* Only hypervisor drivers are permitted to auto-open on NULL uri */
return VIR_DRV_OPEN_DECLINED;
} else {
- if (STRNEQ_NULLABLE(conn->uri->scheme, "nodedev"))
- return VIR_DRV_OPEN_DECLINED;
-
if (driver == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("nodedev state driver is not active"));
static virConnectDriver halConnectDriver = {
.localOnly = true,
+ .uriSchemes = (const char *[]){ "nodedev", NULL },
.hypervisorDriver = &halHypervisorDriver,
.nodeDeviceDriver = &halNodeDeviceDriver,
};
static virConnectDriver udevConnectDriver = {
.localOnly = true,
+ .uriSchemes = (const char *[]){ "nodedev", NULL },
.hypervisorDriver = &udevHypervisorDriver,
.nodeDeviceDriver = &udevNodeDeviceDriver,
};
/* Only hypervisor drivers are permitted to auto-open on NULL uri */
return VIR_DRV_OPEN_DECLINED;
} else {
- if (STRNEQ_NULLABLE(conn->uri->scheme, "nwfilter"))
- return VIR_DRV_OPEN_DECLINED;
-
if (driver == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("nwfilter state driver is not active"));
static virConnectDriver nwfilterConnectDriver = {
.localOnly = true,
+ .uriSchemes = (const char *[]){ "nwfilter", NULL },
.hypervisorDriver = &nwfilterHypervisorDriver,
.nwfilterDriver = &nwfilterDriver,
};
if (conn->uri == NULL) {
return VIR_DRV_OPEN_DECLINED;
} else {
- /* If scheme isn't 'openvz', then its for another driver */
- if (conn->uri->scheme == NULL ||
- STRNEQ(conn->uri->scheme, "openvz"))
- return VIR_DRV_OPEN_DECLINED;
-
/* If path isn't /system, then they typoed, so tell them correct path */
if (conn->uri->path == NULL ||
STRNEQ(conn->uri->path, "/system")) {
static virConnectDriver openvzConnectDriver = {
.localOnly = true,
+ .uriSchemes = (const char *[]){ "openvz", NULL },
.hypervisorDriver = &openvzHypervisorDriver,
};
if (!conn || !conn->uri)
return VIR_DRV_OPEN_DECLINED;
- if (conn->uri->scheme == NULL || STRNEQ(conn->uri->scheme, "phyp"))
- return VIR_DRV_OPEN_DECLINED;
-
if (conn->uri->server == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Missing server name in phyp:// URI"));
};
static virConnectDriver phypConnectDriver = {
+ .uriSchemes = (const char *[]){ "phyp", NULL },
.hypervisorDriver = &phypHypervisorDriver,
.interfaceDriver = &phypInterfaceDriver,
.storageDriver = &phypStorageDriver,
if (conn->uri == NULL) {
return VIR_DRV_OPEN_DECLINED;
} else {
- /* If URI isn't 'qemu' its definitely not for us */
- if (conn->uri->scheme == NULL ||
- STRNEQ(conn->uri->scheme, "qemu")) {
- ret = VIR_DRV_OPEN_DECLINED;
- goto cleanup;
- }
-
if (qemu_driver == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("qemu state driver is not active"));
static virConnectDriver qemuConnectDriver = {
.localOnly = true,
+ .uriSchemes = (const char *[]){ "qemu", NULL },
.hypervisorDriver = &qemuHypervisorDriver,
};
/* Only hypervisor drivers are permitted to auto-open on NULL uri */
return VIR_DRV_OPEN_DECLINED;
} else {
- if (STRNEQ_NULLABLE(conn->uri->scheme, "secret"))
- return VIR_DRV_OPEN_DECLINED;
-
if (driver == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("secret state driver is not active"));
static virConnectDriver secretConnectDriver = {
.localOnly = true,
+ .uriSchemes = (const char *[]){ "secret", NULL },
.hypervisorDriver = &secretHypervisorDriver,
.secretDriver = &secretDriver,
};
/* Only hypervisor drivers are permitted to auto-open on NULL uri */
return VIR_DRV_OPEN_DECLINED;
} else {
- if (STRNEQ_NULLABLE(conn->uri->scheme, "storage"))
- return VIR_DRV_OPEN_DECLINED;
-
if (driver == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("storage state driver is not active"));
static virConnectDriver storageConnectDriver = {
.localOnly = true,
+ .uriSchemes = (const char *[]){ "storage", NULL },
.hypervisorDriver = &storageHypervisorDriver,
.storageDriver = &storageDriver,
};
if (!conn->uri)
return VIR_DRV_OPEN_DECLINED;
- if (!conn->uri->scheme || STRNEQ(conn->uri->scheme, "test"))
- return VIR_DRV_OPEN_DECLINED;
-
/* From this point on, the connection is for us. */
if (!conn->uri->path
|| conn->uri->path[0] == '\0'
static virConnectDriver testConnectDriver = {
.localOnly = true,
+ .uriSchemes = (const char *[]){ "test", NULL },
.hypervisorDriver = &testHypervisorDriver,
.interfaceDriver = &testInterfaceDriver,
.networkDriver = &testNetworkDriver,
if (conn->uri == NULL) {
return VIR_DRV_OPEN_DECLINED;
} else {
- if (conn->uri->scheme == NULL ||
- STRNEQ(conn->uri->scheme, "uml"))
- return VIR_DRV_OPEN_DECLINED;
-
/* Check path and tell them correct path if they made a mistake */
if (uml_driver->privileged) {
if (STRNEQ(conn->uri->path, "/system") &&
static virConnectDriver umlConnectDriver = {
.localOnly = true,
+ .uriSchemes = (const char *[]){ "uml", NULL },
.hypervisorDriver = ¨HypervisorDriver,
};
if (conn->uri == NULL)
return VIR_DRV_OPEN_DECLINED;
- if (conn->uri->scheme == NULL ||
- STRNEQ(conn->uri->scheme, "vbox"))
- return VIR_DRV_OPEN_DECLINED;
-
if (conn->uri->path == NULL || STREQ(conn->uri->path, "")) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("no VirtualBox driver path specified (try vbox:///session)"));
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
- if (conn->uri == NULL ||
- conn->uri->scheme == NULL ||
- STRNEQ(conn->uri->scheme, "vbox"))
+ if (conn->uri == NULL)
return VIR_DRV_OPEN_DECLINED;
if (conn->uri->path == NULL || STREQ(conn->uri->path, "")) {
static virConnectDriver vboxConnectDriver = {
.localOnly = true,
+ .uriSchemes = (const char *[]){ "vbox", NULL },
.hypervisorDriver = NULL,
};
/* @TODO accept */
return VIR_DRV_OPEN_DECLINED;
} else {
- if (conn->uri->scheme == NULL ||
- (STRNEQ(conn->uri->scheme, "vmwareplayer") &&
- STRNEQ(conn->uri->scheme, "vmwarews") &&
- STRNEQ(conn->uri->scheme, "vmwarefusion")))
- return VIR_DRV_OPEN_DECLINED;
-
/* If path isn't /session, then they typoed, so tell them correct path */
if (conn->uri->path == NULL || STRNEQ(conn->uri->path, "/session")) {
virReportError(VIR_ERR_INTERNAL_ERROR,
static virConnectDriver vmwareConnectDriver = {
.localOnly = true,
+ .uriSchemes = (const char *[]){ "vmwareplayer", "vmwarews", "vmwarefusion", NULL },
.hypervisorDriver = &vmwareHypervisorDriver,
};
if (!conn->uri)
return VIR_DRV_OPEN_DECLINED;
- if (!conn->uri->scheme)
- return VIR_DRV_OPEN_DECLINED;
-
- if (STRNEQ(conn->uri->scheme, "vz") &&
- STRNEQ(conn->uri->scheme, "parallels"))
- return VIR_DRV_OPEN_DECLINED;
-
- if (STREQ(conn->uri->scheme, "vz") && STRNEQ(conn->driver->name, "vz"))
- return VIR_DRV_OPEN_DECLINED;
-
- if (STREQ(conn->uri->scheme, "parallels") && STRNEQ(conn->driver->name, "Parallels"))
- return VIR_DRV_OPEN_DECLINED;
-
/* From this point on, the connection is for us. */
if (STRNEQ_NULLABLE(conn->uri->path, "/system")) {
virReportError(VIR_ERR_INTERNAL_ERROR,
static virConnectDriver vzConnectDriver = {
.localOnly = true,
+ .uriSchemes = (const char *[]){ "vz", NULL },
.hypervisorDriver = &vzHypervisorDriver,
};
parallelsHypervisorDriver.name = "Parallels";
parallelsConnectDriver = vzConnectDriver;
parallelsConnectDriver.hypervisorDriver = ¶llelsHypervisorDriver;
+ parallelsConnectDriver.uriSchemes = (const char *[]){ "parallels", NULL },
if (virRegisterConnectDriver(¶llelsConnectDriver, true) < 0)
return -1;
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
- if (conn->uri == NULL || conn->uri->scheme == NULL ||
- STRCASENEQ(conn->uri->scheme, "XenAPI")) {
+ if (conn->uri == NULL)
return VIR_DRV_OPEN_DECLINED;
- }
if (conn->uri->server == NULL) {
xenapiSessionErrorHandler(conn, VIR_ERR_INVALID_ARG,
static virConnectDriver xenapiConnectDriver = {
+ .uriSchemes = (const char *[]){ "xenapi", NULL },
.hypervisorDriver = &xenapiHypervisorDriver,
};