From patchwork Sat Aug 11 20:59:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10563563 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AB92F1510 for ; Sat, 11 Aug 2018 21:11:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A35C29906 for ; Sat, 11 Aug 2018 21:11:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8BDDC298D9; Sat, 11 Aug 2018 21:11:02 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 10D0E298D9 for ; Sat, 11 Aug 2018 21:11:01 +0000 (UTC) Received: from localhost ([::1]:33228 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fobA5-0006Lt-38 for patchwork-qemu-devel@patchwork.kernel.org; Sat, 11 Aug 2018 17:11:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48276) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fob0O-0005Ov-AK for qemu-devel@nongnu.org; Sat, 11 Aug 2018 17:01:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fob0N-0001Z2-Ih for qemu-devel@nongnu.org; Sat, 11 Aug 2018 17:01:00 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:46832) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fob0N-0001Ym-CV for qemu-devel@nongnu.org; Sat, 11 Aug 2018 17:00:59 -0400 Received: by mail-pg1-x536.google.com with SMTP id f14-v6so5850797pgv.13 for ; Sat, 11 Aug 2018 14:00:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kUQIPs69dPjU+OLFvSIP7I8hJ4jrJ7hci6aj9qXare4=; b=VM20Qo+zYM0YoOuNIYjt2ImNkEuT4xnfWRfFYSDowjVDSee9sK/vwMj4p7nyjeC71B tNX+WFOKj1fnfhgSAaPLJFYULLiLZfpVg9F4POWzwTH5n09nSwjLjpKPZreGbQv1aSgE airkJ9w5vCKXKrUs2xi8xMTrkl82Wy+LTPNp2ufUObrPjXlADQreR05FLMcWpaxwiNNI a5yCUL/MhFcfori/pjSzg0QKSMrn8yrKci/sES1SMraidU/jvc/YueZt75KE/pAPzsoN v9KYlrt+wE10ixeWuxIytpeI4oPfk1whZIXistieREgUL5fLLuw2NcD8Oq9VdoAAgniE CZvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kUQIPs69dPjU+OLFvSIP7I8hJ4jrJ7hci6aj9qXare4=; b=V1lzgs4dvNj2iHcjfoIrafGM0Tj1x9nwhi3qzYEfPLJXX12BpQbLLk/zrfm1WKAn9M roofg9ots6t7LAXFORzqZQZbgqLMa8UkK6VRRppdyL85gOs9cQokE8u32AKnLWu8LLeQ 40w03PT8WjHTMHHxrp2N1DAAD73yJL//V9zEbvTtN72zfCHffgrHG00WmcvuM6wNEZaq Y4R518TEiX9AMNbkM/q0EN8DenEy2p2pONt4adabuBXAOgh/+NB3aOfk5TV2ltkETcmv FVUKqWR0kSdTHyNTE6ihrnGibnjKw3oEcSi+R0l9mn06o4k2C/zCy2PMzVMJAhZGSnD3 YgnQ== X-Gm-Message-State: AOUpUlGL8yCZZuQcrT5yen3hYVOaQJ2lp2+CvTZ7zXI/J8rm8WajMPAa kFSvXJB/s8oPmpYLUYs4CpS9dXl0 X-Google-Smtp-Source: AA+uWPxmA/Ni+S3D8QeszkMxXYpX3QHVMyJhmXlvRbucl3BGGTLzOT8liFmlR9aD5ZDEELF/IZRcVA== X-Received: by 2002:a63:7c5c:: with SMTP id l28-v6mr11562876pgn.352.1534021258091; Sat, 11 Aug 2018 14:00:58 -0700 (PDT) Received: from localhost.localdomain (155.150.229.35.bc.googleusercontent.com. [35.229.150.155]) by smtp.gmail.com with ESMTPSA id h24-v6sm23502641pfk.113.2018.08.11.14.00.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Aug 2018 14:00:57 -0700 (PDT) From: Zhang Chen To: qemu-devel@nongnu.org, Paolo Bonzini , Juan Quintela , "Dr . David Alan Gilbert" , Jason Wang , Eric Blake , Markus Armbruster Date: Sun, 12 Aug 2018 04:59:19 +0800 Message-Id: <20180811205924.4113-16-zhangckid@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180811205924.4113-1-zhangckid@gmail.com> References: <20180811205924.4113-1-zhangckid@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::536 Subject: [Qemu-devel] [PATCH V11 15/20] net/net.c: Add net client type check function for COLO X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen , zhanghailiang , Li Zhijian , Zhang Chen Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Zhang Chen We add is_colo_support_client_type() to check the net client type for COLO-compare. Currently we just support TAP. Suggested by Jason. Signed-off-by: Zhang Chen Signed-off-by: Zhang Chen --- include/net/net.h | 1 + net/colo-compare.c | 5 +++++ net/net.c | 14 ++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/include/net/net.h b/include/net/net.h index 1425960f76..dcbc7ba9c0 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -212,6 +212,7 @@ void hmp_host_net_add(Monitor *mon, const QDict *qdict); void hmp_host_net_remove(Monitor *mon, const QDict *qdict); void netdev_add(QemuOpts *opts, Error **errp); void qmp_netdev_add(QDict *qdict, QObject **ret, Error **errp); +bool is_colo_support_client_type(void); int net_hub_id_for_client(NetClientState *nc, int *id); NetClientState *net_hub_port_find(int hub_id); diff --git a/net/colo-compare.c b/net/colo-compare.c index 426eab5973..b8c0240725 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -996,6 +996,11 @@ static void colo_compare_complete(UserCreatable *uc, Error **errp) return; } + if (!is_colo_support_client_type()) { + error_setg(errp, "COLO-compare: Net client type is not supported"); + return; + } + net_socket_rs_init(&s->pri_rs, compare_pri_rs_finalize, s->vnet_hdr); net_socket_rs_init(&s->sec_rs, compare_sec_rs_finalize, s->vnet_hdr); diff --git a/net/net.c b/net/net.c index 2a3133990c..a77ea88fff 100644 --- a/net/net.c +++ b/net/net.c @@ -1733,3 +1733,17 @@ int net_fill_rstate(SocketReadState *rs, const uint8_t *buf, int size) assert(size == 0); return 0; } + +/* Currently, COLO just support TAP */ +bool is_colo_support_client_type(void) +{ + NetClientState *nc; + + QTAILQ_FOREACH(nc, &net_clients, next) { + if (nc->info->type != NET_CLIENT_DRIVER_TAP) { + return false; + } + } + + return true; +}