From patchwork Sun Jul 22 19:33:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10539383 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 D0EFB1805 for ; Sun, 22 Jul 2018 19:41:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C16BE2842E for ; Sun, 22 Jul 2018 19:41:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3E2128434; Sun, 22 Jul 2018 19:41:55 +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 517C32842E for ; Sun, 22 Jul 2018 19:41:55 +0000 (UTC) Received: from localhost ([::1]:57247 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhKEs-0000Ay-BH for patchwork-qemu-devel@patchwork.kernel.org; Sun, 22 Jul 2018 15:41:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhK8l-0003Gs-Ph for qemu-devel@nongnu.org; Sun, 22 Jul 2018 15:35:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhK8k-0000zq-PA for qemu-devel@nongnu.org; Sun, 22 Jul 2018 15:35:35 -0400 Received: from mail-pl0-x230.google.com ([2607:f8b0:400e:c01::230]:35438) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhK8k-0000zS-FK for qemu-devel@nongnu.org; Sun, 22 Jul 2018 15:35:34 -0400 Received: by mail-pl0-x230.google.com with SMTP id w3-v6so7296826plq.2 for ; Sun, 22 Jul 2018 12:35:34 -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=K3dkhi7bMX5ekmDfrikbh+64RrjWU3/pDvJ5q8A7RAU=; b=Ny0jFUJpCDONUYnniS3CgZxSK/SFhWh3uS3HSHu18uXydx6mwnDPlNQSiOo//pAPkX NaZawBtzsHaLVbO9666dnfmkQfxP1QiMtVerqsYzAjqxMexUtNFkq7yZzi1CT45Ybiyl IPDbRC4GG9WLKCEg+svHJtifzxdl3Vseaj4Uw5MamUiarrCBC2WT6rENyH+8RDTPi8w1 a7c5hKrIsWW6xN4/azlIurWHJFwqnMq1OpXu19bd2N9ND/hnuZbsigkrJhL3/R01+Cyj cibCd7KnE3rL06jh7s0wtPax7XXzDu/Y+oyxf1fqvuIa+Up8Y3oSuE/l8V3uk5I53PmX ZnBg== 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=K3dkhi7bMX5ekmDfrikbh+64RrjWU3/pDvJ5q8A7RAU=; b=kB+JoqYDVNvGFH7qvGNsVA0cN86T/ie7SXXuT6rATjQ58EfcY+0hY7Hr+wUk7CJ1J2 D2Xi5FD8UzHJQ8wt/MwM778Dwdi/v5DadVvLCnLlPfLyaVld52kjQ/1ua+SMP4533J3I r2WwME/x2cpw6Lbf9zNn5dVOafdwTAVVwjpPbDFSJbmJ3amXyw9yVBGPBtK6AzxfgRIO ZmipytqxMg2BWFeceGDK629xfDvfrjFDtMQfSJst69f1t/bGkqy1fkNIHfDki11OvY4E VXkvDMQOdtJjGDc74yOzHyvVuwqOvY/j2W3CKB69I9n3RZa78+zb2yUXFDwqW02tQ5OB pNfw== X-Gm-Message-State: AOUpUlFNTx8natVfdJA5H453PuCRV1WWmziwk2MEJrUofjgDKlgwJcZK cA/YQwtLQqgncUwBb8B2O3LtScex X-Google-Smtp-Source: AAOMgpeRVoDeMUFoeXZV2qnQqTcE4tp4WVt4+i4Ct2i4TVfzISdDEALccAr1J0GRd06dV3jTPgrJQg== X-Received: by 2002:a17:902:542:: with SMTP id 60-v6mr10326832plf.122.1532288133206; Sun, 22 Jul 2018 12:35:33 -0700 (PDT) Received: from localhost.localdomain (155.150.229.35.bc.googleusercontent.com. [35.229.150.155]) by smtp.gmail.com with ESMTPSA id 87-v6sm14215353pfn.103.2018.07.22.12.35.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Jul 2018 12:35:32 -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: Mon, 23 Jul 2018 03:33:45 +0800 Message-Id: <20180722193350.6028-16-zhangckid@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180722193350.6028-1-zhangckid@gmail.com> References: <20180722193350.6028-1-zhangckid@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::230 Subject: [Qemu-devel] [PATCH V10 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 --- 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; +}