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

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



On Fri, Apr 02, 2010 at 02:12:12PM -0600, Eric Blake wrote:
> On 04/02/2010 01:54 PM, Daniel Veillard wrote:
> > +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;
> > +}
> 
> Shouldn't this be able to return 1 in the case where
> virDomainHasManagedSaveImage returns 1?

  yes it's a bug, we need a real return value structure

> > +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;
> > +}
> 
> Likewise.

  Yup, I end up with the following change on top of the previous patch,

   thanks a lot !

Daniel


-- 
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/
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index f86c7f1..0374f9a 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -1657,6 +1657,10 @@ struct remote_domain_has_managed_save_image_args {
     unsigned flags;
 };
 
+struct remote_domain_has_managed_save_image_ret {
+    int ret;
+};
+
 struct remote_domain_managed_save_remove_args {
     remote_nonnull_domain dom;
     unsigned flags;
diff --git a/daemon/remote.c b/daemon/remote.c
index b708027..780d536 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -2448,7 +2448,7 @@ remoteDispatchDomainHasManagedSaveImage (struct qemud_server *server ATTRIBUTE_U
                                          remote_message_header *hdr ATTRIBUTE_UNUSED,
                                          remote_error *rerr,
                                          remote_domain_has_managed_save_image_args *args,
-                                         void *ret ATTRIBUTE_UNUSED)
+                                         remote_domain_has_managed_save_image_ret *ret)
 {
     virDomainPtr dom;
 
@@ -2458,7 +2458,8 @@ remoteDispatchDomainHasManagedSaveImage (struct qemud_server *server ATTRIBUTE_U
         return -1;
     }
 
-    if (virDomainHasManagedSaveImage (dom, args->flags) == -1) {
+    ret->ret = virDomainHasManagedSaveImage (dom, args->flags);
+    if (ret->ret == -1) {
         virDomainFree(dom);
         remoteDispatchConnError(rerr, conn);
         return -1;
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 47e9c7d..ede00e8 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -3645,6 +3645,7 @@ remoteDomainHasManagedSaveImage (virDomainPtr domain, unsigned int flags)
 {
     int rv = -1;
     remote_domain_has_managed_save_image_args args;
+    remote_domain_has_managed_save_image_ret ret;
     struct private_data *priv = domain->conn->privateData;
 
     remoteDriverLock(priv);
@@ -3654,10 +3655,10 @@ remoteDomainHasManagedSaveImage (virDomainPtr domain, unsigned int 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)
+              (xdrproc_t) xdr_remote_domain_has_managed_save_image_ret, (char *) &ret) == -1)
         goto done;
 
-    rv = 0;
+    rv = ret.ret;
 
 done:
     remoteDriverUnlock(priv);
diff --git a/daemon/remote_dispatch_prototypes.h b/daemon/remote_dispatch_prototypes.h
index 3671a26..c33c144 100644
--- a/daemon/remote_dispatch_prototypes.h
+++ b/daemon/remote_dispatch_prototypes.h
@@ -289,7 +289,7 @@ static int remoteDispatchDomainHasManagedSaveImage(
     remote_message_header *hdr,
     remote_error *err,
     remote_domain_has_managed_save_image_args *args,
-    void *ret);
+    remote_domain_has_managed_save_image_ret *ret);
 static int remoteDispatchDomainInterfaceStats(
     struct qemud_server *server,
     struct qemud_client *client,
diff --git a/daemon/remote_dispatch_ret.h b/daemon/remote_dispatch_ret.h
index b134f25..84f401b 100644
--- a/daemon/remote_dispatch_ret.h
+++ b/daemon/remote_dispatch_ret.h
@@ -125,3 +125,4 @@
     remote_num_of_nwfilters_ret val_remote_num_of_nwfilters_ret;
     remote_list_nwfilters_ret val_remote_list_nwfilters_ret;
     remote_nwfilter_define_xml_ret val_remote_nwfilter_define_xml_ret;
+    remote_domain_has_managed_save_image_ret val_remote_domain_has_managed_save_image_ret;
diff --git a/daemon/remote_dispatch_table.h b/daemon/remote_dispatch_table.h
index ac54f00..bda7af2 100644
--- a/daemon/remote_dispatch_table.h
+++ b/daemon/remote_dispatch_table.h
@@ -920,7 +920,7 @@
 {   /* DomainHasManagedSaveImage => 183 */
     .fn = (dispatch_fn) remoteDispatchDomainHasManagedSaveImage,
     .args_filter = (xdrproc_t) xdr_remote_domain_has_managed_save_image_args,
-    .ret_filter = (xdrproc_t) xdr_void,
+    .ret_filter = (xdrproc_t) xdr_remote_domain_has_managed_save_image_ret,
 },
 {   /* DomainManagedSaveRemove => 184 */
     .fn = (dispatch_fn) remoteDispatchDomainManagedSaveRemove,
diff --git a/src/remote/remote_protocol.c b/src/remote/remote_protocol.c
index 47a98e0..68b827a 100644
--- a/src/remote/remote_protocol.c
+++ b/src/remote/remote_protocol.c
@@ -3311,6 +3311,15 @@ xdr_remote_domain_has_managed_save_image_args (XDR *xdrs, remote_domain_has_mana
 }
 
 bool_t
+xdr_remote_domain_has_managed_save_image_ret (XDR *xdrs, remote_domain_has_managed_save_image_ret *objp)
+{
+
+         if (!xdr_int (xdrs, &objp->ret))
+                 return FALSE;
+        return TRUE;
+}
+
+bool_t
 xdr_remote_domain_managed_save_remove_args (XDR *xdrs, remote_domain_managed_save_remove_args *objp)
 {
 
diff --git a/src/remote/remote_protocol.h b/src/remote/remote_protocol.h
index 45dc652..6558948 100644
--- a/src/remote/remote_protocol.h
+++ b/src/remote/remote_protocol.h
@@ -1873,6 +1873,11 @@ struct remote_domain_has_managed_save_image_args {
 };
 typedef struct remote_domain_has_managed_save_image_args remote_domain_has_managed_save_image_args;
 
+struct remote_domain_has_managed_save_image_ret {
+        int ret;
+};
+typedef struct remote_domain_has_managed_save_image_ret remote_domain_has_managed_save_image_ret;
+
 struct remote_domain_managed_save_remove_args {
         remote_nonnull_domain dom;
         u_int flags;
@@ -2403,6 +2408,7 @@ extern  bool_t xdr_remote_domain_event_graphics_identity (XDR *, remote_domain_e
 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_has_managed_save_image_ret (XDR *, remote_domain_has_managed_save_image_ret*);
 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*);
@@ -2715,6 +2721,7 @@ 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_has_managed_save_image_ret ();
 extern bool_t xdr_remote_domain_managed_save_remove_args ();
 extern bool_t xdr_remote_procedure ();
 extern bool_t xdr_remote_message_type ();

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