---
Notes:
Version 3:
- no changes
Version 2:
- new patch
src/esx/esx_driver.c | 18 ++++++++++++++++++
src/hyperv/hyperv_driver.c | 18 ++++++++++++++++++
src/libxl/libxl_driver.c | 8 ++++++++
src/lxc/lxc_driver.c | 7 +++++++
src/openvz/openvz_driver.c | 7 +++++++
src/phyp/phyp_driver.c | 18 ++++++++++++++++++
src/qemu/qemu_driver.c | 6 ++++++
src/remote/remote_driver.c | 18 ++++++++++++++++++
src/rpc/virnetclient.c | 14 ++++++++++++++
src/rpc/virnetclient.h | 1 +
src/test/test_driver.c | 6 ++++++
src/uml/uml_driver.c | 7 +++++++
src/vbox/vbox_tmpl.c | 6 ++++++
src/vmware/vmware_driver.c | 7 +++++++
src/xen/xen_driver.c | 8 ++++++++
src/xenapi/xenapi_driver.c | 12 ++++++++++++
16 files changed, 161 insertions(+), 0 deletions(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 5dc7d78..837f37e 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -4166,6 +4166,23 @@ esxIsSecure(virConnectPtr conn)
static int
+esxIsAlive(virConnectPtr conn)
+{
+ esxPrivate *priv = conn->privateData;
+
+ /* XXX we should be able to do something better than this is simple, safe,
+ * and good enough for now. In worst case, the function will return true
+ * even though the connection is not alive.
+ */
+ if (priv->host)
+ return 1;
+ else
+ return 0;
+}
+
+
+
+static int
esxDomainIsActive(virDomainPtr domain)
{
int result = -1;
@@ -4979,6 +4996,7 @@ static virDriver esxDriver = {
.domainSnapshotCurrent = esxDomainSnapshotCurrent, /* 0.8.0 */
.domainRevertToSnapshot = esxDomainRevertToSnapshot, /* 0.8.0 */
.domainSnapshotDelete = esxDomainSnapshotDelete, /* 0.8.0 */
+ .isAlive = esxIsAlive, /* 0.9.7 */
};
diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index 39b55f8..7665a76 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -1119,6 +1119,23 @@ hypervIsSecure(virConnectPtr conn)
static int
+hypervIsAlive(virConnectPtr conn)
+{
+ hypervPrivate *priv = conn->privateData;
+
+ /* XXX we should be able to do something better than this is simple, safe,
+ * and good enough for now. In worst case, the function will return true
+ * even though the connection is not alive.
+ */
+ if (priv->client)
+ return 1;
+ else
+ return 0;
+}
+
+
+
+static int
hypervDomainIsActive(virDomainPtr domain)
{
int result = -1;
@@ -1276,6 +1293,7 @@ static virDriver hypervDriver = {
.domainManagedSave = hypervDomainManagedSave, /* 0.9.5 */
.domainHasManagedSaveImage = hypervDomainHasManagedSaveImage, /* 0.9.5 */
.domainManagedSaveRemove = hypervDomainManagedSaveRemove, /* 0.9.5 */
+ .isAlive = hypervIsAlive, /* 0.9.7 */
};
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index d324632..42503d6 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -3875,6 +3875,13 @@ libxlDomainEventDeregisterAny(virConnectPtr conn, int callbackID)
}
+static int
+libxlIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED)
+{
+ return 1;
+}
+
+
static virDriver libxlDriver = {
.no = VIR_DRV_LIBXL,
.name = "xenlight",
@@ -3948,6 +3955,7 @@ static virDriver libxlDriver = {
.domainIsUpdated = libxlDomainIsUpdated, /* 0.9.0 */
.domainEventRegisterAny = libxlDomainEventRegisterAny, /* 0.9.0 */
.domainEventDeregisterAny = libxlDomainEventDeregisterAny, /* 0.9.0 */
+ .isAlive = libxlIsAlive, /* 0.9.7 */
};
static virStateDriver libxlStateDriver = {
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index c475887..3bf85a1 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -186,6 +186,12 @@ static int lxcIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED)
}
+static int lxcIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED)
+{
+ return 1;
+}
+
+
static char *lxcGetCapabilities(virConnectPtr conn) {
lxc_driver_t *driver = conn->privateData;
char *xml;
@@ -3008,6 +3014,7 @@ static virDriver lxcDriver = {
.domainEventRegisterAny = lxcDomainEventRegisterAny, /* 0.8.0 */
.domainEventDeregisterAny = lxcDomainEventDeregisterAny, /* 0.8.0 */
.domainOpenConsole = lxcDomainOpenConsole, /* 0.8.6 */
+ .isAlive = lxcIsAlive, /* 0.9.7 */
};
static virStateDriver lxcStateDriver = {
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 69ff444..8a4e6cf 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -1426,6 +1426,12 @@ static int openvzIsSecure(virConnectPtr conn ATTRIBUTE_UNUSED) {
return 1;
}
+static int
+openvzIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED)
+{
+ return 1;
+}
+
static char *openvzGetCapabilities(virConnectPtr conn) {
struct openvz_driver *driver = conn->privateData;
char *ret;
@@ -1714,6 +1720,7 @@ static virDriver openvzDriver = {
.domainIsActive = openvzDomainIsActive, /* 0.7.3 */
.domainIsPersistent = openvzDomainIsPersistent, /* 0.7.3 */
.domainIsUpdated = openvzDomainIsUpdated, /* 0.8.6 */
+ .isAlive = openvzIsAlive, /* 0.9.7 */
};
int openvzRegister(void) {
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index ff16aae..458c9c9 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -1284,6 +1284,23 @@ phypIsSecure(virConnectPtr conn ATTRIBUTE_UNUSED)
return 1;
}
+
+static int
+phypIsAlive(virConnectPtr conn)
+{
+ ConnectionData *connection_data = conn->networkPrivateData;
+
+ /* XXX we should be able to do something better but this is simple, safe,
+ * and good enough for now. In worst case, the function will return true
+ * even though the connection is not alive.
+ */
+ if (connection_data && connection_data->session)
+ return 1;
+ else
+ return 0;
+}
+
+
static int
phypIsUpdated(virDomainPtr conn ATTRIBUTE_UNUSED)
{
@@ -3786,6 +3803,7 @@ static virDriver phypDriver = {
.isEncrypted = phypIsEncrypted, /* 0.7.3 */
.isSecure = phypIsSecure, /* 0.7.3 */
.domainIsUpdated = phypIsUpdated, /* 0.8.6 */
+ .isAlive = phypIsAlive, /* 0.9.7 */
};
static virStorageDriver phypStorageDriver = {
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ec01cd5..c013356 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -942,6 +942,11 @@ static int qemuIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED)
return 0;
}
+static int qemuIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED)
+{
+ return 1;
+}
+
static int kvmGetMaxVCPUs(void) {
int maxvcpus = 1;
@@ -10718,6 +10723,7 @@ static virDriver qemuDriver = {
.domainGetBlockJobInfo = qemuDomainGetBlockJobInfo, /* 0.9.4 */
.domainBlockJobSetSpeed = qemuDomainBlockJobSetSpeed, /* 0.9.4 */
.domainBlockPull = qemuDomainBlockPull, /* 0.9.4 */
+ .isAlive = qemuIsAlive, /* 0.9.7 */
};
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 28cd5e3..a41b041 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -4130,6 +4130,23 @@ cleanup:
}
+static int
+remoteIsAlive(virConnectPtr conn)
+{
+ struct private_data *priv = conn->privateData;
+ bool ret;
+
+ remoteDriverLock(priv);
+ ret = virNetClientIsOpen(priv->client);
+ remoteDriverUnlock(priv);
+
+ if (ret)
+ return 1;
+ else
+ return 0;
+}
+
+
#include "remote_client_bodies.h"
#include "qemu_client_bodies.h"
@@ -4483,6 +4500,7 @@ static virDriver remote_driver = {
.domainBlockJobSetSpeed = remoteDomainBlockJobSetSpeed, /* 0.9.4 */
.domainBlockPull = remoteDomainBlockPull, /* 0.9.4 */
.setKeepAlive = remoteSetKeepAlive, /* 0.9.7 */
+ .isAlive = remoteIsAlive, /* 0.9.7 */
};
static virNetworkDriver network_driver = {
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index 44ced2e..bf98bd6 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -567,6 +567,20 @@ bool virNetClientIsEncrypted(virNetClientPtr client)
}
+bool virNetClientIsOpen(virNetClientPtr client)
+{
+ bool ret;
+
+ if (!client)
+ return false;
+
+ virNetClientLock(client);
+ ret = client->sock && !client->wantClose;
+ virNetClientUnlock(client);
+ return ret;
+}
+
+
int virNetClientAddProgram(virNetClientPtr client,
virNetClientProgramPtr prog)
{
diff --git a/src/rpc/virnetclient.h b/src/rpc/virnetclient.h
index 3227a4e..7d7a8c0 100644
--- a/src/rpc/virnetclient.h
+++ b/src/rpc/virnetclient.h
@@ -78,6 +78,7 @@ int virNetClientSetTLSSession(virNetClientPtr client,
virNetTLSContextPtr tls);
bool virNetClientIsEncrypted(virNetClientPtr client);
+bool virNetClientIsOpen(virNetClientPtr client);
const char *virNetClientLocalAddrString(virNetClientPtr client);
const char *virNetClientRemoteAddrString(virNetClientPtr client);
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index b3e24b4..7f1f8b6 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1184,6 +1184,11 @@ static int testIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED)
return 0;
}
+static int testIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED)
+{
+ return 1;
+}
+
static int testGetMaxVCPUs(virConnectPtr conn ATTRIBUTE_UNUSED,
const char *type ATTRIBUTE_UNUSED)
{
@@ -5624,6 +5629,7 @@ static virDriver testDriver = {
.domainIsUpdated = testDomainIsUpdated, /* 0.8.6 */
.domainEventRegisterAny = testDomainEventRegisterAny, /* 0.8.0 */
.domainEventDeregisterAny = testDomainEventDeregisterAny, /* 0.8.0 */
+ .isAlive = testIsAlive, /* 0.9.7 */
};
static virNetworkDriver testNetworkDriver = {
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 2b7219a..2ad3084 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -1098,6 +1098,12 @@ static int umlIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED)
}
+static int umlIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED)
+{
+ return 1;
+}
+
+
static char *umlGetCapabilities(virConnectPtr conn) {
struct uml_driver *driver = (struct uml_driver *)conn->privateData;
char *xml;
@@ -2462,6 +2468,7 @@ static virDriver umlDriver = {
.domainEventRegisterAny = umlDomainEventRegisterAny, /* 0.9.4 */
.domainEventDeregisterAny = umlDomainEventDeregisterAny, /* 0.9.4 */
.domainOpenConsole = umlDomainOpenConsole, /* 0.8.6 */
+ .isAlive = umlIsAlive, /* 0.9.7 */
};
static int
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 9b674a9..4d12649 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -1070,6 +1070,11 @@ static int vboxIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED) {
return 0;
}
+static int vboxIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED)
+{
+ return 1;
+}
+
static int vboxGetMaxVcpus(virConnectPtr conn, const char *type ATTRIBUTE_UNUSED) {
VBOX_OBJECT_CHECK(conn, int, -1);
PRUint32 maxCPUCount = 0;
@@ -8976,6 +8981,7 @@ virDriver NAME(Driver) = {
.domainSnapshotCurrent = vboxDomainSnapshotCurrent, /* 0.8.0 */
.domainRevertToSnapshot = vboxDomainRevertToSnapshot, /* 0.8.0 */
.domainSnapshotDelete = vboxDomainSnapshotDelete, /* 0.8.0 */
+ .isAlive = vboxIsAlive, /* 0.9.7 */
};
virNetworkDriver NAME(NetworkDriver) = {
diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index b2cfdce..987a7a8 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -958,6 +958,12 @@ vmwareDomainGetState(virDomainPtr dom,
return ret;
}
+static int
+vmwareIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED)
+{
+ return 1;
+}
+
static virDriver vmwareDriver = {
.no = VIR_DRV_VMWARE,
.name = "VMWARE",
@@ -990,6 +996,7 @@ static virDriver vmwareDriver = {
.domainUndefineFlags = vmwareDomainUndefineFlags, /* 0.9.4 */
.domainIsActive = vmwareDomainIsActive, /* 0.8.7 */
.domainIsPersistent = vmwareDomainIsPersistent, /* 0.8.7 */
+ .isAlive = vmwareIsAlive, /* 0.9.7 */
};
int
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index 9c96fca..52f8601 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -516,6 +516,13 @@ xenUnifiedIsSecure(virConnectPtr conn)
return ret;
}
+static int
+xenUnifiedIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED)
+{
+ /* XenD reconnects for each request */
+ return 1;
+}
+
int
xenUnifiedGetMaxVcpus (virConnectPtr conn, const char *type)
{
@@ -2259,6 +2266,7 @@ static virDriver xenUnifiedDriver = {
.domainEventRegisterAny = xenUnifiedDomainEventRegisterAny, /* 0.8.0 */
.domainEventDeregisterAny = xenUnifiedDomainEventDeregisterAny, /* 0.8.0 */
.domainOpenConsole = xenUnifiedDomainOpenConsole, /* 0.8.6 */
+ .isAlive = xenUnifiedIsAlive, /* 0.9.7 */
};
/**
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index 80a706a..a5ab98a 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -1887,6 +1887,17 @@ xenapiNodeGetCellsFreeMemory (virConnectPtr conn, unsigned long
long *freeMems,
}
}
+static int
+xenapiIsAlive(virConnectPtr conn)
+{
+ struct _xenapiPrivate *priv = conn->privateData;
+
+ if (priv->session && priv->session->ok)
+ return 1;
+ else
+ return 0;
+}
+
/* The interface which we export upwards to libvirt.c. */
static virDriver xenapiDriver = {
.no = VIR_DRV_XENAPI,
@@ -1937,6 +1948,7 @@ static virDriver xenapiDriver = {
.nodeGetCellsFreeMemory = xenapiNodeGetCellsFreeMemory, /* 0.8.0 */
.nodeGetFreeMemory = xenapiNodeGetFreeMemory, /* 0.8.0 */
.domainIsUpdated = xenapiDomainIsUpdated, /* 0.8.6 */
+ .isAlive = xenapiIsAlive, /* 0.9.7 */
};
/**
--
1.7.7