* 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,
--
1.7.0.1