]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Rename 'direction' to 'type' in remote_message_header
authorDaniel P. Berrange <berrange@redhat.com>
Fri, 10 Jul 2009 12:02:08 +0000 (13:02 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 16 Jul 2009 15:09:48 +0000 (16:09 +0100)
The 'remote_message_header' struct has a mis-leadingly named
field 'direction'. It is really a reflection of the type of
message, and some types can be sent in either direction. Thus
the field is more accurately named 'type'. No function change.

* qemud/remote_protocol.x: Rename 'direction' to 'type' in
  'remote_message_header. Write better docs describing the
  message header field semantics & usage
* qemud/remote_protocol.c, qemud/remote_protocol.h: Regenerate
* qemud/remote.c, qemud/dispatch.c, src/remote_internal.c
  Update to reflect rename of 'direction' to 'type'

qemud/dispatch.c
qemud/remote.c
qemud/remote_protocol.c
qemud/remote_protocol.h
qemud/remote_protocol.x
src/remote_internal.c

index 80b47698608afded027da1c66b076148c35cf0f1..a60f2f47d164f34cb408fe0748f957ec36beaebd 100644 (file)
@@ -129,7 +129,7 @@ remoteSerializeError(struct qemud_client *client,
                      int program,
                      int version,
                      int procedure,
-                     int direction,
+                     int type,
                      int serial)
 {
     XDR xdr;
@@ -143,7 +143,7 @@ remoteSerializeError(struct qemud_client *client,
     msg->hdr.prog = program;
     msg->hdr.vers = version;
     msg->hdr.proc = procedure;
-    msg->hdr.direction = direction;
+    msg->hdr.type = type;
     msg->hdr.serial = serial;
     msg->hdr.status = REMOTE_ERROR;
 
@@ -354,13 +354,13 @@ remoteDispatchClientRequest (struct qemud_server *server,
         goto error;
     }
 
-    switch (msg->hdr.direction) {
+    switch (msg->hdr.type) {
     case REMOTE_CALL:
         return remoteDispatchClientCall(server, client, msg);
 
     default:
-        remoteDispatchFormatError (&rerr, _("direction (%d) != REMOTE_CALL"),
-                                   (int) msg->hdr.direction);
+        remoteDispatchFormatError (&rerr, _("type (%d) != REMOTE_CALL"),
+                                   (int) msg->hdr.type);
     }
 
 error:
@@ -468,11 +468,11 @@ remoteDispatchClientCall (struct qemud_server *server,
         goto rpc_error;
 
     /* Return header. We're re-using same message object, so
-     * only need to tweak direction/status fields */
+     * only need to tweak type/status fields */
     /*msg->hdr.prog = msg->hdr.prog;*/
     /*msg->hdr.vers = msg->hdr.vers;*/
     /*msg->hdr.proc = msg->hdr.proc;*/
-    msg->hdr.direction = REMOTE_REPLY;
+    msg->hdr.type = REMOTE_REPLY;
     /*msg->hdr.serial = msg->hdr.serial;*/
     msg->hdr.status = REMOTE_OK;
 
index 3a43472e2b464c8a804ac7828c02499be7402c62..39f6487890bd4a3ed193fc638f28f640059f3900 100644 (file)
@@ -4422,7 +4422,7 @@ remoteDispatchDomainEventSend (struct qemud_client *client,
     msg->hdr.prog = REMOTE_PROGRAM;
     msg->hdr.vers = REMOTE_PROTOCOL_VERSION;
     msg->hdr.proc = REMOTE_PROC_DOMAIN_EVENT;
-    msg->hdr.direction = REMOTE_MESSAGE;
+    msg->hdr.type = REMOTE_MESSAGE;
     msg->hdr.serial = 1;
     msg->hdr.status = REMOTE_OK;
 
index f6dac7a7fd70a3fdd73fb326179b171bb2050023..65f9a73c0e262d254b56c5a7770b28e6ea3ef489 100644 (file)
@@ -2514,7 +2514,7 @@ xdr_remote_procedure (XDR *xdrs, remote_procedure *objp)
 }
 
 bool_t
-xdr_remote_message_direction (XDR *xdrs, remote_message_direction *objp)
+xdr_remote_message_type (XDR *xdrs, remote_message_type *objp)
 {
 
          if (!xdr_enum (xdrs, (enum_t *) objp))
@@ -2541,7 +2541,7 @@ xdr_remote_message_header (XDR *xdrs, remote_message_header *objp)
                  return FALSE;
          if (!xdr_remote_procedure (xdrs, &objp->proc))
                  return FALSE;
-         if (!xdr_remote_message_direction (xdrs, &objp->direction))
+         if (!xdr_remote_message_type (xdrs, &objp->type))
                  return FALSE;
          if (!xdr_u_int (xdrs, &objp->serial))
                  return FALSE;
index 21eae07bcf3ab59e1d7da879b7d707aed7894f04..dae304e544db5158d2a78de27a278918cb54f57f 100644 (file)
@@ -1551,12 +1551,12 @@ enum remote_procedure {
 };
 typedef enum remote_procedure remote_procedure;
 
-enum remote_message_direction {
+enum remote_message_type {
         REMOTE_CALL = 0,
         REMOTE_REPLY = 1,
         REMOTE_MESSAGE = 2,
 };
-typedef enum remote_message_direction remote_message_direction;
+typedef enum remote_message_type remote_message_type;
 
 enum remote_message_status {
         REMOTE_OK = 0,
@@ -1569,7 +1569,7 @@ struct remote_message_header {
         u_int prog;
         u_int vers;
         remote_procedure proc;
-        remote_message_direction direction;
+        remote_message_type type;
         u_int serial;
         remote_message_status status;
 };
@@ -1808,7 +1808,7 @@ extern  bool_t xdr_remote_domain_xml_from_native_ret (XDR *, remote_domain_xml_f
 extern  bool_t xdr_remote_domain_xml_to_native_args (XDR *, remote_domain_xml_to_native_args*);
 extern  bool_t xdr_remote_domain_xml_to_native_ret (XDR *, remote_domain_xml_to_native_ret*);
 extern  bool_t xdr_remote_procedure (XDR *, remote_procedure*);
-extern  bool_t xdr_remote_message_direction (XDR *, remote_message_direction*);
+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*);
 
@@ -2043,7 +2043,7 @@ extern bool_t xdr_remote_domain_xml_from_native_ret ();
 extern bool_t xdr_remote_domain_xml_to_native_args ();
 extern bool_t xdr_remote_domain_xml_to_native_ret ();
 extern bool_t xdr_remote_procedure ();
-extern bool_t xdr_remote_message_direction ();
+extern bool_t xdr_remote_message_type ();
 extern bool_t xdr_remote_message_status ();
 extern bool_t xdr_remote_message_header ();
 
index 1fb826b1cdddeb6e9e944f97ba7333871ff766f3..9e75c59ef9b8bb8287ea147149414d3755abad94 100644 (file)
@@ -1409,23 +1409,55 @@ enum remote_procedure {
     REMOTE_PROC_DOMAIN_XML_TO_NATIVE = 136
 };
 
-/* Custom RPC structure. */
-/* Each message consists of:
- *    int length               Number of bytes in message _including_ length.
- *    remote_message_header    Header.
- * then either: args           Arguments (for REMOTE_CALL).
- *          or: ret            Return (for REMOTE_REPLY, status = REMOTE_OK)
- *          or: remote_error   Error (for REMOTE_REPLY, status = REMOTE_ERROR)
+
+/*
+ * 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 matches that from the corresponding REMOTE_CALL, or zero
+ *
+ *
+ * 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
  *
- * The first two words (length, program number) are meant to be compatible
- * with the qemud protocol (qemud/protocol.x), although the rest of the
- * messages are completely different.
  */
-
-enum remote_message_direction {
-    REMOTE_CALL = 0,            /* client -> server */
-    REMOTE_REPLY = 1,           /* server -> client */
-    REMOTE_MESSAGE = 2          /* server -> client, asynchronous [NYI] */
+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
 };
 
 enum remote_message_status {
@@ -1447,7 +1479,7 @@ struct remote_message_header {
     unsigned prog;              /* REMOTE_PROGRAM */
     unsigned vers;              /* REMOTE_PROTOCOL_VERSION */
     remote_procedure proc;      /* REMOTE_PROC_x */
-    remote_message_direction direction;
+    remote_message_type type;
     unsigned serial;            /* Serial number of message. */
     remote_message_status status;
 };
index c5ab4b1ce3684ea85637ff36bedc06a59513a7a9..76d9ce178788c504293fb99d84740475c4a3e61d 100644 (file)
@@ -6269,7 +6269,7 @@ prepareCall(virConnectPtr conn,
     hdr.prog = REMOTE_PROGRAM;
     hdr.vers = REMOTE_PROTOCOL_VERSION;
     hdr.proc = proc_nr;
-    hdr.direction = REMOTE_CALL;
+    hdr.type = REMOTE_CALL;
     hdr.serial = rv->serial;
     hdr.status = REMOTE_OK;
 
@@ -6664,14 +6664,14 @@ processCallRecvMsg(virConnectPtr conn, struct private_data *priv,
     }
 
     /* Async events from server need special handling */
-    if (hdr.direction == REMOTE_MESSAGE) {
+    if (hdr.type == REMOTE_MESSAGE) {
         processCallAsyncEvent(conn, priv, in_open,
                               &hdr, &xdr);
         xdr_destroy(&xdr);
         return 0;
     }
 
-    if (hdr.direction != REMOTE_REPLY) {
+    if (hdr.type != REMOTE_REPLY) {
         virRaiseError (in_open ? NULL : conn,
                        NULL, NULL, VIR_FROM_REMOTE,
                        VIR_ERR_RPC, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,