Hi, All.
Thank you for many comments.
And I extremely apologize not to use git... My company's network closes
the almost port and only http via proxy and simple mail are available.
The attached patch is reflected all comments.
Especially,
> diff -uNrp libvirt-0.9.13.orig/src/driver.h
libvirt-0.9.13/src/driver.h
> --- libvirt-0.9.13.orig/src/driver.h 2012-06-25 16:06:18.000000000 +0900
> +++ libvirt-0.9.13/src/driver.h 2012-07-02 10:02:54.405454285 +0900
> @@ -860,6 +860,10 @@ typedef char *
> const char *uri,
> unsigned int flags);
>
> +typedef int
> + (*virDrvDomainGuestAgentCommand)(virDomainPtr domain, const
char *cmd,
> + char **result, unsigned int
flags);
> +
> /**
> * _virDriver:
> *
> @@ -1041,6 +1045,7 @@ struct _virDriver {
> virDrvDomainGetDiskErrors domainGetDiskErrors;
> virDrvDomainSetMetadata domainSetMetadata;
> virDrvDomainGetMetadata domainGetMetadata;
> + virDrvDomainGuestAgentCommand qemuDomainGuestAgentCommand;
> };
I'd move these two as close as possible to
virDrvDomainQemuMonitorCommand so
we have similar commands grouped.
I moved virDrvDomainQemuMonitorCommand to virDrvDomainQemuSupportCommand
to close two functions.
In addition,
> diff -uNrp libvirt-0.9.13.orig/src/qemu/qemu_agent.c
libvirt-0.9.13/src/qemu/qemu_agent.c
> --- libvirt-0.9.13.orig/src/qemu/qemu_agent.c 2012-06-25
16:06:18.000000000 +0900
> +++ libvirt-0.9.13/src/qemu/qemu_agent.c 2012-07-02
10:02:54.408488163 +0900
> @@ -1410,3 +1410,29 @@ qemuAgentSuspend(qemuAgentPtr mon,
> virJSONValueFree(reply);
> return ret;
> }
> +
> +int qemuAgentGuestAgentCommand(qemuAgentPtr mon,
> + const char *cmd,
> + char **result)
> +{
> + int ret = -1;
> + virJSONValuePtr jcmd;
> + virJSONValuePtr reply = NULL;
> +
> + jcmd = qemuAgentMakeCommand(cmd, NULL);
> + if (!jcmd)
> + return ret;
This is confusing. In case of qemu-monitor-command we require user to
pass whole
command string:
{'execute':'some-dummy-command'}
which is correct as we don't lock them in {'execute':'%s'} scheme.
Remember, we want them to
use commands/features not yet exposed by libvirt. So if qemu will
ever come up with different
command scheme this API will remain broken. In addition - and this is
even more serious - there is
no way of specifying arguments to a command, e.g. guest-sync take an
integer:
{'execute':'guest-sync',
'arguments':{'id':123}}
Therefore I think we need to drop qemuAgentMakeCommand() here and
require users to
do
the very same here as they do in qemu-monitor-command.
I prefer to the type of 'virsh qemu-agent-command guest-info', bacause
it is user friendly. But I understood the problem and fixed.
Regards
MATSUDA Daiki
$ diffstat libvirt-0.9.13_qemu_agent_command3.patch
daemon/remote.c | 36 +++++++++++++++++
docs/hvsupport.pl | 1
include/libvirt/libvirt-qemu.h | 3 +
python/generator.py | 1
python/libvirt-qemu-override-api.xml | 7 +++
python/libvirt-qemu-override.c | 31 ++++++++++++++
src/driver.h | 5 +-
src/libvirt-qemu.c | 49 +++++++++++++++++++++++
src/libvirt_qemu.syms | 5 ++
src/qemu/qemu_agent.c | 26 ++++++++++++
src/qemu/qemu_agent.h | 4 +
src/qemu/qemu_driver.c | 73
+++++++++++++++++++++++++++++++++++
src/qemu_protocol-structs | 9 ++++
src/remote/qemu_protocol.x | 13 +++++-
src/remote/remote_driver.c | 39 ++++++++++++++++++
tools/virsh.c | 64 ++++++++++++++++++++++++++++++
16 files changed, 363 insertions(+), 3 deletions(-)
virsh # qemu-agent-command RHEL58_64
'{"execute":"guest-info"}'
{"return":{"version":"1.1.50","supported_commands":[{"enabled":true,"name":"guest-network-get-interfaces"},{"enabled":true,"name":"guest-suspend-hybrid"},{"enabled":true,"name":"guest-suspend-ram"},{"enabled":true,"name":"guest-suspend-disk"},{"enabled":true,"name":"guest-fsfreeze-thaw"},{"enabled":true,"name":"guest-fsfreeze-freeze"},{"enabled":true,"name":"guest-fsfreeze-status"},{"enabled":true,"name":"guest-file-flush"},{"enabled":true,"name":"guest-file-seek"},{"enabled":true,"name":"guest-file-write"},{"enabled":true,"name":"guest-file-read"},{"enabled":true,"name":"guest-file-close"},{"enabled":true,"name":"guest-file-open"},{"enabled":true,"name":"guest-shutdown"},{"enabled":true,"name":"guest-info"},{"enabled":true,"name":"guest-ping"},{"enabled":true,"name":"guest-sync"},{"enabled":true,"name":"guest-sync-delimited"}]}}
virsh # qemu-agent-command RHEL58_64 '{"execute":"guest-sync",
"arguments":{"id":123}}'
{"return":123}