From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:44055) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQG9S-00080U-Fl for qemu-devel@nongnu.org; Thu, 11 Apr 2013 07:58:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UQG9R-0007V0-JA for qemu-devel@nongnu.org; Thu, 11 Apr 2013 07:58:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64287) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQG9R-0007Uu-BR for qemu-devel@nongnu.org; Thu, 11 Apr 2013 07:58:49 -0400 From: Amos Kong Date: Thu, 11 Apr 2013 19:58:39 +0800 Message-Id: <1365681519-4614-1-git-send-email-akong@redhat.com> In-Reply-To: <20130411082240.GF5253@stefanha-thinkpad.redhat.com> References: <20130411082240.GF5253@stefanha-thinkpad.redhat.com> Subject: [Qemu-devel] [PATCH] net: make nic name unique List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: anthony@codemonkey.ws, stefanha@redhat.com, afaerber@suse.de If we don't assign 'id' for nic device, device's name will be $model.$idx. The $idx is always 0 if we use new style of cmdline. This problem was introduced by commit d33d93b2. 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 remove the check of hub, allocate increased id for all devices that have same model. Signed-off-by: Amos Kong --- net/net.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/net.c b/net/net.c index 67032f5..631e7d0 100644 --- a/net/net.c +++ b/net/net.c @@ -171,8 +171,7 @@ static char *assign_name(NetClientState *nc1, const char *model) 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++; } } -- 1.8.1.4