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

[Xen-devel] [PATCH V4 4/8] COLO-Proxy: Add primary userspace colo proxy start args



Qemu need this args to start userspace colo-proxy.

Signed-off-by: Zhang Chen <zhangchen.fnst@xxxxxxxxxxxxxx>
---
 tools/libxl/libxl_dm.c      | 98 +++++++++++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_nic.c     | 78 ++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_types.idl | 31 +++++++++++++-
 tools/xl/xl_parse.c         | 58 +++++++++++++++++++++++++++
 4 files changed, 264 insertions(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 281058d..abd4edd 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -1244,7 +1244,105 @@ static int libxl__build_device_model_args_new(libxl__gc 
*gc,
                                            nics[i].devid, ifname,
                                            libxl_tapif_script(gc),
                                            libxl_tapif_script(gc)));
+
+                /* Userspace COLO Proxy need this */
+#define APPEND_COLO_SOCK_SERVER(sock_id, sock_ip, sock_port) ({             \
+    if (nics[i].colo_##sock_id &&                                           \
+        nics[i].colo_##sock_ip &&                                           \
+        nics[i].colo_##sock_port) {                                         \
+        flexarray_append(dm_args, "-chardev");                              \
+        flexarray_append(dm_args,                                           \
+            GCSPRINTF("socket,id=%s,host=%s,port=%s,server,nowait",         \
+                      nics[i].colo_##sock_id,                               \
+                      nics[i].colo_##sock_ip,                               \
+                      nics[i].colo_##sock_port));                           \
+        }                                                                   \
+})
+
+#define APPEND_COLO_SOCK_CLIENT(sock_id, sock_ip, sock_port) ({             \
+    if (nics[i].colo_##sock_id &&                                           \
+        nics[i].colo_##sock_ip &&                                           \
+        nics[i].colo_##sock_port) {                                         \
+        flexarray_append(dm_args, "-chardev");                              \
+        flexarray_append(dm_args,                                           \
+            GCSPRINTF("socket,id=%s,host=%s,port=%s",                       \
+                      nics[i].colo_##sock_id,                               \
+                      nics[i].colo_##sock_ip,                               \
+                      nics[i].colo_##sock_port));                           \
+        }                                                                   \
+})
+
+                if (state->saved_state) {
+                    /* secondary colo run */
+                } else {
+                    /* primary colo run */
+
+                    APPEND_COLO_SOCK_SERVER(sock_mirror_id,
+                                            sock_mirror_ip,
+                                            sock_mirror_port);
+
+                    APPEND_COLO_SOCK_SERVER(sock_compare_pri_in_id,
+                                            sock_compare_pri_in_ip,
+                                            sock_compare_pri_in_port);
+
+                    APPEND_COLO_SOCK_SERVER(sock_compare_sec_in_id,
+                                            sock_compare_sec_in_ip,
+                                            sock_compare_sec_in_port);
+
+                    APPEND_COLO_SOCK_SERVER(sock_redirector0_id,
+                                            sock_redirector0_ip,
+                                            sock_redirector0_port);
+
+                    APPEND_COLO_SOCK_CLIENT(sock_redirector1_id,
+                                            sock_redirector1_ip,
+                                            sock_redirector1_port);
+
+                    APPEND_COLO_SOCK_CLIENT(sock_redirector2_id,
+                                            sock_redirector2_ip,
+                                            sock_redirector2_port);
+
+                    if (nics[i].colo_filter_mirror_queue &&
+                        nics[i].colo_filter_mirror_outdev) {
+                        flexarray_append(dm_args, "-object");
+                        flexarray_append(dm_args,
+                           
GCSPRINTF("filter-mirror,id=m1,netdev=net%d,queue=%s,outdev=%s",
+                                     nics[i].devid,
+                                     nics[i].colo_filter_mirror_queue,
+                                     nics[i].colo_filter_mirror_outdev));
+                    }
+                    if (nics[i].colo_filter_redirector0_queue &&
+                        nics[i].colo_filter_redirector0_indev) {
+                        flexarray_append(dm_args, "-object");
+                        flexarray_append(dm_args,
+                           
GCSPRINTF("filter-redirector,id=r1,netdev=net%d,queue=%s,indev=%s",
+                                     nics[i].devid,
+                                     nics[i].colo_filter_redirector0_queue,
+                                     nics[i].colo_filter_redirector0_indev));
+                    }
+                    if (nics[i].colo_filter_redirector1_queue &&
+                        nics[i].colo_filter_redirector1_outdev) {
+                        flexarray_append(dm_args, "-object");
+                        flexarray_append(dm_args,
+                          
GCSPRINTF("filter-redirector,id=r2,netdev=net%d,queue=%s,outdev=%s",
+                                     nics[i].devid,
+                                     nics[i].colo_filter_redirector1_queue,
+                                     nics[i].colo_filter_redirector1_outdev));
+                    }
+                    if (nics[i].colo_compare_pri_in &&
+                        nics[i].colo_compare_sec_in &&
+                        nics[i].colo_compare_out) {
+                        flexarray_append(dm_args, "-object");
+                        flexarray_append(dm_args,
+                           
GCSPRINTF("colo-compare,id=c1,primary_in=%s,secondary_in=%s,outdev=%s",
+                                     nics[i].colo_compare_pri_in,
+                                     nics[i].colo_compare_sec_in,
+                                     nics[i].colo_compare_out));
+                    }
+                }
                 ioemu_nics++;
+
+#undef APPEND_COLO_SOCK_SERVER
+#undef APPEND_COLO_SOCK_CLIENT
             }
         }
         /* If we have no emulated nics, tell qemu not to create any */
diff --git a/tools/libxl/libxl_nic.c b/tools/libxl/libxl_nic.c
index 61b55ca..7c57bcf 100644
--- a/tools/libxl/libxl_nic.c
+++ b/tools/libxl/libxl_nic.c
@@ -196,6 +196,45 @@ static void libxl__device_nic_add(libxl__egc *egc, 
uint32_t domid,
         flexarray_append(back, nic->coloft_forwarddev);
     }
 
+#define MAYBE_ADD_COLO_ARGS(arg) ({                                       \
+    if (nic->colo_##arg) {                                                \
+        flexarray_append(back, "colo_"#arg);                              \
+        flexarray_append(back, nic->colo_##arg);                          \
+    }                                                                     \
+})
+
+    MAYBE_ADD_COLO_ARGS(sock_mirror_id);
+    MAYBE_ADD_COLO_ARGS(sock_mirror_ip);
+    MAYBE_ADD_COLO_ARGS(sock_mirror_port);
+    MAYBE_ADD_COLO_ARGS(sock_compare_pri_in_id);
+    MAYBE_ADD_COLO_ARGS(sock_compare_pri_in_ip);
+    MAYBE_ADD_COLO_ARGS(sock_compare_pri_in_port);
+    MAYBE_ADD_COLO_ARGS(sock_compare_sec_in_id);
+    MAYBE_ADD_COLO_ARGS(sock_compare_sec_in_ip);
+    MAYBE_ADD_COLO_ARGS(sock_compare_sec_in_port);
+    MAYBE_ADD_COLO_ARGS(sock_redirector0_id);
+    MAYBE_ADD_COLO_ARGS(sock_redirector0_ip);
+    MAYBE_ADD_COLO_ARGS(sock_redirector0_port);
+    MAYBE_ADD_COLO_ARGS(sock_redirector1_id);
+    MAYBE_ADD_COLO_ARGS(sock_redirector1_ip);
+    MAYBE_ADD_COLO_ARGS(sock_redirector1_port);
+    MAYBE_ADD_COLO_ARGS(sock_redirector2_id);
+    MAYBE_ADD_COLO_ARGS(sock_redirector2_ip);
+    MAYBE_ADD_COLO_ARGS(sock_redirector2_port);
+    MAYBE_ADD_COLO_ARGS(filter_mirror_queue);
+    MAYBE_ADD_COLO_ARGS(filter_mirror_outdev);
+    MAYBE_ADD_COLO_ARGS(filter_redirector0_queue);
+    MAYBE_ADD_COLO_ARGS(filter_redirector0_indev);
+    MAYBE_ADD_COLO_ARGS(filter_redirector0_outdev);
+    MAYBE_ADD_COLO_ARGS(filter_redirector1_queue);
+    MAYBE_ADD_COLO_ARGS(filter_redirector1_indev);
+    MAYBE_ADD_COLO_ARGS(filter_redirector1_outdev);
+    MAYBE_ADD_COLO_ARGS(compare_pri_in);
+    MAYBE_ADD_COLO_ARGS(compare_sec_in);
+    MAYBE_ADD_COLO_ARGS(compare_out);
+
+#undef MAYBE_ADD_COLO_ARGS
+
     flexarray_append(back, "mac");
     flexarray_append(back,GCSPRINTF(LIBXL_MAC_FMT, LIBXL_MAC_BYTES(nic->mac)));
     if (nic->ip) {
@@ -349,6 +388,45 @@ static int libxl__device_nic_from_xenstore(libxl__gc *gc,
                                 (const char **)(&nic->coloft_forwarddev));
     if (rc) goto out;
 
+#define CHECK_COLO_ARGS(arg) ({                                           \
+    rc = libxl__xs_read_checked(NOGC, XBT_NULL,                           \
+                                GCSPRINTF("%s/colo_"#arg, libxl_path),    \
+                                (const char **)(&nic->colo_##arg));       \
+    if (rc) goto out;                                                     \
+})
+
+    CHECK_COLO_ARGS(sock_mirror_id);
+    CHECK_COLO_ARGS(sock_mirror_ip);
+    CHECK_COLO_ARGS(sock_mirror_port);
+    CHECK_COLO_ARGS(sock_compare_pri_in_id);
+    CHECK_COLO_ARGS(sock_compare_pri_in_ip);
+    CHECK_COLO_ARGS(sock_compare_pri_in_port);
+    CHECK_COLO_ARGS(sock_compare_sec_in_id);
+    CHECK_COLO_ARGS(sock_compare_sec_in_ip);
+    CHECK_COLO_ARGS(sock_compare_sec_in_port);
+    CHECK_COLO_ARGS(sock_redirector0_id);
+    CHECK_COLO_ARGS(sock_redirector0_ip);
+    CHECK_COLO_ARGS(sock_redirector0_port);
+    CHECK_COLO_ARGS(sock_redirector1_id);
+    CHECK_COLO_ARGS(sock_redirector1_ip);
+    CHECK_COLO_ARGS(sock_redirector1_port);
+    CHECK_COLO_ARGS(sock_redirector2_id);
+    CHECK_COLO_ARGS(sock_redirector2_ip);
+    CHECK_COLO_ARGS(sock_redirector2_port);
+    CHECK_COLO_ARGS(filter_mirror_queue);
+    CHECK_COLO_ARGS(filter_mirror_outdev);
+    CHECK_COLO_ARGS(filter_redirector0_queue);
+    CHECK_COLO_ARGS(filter_redirector0_indev);
+    CHECK_COLO_ARGS(filter_redirector0_outdev);
+    CHECK_COLO_ARGS(filter_redirector1_queue);
+    CHECK_COLO_ARGS(filter_redirector1_indev);
+    CHECK_COLO_ARGS(filter_redirector1_outdev);
+    CHECK_COLO_ARGS(compare_pri_in);
+    CHECK_COLO_ARGS(compare_sec_in);
+    CHECK_COLO_ARGS(compare_out);
+
+#undef CHECK_COLO_ARGS
+
     /* vif_ioemu nics use the same xenstore entries as vif interfaces */
     rc = libxl__xs_read_checked(gc, XBT_NULL,
                                 GCSPRINTF("%s/type", libxl_path), &tmp);
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 89c2c9d..07ce345 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -629,7 +629,36 @@ libxl_device_nic = Struct("device_nic", [
     ("gatewaydev", string),
     # Note that the COLO configuration settings should be considered unstable.
     # They may change incompatibly in future versions of Xen.
-    ("coloft_forwarddev", string)
+    ("coloft_forwarddev", string),
+    ("colo_sock_mirror_id", string),
+    ("colo_sock_mirror_ip", string),
+    ("colo_sock_mirror_port", string),
+    ("colo_sock_compare_pri_in_id", string),
+    ("colo_sock_compare_pri_in_ip", string),
+    ("colo_sock_compare_pri_in_port", string),
+    ("colo_sock_compare_sec_in_id", string),
+    ("colo_sock_compare_sec_in_ip", string),
+    ("colo_sock_compare_sec_in_port", string),
+    ("colo_sock_redirector0_id", string),
+    ("colo_sock_redirector0_ip", string),
+    ("colo_sock_redirector0_port", string),
+    ("colo_sock_redirector1_id", string),
+    ("colo_sock_redirector1_ip", string),
+    ("colo_sock_redirector1_port", string),
+    ("colo_sock_redirector2_id", string),
+    ("colo_sock_redirector2_ip", string),
+    ("colo_sock_redirector2_port", string),
+    ("colo_filter_mirror_queue", string),
+    ("colo_filter_mirror_outdev", string),
+    ("colo_filter_redirector0_queue", string),
+    ("colo_filter_redirector0_indev", string),
+    ("colo_filter_redirector0_outdev", string),
+    ("colo_filter_redirector1_queue", string),
+    ("colo_filter_redirector1_indev", string),
+    ("colo_filter_redirector1_outdev", string),
+    ("colo_compare_pri_in", string),
+    ("colo_compare_sec_in", string),
+    ("colo_compare_out", string)
     ])
 
 libxl_device_pci = Struct("device_pci", [
diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index 1ef0c27..88ef1c6 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -458,6 +458,64 @@ int parse_nic_config(libxl_device_nic *nic, XLU_Config 
**config, char *token)
         parse_vif_rate(config, oparg, nic);
     } else if (MATCH_OPTION("forwarddev", token, oparg)) {
         replace_string(&nic->coloft_forwarddev, oparg);
+    } else if (MATCH_OPTION("colo_sock_mirror_id", token, oparg)) {
+        replace_string(&nic->colo_sock_mirror_id, oparg);
+    } else if (MATCH_OPTION("colo_sock_mirror_ip", token, oparg)) {
+        replace_string(&nic->colo_sock_mirror_ip, oparg);
+    } else if (MATCH_OPTION("colo_sock_mirror_port", token, oparg)) {
+        replace_string(&nic->colo_sock_mirror_port, oparg);
+    } else if (MATCH_OPTION("colo_sock_compare_sec_in_id", token, oparg)) {
+        replace_string(&nic->colo_sock_compare_sec_in_id, oparg);
+    } else if (MATCH_OPTION("colo_sock_compare_sec_in_ip", token, oparg)) {
+        replace_string(&nic->colo_sock_compare_sec_in_ip, oparg);
+    } else if (MATCH_OPTION("colo_sock_compare_sec_in_port", token, oparg)) {
+        replace_string(&nic->colo_sock_compare_sec_in_port, oparg);
+    } else if (MATCH_OPTION("colo_sock_redirector0_id", token, oparg)) {
+        replace_string(&nic->colo_sock_redirector0_id, oparg);
+    } else if (MATCH_OPTION("colo_sock_redirector0_ip", token, oparg)) {
+        replace_string(&nic->colo_sock_redirector0_ip, oparg);
+    } else if (MATCH_OPTION("colo_sock_redirector0_port", token, oparg)) {
+        replace_string(&nic->colo_sock_redirector0_port, oparg);
+    } else if (MATCH_OPTION("colo_sock_redirector1_id", token, oparg)) {
+        replace_string(&nic->colo_sock_redirector1_id, oparg);
+    } else if (MATCH_OPTION("colo_sock_redirector1_ip", token, oparg)) {
+        replace_string(&nic->colo_sock_redirector1_ip, oparg);
+    } else if (MATCH_OPTION("colo_sock_redirector1_port", token, oparg)) {
+        replace_string(&nic->colo_sock_redirector1_port, oparg);
+    } else if (MATCH_OPTION("colo_sock_redirector2_id", token, oparg)) {
+        replace_string(&nic->colo_sock_redirector2_id, oparg);
+    } else if (MATCH_OPTION("colo_sock_redirector2_ip", token, oparg)) {
+        replace_string(&nic->colo_sock_redirector2_ip, oparg);
+    } else if (MATCH_OPTION("colo_sock_redirector2_port", token, oparg)) {
+        replace_string(&nic->colo_sock_redirector2_port, oparg);
+    } else if (MATCH_OPTION("colo_sock_compare_pri_in_id", token, oparg)) {
+        replace_string(&nic->colo_sock_compare_pri_in_id, oparg);
+    } else if (MATCH_OPTION("colo_sock_compare_pri_in_ip", token, oparg)) {
+        replace_string(&nic->colo_sock_compare_pri_in_ip, oparg);
+    } else if (MATCH_OPTION("colo_sock_compare_pri_in_port", token, oparg)) {
+        replace_string(&nic->colo_sock_compare_pri_in_port, oparg);
+    } else if (MATCH_OPTION("colo_filter_mirror_queue", token, oparg)) {
+        replace_string(&nic->colo_filter_mirror_queue, oparg);
+    } else if (MATCH_OPTION("colo_filter_mirror_outdev", token, oparg)) {
+        replace_string(&nic->colo_filter_mirror_outdev, oparg);
+    } else if (MATCH_OPTION("colo_filter_redirector0_queue", token, oparg)) {
+        replace_string(&nic->colo_filter_redirector0_queue, oparg);
+    } else if (MATCH_OPTION("colo_filter_redirector0_indev", token, oparg)) {
+        replace_string(&nic->colo_filter_redirector0_indev, oparg);
+    } else if (MATCH_OPTION("colo_filter_redirector0_outdev", token, oparg)) {
+        replace_string(&nic->colo_filter_redirector0_outdev, oparg);
+    } else if (MATCH_OPTION("colo_filter_redirector1_queue", token, oparg)) {
+        replace_string(&nic->colo_filter_redirector1_queue, oparg);
+    } else if (MATCH_OPTION("colo_filter_redirector1_indev", token, oparg)) {
+        replace_string(&nic->colo_filter_redirector1_indev, oparg);
+    } else if (MATCH_OPTION("colo_filter_redirector1_outdev", token, oparg)) {
+        replace_string(&nic->colo_filter_redirector1_outdev, oparg);
+    } else if (MATCH_OPTION("colo_compare_pri_in", token, oparg)) {
+        replace_string(&nic->colo_compare_pri_in, oparg);
+    } else if (MATCH_OPTION("colo_compare_sec_in", token, oparg)) {
+        replace_string(&nic->colo_compare_sec_in, oparg);
+    } else if (MATCH_OPTION("colo_compare_out", token, oparg)) {
+        replace_string(&nic->colo_compare_out, oparg);
     } else if (MATCH_OPTION("accel", token, oparg)) {
         fprintf(stderr, "the accel parameter for vifs is currently not 
supported\n");
     } else if (MATCH_OPTION("devid", token, oparg)) {
-- 
2.7.4




_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.