[PATCH v3 1/2] Add VIR_TYPED_PARAM_STRING

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

 



This makes string can be transported between client and server.
For compatibility,

    o new server should not send strings to old client if it
      doesn't see the flag VIR_DOMAIN_TYPED_STRING_OKAY.
    o new client that wants to be able to send/receive strings
      should always set the flag VIR_DOMAIN_TYPED_STRING_OKAY;
      if it is rejected by a old server that doesn't understand
      VIR_DOMAIN_TYPED_STRING_OKAY, then the client should have
      a second try with out flag VIR_DOMAIN_TYPED_STRING_OKAY
      to cope with an old server.

Ideas of compatibility are coming from Eric, thanks.
---
 daemon/remote.c              |   17 +++++++++++++++++
 include/libvirt/libvirt.h.in |    5 ++++-
 src/remote/remote_driver.c   |   17 +++++++++++++++++
 src/remote/remote_protocol.x |    2 ++
 src/remote_protocol-structs  |    2 ++
 5 files changed, 42 insertions(+), 1 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 245d41c..82ee13b 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -672,6 +672,15 @@ remoteSerializeTypedParameters(virTypedParameterPtr params,
         case VIR_TYPED_PARAM_BOOLEAN:
             val[i].value.remote_typed_param_value_u.b = params[i].value.b;
             break;
+        case VIR_TYPED_PARAM_STRING:
+            if (params[i].value.s) {
+                val[i].value.remote_typed_param_value_u.s = strdup(params[i].value.s);
+                if (val[i].value.remote_typed_param_value_u.s == NULL) {
+                    virReportOOMError();
+                    goto cleanup;
+                }
+            }
+            break;
         default:
             virNetError(VIR_ERR_RPC, _("unknown parameter type: %d"),
                         params[i].type);
@@ -750,6 +759,14 @@ remoteDeserializeTypedParameters(remote_typed_param *args_params_val,
             params[i].value.b =
                 args_params_val[i].value.remote_typed_param_value_u.b;
             break;
+        case VIR_TYPED_PARAM_STRING:
+            params[i].value.s =
+                strdup(args_params_val[i].value.remote_typed_param_value_u.s);
+            if (params[i].value.s == NULL) {
+                virReportOOMError();
+                goto cleanup;
+            }
+            break;
         default:
             virNetError(VIR_ERR_INTERNAL_ERROR, _("unknown parameter type: %d"),
                         params[i].type);
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 39155a6..448a0e7 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -205,6 +205,7 @@ typedef enum {
     VIR_DOMAIN_AFFECT_CURRENT = 0,      /* Affect current domain state.  */
     VIR_DOMAIN_AFFECT_LIVE    = 1 << 0, /* Affect running domain state.  */
     VIR_DOMAIN_AFFECT_CONFIG  = 1 << 1, /* Affect persistent domain state.  */
+    VIR_DOMAIN_TYPED_STRING_OKAY = 1 << 2,
 } virDomainModificationImpact;
 
 /**
@@ -489,7 +490,8 @@ typedef enum {
     VIR_TYPED_PARAM_LLONG   = 3, /* long long case */
     VIR_TYPED_PARAM_ULLONG  = 4, /* unsigned long long case */
     VIR_TYPED_PARAM_DOUBLE  = 5, /* double case */
-    VIR_TYPED_PARAM_BOOLEAN = 6  /* boolean(character) case */
+    VIR_TYPED_PARAM_BOOLEAN = 6, /* boolean(character) case */
+    VIR_TYPED_PARAM_STRING  = 7  /* string case */
 } virTypedParameterType;
 
 /**
@@ -520,6 +522,7 @@ struct _virTypedParameter {
         unsigned long long int ul;  /* type is ULLONG */
         double d;                   /* type is DOUBLE */
         char b;                     /* type is BOOLEAN */
+        char *s;                    /* type is STRING */
     } value; /* parameter value */
 };
 
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 1217d94..85eaeea 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -1276,6 +1276,15 @@ remoteSerializeTypedParameters(virTypedParameterPtr params,
         case VIR_TYPED_PARAM_BOOLEAN:
             val[i].value.remote_typed_param_value_u.b = params[i].value.b;
             break;
+        case VIR_TYPED_PARAM_STRING:
+            if (params[i].value.s) {
+                val[i].value.remote_typed_param_value_u.s = strdup(params[i].value.s);
+                if (val[i].value.remote_typed_param_value_u.s == NULL) {
+                    virReportOOMError();
+                    goto cleanup;
+                }
+            }
+            break;
         default:
             remoteError(VIR_ERR_RPC, _("unknown parameter type: %d"),
                 params[i].type);
@@ -1347,6 +1356,14 @@ remoteDeserializeTypedParameters(remote_typed_param *ret_params_val,
             params[i].value.b =
                 ret_params_val[i].value.remote_typed_param_value_u.b;
             break;
+        case VIR_TYPED_PARAM_STRING:
+            params[i].value.s =
+                strdup(ret_params_val[i].value.remote_typed_param_value_u.s);
+            if (params[i].value.s == NULL) {
+                virReportOOMError();
+                goto cleanup;
+            }
+            break;
         default:
             remoteError(VIR_ERR_RPC, _("unknown parameter type: %d"),
                         params[i].type);
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 455e324..ec2fc84 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -317,6 +317,8 @@ union remote_typed_param_value switch (int type) {
      double d;
  case VIR_TYPED_PARAM_BOOLEAN:
      int b;
+ case VIR_TYPED_PARAM_STRING:
+     remote_nonnull_string s;
 };
 
 struct remote_typed_param {
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 810b19c..9ddd4e1 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -6,6 +6,7 @@ enum {
         VIR_TYPED_PARAM_ULLONG = 4,
         VIR_TYPED_PARAM_DOUBLE = 5,
         VIR_TYPED_PARAM_BOOLEAN = 6,
+        VIR_TYPED_PARAM_STRING = 7,
 };
 struct remote_nonnull_domain {
         remote_nonnull_string      name;
@@ -78,6 +79,7 @@ struct remote_typed_param_value {
                 uint64_t           ul;
                 double             d;
                 int                b;
+                remote_nonnull_string s;
         } remote_typed_param_value_u;
 };
 struct remote_typed_param {
-- 
1.7.3.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]