提交 847fc994 编写于 作者: M MATSUDA Daiki 提交者: Daniel Veillard

agent: add virDrvDomainQemuAgentCommand prototype for drivers.

Add virDrvDomainQemuAgentCommand prototype for drivers.
Add virDomainQemuAgentCommand() for virDrvDomainQemuAgentCommand.
Signed-off-by: NMATSUDA Daiki <matsudadik@intellilink.co.jp>
上级 ff049d22
......@@ -51,6 +51,9 @@ typedef enum {
VIR_DOMAIN_QEMU_AGENT_COMMAND_NOWAIT = 0,
} virDomainQemuAgentCommandTimeoutValues;
char *virDomainQemuAgentCommand(virDomainPtr domain, const char *cmd,
int timeout, unsigned int flags);
# ifdef __cplusplus
}
# endif
......
......@@ -431,6 +431,7 @@ skip_impl = (
qemu_skip_impl = (
'virDomainQemuMonitorCommand',
'virDomainQemuAgentCommand',
)
......
......@@ -701,6 +701,9 @@ typedef int
typedef int
(*virDrvDomainQemuMonitorCommand)(virDomainPtr domain, const char *cmd,
char **result, unsigned int flags);
typedef char *
(*virDrvDomainQemuAgentCommand)(virDomainPtr domain, const char *cmd,
int timeout, unsigned int flags);
/* Choice of unsigned int rather than pid_t is intentional. */
typedef virDomainPtr
......@@ -1064,6 +1067,7 @@ struct _virDriver {
virDrvDomainGetDiskErrors domainGetDiskErrors;
virDrvDomainSetMetadata domainSetMetadata;
virDrvDomainGetMetadata domainGetMetadata;
virDrvDomainQemuAgentCommand qemuDomainArbitraryAgentCommand;
};
typedef int
......
......@@ -185,3 +185,57 @@ error:
virDispatchError(conn);
return NULL;
}
/**
* virDomainQemuAgentCommand:
* @domain: a domain object
* @cmd: the guest agent command string
* @timeout: timeout seconds
* @flags: execution flags
*
* Execute an arbitrary Guest Agent command.
*
* Issue @cmd to the guest agent running in @domain.
* @timeout must be -2, -1, 0 or positive.
* VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK(-2): meaning to block forever waiting for
* a result.
* VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT(-1): use default timeout value.
* VIR_DOMAIN_QEMU_AGENT_COMMAND_NOWAIT(0): does not wait.
* positive value: wait for @timeout seconds
*
* Returns strings if success, NULL in failure.
*/
char *
virDomainQemuAgentCommand(virDomainPtr domain,
const char *cmd,
int timeout,
unsigned int flags)
{
virConnectPtr conn;
VIR_DEBUG("domain=%p, cmd=%s, timeout=%d, flags=%x",
domain, cmd, timeout, flags);
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
virDispatchError(NULL);
return NULL;
}
if (domain->conn->flags & VIR_CONNECT_RO) {
virLibDomainError(NULL, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
return NULL;
}
conn = domain->conn;
if (conn->driver->qemuDomainArbitraryAgentCommand) {
return conn->driver->qemuDomainArbitraryAgentCommand(domain, cmd,
timeout, flags);
}
virLibConnError(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
/* Copy to connection error object for back compatibility */
virDispatchError(conn);
return NULL;
}
......@@ -19,3 +19,8 @@ LIBVIRT_QEMU_0.9.4 {
global:
virDomainQemuAttach;
} LIBVIRT_QEMU_0.8.3;
LIBVIRT_QEMU_0.10.1 {
global:
virDomainQemuAgentCommand;
} LIBVIRT_QEMU_0.9.4;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册