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

[libvirt] [PATCH] [2/4] Implement remote protocol for managed save



* src/remote/remote_protocol.x src/remote/remote_protocol.h
  src/remote/remote_protocol.c src/remote/remote_driver.c: add the entry
  points in the remote driver
* daemon/remote.c daemon/remote_dispatch_args.h
  daemon/remote_dispatch_prototypes.h daemon/remote_dispatch_table.h:
  and implement the daemon counterpart

diff --git a/daemon/remote.c b/daemon/remote.c
index 67162d5..b708027 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -2416,6 +2416,84 @@ remoteDispatchListDomains (struct qemud_server *server ATTRIBUTE_UNUSED,
 }
 
 static int
+remoteDispatchDomainManagedSave (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_managed_save_args *args,
+                                 void *ret ATTRIBUTE_UNUSED)
+{
+    virDomainPtr dom;
+
+    dom = get_nonnull_domain (conn, args->dom);
+    if (dom == NULL) {
+        remoteDispatchConnError(rerr, conn);
+        return -1;
+    }
+
+    if (virDomainManagedSave (dom, args->flags) == -1) {
+        virDomainFree(dom);
+        remoteDispatchConnError(rerr, conn);
+        return -1;
+    }
+    virDomainFree(dom);
+    return 0;
+}
+
+static int
+remoteDispatchDomainHasManagedSaveImage (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_has_managed_save_image_args *args,
+                                         void *ret ATTRIBUTE_UNUSED)
+{
+    virDomainPtr dom;
+
+    dom = get_nonnull_domain (conn, args->dom);
+    if (dom == NULL) {
+        remoteDispatchConnError(rerr, conn);
+        return -1;
+    }
+
+    if (virDomainHasManagedSaveImage (dom, args->flags) == -1) {
+        virDomainFree(dom);
+        remoteDispatchConnError(rerr, conn);
+        return -1;
+    }
+    virDomainFree(dom);
+    return 0;
+}
+
+static int
+remoteDispatchDomainManagedSaveRemove (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_managed_save_remove_args *args,
+                                       void *ret ATTRIBUTE_UNUSED)
+{
+    virDomainPtr dom;
+
+    dom = get_nonnull_domain (conn, args->dom);
+    if (dom == NULL) {
+        remoteDispatchConnError(rerr, conn);
+        return -1;
+    }
+
+    if (virDomainManagedSaveRemove (dom, args->flags) == -1) {
+        virDomainFree(dom);
+        remoteDispatchConnError(rerr, conn);
+        return -1;
+    }
+    virDomainFree(dom);
+    return 0;
+}
+
+static int
 remoteDispatchListNetworks (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 b188e6e..51c1675 100644
--- a/daemon/remote_dispatch_args.h
+++ b/daemon/remote_dispatch_args.h
@@ -151,3 +151,6 @@
     remote_list_nwfilters_args val_remote_list_nwfilters_args;
     remote_nwfilter_define_xml_args val_remote_nwfilter_define_xml_args;
     remote_nwfilter_undefine_args val_remote_nwfilter_undefine_args;
+    remote_domain_managed_save_args val_remote_domain_managed_save_args;
+    remote_domain_has_managed_save_image_args val_remote_domain_has_managed_save_image_args;
+    remote_domain_managed_save_remove_args val_remote_domain_managed_save_remove_args;
diff --git a/daemon/remote_dispatch_prototypes.h b/daemon/remote_dispatch_prototypes.h
index e155c69..3671a26 100644
--- a/daemon/remote_dispatch_prototypes.h
+++ b/daemon/remote_dispatch_prototypes.h
@@ -282,6 +282,14 @@ static int remoteDispatchDomainGetVcpus(
     remote_error *err,
     remote_domain_get_vcpus_args *args,
     remote_domain_get_vcpus_ret *ret);
+static int remoteDispatchDomainHasManagedSaveImage(
+    struct qemud_server *server,
+    struct qemud_client *client,
+    virConnectPtr conn,
+    remote_message_header *hdr,
+    remote_error *err,
+    remote_domain_has_managed_save_image_args *args,
+    void *ret);
 static int remoteDispatchDomainInterfaceStats(
     struct qemud_server *server,
     struct qemud_client *client,
@@ -330,6 +338,22 @@ static int remoteDispatchDomainLookupByUuid(
     remote_error *err,
     remote_domain_lookup_by_uuid_args *args,
     remote_domain_lookup_by_uuid_ret *ret);
+static int remoteDispatchDomainManagedSave(
+    struct qemud_server *server,
+    struct qemud_client *client,
+    virConnectPtr conn,
+    remote_message_header *hdr,
+    remote_error *err,
+    remote_domain_managed_save_args *args,
+    void *ret);
+static int remoteDispatchDomainManagedSaveRemove(
+    struct qemud_server *server,
+    struct qemud_client *client,
+    virConnectPtr conn,
+    remote_message_header *hdr,
+    remote_error *err,
+    remote_domain_managed_save_remove_args *args,
+    void *ret);
 static int remoteDispatchDomainMemoryPeek(
     struct qemud_server *server,
     struct qemud_client *client,
diff --git a/daemon/remote_dispatch_table.h b/daemon/remote_dispatch_table.h
index 24756d7..ac54f00 100644
--- a/daemon/remote_dispatch_table.h
+++ b/daemon/remote_dispatch_table.h
@@ -912,3 +912,18 @@
     .args_filter = (xdrproc_t) xdr_remote_nwfilter_undefine_args,
     .ret_filter = (xdrproc_t) xdr_void,
 },
+{   /* DomainManagedSave => 182 */
+    .fn = (dispatch_fn) remoteDispatchDomainManagedSave,
+    .args_filter = (xdrproc_t) xdr_remote_domain_managed_save_args,
+    .ret_filter = (xdrproc_t) xdr_void,
+},
+{   /* DomainHasManagedSaveImage => 183 */
+    .fn = (dispatch_fn) remoteDispatchDomainHasManagedSaveImage,
+    .args_filter = (xdrproc_t) xdr_remote_domain_has_managed_save_image_args,
+    .ret_filter = (xdrproc_t) xdr_void,
+},
+{   /* DomainManagedSaveRemove => 184 */
+    .fn = (dispatch_fn) remoteDispatchDomainManagedSaveRemove,
+    .args_filter = (xdrproc_t) xdr_remote_domain_managed_save_remove_args,
+    .ret_filter = (xdrproc_t) xdr_void,
+},
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 9b500d0..47e9c7d 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -3616,6 +3616,78 @@ done:
     return rv;
 }
 
+static int
+remoteDomainManagedSave (virDomainPtr domain, unsigned int flags)
+{
+    int rv = -1;
+    remote_domain_managed_save_args args;
+    struct private_data *priv = domain->conn->privateData;
+
+    remoteDriverLock(priv);
+
+    make_nonnull_domain (&args.dom, domain);
+    args.flags = flags;
+
+    if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_MANAGED_SAVE,
+              (xdrproc_t) xdr_remote_domain_managed_save_args, (char *) &args,
+              (xdrproc_t) xdr_void, (char *) NULL) == -1)
+        goto done;
+
+    rv = 0;
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
+static int
+remoteDomainHasManagedSaveImage (virDomainPtr domain, unsigned int flags)
+{
+    int rv = -1;
+    remote_domain_has_managed_save_image_args args;
+    struct private_data *priv = domain->conn->privateData;
+
+    remoteDriverLock(priv);
+
+    make_nonnull_domain (&args.dom, domain);
+    args.flags = flags;
+
+    if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_HAS_MANAGED_SAVE_IMAGE,
+              (xdrproc_t) xdr_remote_domain_has_managed_save_image_args, (char *) &args,
+              (xdrproc_t) xdr_void, (char *) NULL) == -1)
+        goto done;
+
+    rv = 0;
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
+static int
+remoteDomainManagedSaveRemove (virDomainPtr domain, unsigned int flags)
+{
+    int rv = -1;
+    remote_domain_managed_save_remove_args args;
+    struct private_data *priv = domain->conn->privateData;
+
+    remoteDriverLock(priv);
+
+    make_nonnull_domain (&args.dom, domain);
+    args.flags = flags;
+
+    if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_MANAGED_SAVE_REMOVE,
+              (xdrproc_t) xdr_remote_domain_managed_save_remove_args, (char *) &args,
+              (xdrproc_t) xdr_void, (char *) NULL) == -1)
+        goto done;
+
+    rv = 0;
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
 /*----------------------------------------------------------------------*/
 
 static virDrvOpenStatus ATTRIBUTE_NONNULL (1)
@@ -9818,9 +9890,9 @@ static virDriver remote_driver = {
     remoteDomainMigrateSetMaxDowntime, /* domainMigrateSetMaxDowntime */
     remoteDomainEventRegisterAny, /* domainEventRegisterAny */
     remoteDomainEventDeregisterAny, /* domainEventDeregisterAny */
-    NULL, /* domainManagedSave */
-    NULL, /* domainHasManagedSaveImage */
-    NULL, /* domainManagedSaveRemove */
+    remoteDomainManagedSave, /* domainManagedSave */
+    remoteDomainHasManagedSaveImage, /* domainHasManagedSaveImage */
+    remoteDomainManagedSaveRemove, /* domainManagedSaveRemove */
 };
 
 static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.c b/src/remote/remote_protocol.c
index f252d85..47a98e0 100644
--- a/src/remote/remote_protocol.c
+++ b/src/remote/remote_protocol.c
@@ -3289,6 +3289,39 @@ xdr_remote_domain_event_graphics_msg (XDR *xdrs, remote_domain_event_graphics_ms
 }
 
 bool_t
+xdr_remote_domain_managed_save_args (XDR *xdrs, remote_domain_managed_save_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_has_managed_save_image_args (XDR *xdrs, remote_domain_has_managed_save_image_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_managed_save_remove_args (XDR *xdrs, remote_domain_managed_save_remove_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_procedure (XDR *xdrs, remote_procedure *objp)
 {
 
diff --git a/src/remote/remote_protocol.h b/src/remote/remote_protocol.h
index d898502..45dc652 100644
--- a/src/remote/remote_protocol.h
+++ b/src/remote/remote_protocol.h
@@ -1860,6 +1860,24 @@ struct remote_domain_event_graphics_msg {
         } subject;
 };
 typedef struct remote_domain_event_graphics_msg remote_domain_event_graphics_msg;
+
+struct remote_domain_managed_save_args {
+        remote_nonnull_domain dom;
+        u_int flags;
+};
+typedef struct remote_domain_managed_save_args remote_domain_managed_save_args;
+
+struct remote_domain_has_managed_save_image_args {
+        remote_nonnull_domain dom;
+        u_int flags;
+};
+typedef struct remote_domain_has_managed_save_image_args remote_domain_has_managed_save_image_args;
+
+struct remote_domain_managed_save_remove_args {
+        remote_nonnull_domain dom;
+        u_int flags;
+};
+typedef struct remote_domain_managed_save_remove_args remote_domain_managed_save_remove_args;
 #define REMOTE_PROGRAM 0x20008086
 #define REMOTE_PROTOCOL_VERSION 1
 
@@ -2045,6 +2063,9 @@ enum remote_procedure {
         REMOTE_PROC_LIST_NWFILTERS = 179,
         REMOTE_PROC_NWFILTER_DEFINE_XML = 180,
         REMOTE_PROC_NWFILTER_UNDEFINE = 181,
+        REMOTE_PROC_DOMAIN_MANAGED_SAVE = 182,
+        REMOTE_PROC_DOMAIN_HAS_MANAGED_SAVE_IMAGE = 183,
+        REMOTE_PROC_DOMAIN_MANAGED_SAVE_REMOVE = 184,
 };
 typedef enum remote_procedure remote_procedure;
 
@@ -2380,6 +2401,9 @@ extern  bool_t xdr_remote_domain_event_io_error_msg (XDR *, remote_domain_event_
 extern  bool_t xdr_remote_domain_event_graphics_address (XDR *, remote_domain_event_graphics_address*);
 extern  bool_t xdr_remote_domain_event_graphics_identity (XDR *, remote_domain_event_graphics_identity*);
 extern  bool_t xdr_remote_domain_event_graphics_msg (XDR *, remote_domain_event_graphics_msg*);
+extern  bool_t xdr_remote_domain_managed_save_args (XDR *, remote_domain_managed_save_args*);
+extern  bool_t xdr_remote_domain_has_managed_save_image_args (XDR *, remote_domain_has_managed_save_image_args*);
+extern  bool_t xdr_remote_domain_managed_save_remove_args (XDR *, remote_domain_managed_save_remove_args*);
 extern  bool_t xdr_remote_procedure (XDR *, remote_procedure*);
 extern  bool_t xdr_remote_message_type (XDR *, remote_message_type*);
 extern  bool_t xdr_remote_message_status (XDR *, remote_message_status*);
@@ -2689,6 +2713,9 @@ extern bool_t xdr_remote_domain_event_io_error_msg ();
 extern bool_t xdr_remote_domain_event_graphics_address ();
 extern bool_t xdr_remote_domain_event_graphics_identity ();
 extern bool_t xdr_remote_domain_event_graphics_msg ();
+extern bool_t xdr_remote_domain_managed_save_args ();
+extern bool_t xdr_remote_domain_has_managed_save_image_args ();
+extern bool_t xdr_remote_domain_managed_save_remove_args ();
 extern bool_t xdr_remote_procedure ();
 extern bool_t xdr_remote_message_type ();
 extern bool_t xdr_remote_message_status ();
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index bf87c33..f86c7f1 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -1647,6 +1647,21 @@ struct remote_domain_event_graphics_msg {
     remote_domain_event_graphics_identity subject<REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX>;
 };
 
+struct remote_domain_managed_save_args {
+    remote_nonnull_domain dom;
+    unsigned flags;
+};
+
+struct remote_domain_has_managed_save_image_args {
+    remote_nonnull_domain dom;
+    unsigned flags;
+};
+
+struct remote_domain_managed_save_remove_args {
+    remote_nonnull_domain dom;
+    unsigned flags;
+};
+
 /*----- Protocol. -----*/
 
 /* Define the program number, protocol version and procedure numbers here. */
@@ -1852,7 +1867,10 @@ enum remote_procedure {
     REMOTE_PROC_LIST_NWFILTERS = 179,
     REMOTE_PROC_NWFILTER_DEFINE_XML = 180,
 
-    REMOTE_PROC_NWFILTER_UNDEFINE = 181
+    REMOTE_PROC_NWFILTER_UNDEFINE = 181,
+    REMOTE_PROC_DOMAIN_MANAGED_SAVE = 182,
+    REMOTE_PROC_DOMAIN_HAS_MANAGED_SAVE_IMAGE = 183,
+    REMOTE_PROC_DOMAIN_MANAGED_SAVE_REMOVE = 184
 
     /*
      * Notice how the entries are grouped in sets of 10 ?

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/


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