Re: [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.

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

 



2011/6/1 Adam Litke <agl@xxxxxxxxxx>:

This commit has a pretty long summary line.

> * 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@xxxxxxxxxx>
> ---
> Â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.

>
> Â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.

> 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 also miss corresponding updates to src/remote_protocol-structs.

Matthias

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