[libvirt] [PATCH 6/5] [RFC - don't use] remote: optimize remoteDomainCreate

Daniel P. Berrange berrange at redhat.com
Thu Jun 10 17:56:15 UTC 2010


On Thu, Jun 10, 2010 at 11:16:14AM -0600, Eric Blake wrote:
> * src/remote/remote_driver.c (remoteDomainCreate): Rewrite to take
> 1 RPC instead of 2 when talking to newer server, at expense of 3
> RPC instead of 2 for older server.
> ---
> 
> I had already started coding this, but then Daniel Berrange
> reminded me off-list that changing existing API just for a
> minor optimization in the number of RPC calls is not a good
> idea: clients (like virsh) are already free to do the optimization
> themselves, and libvirt RPC calls tend not to be the critical
> path in the system in the first place.
> 
> So, I'm posting this to have it archived, before nuking the
> commit from my repo.
> 
>  src/remote/remote_driver.c |   20 ++++++++++++++++++++
>  1 files changed, 20 insertions(+), 0 deletions(-)
> 
> diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
> index 7052bf1..a613ead 100644
> --- a/src/remote/remote_driver.c
> +++ b/src/remote/remote_driver.c
> @@ -3001,6 +3001,8 @@ static int
>  remoteDomainCreate (virDomainPtr domain)
>  {
>      int rv = -1;
> +    remote_domain_create_with_flags_args args0;
> +    remote_domain_create_with_flags_ret ret0;
>      remote_domain_create_args args;
>      remote_domain_lookup_by_uuid_args args2;
>      remote_domain_lookup_by_uuid_ret ret2;
> @@ -3008,6 +3010,24 @@ remoteDomainCreate (virDomainPtr domain)
> 
>      remoteDriverLock(priv);
> 
> +    /* First, try the newer API, for fewer call()s.  */
> +    make_nonnull_domain (&args0.dom, domain);
> +    args0.flags = 0;
> +
> +    memset (&ret0, 0, sizeof ret0);
> +    if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS,
> +              (xdrproc_t) xdr_remote_domain_create_with_flags_args,
> +              (char *) &args0,
> +              (xdrproc_t) xdr_remote_domain_create_with_flags_ret,
> +              (char *) &ret0) == 0) {
> +        domain->id = ret0.dom.id;
> +        xdr_free ((xdrproc_t) &xdr_remote_domain_create_with_flags_ret,
> +                  (char *) &ret0);
> +        rv = 0;
> +        goto done;
> +    }
> +
> +    /* Fall back to the older 2-call sequence.  */
>      make_nonnull_domain (&args.dom, domain);
> 
>      if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_CREATE,

NACK, this is not required. The existing method is guarenteed to always
exist, so there is no benefit to calling the new method & it adds an
extra RPC call when talking to old servers


Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list