[PATCHv2 2/5] remote: protocol implementation for virDomainCreateWithFlags

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

 



Define the wire format for the new virDomainCreateWithFlags
API, and implement client and server side of marshaling code.

* daemon/remote.c (remoteDispatchDomainCreateWithFlags): Add
server side dispatch for virDomainCreateWithFlags.
* src/remote/remote_driver.c (remoteDomainCreateWithFlags)
(remote_driver): Client side serialization.
* src/remote/remote_protocol.x
(remote_domain_create_with_flags_args)
(remote_domain_create_with_flags_ret)
(REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS): Define wire format.
* daemon/remote_dispatch_args.h: Regenerate.
* daemon/remote_dispatch_prototypes.h: Likewise.
* daemon/remote_dispatch_table.h: Likewise.
* src/remote/remote_protocol.c: Likewise.
* src/remote/remote_protocol.h: Likewise.
* src/remote_protocol-structs: Likewise.
---

diff from v1: use right type in .x, then rerun 'make rpcgen'.

 daemon/remote.c                     |   27 +++++++++++++++++++++++++++
 daemon/remote_dispatch_args.h       |    1 +
 daemon/remote_dispatch_prototypes.h |    8 ++++++++
 daemon/remote_dispatch_ret.h        |    1 +
 daemon/remote_dispatch_table.h      |    5 +++++
 src/remote/remote_driver.c          |   34 +++++++++++++++++++++++++++++++++-
 src/remote/remote_protocol.c        |   20 ++++++++++++++++++++
 src/remote/remote_protocol.h        |   16 ++++++++++++++++
 src/remote/remote_protocol.x        |   14 ++++++++++++--
 src/remote_protocol-structs         |    7 +++++++
 10 files changed, 130 insertions(+), 3 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index c54565c..88a5494 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -1213,6 +1213,33 @@ remoteDispatchDomainCreate (struct qemud_server *server ATTRIBUTE_UNUSED,
 }

 static int
+remoteDispatchDomainCreateWithFlags (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_create_with_flags_args *args,
+                                     remote_domain_create_with_flags_ret *ret)
+{
+    virDomainPtr dom;
+
+    dom = get_nonnull_domain (conn, args->dom);
+    if (dom == NULL) {
+        remoteDispatchConnError(rerr, conn);
+        return -1;
+    }
+
+    if (virDomainCreateWithFlags (dom, args->flags) == -1) {
+        virDomainFree(dom);
+        remoteDispatchConnError(rerr, conn);
+        return -1;
+    }
+    ret->dom.id = dom->id;
+    virDomainFree(dom);
+    return 0;
+}
+
+static int
 remoteDispatchDomainCreateXml (struct qemud_server *server ATTRIBUTE_UNUSED,
                                struct qemud_client *client ATTRIBUTE_UNUSED,
                                virConnectPtr conn,
diff --git a/daemon/remote_dispatch_args.h b/daemon/remote_dispatch_args.h
index b0c52d2..ee95043 100644
--- a/daemon/remote_dispatch_args.h
+++ b/daemon/remote_dispatch_args.h
@@ -164,3 +164,4 @@
     remote_domain_revert_to_snapshot_args val_remote_domain_revert_to_snapshot_args;
     remote_domain_snapshot_delete_args val_remote_domain_snapshot_delete_args;
     remote_domain_get_block_info_args val_remote_domain_get_block_info_args;
+    remote_domain_create_with_flags_args val_remote_domain_create_with_flags_args;
diff --git a/daemon/remote_dispatch_prototypes.h b/daemon/remote_dispatch_prototypes.h
index 79d1eec..cf1a0f9 100644
--- a/daemon/remote_dispatch_prototypes.h
+++ b/daemon/remote_dispatch_prototypes.h
@@ -122,6 +122,14 @@ static int remoteDispatchDomainCreate(
     remote_error *err,
     remote_domain_create_args *args,
     void *ret);
+static int remoteDispatchDomainCreateWithFlags(
+    struct qemud_server *server,
+    struct qemud_client *client,
+    virConnectPtr conn,
+    remote_message_header *hdr,
+    remote_error *err,
+    remote_domain_create_with_flags_args *args,
+    remote_domain_create_with_flags_ret *ret);
 static int remoteDispatchDomainCreateXml(
     struct qemud_server *server,
     struct qemud_client *client,
diff --git a/daemon/remote_dispatch_ret.h b/daemon/remote_dispatch_ret.h
index f9d6237..75ac0b2 100644
--- a/daemon/remote_dispatch_ret.h
+++ b/daemon/remote_dispatch_ret.h
@@ -134,3 +134,4 @@
     remote_domain_has_current_snapshot_ret val_remote_domain_has_current_snapshot_ret;
     remote_domain_snapshot_current_ret val_remote_domain_snapshot_current_ret;
     remote_domain_get_block_info_ret val_remote_domain_get_block_info_ret;
+    remote_domain_create_with_flags_ret val_remote_domain_create_with_flags_ret;
diff --git a/daemon/remote_dispatch_table.h b/daemon/remote_dispatch_table.h
index 86bd3b0..ef00edd 100644
--- a/daemon/remote_dispatch_table.h
+++ b/daemon/remote_dispatch_table.h
@@ -982,3 +982,8 @@
     .args_filter = (xdrproc_t) xdr_void,
     .ret_filter = (xdrproc_t) xdr_void,
 },
+{   /* DomainCreateWithFlags => 196 */
+    .fn = (dispatch_fn) remoteDispatchDomainCreateWithFlags,
+    .args_filter = (xdrproc_t) xdr_remote_domain_create_with_flags_args,
+    .ret_filter = (xdrproc_t) xdr_remote_domain_create_with_flags_ret,
+},
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 3f37cc8..7052bf1 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -3036,6 +3036,38 @@ done:
     return rv;
 }

+static int
+remoteDomainCreateWithFlags (virDomainPtr domain, unsigned int flags)
+{
+    int rv = -1;
+    remote_domain_create_with_flags_args args;
+    remote_domain_create_with_flags_ret ret;
+    struct private_data *priv = domain->conn->privateData;
+
+    remoteDriverLock(priv);
+
+    make_nonnull_domain (&args.dom, domain);
+    args.flags = flags;
+
+    memset (&ret, 0, sizeof ret);
+    if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS,
+              (xdrproc_t) xdr_remote_domain_create_with_flags_args,
+              (char *) &args,
+              (xdrproc_t) xdr_remote_domain_create_with_flags_ret,
+              (char *) &ret) == -1)
+        goto done;
+
+    domain->id = ret.dom.id;
+    xdr_free ((xdrproc_t) &xdr_remote_domain_create_with_flags_ret,
+              (char *) &ret);
+
+    rv = 0;
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
 static virDomainPtr
 remoteDomainDefineXML (virConnectPtr conn, const char *xml)
 {
@@ -10215,7 +10247,7 @@ static virDriver remote_driver = {
     remoteListDefinedDomains, /* listDefinedDomains */
     remoteNumOfDefinedDomains, /* numOfDefinedDomains */
     remoteDomainCreate, /* domainCreate */
-    NULL, /* domainCreateWithFlags */
+    remoteDomainCreateWithFlags, /* domainCreateWithFlags */
     remoteDomainDefineXML, /* domainDefineXML */
     remoteDomainUndefine, /* domainUndefine */
     remoteDomainAttachDevice, /* domainAttachDevice */
diff --git a/src/remote/remote_protocol.c b/src/remote/remote_protocol.c
index 972bf52..33bbac5 100644
--- a/src/remote/remote_protocol.c
+++ b/src/remote/remote_protocol.c
@@ -1203,6 +1203,26 @@ xdr_remote_domain_create_args (XDR *xdrs, remote_domain_create_args *objp)
 }

 bool_t
+xdr_remote_domain_create_with_flags_args (XDR *xdrs, remote_domain_create_with_flags_args *objp)
+{
+
+         if (!xdr_remote_nonnull_domain (xdrs, &objp->dom))
+                 return FALSE;
+         if (!xdr_u_int (xdrs, &objp->flags))
+                 return FALSE;
+        return TRUE;
+}
+
+bool_t
+xdr_remote_domain_create_with_flags_ret (XDR *xdrs, remote_domain_create_with_flags_ret *objp)
+{
+
+         if (!xdr_remote_nonnull_domain (xdrs, &objp->dom))
+                 return FALSE;
+        return TRUE;
+}
+
+bool_t
 xdr_remote_domain_define_xml_args (XDR *xdrs, remote_domain_define_xml_args *objp)
 {

diff --git a/src/remote/remote_protocol.h b/src/remote/remote_protocol.h
index a600af6..cf8e2cb 100644
--- a/src/remote/remote_protocol.h
+++ b/src/remote/remote_protocol.h
@@ -666,6 +666,17 @@ struct remote_domain_create_args {
 };
 typedef struct remote_domain_create_args remote_domain_create_args;

+struct remote_domain_create_with_flags_args {
+        remote_nonnull_domain dom;
+        u_int flags;
+};
+typedef struct remote_domain_create_with_flags_args remote_domain_create_with_flags_args;
+
+struct remote_domain_create_with_flags_ret {
+        remote_nonnull_domain dom;
+};
+typedef struct remote_domain_create_with_flags_ret remote_domain_create_with_flags_ret;
+
 struct remote_domain_define_xml_args {
         remote_nonnull_string xml;
 };
@@ -2215,6 +2226,7 @@ enum remote_procedure {
         REMOTE_PROC_DOMAIN_SNAPSHOT_DELETE = 193,
         REMOTE_PROC_DOMAIN_GET_BLOCK_INFO = 194,
         REMOTE_PROC_DOMAIN_EVENT_IO_ERROR_REASON = 195,
+        REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS = 196,
 };
 typedef enum remote_procedure remote_procedure;

@@ -2345,6 +2357,8 @@ extern  bool_t xdr_remote_list_defined_domains_args (XDR *, remote_list_defined_
 extern  bool_t xdr_remote_list_defined_domains_ret (XDR *, remote_list_defined_domains_ret*);
 extern  bool_t xdr_remote_num_of_defined_domains_ret (XDR *, remote_num_of_defined_domains_ret*);
 extern  bool_t xdr_remote_domain_create_args (XDR *, remote_domain_create_args*);
+extern  bool_t xdr_remote_domain_create_with_flags_args (XDR *, remote_domain_create_with_flags_args*);
+extern  bool_t xdr_remote_domain_create_with_flags_ret (XDR *, remote_domain_create_with_flags_ret*);
 extern  bool_t xdr_remote_domain_define_xml_args (XDR *, remote_domain_define_xml_args*);
 extern  bool_t xdr_remote_domain_define_xml_ret (XDR *, remote_domain_define_xml_ret*);
 extern  bool_t xdr_remote_domain_undefine_args (XDR *, remote_domain_undefine_args*);
@@ -2678,6 +2692,8 @@ extern bool_t xdr_remote_list_defined_domains_args ();
 extern bool_t xdr_remote_list_defined_domains_ret ();
 extern bool_t xdr_remote_num_of_defined_domains_ret ();
 extern bool_t xdr_remote_domain_create_args ();
+extern bool_t xdr_remote_domain_create_with_flags_args ();
+extern bool_t xdr_remote_domain_create_with_flags_ret ();
 extern bool_t xdr_remote_domain_define_xml_args ();
 extern bool_t xdr_remote_domain_define_xml_ret ();
 extern bool_t xdr_remote_domain_undefine_args ();
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 1ce488c..db412be 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -3,7 +3,7 @@
  *   remote_internal driver and libvirtd.  This protocol is
  *   internal and may change at any time.
  *
- * Copyright (C) 2006-2008 Red Hat, Inc.
+ * Copyright (C) 2006-2010 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -696,6 +696,15 @@ struct remote_domain_create_args {
     remote_nonnull_domain dom;
 };

+struct remote_domain_create_with_flags_args {
+    remote_nonnull_domain dom;
+    unsigned int flags;
+};
+
+struct remote_domain_create_with_flags_ret {
+    remote_nonnull_domain dom;
+};
+
 struct remote_domain_define_xml_args {
     remote_nonnull_string xml;
 };
@@ -2004,7 +2013,8 @@ enum remote_procedure {
     REMOTE_PROC_DOMAIN_REVERT_TO_SNAPSHOT = 192,
     REMOTE_PROC_DOMAIN_SNAPSHOT_DELETE = 193,
     REMOTE_PROC_DOMAIN_GET_BLOCK_INFO = 194,
-    REMOTE_PROC_DOMAIN_EVENT_IO_ERROR_REASON = 195
+    REMOTE_PROC_DOMAIN_EVENT_IO_ERROR_REASON = 195,
+    REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS = 196

     /*
      * Notice how the entries are grouped in sets of 10 ?
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index c8f81f3..2e67931 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -406,6 +406,13 @@ struct remote_num_of_defined_domains_ret {
 struct remote_domain_create_args {
 	remote_nonnull_domain      dom;
 };
+struct remote_domain_create_with_flags_args {
+	remote_nonnull_domain      dom;
+	int                        flags;
+};
+struct remote_domain_create_with_flags_ret {
+	remote_nonnull_domain      dom;
+};
 struct remote_domain_define_xml_args {
 	remote_nonnull_string      xml;
 };
-- 
1.7.0.1

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