Allow remote://hostname/ style URIs for automatic driver probe. Fix virGetVersion impl

This commit is contained in:
Daniel P. Berrange 2008-11-28 12:03:20 +00:00
parent 319b83fc28
commit d88d459d7b
14 changed files with 122 additions and 45 deletions

View File

@ -1,3 +1,19 @@
Fri Nov 28 11:58:40 GMT 2008 Daniel P. Berrange <berrange@redhat.com>
Allow generic remote://hostname/ URI for automatic probe
of hypervisor driver.
* docs/uri.html, docs/uri.html.in: Document remote://hostname/ style
URI syntax
* src/driver.h: Remove version field
* src/libvirt.c: Directly impl virGetVersion() instead of calling out
to individual drivers
* src/lxc_driver.c, src/openvz_driver.c, src/qemu_driver.c,
src/remote_internal.h, src/test.c, src/uml_driver.c,
src/xen_unified.c, src/xen_unified.h: Remove version from
driver tables.
* src/remote_internal.c: Allow 'remote' as a URI scheme for
automatically probing on remote server
Fri Nov 28 11:21:40 GMT 2008 Daniel P. Berrange <berrange@redhat.com> Fri Nov 28 11:21:40 GMT 2008 Daniel P. Berrange <berrange@redhat.com>
Fix XM driver disk parsing with no source CDROMs Fix XM driver disk parsing with no source CDROMs

View File

@ -221,13 +221,21 @@ here</a>.
</h3> </h3>
<p> <p>
Remote URIs are formed by taking ordinary local URIs and adding a Remote URIs are formed by taking ordinary local URIs and adding a
hostname and/or transport name. For example: hostname and/or transport name. As a special case, using a URI
scheme of 'remote', will tell the remote libvirtd server to probe
for the optimal hypervisor driver. This is equivalent to passing
a NULL URI for a local connection. For example:
</p> </p>
<table class="top_table"><tr><th> Local URI </th><th> Remote URI </th><th> Meaning </th></tr><tr><td> <table class="top_table"><tr><th> Local URI </th><th> Remote URI </th><th> Meaning </th></tr><tr><td>
<code>xen:///</code> <code>xen:///</code>
</td><td> </td><td>
<code>xen://oirase/</code> <code>xen://oirase/</code>
</td><td> Connect to the Xen hypervisor running on host <code>oirase</code> </td><td> Connect to the Xen hypervisor running on host <code>oirase</code>
using TLS. </td></tr><tr><td>
<code>NULL</code>
</td><td>
<code>remote://oirase/</code>
</td><td> Connect to the "default" hypervisor running on host <code>oirase</code>
using TLS. </td></tr><tr><td> using TLS. </td></tr><tr><td>
<code>xen:///</code> <code>xen:///</code>
</td><td> </td><td>

View File

@ -124,7 +124,10 @@ here</a>.
</h3> </h3>
<p> <p>
Remote URIs are formed by taking ordinary local URIs and adding a Remote URIs are formed by taking ordinary local URIs and adding a
hostname and/or transport name. For example: hostname and/or transport name. As a special case, using a URI
scheme of 'remote', will tell the remote libvirtd server to probe
for the optimal hypervisor driver. This is equivalent to passing
a NULL URI for a local connection. For example:
</p> </p>
<table class="top_table"> <table class="top_table">
<tr> <tr>
@ -140,6 +143,16 @@ hostname and/or transport name. For example:
<code>xen://oirase/</code> <code>xen://oirase/</code>
</td> </td>
<td> Connect to the Xen hypervisor running on host <code>oirase</code> <td> Connect to the Xen hypervisor running on host <code>oirase</code>
using TLS. </td>
</tr>
<tr>
<td>
<code>NULL</code>
</td>
<td>
<code>remote://oirase/</code>
</td>
<td> Connect to the "default" hypervisor running on host <code>oirase</code>
using TLS. </td> using TLS. </td>
</tr> </tr>
<tr> <tr>

View File

@ -328,7 +328,6 @@ typedef virDomainPtr
struct _virDriver { struct _virDriver {
int no; /* the number virDrvNo */ int no; /* the number virDrvNo */
const char * name; /* the name of the driver */ const char * name; /* the name of the driver */
unsigned long ver; /* the version of the backend */
virDrvOpen open; virDrvOpen open;
virDrvClose close; virDrvClose close;
virDrvDrvSupportsFeature supports_feature; virDrvDrvSupportsFeature supports_feature;

View File

@ -734,7 +734,6 @@ int
virGetVersion(unsigned long *libVer, const char *type, virGetVersion(unsigned long *libVer, const char *type,
unsigned long *typeVer) unsigned long *typeVer)
{ {
int i;
DEBUG("libVir=%p, type=%s, typeVer=%p", libVer, type, typeVer); DEBUG("libVir=%p, type=%s, typeVer=%p", libVer, type, typeVer);
if (!initialized) if (!initialized)
@ -748,15 +747,36 @@ virGetVersion(unsigned long *libVer, const char *type,
if (typeVer != NULL) { if (typeVer != NULL) {
if (type == NULL) if (type == NULL)
type = "Xen"; type = "Xen";
for (i = 0;i < virDriverTabCount;i++) { *typeVer = 0;
if ((virDriverTab[i] != NULL) && #if WITH_XEN
(STRCASEEQ(virDriverTab[i]->name, type))) { if (STRCASEEQ(type, "Xen"))
*typeVer = virDriverTab[i]->ver; *typeVer = xenUnifiedVersion();
break; #endif
} #if WITH_TEST
} if (STRCASEEQ(type, "Test"))
if (i >= virDriverTabCount) { *typeVer = LIBVIR_VERSION_NUMBER;
*typeVer = 0; #endif
#if WITH_QEMU
if (STRCASEEQ(type, "QEMU"))
*typeVer = LIBVIR_VERSION_NUMBER;
#endif
#if WITH_LXC
if (STRCASEEQ(type, "LXC"))
*typeVer = LIBVIR_VERSION_NUMBER;
#endif
#if WITH_OPENVZ
if (STRCASEEQ(type, "OpenVZ"))
*typeVer = LIBVIR_VERSION_NUMBER;
#endif
#if WITH_UML
if (STRCASEEQ(type, "UML"))
*typeVer = LIBVIR_VERSION_NUMBER;
#endif
#if WITH_REMOTE
if (STRCASEEQ(type, "Remote"))
*typeVer = remoteVersion();
#endif
if (*typeVer == 0) {
virLibConnError(NULL, VIR_ERR_NO_SUPPORT, type); virLibConnError(NULL, VIR_ERR_NO_SUPPORT, type);
return (-1); return (-1);
} }

View File

@ -1232,7 +1232,6 @@ static int lxcGetSchedulerParameters(virDomainPtr _domain,
static virDriver lxcDriver = { static virDriver lxcDriver = {
VIR_DRV_LXC, /* the number virDrvNo */ VIR_DRV_LXC, /* the number virDrvNo */
"LXC", /* the name of the driver */ "LXC", /* the name of the driver */
LIBVIR_VERSION_NUMBER, /* the version of the backend */
lxcOpen, /* open */ lxcOpen, /* open */
lxcClose, /* close */ lxcClose, /* close */
NULL, /* supports_feature */ NULL, /* supports_feature */

View File

@ -1087,7 +1087,6 @@ static int openvzNumDefinedDomains(virConnectPtr conn) {
static virDriver openvzDriver = { static virDriver openvzDriver = {
VIR_DRV_OPENVZ, VIR_DRV_OPENVZ,
"OPENVZ", "OPENVZ",
LIBVIR_VERSION_NUMBER,
openvzOpen, /* open */ openvzOpen, /* open */
openvzClose, /* close */ openvzClose, /* close */
NULL, /* supports_feature */ NULL, /* supports_feature */

View File

@ -3725,7 +3725,6 @@ qemudDomainMigrateFinish2 (virConnectPtr dconn,
static virDriver qemuDriver = { static virDriver qemuDriver = {
VIR_DRV_QEMU, VIR_DRV_QEMU,
"QEMU", "QEMU",
LIBVIR_VERSION_NUMBER,
qemudOpen, /* open */ qemudOpen, /* open */
qemudClose, /* close */ qemudClose, /* close */
qemudSupportsFeature, /* supports_feature */ qemudSupportsFeature, /* supports_feature */

View File

@ -430,28 +430,40 @@ doRemoteOpen (virConnectPtr conn,
/* Construct the original name. */ /* Construct the original name. */
if (!name) { if (!name) {
xmlURI tmpuri = { if (STREQ(conn->uri->scheme, "remote") ||
.scheme = conn->uri->scheme, STRPREFIX(conn->uri->scheme, "remote+")) {
/* Allow remote serve to probe */
name = strdup("");
} else {
xmlURI tmpuri = {
.scheme = conn->uri->scheme,
#ifdef HAVE_XMLURI_QUERY_RAW #ifdef HAVE_XMLURI_QUERY_RAW
.query_raw = qparam_get_query (vars), .query_raw = qparam_get_query (vars),
#else #else
.query = qparam_get_query (vars), .query = qparam_get_query (vars),
#endif #endif
.path = conn->uri->path, .path = conn->uri->path,
.fragment = conn->uri->fragment, .fragment = conn->uri->fragment,
}; };
/* Evil, blank out transport scheme temporarily */ /* Evil, blank out transport scheme temporarily */
if (transport_str) { if (transport_str) {
assert (transport_str[-1] == '+'); assert (transport_str[-1] == '+');
transport_str[-1] = '\0'; transport_str[-1] = '\0';
}
name = (char *) xmlSaveUri (&tmpuri);
#ifdef HAVE_XMLURI_QUERY_RAW
VIR_FREE(tmpuri.query_raw);
#else
VIR_FREE(tmpuri.query);
#endif
/* Restore transport scheme */
if (transport_str)
transport_str[-1] = '+';
} }
name = (char *) xmlSaveUri (&tmpuri);
/* Restore transport scheme */
if (transport_str)
transport_str[-1] = '+';
} }
free_qparam_set (vars); free_qparam_set (vars);
@ -1330,7 +1342,7 @@ remoteType (virConnectPtr conn)
} }
static int static int
remoteVersion (virConnectPtr conn, unsigned long *hvVer) remoteGetVersion (virConnectPtr conn, unsigned long *hvVer)
{ {
remote_get_version_ret ret; remote_get_version_ret ret;
GET_PRIVATE (conn, -1); GET_PRIVATE (conn, -1);
@ -5300,15 +5312,19 @@ make_nonnull_storage_vol (remote_nonnull_storage_vol *vol_dst, virStorageVolPtr
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
unsigned long remoteVersion(void)
{
return REMOTE_PROTOCOL_VERSION;
}
static virDriver driver = { static virDriver driver = {
.no = VIR_DRV_REMOTE, .no = VIR_DRV_REMOTE,
.name = "remote", .name = "remote",
.ver = REMOTE_PROTOCOL_VERSION,
.open = remoteOpen, .open = remoteOpen,
.close = remoteClose, .close = remoteClose,
.supports_feature = remoteSupportsFeature, .supports_feature = remoteSupportsFeature,
.type = remoteType, .type = remoteType,
.version = remoteVersion, .version = remoteGetVersion,
.getHostname = remoteGetHostname, .getHostname = remoteGetHostname,
.getMaxVcpus = remoteGetMaxVcpus, .getMaxVcpus = remoteGetMaxVcpus,
.nodeGetInfo = remoteNodeGetInfo, .nodeGetInfo = remoteNodeGetInfo,

View File

@ -28,6 +28,8 @@
int remoteRegister (void); int remoteRegister (void);
unsigned long remoteVersion(void);
#define LIBVIRTD_LISTEN_ADDR NULL #define LIBVIRTD_LISTEN_ADDR NULL
#define LIBVIRTD_TLS_PORT "16514" #define LIBVIRTD_TLS_PORT "16514"
#define LIBVIRTD_TCP_PORT "16509" #define LIBVIRTD_TCP_PORT "16509"

View File

@ -2194,7 +2194,6 @@ testStorageVolumeGetPath(virStorageVolPtr obj) {
static virDriver testDriver = { static virDriver testDriver = {
VIR_DRV_TEST, VIR_DRV_TEST,
"Test", "Test",
LIBVIR_VERSION_NUMBER,
testOpen, /* open */ testOpen, /* open */
testClose, /* close */ testClose, /* close */
NULL, /* supports_feature */ NULL, /* supports_feature */

View File

@ -1593,7 +1593,6 @@ found:
static virDriver umlDriver = { static virDriver umlDriver = {
VIR_DRV_UML, VIR_DRV_UML,
"UML", "UML",
LIBVIR_VERSION_NUMBER,
umlOpen, /* open */ umlOpen, /* open */
umlClose, /* close */ umlClose, /* close */
NULL, /* supports_feature */ NULL, /* supports_feature */

View File

@ -392,6 +392,17 @@ xenUnifiedClose (virConnectPtr conn)
return 0; return 0;
} }
#define HV_VERSION ((DOM0_INTERFACE_VERSION >> 24) * 1000000 + \
((DOM0_INTERFACE_VERSION >> 16) & 0xFF) * 1000 + \
(DOM0_INTERFACE_VERSION & 0xFFFF))
unsigned long xenUnifiedVersion(void)
{
return HV_VERSION;
}
static const char * static const char *
xenUnifiedType (virConnectPtr conn) xenUnifiedType (virConnectPtr conn)
{ {
@ -416,7 +427,7 @@ xenUnifiedSupportsFeature (virConnectPtr conn ATTRIBUTE_UNUSED, int feature)
} }
static int static int
xenUnifiedVersion (virConnectPtr conn, unsigned long *hvVer) xenUnifiedGetVersion (virConnectPtr conn, unsigned long *hvVer)
{ {
GET_PRIVATE(conn); GET_PRIVATE(conn);
int i; int i;
@ -1366,20 +1377,15 @@ xenUnifiedDomainEventDeregister (virConnectPtr conn,
/*----- Register with libvirt.c, and initialise Xen drivers. -----*/ /*----- Register with libvirt.c, and initialise Xen drivers. -----*/
#define HV_VERSION ((DOM0_INTERFACE_VERSION >> 24) * 1000000 + \
((DOM0_INTERFACE_VERSION >> 16) & 0xFF) * 1000 + \
(DOM0_INTERFACE_VERSION & 0xFFFF))
/* The interface which we export upwards to libvirt.c. */ /* The interface which we export upwards to libvirt.c. */
static virDriver xenUnifiedDriver = { static virDriver xenUnifiedDriver = {
.no = VIR_DRV_XEN_UNIFIED, .no = VIR_DRV_XEN_UNIFIED,
.name = "Xen", .name = "Xen",
.ver = HV_VERSION,
.open = xenUnifiedOpen, .open = xenUnifiedOpen,
.close = xenUnifiedClose, .close = xenUnifiedClose,
.supports_feature = xenUnifiedSupportsFeature, .supports_feature = xenUnifiedSupportsFeature,
.type = xenUnifiedType, .type = xenUnifiedType,
.version = xenUnifiedVersion, .version = xenUnifiedGetVersion,
.getHostname = xenUnifiedGetHostname, .getHostname = xenUnifiedGetHostname,
.getMaxVcpus = xenUnifiedGetMaxVcpus, .getMaxVcpus = xenUnifiedGetMaxVcpus,
.nodeGetInfo = xenUnifiedNodeGetInfo, .nodeGetInfo = xenUnifiedNodeGetInfo,

View File

@ -185,4 +185,6 @@ void xenUnifiedDomainEventDispatch (xenUnifiedPrivatePtr priv,
virDomainPtr dom, virDomainPtr dom,
int event, int event,
int detail); int detail);
unsigned long xenUnifiedVersion(void);
#endif /* __VIR_XEN_UNIFIED_H__ */ #endif /* __VIR_XEN_UNIFIED_H__ */