---
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 f1102ea..c71f4f8 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -4145,6 +4145,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;
@@ -4813,6 +4830,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 b022fee..bf8575c 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -1100,6 +1100,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;
@@ -1257,6 +1274,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 6cf7203..28a7f9c 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -185,6 +185,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;
@@ -2986,6 +2992,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 0d0bea2..c5fd9eb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -938,6 +938,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;
@@ -10450,6 +10455,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 e218c40..9bae3fc 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -4110,6 +4110,23 @@ remoteStartKeepAlive(virConnectPtr conn, int interval, unsigned int
count)
}
+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"
@@ -4460,6 +4477,7 @@ static virDriver remote_driver = {
.domainBlockPull = remoteDomainBlockPull, /* 0.9.4 */
.allowKeepAlive = remoteAllowKeepAlive, /* 0.9.7 */
.startKeepAlive = remoteStartKeepAlive, /* 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 dee5059..9ccdf08 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -581,6 +581,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 e337ee0..5787a7c 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 0e4364f..93ab930 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;
@@ -8875,6 +8880,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.6.1