From patchwork Fri May 3 11:57:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 241300 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 99CBB2C00CA for ; Fri, 3 May 2013 22:31:31 +1000 (EST) Received: from localhost ([::1]:33026 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYEfG-0005yF-Ss for incoming@patchwork.ozlabs.org; Fri, 03 May 2013 08:00:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:42195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYEcT-0002OP-8u for qemu-devel@nongnu.org; Fri, 03 May 2013 07:57:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UYEcQ-0002kI-IO for qemu-devel@nongnu.org; Fri, 03 May 2013 07:57:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64621) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYEcQ-0002k7-17 for qemu-devel@nongnu.org; Fri, 03 May 2013 07:57:42 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r43BvfmC024265 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 3 May 2013 07:57:41 -0400 Received: from localhost (ovpn-112-30.ams2.redhat.com [10.36.112.30]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r43Bvee2013893; Fri, 3 May 2013 07:57:40 -0400 From: Stefan Hajnoczi To: Date: Fri, 3 May 2013 13:57:33 +0200 Message-Id: <1367582254-15060-2-git-send-email-stefanha@redhat.com> In-Reply-To: <1367582254-15060-1-git-send-email-stefanha@redhat.com> References: <1367582254-15060-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Anthony Liguori , Amos Kong , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH 1/2] 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 From: Amos Kong 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 Signed-off-by: Stefan Hajnoczi --- net/net.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/net/net.c b/net/net.c index 7869161..43a74e4 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++; } }