From patchwork Fri Jul 24 10:55:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Hongyang X-Patchwork-Id: 499686 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9CE0C1402A7 for ; Fri, 24 Jul 2015 20:59:03 +1000 (AEST) Received: from localhost ([::1]:44533 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZIagv-0005Vi-L8 for incoming@patchwork.ozlabs.org; Fri, 24 Jul 2015 06:59:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43028) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZIaeP-000151-HY for qemu-devel@nongnu.org; Fri, 24 Jul 2015 06:56:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZIaeO-00007H-La for qemu-devel@nongnu.org; Fri, 24 Jul 2015 06:56:25 -0400 Received: from [59.151.112.132] (port=61232 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZIaeN-0008QF-6o for qemu-devel@nongnu.org; Fri, 24 Jul 2015 06:56:24 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="98817549" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 24 Jul 2015 18:59:59 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t6OAsVHL024402; Fri, 24 Jul 2015 18:54:31 +0800 Received: from localhost (10.167.226.223) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 24 Jul 2015 18:56:19 +0800 From: Yang Hongyang To: Date: Fri, 24 Jul 2015 18:55:56 +0800 Message-ID: <1437735359-17415-7-git-send-email-yanghy@cn.fujitsu.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1437735359-17415-1-git-send-email-yanghy@cn.fujitsu.com> References: <1437735359-17415-1-git-send-email-yanghy@cn.fujitsu.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: jasowang@redhat.com, mrhines@linux.vnet.ibm.com, thuth@redhat.com, stefanha@redhat.com, Yang Hongyang Subject: [Qemu-devel] [PATCH 6/9] introduce qemu_find_net_clients_by_model X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Yang Hongyang --- include/net/net.h | 2 ++ net/net.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/net/net.h b/include/net/net.h index 250f365..10927e1 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -108,6 +108,8 @@ char *qemu_mac_strdup_printf(const uint8_t *macaddr); NetClientState *qemu_find_netdev(const char *id); int qemu_find_net_clients_except(const char *id, NetClientState **ncs, NetClientOptionsKind type, int max); +int qemu_find_net_clients_by_model(const char *model, NetClientState **ncs, + int max); NetClientState *qemu_new_net_client(NetClientInfo *info, NetClientState *peer, const char *model, diff --git a/net/net.c b/net/net.c index 856a0fe..7b62e52 100644 --- a/net/net.c +++ b/net/net.c @@ -780,6 +780,24 @@ int qemu_find_net_clients_except(const char *id, NetClientState **ncs, return ret; } +int qemu_find_net_clients_by_model(const char *model, NetClientState **ncs, + int max) +{ + NetClientState *nc; + int ret = 0; + + QTAILQ_FOREACH(nc, &net_clients, next) { + if (!strcmp(nc->model, model)) { + if (ret < max) { + ncs[ret] = nc; + } + ret++; + } + } + + return ret; +} + static int nic_get_free_idx(void) { int index;