(*virDrvDomainBlockPull)(virDomainPtr dom, const char *path,
unsigned long bandwidth, unsigned int flags);
+typedef int
+ (*virDrvSetKeepAlive)(virConnectPtr conn,
+ int interval,
+ unsigned int count);
/**
* _virDriver:
virDrvDomainGetBlockJobInfo domainGetBlockJobInfo;
virDrvDomainBlockJobSetSpeed domainBlockJobSetSpeed;
virDrvDomainBlockPull domainBlockPull;
+ virDrvSetKeepAlive setKeepAlive;
};
typedef int
virDispatchError(dom->conn);
return -1;
}
+
+
+/**
+ * virConnectSetKeepAlive:
+ * @conn: pointer to a hypervisor connection
+ * @interval: number of seconds of inactivity before a keepalive message is sent
+ * @count: number of messages that can be sent in a row
+ *
+ * Start sending keepalive messages after interval second of inactivity and
+ * consider the connection to be broken when no response is received after
+ * count keepalive messages sent in a row. In other words, sending count + 1
+ * keepalive message results in closing the connection. When interval is <= 0,
+ * no keepalive messages will be sent. When count is 0, the connection will be
+ * automatically closed after interval seconds of inactivity without sending
+ * any keepalive messages.
+ *
+ * Note: client has to implement and run event loop to be able to use keepalive
+ * messages. Failure to do so may result in connections being closed
+ * unexpectedly.
+ *
+ * Returns -1 on error, 0 on success, 1 when remote party doesn't support
+ * keepalive messages.
+ */
+int virConnectSetKeepAlive(virConnectPtr conn,
+ int interval,
+ unsigned int count)
+{
+ int ret = -1;
+
+ VIR_DEBUG("conn=%p, interval=%d, count=%u", conn, interval, count);
+
+ virResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virDispatchError(NULL);
+ return -1;
+ }
+
+ if (interval <= 0) {
+ virLibConnError(VIR_ERR_INVALID_ARG,
+ _("negative or zero interval make no sense"));
+ goto error;
+ }
+
+ if (conn->driver->setKeepAlive) {
+ ret = conn->driver->setKeepAlive(conn, interval, count);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ virDispatchError(conn);
+ return -1;
+}
*
* The remote driver passes features through to the real driver at the
* remote end unmodified, except if you query a VIR_DRV_FEATURE_REMOTE*
- * feature.
- *
+ * feature. Queries for VIR_DRV_FEATURE_PROGRAM* features are answered
+ * directly by the RPC layer and not by the real driver.
*/
enum {
/* Driver supports V1-style virDomainMigrate, ie. domainMigratePrepare/
* Support for VIR_TYPED_PARAM_STRING
*/
VIR_DRV_FEATURE_TYPED_PARAM_STRING = 9,
+
+ /*
+ * Remote party supports keepalive program (i.e., sending keepalive
+ * messages).
+ */
+ VIR_DRV_FEATURE_PROGRAM_KEEPALIVE = 10,
};
* not have a need to integrate with an external event
* loop impl.
*
- * Once registered, the application can invoke
- * virEventRunDefaultImpl in a loop to process
- * events
+ * Once registered, the application has to invoke virEventRunDefaultImpl in
+ * a loop to process events. Failure to do so may result in connections being
+ * closed unexpectedly as a result of keepalive timeout.
*
* Returns 0 on success, -1 on failure.
*/