summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2008-11-28 12:03:20 +0000
committerDaniel P. Berrange <berrange@redhat.com>2008-11-28 12:03:20 +0000
commitd88d459d7b6100f0967e1504ba9b326648b6ea4a (patch)
treef60cabc2d034a5f2d65953dcf9c1ed06be9a7fa0 /src
parentFix XM driver handling of disk source paths (diff)
downloadlibvirt-d88d459d7b6100f0967e1504ba9b326648b6ea4a.tar.gz
libvirt-d88d459d7b6100f0967e1504ba9b326648b6ea4a.tar.bz2
libvirt-d88d459d7b6100f0967e1504ba9b326648b6ea4a.zip
Allow remote://hostname/ style URIs for automatic driver probe. Fix virGetVersion impl
Diffstat (limited to 'src')
-rw-r--r--src/driver.h1
-rw-r--r--src/libvirt.c40
-rw-r--r--src/lxc_driver.c1
-rw-r--r--src/openvz_driver.c1
-rw-r--r--src/qemu_driver.c1
-rw-r--r--src/remote_internal.c56
-rw-r--r--src/remote_internal.h2
-rw-r--r--src/test.c1
-rw-r--r--src/uml_driver.c1
-rw-r--r--src/xen_unified.c20
-rw-r--r--src/xen_unified.h2
11 files changed, 83 insertions, 43 deletions
diff --git a/src/driver.h b/src/driver.h
index 5fd3843f0..8c394e262 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -328,7 +328,6 @@ typedef virDomainPtr
struct _virDriver {
int no; /* the number virDrvNo */
const char * name; /* the name of the driver */
- unsigned long ver; /* the version of the backend */
virDrvOpen open;
virDrvClose close;
virDrvDrvSupportsFeature supports_feature;
diff --git a/src/libvirt.c b/src/libvirt.c
index 926c4a55c..a279024eb 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -734,7 +734,6 @@ int
virGetVersion(unsigned long *libVer, const char *type,
unsigned long *typeVer)
{
- int i;
DEBUG("libVir=%p, type=%s, typeVer=%p", libVer, type, typeVer);
if (!initialized)
@@ -748,15 +747,36 @@ virGetVersion(unsigned long *libVer, const char *type,
if (typeVer != NULL) {
if (type == NULL)
type = "Xen";
- for (i = 0;i < virDriverTabCount;i++) {
- if ((virDriverTab[i] != NULL) &&
- (STRCASEEQ(virDriverTab[i]->name, type))) {
- *typeVer = virDriverTab[i]->ver;
- break;
- }
- }
- if (i >= virDriverTabCount) {
- *typeVer = 0;
+ *typeVer = 0;
+#if WITH_XEN
+ if (STRCASEEQ(type, "Xen"))
+ *typeVer = xenUnifiedVersion();
+#endif
+#if WITH_TEST
+ if (STRCASEEQ(type, "Test"))
+ *typeVer = LIBVIR_VERSION_NUMBER;
+#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);
return (-1);
}
diff --git a/src/lxc_driver.c b/src/lxc_driver.c
index cebc2ca2f..3ec1cb4da 100644
--- a/src/lxc_driver.c
+++ b/src/lxc_driver.c
@@ -1232,7 +1232,6 @@ static int lxcGetSchedulerParameters(virDomainPtr _domain,
static virDriver lxcDriver = {
VIR_DRV_LXC, /* the number virDrvNo */
"LXC", /* the name of the driver */
- LIBVIR_VERSION_NUMBER, /* the version of the backend */
lxcOpen, /* open */
lxcClose, /* close */
NULL, /* supports_feature */
diff --git a/src/openvz_driver.c b/src/openvz_driver.c
index 83cf19ab7..087ef4754 100644
--- a/src/openvz_driver.c
+++ b/src/openvz_driver.c
@@ -1087,7 +1087,6 @@ static int openvzNumDefinedDomains(virConnectPtr conn) {
static virDriver openvzDriver = {
VIR_DRV_OPENVZ,
"OPENVZ",
- LIBVIR_VERSION_NUMBER,
openvzOpen, /* open */
openvzClose, /* close */
NULL, /* supports_feature */
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 90c6b194b..efe780c3b 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -3725,7 +3725,6 @@ qemudDomainMigrateFinish2 (virConnectPtr dconn,
static virDriver qemuDriver = {
VIR_DRV_QEMU,
"QEMU",
- LIBVIR_VERSION_NUMBER,
qemudOpen, /* open */
qemudClose, /* close */
qemudSupportsFeature, /* supports_feature */
diff --git a/src/remote_internal.c b/src/remote_internal.c
index 3fdbc8bbb..7bf8766a8 100644
--- a/src/remote_internal.c
+++ b/src/remote_internal.c
@@ -430,28 +430,40 @@ doRemoteOpen (virConnectPtr conn,
/* Construct the original name. */
if (!name) {
- xmlURI tmpuri = {
- .scheme = conn->uri->scheme,
+ if (STREQ(conn->uri->scheme, "remote") ||
+ STRPREFIX(conn->uri->scheme, "remote+")) {
+ /* Allow remote serve to probe */
+ name = strdup("");
+ } else {
+ xmlURI tmpuri = {
+ .scheme = conn->uri->scheme,
#ifdef HAVE_XMLURI_QUERY_RAW
- .query_raw = qparam_get_query (vars),
+ .query_raw = qparam_get_query (vars),
#else
- .query = qparam_get_query (vars),
+ .query = qparam_get_query (vars),
#endif
- .path = conn->uri->path,
- .fragment = conn->uri->fragment,
- };
-
- /* Evil, blank out transport scheme temporarily */
- if (transport_str) {
- assert (transport_str[-1] == '+');
- transport_str[-1] = '\0';
- }
+ .path = conn->uri->path,
+ .fragment = conn->uri->fragment,
+ };
+
+ /* Evil, blank out transport scheme temporarily */
+ if (transport_str) {
+ assert (transport_str[-1] == '+');
+ transport_str[-1] = '\0';
+ }
- name = (char *) xmlSaveUri (&tmpuri);
+ name = (char *) xmlSaveUri (&tmpuri);
- /* Restore transport scheme */
- if (transport_str)
- transport_str[-1] = '+';
+#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] = '+';
+ }
}
free_qparam_set (vars);
@@ -1330,7 +1342,7 @@ remoteType (virConnectPtr conn)
}
static int
-remoteVersion (virConnectPtr conn, unsigned long *hvVer)
+remoteGetVersion (virConnectPtr conn, unsigned long *hvVer)
{
remote_get_version_ret ret;
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 = {
.no = VIR_DRV_REMOTE,
.name = "remote",
- .ver = REMOTE_PROTOCOL_VERSION,
.open = remoteOpen,
.close = remoteClose,
.supports_feature = remoteSupportsFeature,
.type = remoteType,
- .version = remoteVersion,
+ .version = remoteGetVersion,
.getHostname = remoteGetHostname,
.getMaxVcpus = remoteGetMaxVcpus,
.nodeGetInfo = remoteNodeGetInfo,
diff --git a/src/remote_internal.h b/src/remote_internal.h
index 2abee7703..4d62e15e8 100644
--- a/src/remote_internal.h
+++ b/src/remote_internal.h
@@ -28,6 +28,8 @@
int remoteRegister (void);
+unsigned long remoteVersion(void);
+
#define LIBVIRTD_LISTEN_ADDR NULL
#define LIBVIRTD_TLS_PORT "16514"
#define LIBVIRTD_TCP_PORT "16509"
diff --git a/src/test.c b/src/test.c
index 3648c0578..7998886c5 100644
--- a/src/test.c
+++ b/src/test.c
@@ -2194,7 +2194,6 @@ testStorageVolumeGetPath(virStorageVolPtr obj) {
static virDriver testDriver = {
VIR_DRV_TEST,
"Test",
- LIBVIR_VERSION_NUMBER,
testOpen, /* open */
testClose, /* close */
NULL, /* supports_feature */
diff --git a/src/uml_driver.c b/src/uml_driver.c
index 337a8ea5b..1ce1d781a 100644
--- a/src/uml_driver.c
+++ b/src/uml_driver.c
@@ -1593,7 +1593,6 @@ found:
static virDriver umlDriver = {
VIR_DRV_UML,
"UML",
- LIBVIR_VERSION_NUMBER,
umlOpen, /* open */
umlClose, /* close */
NULL, /* supports_feature */
diff --git a/src/xen_unified.c b/src/xen_unified.c
index ef3784780..4229f0ef1 100644
--- a/src/xen_unified.c
+++ b/src/xen_unified.c
@@ -392,6 +392,17 @@ xenUnifiedClose (virConnectPtr conn)
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 *
xenUnifiedType (virConnectPtr conn)
{
@@ -416,7 +427,7 @@ xenUnifiedSupportsFeature (virConnectPtr conn ATTRIBUTE_UNUSED, int feature)
}
static int
-xenUnifiedVersion (virConnectPtr conn, unsigned long *hvVer)
+xenUnifiedGetVersion (virConnectPtr conn, unsigned long *hvVer)
{
GET_PRIVATE(conn);
int i;
@@ -1366,20 +1377,15 @@ xenUnifiedDomainEventDeregister (virConnectPtr conn,
/*----- 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. */
static virDriver xenUnifiedDriver = {
.no = VIR_DRV_XEN_UNIFIED,
.name = "Xen",
- .ver = HV_VERSION,
.open = xenUnifiedOpen,
.close = xenUnifiedClose,
.supports_feature = xenUnifiedSupportsFeature,
.type = xenUnifiedType,
- .version = xenUnifiedVersion,
+ .version = xenUnifiedGetVersion,
.getHostname = xenUnifiedGetHostname,
.getMaxVcpus = xenUnifiedGetMaxVcpus,
.nodeGetInfo = xenUnifiedNodeGetInfo,
diff --git a/src/xen_unified.h b/src/xen_unified.h
index 2f9346f62..831cefc3c 100644
--- a/src/xen_unified.h
+++ b/src/xen_unified.h
@@ -185,4 +185,6 @@ void xenUnifiedDomainEventDispatch (xenUnifiedPrivatePtr priv,
virDomainPtr dom,
int event,
int detail);
+unsigned long xenUnifiedVersion(void);
+
#endif /* __VIR_XEN_UNIFIED_H__ */