From patchwork Mon Apr 15 10:55:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amos Kong X-Patchwork-Id: 236560 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 80AFD2C00E1 for ; Mon, 15 Apr 2013 20:56:07 +1000 (EST) Received: from localhost ([::1]:50395 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URh4v-00052q-Kw for incoming@patchwork.ozlabs.org; Mon, 15 Apr 2013 06:56:05 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37807) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URh4R-00052Q-7B for qemu-devel@nongnu.org; Mon, 15 Apr 2013 06:55:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1URh4I-00019I-KX for qemu-devel@nongnu.org; Mon, 15 Apr 2013 06:55:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14577) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URh4I-00018Z-81 for qemu-devel@nongnu.org; Mon, 15 Apr 2013 06:55:26 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3FAtO0O009600 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 15 Apr 2013 06:55:24 -0400 Received: from t430s.nay.redhat.com (vpn1-115-22.nay.redhat.com [10.66.115.22]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r3FAtLLO006374; Mon, 15 Apr 2013 06:55:22 -0400 From: Amos Kong To: qemu-devel@nongnu.org Date: Mon, 15 Apr 2013 18:55:19 +0800 Message-Id: <1366023319-9484-1-git-send-email-akong@redhat.com> In-Reply-To: <1365681519-4614-1-git-send-email-akong@redhat.com> References: <1365681519-4614-1-git-send-email-akong@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: stefanha@redhat.com Subject: [Qemu-devel] [PATCH v2] net: make network client name unique 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 assign_name() creates a name MODEL.NUM, where MODEL is the client's model, and NUM is the number of MODELs that already exist. Markus added NIC naming for non-VLAN clients in commit 53e51d85. commit d33d93b2 incorrectly added a judgement of net-hub. It caused net clients created with -netdev get same names. eg: # qemu-upstream -device virtio-net-pci,netdev=h1 -netdev tap,id=h1 \ -device virtio-net-pci,netdev=h2 -netdev tap,id=h2 .. (qemu) info network virtio-net-pci.0: index=0,type=nic,model=virtio-net-pci,macaddr=52:54:00:12:34:56 \ h1: index=0,type=tap,ifname=tap0,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown virtio-net-pci.0: index=0,type=nic,model=virtio-net-pci,macaddr=52:54:00:12:34:57 \ h2: index=0,type=tap,ifname=tap1,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown This patch removed the check of nic-hub, and created unique names for all net clients that have same model. v2: update commitlog & comments Signed-off-by: Amos Kong --- net/net.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/net/net.c b/net/net.c index 67032f5..9011174 100644 --- a/net/net.c +++ b/net/net.c @@ -157,8 +157,7 @@ void qemu_macaddr_default_if_unset(MACAddr *macaddr) /** * Generate a name for net client * - * Only net clients created with the legacy -net option need this. Naming is - * mandatory for net clients created with -netdev. + * Only net clients created with the legacy -net option and NICs need this. */ static char *assign_name(NetClientState *nc1, const char *model) { @@ -170,9 +169,7 @@ static char *assign_name(NetClientState *nc1, const char *model) if (nc == nc1) { continue; } - /* For compatibility only bump id for net clients on a vlan */ - if (strcmp(nc->model, model) == 0 && - net_hub_id_for_client(nc, NULL) == 0) { + if (strcmp(nc->model, model) == 0) { id++; } }