[libvirt] [PATCH 12/15] Cleanup remote protocol definitions

Daniel P. Berrange berrange at redhat.com
Thu Dec 16 11:22:04 UTC 2010


The standard remote protocol for libvirtd no longer needs to
include definitions of the generic message header/error structs
or status codes. This is all defined in the generic RPC protocol

* src/remote/remote_protocol.x: Remove all RPC message definitions
* src/remote/remote_protocol.h, src/remote/remote_protocol.c:
  Re-generate
* daemon/remote_generate_stubs.pl: Delete obsolete script
---
 src/remote/remote_protocol.c |   85 -------------------------------
 src/remote/remote_protocol.h |   35 -------------
 src/remote/remote_protocol.x |  114 ------------------------------------------
 3 files changed, 0 insertions(+), 234 deletions(-)

diff --git a/src/remote/remote_protocol.c b/src/remote/remote_protocol.c
index 6e07b70..a88439c 100644
--- a/src/remote/remote_protocol.c
+++ b/src/remote/remote_protocol.c
@@ -3747,88 +3747,3 @@ xdr_remote_procedure (XDR *xdrs, remote_procedure *objp)
                  return FALSE;
         return TRUE;
 }
-
-bool_t
-xdr_remote_message_type (XDR *xdrs, remote_message_type *objp)
-{
-
-         if (!xdr_enum (xdrs, (enum_t *) objp))
-                 return FALSE;
-        return TRUE;
-}
-
-bool_t
-xdr_remote_message_status (XDR *xdrs, remote_message_status *objp)
-{
-
-         if (!xdr_enum (xdrs, (enum_t *) objp))
-                 return FALSE;
-        return TRUE;
-}
-
-bool_t
-xdr_remote_message_header (XDR *xdrs, remote_message_header *objp)
-{
-        register int32_t *buf;
-
-
-        if (xdrs->x_op == XDR_ENCODE) {
-                buf = (int32_t*)XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT);
-                if (buf == NULL) {
-                         if (!xdr_u_int (xdrs, &objp->prog))
-                                 return FALSE;
-                         if (!xdr_u_int (xdrs, &objp->vers))
-                                 return FALSE;
-                         if (!xdr_int (xdrs, &objp->proc))
-                                 return FALSE;
-
-                } else {
-                (void)IXDR_PUT_U_INT32(buf, objp->prog);
-                (void)IXDR_PUT_U_INT32(buf, objp->vers);
-                (void)IXDR_PUT_INT32(buf, objp->proc);
-                }
-                 if (!xdr_remote_message_type (xdrs, &objp->type))
-                         return FALSE;
-                 if (!xdr_u_int (xdrs, &objp->serial))
-                         return FALSE;
-                 if (!xdr_remote_message_status (xdrs, &objp->status))
-                         return FALSE;
-                return TRUE;
-        } else if (xdrs->x_op == XDR_DECODE) {
-                buf = (int32_t*)XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT);
-                if (buf == NULL) {
-                         if (!xdr_u_int (xdrs, &objp->prog))
-                                 return FALSE;
-                         if (!xdr_u_int (xdrs, &objp->vers))
-                                 return FALSE;
-                         if (!xdr_int (xdrs, &objp->proc))
-                                 return FALSE;
-
-                } else {
-                objp->prog = IXDR_GET_U_LONG(buf);
-                objp->vers = IXDR_GET_U_LONG(buf);
-                objp->proc = IXDR_GET_INT32(buf);
-                }
-                 if (!xdr_remote_message_type (xdrs, &objp->type))
-                         return FALSE;
-                 if (!xdr_u_int (xdrs, &objp->serial))
-                         return FALSE;
-                 if (!xdr_remote_message_status (xdrs, &objp->status))
-                         return FALSE;
-         return TRUE;
-        }
-
-         if (!xdr_u_int (xdrs, &objp->prog))
-                 return FALSE;
-         if (!xdr_u_int (xdrs, &objp->vers))
-                 return FALSE;
-         if (!xdr_int (xdrs, &objp->proc))
-                 return FALSE;
-         if (!xdr_remote_message_type (xdrs, &objp->type))
-                 return FALSE;
-         if (!xdr_u_int (xdrs, &objp->serial))
-                 return FALSE;
-         if (!xdr_remote_message_status (xdrs, &objp->status))
-                 return FALSE;
-        return TRUE;
-}
diff --git a/src/remote/remote_protocol.h b/src/remote/remote_protocol.h
index 4240963..bbff882 100644
--- a/src/remote/remote_protocol.h
+++ b/src/remote/remote_protocol.h
@@ -30,9 +30,6 @@ extern "C" {
 #ifndef IXDR_GET_U_INT32
 # define IXDR_GET_U_INT32 IXDR_GET_U_LONG
 #endif
-#define REMOTE_MESSAGE_MAX 262144
-#define REMOTE_MESSAGE_HEADER_MAX 24
-#define REMOTE_MESSAGE_PAYLOAD_MAX 262120
 #define REMOTE_STRING_MAX 65536
 
 typedef char *remote_nonnull_string;
@@ -2323,32 +2320,6 @@ enum remote_procedure {
 };
 typedef enum remote_procedure remote_procedure;
 
-enum remote_message_type {
-        REMOTE_CALL = 0,
-        REMOTE_REPLY = 1,
-        REMOTE_MESSAGE = 2,
-        REMOTE_STREAM = 3,
-};
-typedef enum remote_message_type remote_message_type;
-
-enum remote_message_status {
-        REMOTE_OK = 0,
-        REMOTE_ERROR = 1,
-        REMOTE_CONTINUE = 2,
-};
-typedef enum remote_message_status remote_message_status;
-#define REMOTE_MESSAGE_HEADER_XDR_LEN 4
-
-struct remote_message_header {
-        u_int prog;
-        u_int vers;
-        int proc;
-        remote_message_type type;
-        u_int serial;
-        remote_message_status status;
-};
-typedef struct remote_message_header remote_message_header;
-
 /* the xdr functions */
 
 #if defined(__STDC__) || defined(__cplusplus)
@@ -2693,9 +2664,6 @@ extern  bool_t xdr_remote_domain_revert_to_snapshot_args (XDR *, remote_domain_r
 extern  bool_t xdr_remote_domain_snapshot_delete_args (XDR *, remote_domain_snapshot_delete_args*);
 extern  bool_t xdr_remote_domain_open_console_args (XDR *, remote_domain_open_console_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*);
-extern  bool_t xdr_remote_message_header (XDR *, remote_message_header*);
 
 #else /* K&R C */
 extern bool_t xdr_remote_nonnull_string ();
@@ -3039,9 +3007,6 @@ extern bool_t xdr_remote_domain_revert_to_snapshot_args ();
 extern bool_t xdr_remote_domain_snapshot_delete_args ();
 extern bool_t xdr_remote_domain_open_console_args ();
 extern bool_t xdr_remote_procedure ();
-extern bool_t xdr_remote_message_type ();
-extern bool_t xdr_remote_message_status ();
-extern bool_t xdr_remote_message_header ();
 
 #endif /* K&R C */
 
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index e1981fd..733a460 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -60,15 +60,6 @@
 
 /*----- Data types. -----*/
 
-/* Maximum total message size (serialised). */
-const REMOTE_MESSAGE_MAX = 262144;
-
-/* Size of struct remote_message_header (serialized)*/
-const REMOTE_MESSAGE_HEADER_MAX = 24;
-
-/* Size of message payload */
-const REMOTE_MESSAGE_PAYLOAD_MAX = 262120;
-
 /* Length of long, but not unbounded, strings.
  * This is an arbitrary limit designed to stop the decoder from trying
  * to allocate unbounded amounts of memory when fed with a bad message.
@@ -2102,108 +2093,3 @@ enum remote_procedure {
      */
 };
 
-/*
- * RPC wire format
- *
- * Each message consists of:
- *
- *    Name    | Type                  | Description
- * -----------+-----------------------+------------------
- *    Length  | int                   | Total number of bytes in message _including_ length.
- *    Header  | remote_message_header | Control information about procedure call
- *    Payload | -                     | Variable payload data per procedure
- *
- * In header, the 'serial' field varies according to:
- *
- *  - type == REMOTE_CALL
- *      * serial is set by client, incrementing by 1 each time
- *
- *  - type == REMOTE_REPLY
- *      * serial matches that from the corresponding REMOTE_CALL
- *
- *  - type == REMOTE_MESSAGE
- *      * serial is always zero
- *
- *  - type == REMOTE_STREAM
- *      * serial matches that from the corresponding REMOTE_CALL
- *
- * and the 'status' field varies according to:
- *
- *  - type == REMOTE_CALL
- *     * REMOTE_OK always
- *
- *  - type == REMOTE_REPLY
- *     * REMOTE_OK if RPC finished successfully
- *     * REMOTE_ERROR if something failed
- *
- *  - type == REMOTE_MESSAGE
- *     * REMOTE_OK always
- *
- *  - type == REMOTE_STREAM
- *     * REMOTE_CONTINUE if more data is following
- *     * REMOTE_OK if stream is complete
- *     * REMOTE_ERROR if stream had an error
- *
- * Payload varies according to type and status:
- *
- *  - type == REMOTE_CALL
- *          XXX_args  for procedure
- *
- *  - type == REMOTE_REPLY
- *     * status == REMOTE_OK
- *          XXX_ret         for procedure
- *     * status == REMOTE_ERROR
- *          remote_error    Error information
- *
- *  - type == REMOTE_MESSAGE
- *     * status == REMOTE_OK
- *          XXX_args        for procedure
- *     * status == REMOTE_ERROR
- *          remote_error    Error information
- *
- *  - type == REMOTE_STREAM
- *     * status == REMOTE_CONTINUE
- *          byte[]       raw stream data
- *     * status == REMOTE_ERROR
- *          remote_error error information
- *     * status == REMOTE_OK
- *          <empty>
- */
-enum remote_message_type {
-    /* client -> server. args from a method call */
-    REMOTE_CALL = 0,
-    /* server -> client. reply/error from a method call */
-    REMOTE_REPLY = 1,
-    /* either direction. async notification */
-    REMOTE_MESSAGE = 2,
-    /* either direction. stream data packet */
-    REMOTE_STREAM = 3
-};
-
-enum remote_message_status {
-    /* Status is always REMOTE_OK for calls.
-     * For replies, indicates no error.
-     */
-    REMOTE_OK = 0,
-
-    /* For replies, indicates that an error happened, and a struct
-     * remote_error follows.
-     */
-    REMOTE_ERROR = 1,
-
-    /* For streams, indicates that more data is still expected
-     */
-    REMOTE_CONTINUE = 2
-};
-
-/* 4 byte length word per header */
-const REMOTE_MESSAGE_HEADER_XDR_LEN = 4;
-
-struct remote_message_header {
-    unsigned prog;              /* REMOTE_PROGRAM */
-    unsigned vers;              /* REMOTE_PROTOCOL_VERSION */
-    int proc;      /* REMOTE_PROC_x */
-    remote_message_type type;
-    unsigned serial;            /* Serial number of message. */
-    remote_message_status status;
-};
-- 
1.7.2.3




More information about the libvir-list mailing list