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

Re: [libvirt] [PATCH 2/7] Add virDomainBlockPull support to the remote driver. The generator can handle DomainBlockPullAll and DomainBlockPullAbort. DomainBlockPull and DomainBlockPullInfo must be written by hand.



On 06/01/2011 12:13 PM, Matthias Bolte wrote:
> 2011/6/1 Adam Litke <agl us ibm com>:
> 
> This commit has a pretty long summary line.

Fixed.

>> * 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
>> * daemon/remote_generator.pl: Specify the manually-written functions
>>
>> Signed-off-by: Adam Litke <agl us ibm com>
>> ---
>>  daemon/remote.c              |   71 +++++++++++++++++++++++++++++++++++++++++
>>  daemon/remote_generator.pl   |    8 +++-
>>  src/remote/remote_driver.c   |   72 +++++++++++++++++++++++++++++++++++++++--
>>  src/remote/remote_protocol.x |   44 +++++++++++++++++++++++++-
>>  4 files changed, 188 insertions(+), 7 deletions(-)
>>
>> diff --git a/daemon/remote.c b/daemon/remote.c
>> index 2220655..f6aa78e 100644
>> --- a/daemon/remote.c
>> +++ b/daemon/remote.c
>> @@ -1692,6 +1692,77 @@ no_memory:
>>     goto cleanup;
>>  }
>>
>> +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->info.cur = tmp.cur;
>> +    ret->info.end = tmp.end;
>> +
>> +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->info.cur = tmp.cur;
>> +    ret->info.end = tmp.end;
>> +
>> +cleanup:
>> +    if (rv < 0)
>> +        remoteDispatchError(rerr);
>> +    if (dom)
>> +        virDomainFree(dom);
>> +    return rv;
>> +}
> 
> The generator should be able to deal with this. I might have to tweak
> it to handle multi-return-value procedures more general.

That would be excellent.  I am not doing anything particularly special.

>>  static int
>> diff --git a/daemon/remote_generator.pl b/daemon/remote_generator.pl
>> index 062ccc1..d7e0383 100755
>> --- a/daemon/remote_generator.pl
>> +++ b/daemon/remote_generator.pl
>> @@ -278,7 +278,9 @@ elsif ($opt_b) {
>>                           "GetType",
>>                           "NodeDeviceGetParent",
>>                           "NodeGetSecurityModel",
>> -                          "SecretGetValue");
>> +                          "SecretGetValue",
>> +                          "DomainBlockPull",
>> +                          "DomainGetBlockPullInfo");
>>     } elsif ($structprefix eq "qemu") {
>>         @ungeneratable = ("MonitorCommand");
>>     }
>> @@ -779,7 +781,9 @@ elsif ($opt_k) {
>>                           "GetType",
>>                           "NodeDeviceGetParent",
>>                           "NodeGetSecurityModel",
>> -                          "SecretGetValue");
>> +                          "SecretGetValue",
>> +                          "DomainBlockPull",
>> +                          "DomainGetBlockPullInfo");
>>     } elsif ($structprefix eq "qemu") {
>>         @ungeneratable = ("MonitorCommand");
>>     }
> 
> You need to rebase your series to git head as the generator has
> changed much recently.

Ok.  I will do that this afternoon.

>> diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
>> index 07bc629..0a885a9 100644
>> --- a/src/remote/remote_driver.c
>> +++ b/src/remote/remote_driver.c
>> @@ -2844,6 +2844,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.info.cur;
>> +        info->end = ret.info.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.info.cur;
>> +    info->end = ret.info.end;
>> +    rv = 0;
>> +
>> +done:
>> +    remoteDriverUnlock(priv);
>> +    return rv;
>> +}
> 
> This should be generatable as well.
> 
>>
>>  static virDrvOpenStatus ATTRIBUTE_NONNULL (1)
>> @@ -6493,10 +6557,10 @@ static virDriver remote_driver = {
>>     remoteDomainSnapshotDelete, /* domainSnapshotDelete */
>>     remoteQemuDomainMonitorCommand, /* qemuDomainMonitorCommand */
>>     remoteDomainOpenConsole, /* domainOpenConsole */
>> -    NULL, /* domainBlockPull */
>> -    NULL, /* domainBlockPullAll */
>> -    NULL, /* domainBlockPullAbort */
>> -    NULL, /* domainGetBlockPullInfo */
>> +    remoteDomainBlockPull, /* domainBlockPull */
>> +    remoteDomainBlockPullAll, /* domainBlockPullAll */
>> +    remoteDomainBlockPullAbort, /* domainBlockPullAbort */
>> +    remoteDomainGetBlockPullInfo, /* domainGetBlockPullInfo */
>>  };
> 
> Again, you need to rebase this, this was changed to named C99
> initializers recently. Yes, libvirt is a fast moving target :)
> 
>>  static virNetworkDriver network_driver = {
>> diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
>> index c706c36..2f52ceb 100644
>> --- a/src/remote/remote_protocol.x
>> +++ b/src/remote/remote_protocol.x
>> @@ -917,6 +917,43 @@ struct remote_domain_set_autostart_args {
>>     int autostart;
>>  };
>>
>> +struct remote_domain_block_pull_info {
>> +    unsigned hyper cur;
>> +    unsigned hyper end;
>> +};
>> +
>> +struct remote_domain_block_pull_args {
>> +    remote_nonnull_domain dom;
>> +    remote_nonnull_string path;
>> +    unsigned int flags;
>> +};
>> +
>> +struct remote_domain_block_pull_ret {
>> +    remote_domain_block_pull_info info;
>> +};
>> +
>> +struct remote_domain_block_pull_all_args {
>> +    remote_nonnull_domain dom;
>> +    remote_nonnull_string path;
>> +    unsigned int flags;
>> +};
>> +
>> +struct remote_domain_block_pull_abort_args {
>> +    remote_nonnull_domain dom;
>> +    remote_nonnull_string path;
>> +    unsigned int flags;
>> +};
>> +
>> +struct remote_domain_get_block_pull_info_args {
>> +    remote_nonnull_domain dom;
>> +    remote_nonnull_string path;
>> +    unsigned int flags;
>> +};
>> +
>> +struct remote_domain_get_block_pull_info_ret {
>> +    remote_domain_block_pull_info info;
>> +};
>> +
>>  /* Network calls: */
>>
>>  struct remote_num_of_networks_ret {
>> @@ -2176,7 +2213,12 @@ enum remote_procedure {
>>     REMOTE_PROC_DOMAIN_GET_BLKIO_PARAMETERS = 206,
>>     REMOTE_PROC_DOMAIN_MIGRATE_SET_MAX_SPEED = 207,
>>     REMOTE_PROC_STORAGE_VOL_UPLOAD = 208,
>> -    REMOTE_PROC_STORAGE_VOL_DOWNLOAD = 209
>> +    REMOTE_PROC_STORAGE_VOL_DOWNLOAD = 209,
>> +    REMOTE_PROC_DOMAIN_BLOCK_PULL = 210,
>> +
>> +    REMOTE_PROC_DOMAIN_BLOCK_PULL_ALL = 211,
>> +    REMOTE_PROC_DOMAIN_BLOCK_PULL_ABORT = 212,
>> +    REMOTE_PROC_DOMAIN_GET_BLOCK_PULL_INFO = 213
> 
> Annotations for the generator go here.

I am not sure what you mean by annotations for the generator.  Could you
explain further?

> I also miss corresponding updates to src/remote_protocol-structs.

Isn't this file generated from remote-protocol.x?  It seems to have
exactly the same information.

> Matthias

-- 
Adam Litke
IBM Linux Technology Center


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