From patchwork Wed Feb 15 09:54:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 9573691 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 969F360209 for ; Wed, 15 Feb 2017 09:57:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83E2827F85 for ; Wed, 15 Feb 2017 09:57:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7869128464; Wed, 15 Feb 2017 09:57:46 +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 A0C4527F85 for ; Wed, 15 Feb 2017 09:57:45 +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 1cdwIy-0007to-Ve; Wed, 15 Feb 2017 09:55:20 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cdwIx-0007qb-1B for xen-devel@lists.xenproject.org; Wed, 15 Feb 2017 09:55:19 +0000 Received: from [85.158.137.68] by server-3.bemta-3.messagelabs.com id 81/89-14551-68524A85; Wed, 15 Feb 2017 09:55:18 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrJIsWRWlGSWpSXmKPExsViPb2gRbdVdUm EweE1Ihbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8alnUcZCy63M1asmNnH3sB4JL6LkZNDQsBP ovv7c5YuRg4OIYFaibXLArsYuYDMlYwSTx9sYIVwdjFKvHzbzwTSwCZgIDHnykRGkAYRgXKJ2 yvEQWqYBQ4wSpy+upYFpEZYIFjiwJoPzCA2i4CqxIUdi8DivAI+EosnrWOFWCwncfNcJ1gNp4 CvxOd1y8HiQkA19/buZYSoF5Q4OfMJWC+zgITEwRcvmEH2SggoSrRd44UYoyvR8aePEcLWlNi 2+hwbRImVxNStnhBhQYmdzy+wTWAUmYVk6CwkQxcwMq1i1ChOLSpLLdI1MtRLKspMzyjJTczM 0TU0MNbLTS0uTkxPzUlMKtZLzs/dxAgM8noGBsYdjD17/Q4xSnIwKYnysh1bHCHEl5SfUpmRW JwRX1Sak1p8iFGGg0NJgtdfZUmEkGBRanpqRVpmDjDeYNISHDxKIryhIGne4oLE3OLMdIjUKU ZFKXHeJpCEAEgiozQPrg0W45cYZaWEeRkZGBiEeApSi3IzS1DlXzGKczAqCfNOBJnCk5lXAjf 9FdBiJqDFrHELQRaXJCKkpBoYA0PVr3us+xqSanNTbJVImO7TnyL1qkL7So/5J0kdcV9kcXny 1kJ5zy/5Fre6Gfqn7T0asOjM+SSjCQx5j3Tmrf4n6LV43T2+K2UeWwRab4R/mjnhFfdOMckZU 6ukNoc36khXlUwLl6r9dE4x/+xSq82tKUz1akcfn71/ue/P/JprdTcKcgrfKbEUZyQaajEXFS cCAEj7D0zsAgAA X-Env-Sender: zhangchen.fnst@cn.fujitsu.com X-Msg-Ref: server-4.tower-31.messagelabs.com!1487152508!27590115!6 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 39530 invoked from network); 15 Feb 2017 09:55:16 -0000 Received: from cn.fujitsu.com (HELO heian.cn.fujitsu.com) (59.151.112.132) by server-4.tower-31.messagelabs.com with SMTP; 15 Feb 2017 09:55:16 -0000 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="15614565" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 15 Feb 2017 17:55:09 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 71FA747D8AD0; Wed, 15 Feb 2017 17:55:06 +0800 (CST) Received: from localhost.localdomain (10.167.226.56) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 15 Feb 2017 17:55:06 +0800 From: Zhang Chen To: Xen devel , Wei Liu , Ian Jackson Date: Wed, 15 Feb 2017 17:54:31 +0800 Message-ID: <1487152473-3693-6-git-send-email-zhangchen.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487152473-3693-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> References: <1487152473-3693-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.56] X-yoursite-MailScanner-ID: 71FA747D8AD0.A1659 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: zhangchen.fnst@cn.fujitsu.com Cc: Yang Hongyang , Bian Naimeng , eddie , Li Zhijian , Zhang Chen Subject: [Xen-devel] [PATCH RFC V2 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 {