[libvirt] [PATCH 3/8] Add virDomainBlockPull support to the remote driver

Daniel P. Berrange berrange at redhat.com
Tue Jun 14 09:49:58 UTC 2011


On Thu, Jun 09, 2011 at 12:10:09PM -0500, Adam Litke wrote:
> The generator can handle DomainBlockPullAll and DomainBlockPullAbort.
> DomainBlockPull and DomainBlockPullInfo must be written by hand.
> 
> * src/remote/remote_protocol.x: provide defines for the new entry points
> * src/remote/remote_driver.c daemon/remote.c: implement the client and
>   server side
> * src/remote_protocol-structs: structure definitions for protocol verification
> 
> Signed-off-by: Adam Litke <agl at us.ibm.com>
> ---
>  daemon/remote.c              |   71 ++++++++++++++++++++++++++++++++++++++++++
>  src/remote/remote_driver.c   |   68 ++++++++++++++++++++++++++++++++++++++++
>  src/remote/remote_protocol.x |   40 +++++++++++++++++++++++-
>  src/remote_protocol-structs  |   28 ++++++++++++++++
>  4 files changed, 206 insertions(+), 1 deletions(-)
> 
> diff --git a/daemon/remote.c b/daemon/remote.c
> index 49058f2..e0b681c 100644
> --- a/daemon/remote.c
> +++ b/daemon/remote.c
> @@ -1474,6 +1474,77 @@ cleanup:
>      return rv;
>  }
>  
> +static int
> +remoteDispatchDomainBlockPull(struct qemud_server *server ATTRIBUTE_UNUSED,
> +                              struct qemud_client *client ATTRIBUTE_UNUSED,
> +                              virConnectPtr conn,
> +                              remote_message_header *hdr ATTRIBUTE_UNUSED,
> +                              remote_error * rerr,
> +                              remote_domain_block_pull_args *args,
> +                              remote_domain_block_pull_ret *ret)
> +{
> +    virDomainPtr dom = NULL;
> +    virDomainBlockPullInfo tmp;
> +    int rv = -1;
> +
> +    if (!conn) {
> +        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
> +        goto cleanup;
> +    }
> +
> +    if (!(dom = get_nonnull_domain(conn, args->dom)))
> +        goto cleanup;
> +
> +    if (virDomainBlockPull(dom, args->path, &tmp, args->flags) < 0)
> +        goto cleanup;
> +    rv = 0;
> +    ret->cur = tmp.cur;
> +    ret->end = tmp.end;

'rv = 0' should really be the last statement before the cleanup
label. Likewise for next method.

> +
> +cleanup:
> +    if (rv < 0)
> +        remoteDispatchError(rerr);
> +    if (dom)
> +        virDomainFree(dom);
> +    return rv;
> +}
> +
> +static int
> +remoteDispatchDomainGetBlockPullInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
> +                                     struct qemud_client *client ATTRIBUTE_UNUSED,
> +                                     virConnectPtr conn,
> +                                     remote_message_header *hdr ATTRIBUTE_UNUSED,
> +                                     remote_error * rerr,
> +                                     remote_domain_get_block_pull_info_args *args,
> +                                     remote_domain_get_block_pull_info_ret *ret)
> +{
> +    virDomainPtr dom = NULL;
> +    virDomainBlockPullInfo tmp;
> +    int rv = -1;
> +
> +    if (!conn) {
> +        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
> +        goto cleanup;
> +    }
> +
> +    if (!(dom = get_nonnull_domain(conn, args->dom)))
> +        goto cleanup;
> +
> +    if (virDomainGetBlockPullInfo(dom, args->path, &tmp, args->flags) < 0)
> +        goto cleanup;
> +    rv = 0;
> +    ret->cur = tmp.cur;
> +    ret->end = tmp.end;
> +
> +cleanup:
> +    if (rv < 0)
> +        remoteDispatchError(rerr);
> +    if (dom)
> +        virDomainFree(dom);
> +    return rv;
> +}
> +
> +
>  /*-------------------------------------------------------------*/
>  
>  static int
> diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
> index 8335a1a..de9359d 100644
> --- a/src/remote/remote_driver.c
> +++ b/src/remote/remote_driver.c
> @@ -2509,6 +2509,70 @@ done:
>      return rv;
>  }
>  
> +static int remoteDomainBlockPull(virDomainPtr domain,
> +                                 const char *path,
> +                                 virDomainBlockPullInfoPtr info,
> +                                 unsigned int flags)
> +{
> +    int rv = -1;
> +    remote_domain_block_pull_args args;
> +    remote_domain_block_pull_ret ret;
> +    struct private_data *priv = domain->conn->privateData;
> +
> +    remoteDriverLock(priv);
> +
> +    make_nonnull_domain(&args.dom, domain);
> +    args.path = (char *)path;
> +    args.flags = flags;
> +
> +    if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_BLOCK_PULL,
> +             (xdrproc_t)xdr_remote_domain_block_pull_args, (char *)&args,
> +             (xdrproc_t)xdr_remote_domain_block_pull_ret, (char *)&ret) == -1)
> +        goto done;
> +
> +    if (info) {
> +        info->cur = ret.cur;
> +        info->end = ret.end;
> +    }
> +    rv = 0;
> +
> +done:
> +    remoteDriverUnlock(priv);
> +    return rv;
> +}
> +
> +static int remoteDomainGetBlockPullInfo(virDomainPtr domain,
> +                                        const char *path,
> +                                        virDomainBlockPullInfoPtr info,
> +                                        unsigned int flags)
> +{
> +    int rv = -1;
> +    remote_domain_get_block_pull_info_args args;
> +    remote_domain_get_block_pull_info_ret ret;
> +    struct private_data *priv = domain->conn->privateData;
> +
> +    remoteDriverLock(priv);
> +
> +    make_nonnull_domain(&args.dom, domain);
> +    args.path = (char *)path;
> +    args.flags = flags;
> +
> +    if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_BLOCK_PULL_INFO,
> +             (xdrproc_t)xdr_remote_domain_get_block_pull_info_args,
> +               (char *)&args,
> +             (xdrproc_t)xdr_remote_domain_get_block_pull_info_ret,
> +               (char *)&ret) == -1)
> +        goto done;
> +
> +    info->cur = ret.cur;
> +    info->end = ret.end;
> +    rv = 0;
> +
> +done:
> +    remoteDriverUnlock(priv);
> +    return rv;
> +}
> +
>  /*----------------------------------------------------------------------*/
>  
>  static virDrvOpenStatus ATTRIBUTE_NONNULL (1)
> @@ -6337,6 +6401,10 @@ static virDriver remote_driver = {
>      .domainMigratePerform3 = remoteDomainMigratePerform3, /* 0.9.2 */
>      .domainMigrateFinish3 = remoteDomainMigrateFinish3, /* 0.9.2 */
>      .domainMigrateConfirm3 = remoteDomainMigrateConfirm3, /* 0.9.2 */
> +    .domainBlockPull = remoteDomainBlockPull, /* 0.9.2 */
> +    .domainBlockPullAll = remoteDomainBlockPullAll, /* 0.9.2 */
> +    .domainBlockPullAbort = remoteDomainBlockPullAbort, /* 0.9.2 */
> +    .domainGetBlockPullInfo = remoteDomainGetBlockPullInfo, /* 0.9.2 */
>  };

These need updating to 0.9.3


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 :|




More information about the libvir-list mailing list