From patchwork Wed Jun 27 20:41:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10492665 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 DA6E260386 for ; Wed, 27 Jun 2018 21:03:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF9062A199 for ; Wed, 27 Jun 2018 21:03:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABDF12A18B; Wed, 27 Jun 2018 21:03:44 +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 104502A268 for ; Wed, 27 Jun 2018 21:03:32 +0000 (UTC) Received: from localhost ([::1]:33215 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYHbA-0002lN-70 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 27 Jun 2018 17:03:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49952) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYHHQ-0004Qq-EE for qemu-devel@nongnu.org; Wed, 27 Jun 2018 16:43:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYHHP-0006rm-Ik for qemu-devel@nongnu.org; Wed, 27 Jun 2018 16:43:08 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:39601) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYHHP-0006qu-Bv for qemu-devel@nongnu.org; Wed, 27 Jun 2018 16:43:07 -0400 Received: by mail-pl0-x243.google.com with SMTP id s24-v6so1590772plq.6 for ; Wed, 27 Jun 2018 13:43:07 -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=Abb4T//uHh4P68qhN6MzsusgRCJnnTDffWntB+KBgsQ=; b=HHat3ZKGrxrs5+IXfrntd/CjHX6ECrYyXGTHJrj2IiRGaXiVPCki+24ZCccamG5IX+ ImerzWSO1vd8Mv+O9S/OsUEA66JZp3LPNfEVvLvA2ECwGjUVYKeR90uGYYamfZcppBq+ dzGkn/X6a6dwG5mk3ELpGwHqLsTwhzZnAprHAP8dAOGn7Lrpi2vnMAQEdI/miOXfjKop FPb4TGjUJ1AK9mOvKTKtsyXajJfPrRClDFclf1Cr/QDVrtPncB73l798kKYqWMc9OdBx z6ZWfu8QYUV85G1f7pLH3xFIawUv7Ork4yuAXBGvbu/21kierFf2zxBi27AYJ8x9xRZG UHzQ== 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=Abb4T//uHh4P68qhN6MzsusgRCJnnTDffWntB+KBgsQ=; b=QXcZQalFh8dAJaEnEiRBCVxpEd8zSSOnVfW/mNvAmdPwt9gXtx7HbI8Eq7QTr1ERNy nKC27zfKsQjm20tMhIpZ2pLlWewYSu20ZmbestZDCkqapgH+Sx4hud46A3JKXLjduQhF yw3Q9nvDtDroiHfSwN1d9jG/crhLcbUuvCNRLUuehI5FX1jj7r1WPmplkcYL3dPok+mB RSnLIPjP5V+KLc/ZK3stC5CSTbrAkb6jtCzSGSiFedHIKoDZVwhbbfczlQqosw4yhnwt p1ww+cWc027qpJ1J0InQUjCLXC4I7C+qea2mXDAOn47AUneyuLqvTRZDr29FxS3QxCVA OEBg== X-Gm-Message-State: APt69E15GzXX7i5l3FfULeA+zJey/luntly6uDyxg2W9IpL5QLOv3xaA vEg0cTcuI2h1qKptkyEPEgeSFw== X-Google-Smtp-Source: ADUXVKKM/jAxdk35YOL8QjcaoGhqdu0DYEoD/yd0gsvtUAB141DBOMIW1If11rCbv3OFjG0Vhh5uMg== X-Received: by 2002:a17:902:6ac7:: with SMTP id i7-v6mr7808933plt.288.1530132186073; Wed, 27 Jun 2018 13:43:06 -0700 (PDT) Received: from localhost.localdomain (155.150.229.35.bc.googleusercontent.com. [35.229.150.155]) by smtp.gmail.com with ESMTPSA id c67-v6sm9690428pfj.173.2018.06.27.13.43.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 13:43:05 -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: Thu, 28 Jun 2018 04:41:31 +0800 Message-Id: <20180627204136.4177-16-zhangckid@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180627204136.4177-1-zhangckid@gmail.com> References: <20180627204136.4177-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::243 Subject: [Qemu-devel] [PATCH V9 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; +}