mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 19:45:21 +00:00
Introduce virConnectIsAlive API
This API can be used to check if the socket associated with virConnectPtr is still open or it was closed (probably because keepalive protocol timed out). If there the connection is local (i.e., no socket is associated with the connection, it is trivially always alive.
This commit is contained in:
parent
2fb1362883
commit
afdf014f4f
@ -2655,6 +2655,7 @@ int virInterfaceIsActive(virInterfacePtr iface);
|
|||||||
|
|
||||||
int virConnectIsEncrypted(virConnectPtr conn);
|
int virConnectIsEncrypted(virConnectPtr conn);
|
||||||
int virConnectIsSecure(virConnectPtr conn);
|
int virConnectIsSecure(virConnectPtr conn);
|
||||||
|
int virConnectIsAlive(virConnectPtr conn);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CPU specification API
|
* CPU specification API
|
||||||
|
@ -508,6 +508,8 @@ typedef int
|
|||||||
(*virDrvConnectIsEncrypted)(virConnectPtr conn);
|
(*virDrvConnectIsEncrypted)(virConnectPtr conn);
|
||||||
typedef int
|
typedef int
|
||||||
(*virDrvConnectIsSecure)(virConnectPtr conn);
|
(*virDrvConnectIsSecure)(virConnectPtr conn);
|
||||||
|
typedef int
|
||||||
|
(*virDrvConnectIsAlive)(virConnectPtr conn);
|
||||||
typedef int
|
typedef int
|
||||||
(*virDrvDomainIsActive)(virDomainPtr dom);
|
(*virDrvDomainIsActive)(virDomainPtr dom);
|
||||||
typedef int
|
typedef int
|
||||||
@ -904,6 +906,7 @@ struct _virDriver {
|
|||||||
virDrvDomainBlockJobSetSpeed domainBlockJobSetSpeed;
|
virDrvDomainBlockJobSetSpeed domainBlockJobSetSpeed;
|
||||||
virDrvDomainBlockPull domainBlockPull;
|
virDrvDomainBlockPull domainBlockPull;
|
||||||
virDrvSetKeepAlive setKeepAlive;
|
virDrvSetKeepAlive setKeepAlive;
|
||||||
|
virDrvConnectIsAlive isAlive;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef int
|
typedef int
|
||||||
|
@ -17246,3 +17246,39 @@ error:
|
|||||||
virDispatchError(conn);
|
virDispatchError(conn);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virConnectIsAlive:
|
||||||
|
* @conn: pointer to the connection object
|
||||||
|
*
|
||||||
|
* Determine if the connection to the hypervisor is still alive
|
||||||
|
*
|
||||||
|
* A connection will be classed as alive if it is either local, or running
|
||||||
|
* over a channel (TCP or UNIX socket) which is not closed.
|
||||||
|
*
|
||||||
|
* Returns 1 if alive, 0 if dead, -1 on error
|
||||||
|
*/
|
||||||
|
int virConnectIsAlive(virConnectPtr conn)
|
||||||
|
{
|
||||||
|
VIR_DEBUG("conn=%p", conn);
|
||||||
|
|
||||||
|
virResetLastError();
|
||||||
|
|
||||||
|
if (!VIR_IS_CONNECT(conn)) {
|
||||||
|
virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__);
|
||||||
|
virDispatchError(NULL);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (conn->driver->isAlive) {
|
||||||
|
int ret;
|
||||||
|
ret = conn->driver->isAlive(conn);
|
||||||
|
if (ret < 0)
|
||||||
|
goto error;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||||
|
error:
|
||||||
|
virDispatchError(conn);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
@ -500,6 +500,7 @@ LIBVIRT_0.9.7 {
|
|||||||
|
|
||||||
LIBVIRT_0.9.8 {
|
LIBVIRT_0.9.8 {
|
||||||
global:
|
global:
|
||||||
|
virConnectIsAlive;
|
||||||
virConnectSetKeepAlive;
|
virConnectSetKeepAlive;
|
||||||
} LIBVIRT_0.9.7;
|
} LIBVIRT_0.9.7;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user