From patchwork Fri Feb 17 02:18:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 9578635 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1057D6043A for ; Fri, 17 Feb 2017 02:21:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0205428679 for ; Fri, 17 Feb 2017 02:21:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA9C328685; Fri, 17 Feb 2017 02:21:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2AF6A28679 for ; Fri, 17 Feb 2017 02:21:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ceY8Z-00072n-46; Fri, 17 Feb 2017 02:19:07 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ceY8X-000721-Ib for xen-devel@lists.xenproject.org; Fri, 17 Feb 2017 02:19:05 +0000 Received: from [85.158.139.211] by server-15.bemta-5.messagelabs.com id D6/05-01719-89D56A85; Fri, 17 Feb 2017 02:19:04 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrBIsWRWlGSWpSXmKPExsViPb2gRXdG7LI Ig43fBC2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oxLO48yFlxuZ6xYMbOPvYHxSHwXIweHhICf xMS1dl2MnBxCArUSrXc3MnUxcgHZKxklrrRsZYFwdjFKvDm2igWkik3AQGLOlYmMIM0iAuUSt 1eIg9QwC3xklPjWeZUdpEZYwF/iQ9NRJhCbRUBVYk3PTbBeXgEfiZWHWphBbAkBOYmb5zrBbE 4BX4neU/NYQGYKAdXMOCcCUS4ocXLmE7BWZgEJiYMvXjBD3Kwo0XaNF2KKrsS++T0sELamxLb V59ggSqwkpm71hAgLSux8foFtAqPILCRDZyEZuoCRaRWjRnFqUVlqka6hsV5SUWZ6RkluYmaO rqGBqV5uanFxYnpqTmJSsV5yfu4mRmCIMwDBDsZ/2zwPMUpyMCmJ8h5lXhYhxJeUn1KZkVicE V9UmpNafIhRhoNDSYJ3TwxQTrAoNT21Ii0zBxhtMGkJDh4lEd5fIGne4oLE3OLMdIjUKUZFKX HeBSAJAZBERmkeXBsswi8xykoJ8zICHSLEU5BalJtZgir/ilGcg1FJmDcfZApPZl4J3PRXQIu ZgBZ3RiwFWVySiJCSamAsPFQ5LdmaX3HtS6FyRalzl0ynLlxvn+aW/sia30lyZ5TOeca/i4Se PdeYGL1J2ZtHUjDe4tlNraen+KeGZ4R33JTNKDk7P9Jb4YVrq/4ildKVnyL6vjW+38m29+/Up 9HpUrwP1shNUkw6UhKbYGhcd9fHyjqQM7an/8NFrmkeJneXJ3l/+aDEUpyRaKjFXFScCAD8+B 4I6wIAAA== X-Env-Sender: zhangchen.fnst@cn.fujitsu.com X-Msg-Ref: server-7.tower-206.messagelabs.com!1487297939!85163690!3 X-Originating-IP: [59.151.112.132] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 11444 invoked from network); 17 Feb 2017 02:19:03 -0000 Received: from cn.fujitsu.com (HELO heian.cn.fujitsu.com) (59.151.112.132) by server-7.tower-206.messagelabs.com with SMTP; 17 Feb 2017 02:19:03 -0000 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="15685700" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 17 Feb 2017 10:19:02 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id A468F47C4E90; Fri, 17 Feb 2017 10:19:03 +0800 (CST) Received: from localhost.localdomain (10.167.226.56) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 17 Feb 2017 10:19:04 +0800 From: Zhang Chen To: Xen devel , Wei Liu , Ian Jackson Date: Fri, 17 Feb 2017 10:18:27 +0800 Message-ID: <1487297909-1885-6-git-send-email-zhangchen.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487297909-1885-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> References: <1487297909-1885-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.56] X-yoursite-MailScanner-ID: A468F47C4E90.A205D X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: zhangchen.fnst@cn.fujitsu.com Cc: Zhang Chen , Li Zhijian , eddie , Yang Hongyang , Bian Naimeng Subject: [Xen-devel] [PATCH V3 5/7] COLO-Proxy: Add primary userspace colo proxy start args X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Qemu need this args to start userspace colo-proxy. Signed-off-by: Zhang Chen --- tools/libxl/libxl_dm.c | 98 +++++++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_nic.c | 78 ++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_types.idl | 31 +++++++++++++- tools/libxl/xl_cmdimpl.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/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index b286d47..e6cb015 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -1060,6 +1060,64 @@ static int parse_nic_config(libxl_device_nic *nic, XLU_Config **config, char *to 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 {