Re: [PATCH] qemu_agent: support guest-info command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 29, 2012 at 01:58:05PM +0900, MATSUDA, Daiki wrote:

> diff -uNrp libvirt-0.9.13.orig/daemon/remote.c libvirt-0.9.13/daemon/remote.c
> --- libvirt-0.9.13.orig/daemon/remote.c	2012-06-25 16:06:18.000000000 +0900
> +++ libvirt-0.9.13/daemon/remote.c	2012-06-29 12:50:03.752806682 +0900
> @@ -3923,6 +3923,42 @@ cleanup:
>      return rv;
>  }
>  
> +
> +static int
> +remoteDispatchDomainQemuAgentCommand(virNetServerPtr server ATTRIBUTE_UNUSED,
> +                                     virNetServerClientPtr client ATTRIBUTE_UNUSED,
> +                                     virNetMessagePtr msg ATTRIBUTE_UNUSED,
> +                                     virNetMessageErrorPtr rerr,
> +                                     remote_domain_qemu_agent_command_args *args,
> +                                     remote_domain_qemu_agent_command_ret *ret)
> +{
> +    virDomainPtr dom = NULL;
> +    int rv = -1;
> +    struct daemonClientPrivate *priv =
> +        virNetServerClientGetPrivateData(client);
> +
> +    if (!priv->conn) {
> +        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
> +        goto cleanup;
> +    }
> +
> +    if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
> +        goto cleanup;
> +
> +    if (virDomainQemuAgentCommand(dom, args->cmd, &ret->result, args->flags) <0) {
> +        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("Guest Agent Error"));
> +        goto cleanup;
> +    }
> +
> +    rv = 0;
> +cleanup:
> +    if (rv < 0)
> +        virNetMessageSaveError(rerr);
> +    if (dom)
> +        virDomainFree(dom);
> +    return rv;
> +}
> +
>  /*----- Helpers. -----*/
>  
>  /* get_nonnull_domain and get_nonnull_network turn an on-wire
> diff -uNrp libvirt-0.9.13.orig/daemon/remote_dispatch.h libvirt-0.9.13/daemon/remote_dispatch.h
> --- libvirt-0.9.13.orig/daemon/remote_dispatch.h	2012-06-25 19:48:08.000000000 +0900
> +++ libvirt-0.9.13/daemon/remote_dispatch.h	2012-06-29 10:21:21.460454579 +0900
> @@ -12889,6 +12889,28 @@ static int remoteDispatchSupportsFeature
>  
>  
>  
> +static int remoteDispatchDomainQemuAgentCommand(
> +    virNetServerPtr server,
> +    virNetServerClientPtr client,
> +    virNetMessagePtr msg,
> +    virNetMessageErrorPtr rerr,
> +    remote_domain_qemu_agent_command_args *args,
> +    remote_domain_qemu_agent_command_ret *ret);
> +static int remoteDispatchDomainQemuAgentCommandHelper(
> +    virNetServerPtr server,
> +    virNetServerClientPtr client,
> +    virNetMessagePtr msg,
> +    virNetMessageErrorPtr rerr,
> +    void *args,
> +    void *ret)
> +{
> +  VIR_DEBUG("server=%p client=%p msg=%p rerr=%p args=%p ret=%p", server, client, msg, rerr, args, ret);
> +  return remoteDispatchDomainQemuAgentCommand(server, client, msg, rerr, args, ret);
> +}
> +/* remoteDispatchDomainQemuAgentCommand body has to be implemented manually */
> +
> +
> +
>  virNetServerProgramProc remoteProcs[] = {
>  { /* Unused 0 */
>     NULL,
> @@ -15374,5 +15396,14 @@ virNetServerProgramProc remoteProcs[] = 
>     true,
>     1
>  },
> +{ /* Method DomainQemuAgentCommand => 276 */
> +   remoteDispatchDomainQemuAgentCommandHelper,
> +   sizeof(remote_domain_qemu_agent_command_args),
> +   (xdrproc_t)xdr_remote_qemu_agent_command_args,
> +   sizeof(remote_domain_qemu_agent_command_ret),
> +   (xdrproc_t)remote_domain_qemu_agent_command_ret,
> +   true,
> +   0
> +},
>  };
>  size_t remoteNProcs = ARRAY_CARDINALITY(remoteProcs);

This is an auto-generated file. Instead of doing a diff against
two unpacked tar.gz archives, developer against a git checkout,
and use GIT to produce the patch without the auto-generated
cruft.

> diff -uNrp libvirt-0.9.13.orig/include/libvirt/libvirt.h.in libvirt-0.9.13/include/libvirt/libvirt.h.in
> --- libvirt-0.9.13.orig/include/libvirt/libvirt.h.in	2012-06-25 21:42:32.000000000 +0900
> +++ libvirt-0.9.13/include/libvirt/libvirt.h.in	2012-06-29 11:22:38.113455058 +0900
> @@ -4132,6 +4132,9 @@ typedef struct _virTypedParameter virMem
>   */
>  typedef virMemoryParameter *virMemoryParameterPtr;
>  
> +int virDomainQemuAgentCommand(virDomainPtr domain, const char *cmd,
> +                              char **result, unsigned int flags);
> +
>  #ifdef __cplusplus
>  }
>  #endif


This should be in libvirt-qemu.h



> diff -uNrp libvirt-0.9.13.orig/src/libvirt.c libvirt-0.9.13/src/libvirt.c
> --- libvirt-0.9.13.orig/src/libvirt.c	2012-06-28 12:05:04.000000000 +0900
> +++ libvirt-0.9.13/src/libvirt.c	2012-06-29 12:51:51.336454508 +0900
> @@ -18973,3 +18973,44 @@ error:
>      virDispatchError(dom->conn);
>      return -1;
>  }
> +
> +/**
> + * virDomainQemuAgentCommand:
> + * @domain: a domain object
> + * @cmd: execution command on domain's guest agent
> + * @result: returning strings
> + * @flags: execution flags
> + *
> + * Provide a list of Guest Agent's support command.
> + * Returns 0 if succeeded, -1 in failing.
> + */
> +int
> +virDomainQemuAgentCommand(virDomainPtr domain,
> +                          const char *cmd,
> +                          char **result,
> +                          unsigned int flags)
> +{
> +    virConnectPtr conn;
> +    int ret = -1;
> +
> +    if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
> +        virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
> +        return ret;
> +    }
> +
> +    conn = domain->conn;
> +
> +    if (conn->driver->domainQemuAgentCommand) {
> +        ret = conn->driver->domainQemuAgentCommand(domain, cmd, result, flags);
> +        if (ret < 0)
> +            goto error;
> +        return ret;
> +    }
> +
> +    virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
> +
> +error:
> +    /* Copy to connection error object for back compatability */
> +    virDispatchError(domain->conn);
> +    return ret;
> +}

Should be in libvirt-qemu.c


> diff -uNrp libvirt-0.9.13.orig/src/libvirt_public.syms libvirt-0.9.13/src/libvirt_public.syms
> --- libvirt-0.9.13.orig/src/libvirt_public.syms	2012-06-25 16:06:18.000000000 +0900
> +++ libvirt-0.9.13/src/libvirt_public.syms	2012-06-29 09:07:00.357580129 +0900
> @@ -542,6 +542,7 @@ LIBVIRT_0.9.13 {
>          virDomainSnapshotIsCurrent;
>          virDomainSnapshotListAllChildren;
>          virDomainSnapshotRef;
> +        virDomainQemuAgentCommand;
>  } LIBVIRT_0.9.11;
>  


Should be in libvirt_qemu.syms

>  static virNetworkDriver network_driver = {
> diff -uNrp libvirt-0.9.13.orig/src/remote/remote_protocol.x libvirt-0.9.13/src/remote/remote_protocol.x
> --- libvirt-0.9.13.orig/src/remote/remote_protocol.x	2012-06-25 16:06:18.000000000 +0900
> +++ libvirt-0.9.13/src/remote/remote_protocol.x	2012-06-29 12:55:43.752580212 +0900
> @@ -2513,6 +2513,16 @@ struct remote_connect_list_all_domains_r
>      unsigned int ret;
>  };
>  
> +struct remote_domain_qemu_agent_command_args {
> +    remote_nonnull_domain dom;
> +    remote_nonnull_string cmd;
> +    u_int flags;
> +};
> +
> +struct remote_domain_qemu_agent_command_ret {
> +    remote_nonnull_string result;
> +};
> +
>  
>  /*----- Protocol. -----*/
>  
> @@ -2838,7 +2848,8 @@ enum remote_procedure {
>      REMOTE_PROC_DOMAIN_SNAPSHOT_HAS_METADATA = 272, /* autogen autogen */
>      REMOTE_PROC_CONNECT_LIST_ALL_DOMAINS = 273, /* skipgen skipgen priority:high */
>      REMOTE_PROC_DOMAIN_LIST_ALL_SNAPSHOTS = 274, /* skipgen skipgen priority:high */
> -    REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_ALL_CHILDREN = 275 /* skipgen skipgen priority:high */
> +    REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_ALL_CHILDREN = 275, /* skipgen skipgen priority:high */
> +    REMOTE_PROC_DOMAIN_QEMU_AGENT_COMMAND = 276 /* skipgen skipgen */
>  
>      /*
>       * Notice how the entries are grouped in sets of 10 ?


This should bein  qemu_protocol.x

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]