Message ID | 1365681519-4614-1-git-send-email-akong@redhat.com |
---|---|
State | New |
Headers | show |
On Thu, Apr 11, 2013 at 07:58:39PM +0800, Amos Kong wrote: > 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 <akong@redhat.com> > --- > net/net.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) I looked a bit more into this. Markus added NIC naming in 53e51d85ef1fdd295c8f09792b8e7490c148f4b3. Please include this commit ID in the commit message. My hub patches incorrectly dropped Markus' fix and I actually documented this: +/** + * 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. + */ static char *assign_name(VLANClientState *vc1, const char *model) Please update this comment to say "Only net clients created with the legacy -net option and NICs need this". > 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++; > } Please delete the incorrect comment about compatibility when dropping the net_hub_id_for_client() call. Stefan
Stefan Hajnoczi <stefanha@gmail.com> writes: > On Thu, Apr 11, 2013 at 07:58:39PM +0800, Amos Kong wrote: >> 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 There are two kinds of names around here: network client names and device (qdev) IDs. Commit message could be tweaked to make it clearer that this is about network client names. As a general rule in QEMU, we call all objects "device", and all classes "driver" %-/ >> >> This patch remove the check of hub, allocate increased id for all devices >> that have same model. >> >> Signed-off-by: Amos Kong <akong@redhat.com> >> --- >> net/net.c | 3 +-- >> 1 file changed, 1 insertion(+), 2 deletions(-) > > I looked a bit more into this. Markus added NIC naming in > 53e51d85ef1fdd295c8f09792b8e7490c148f4b3. Added it to non-VLAN clients, actually. It already existed for VLAN clients. > Please include this commit ID > in the commit message. > > My hub patches incorrectly dropped Markus' fix and I actually documented > this: > > +/** > + * 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. > + */ > static char *assign_name(VLANClientState *vc1, const char *model) > > Please update this comment to say "Only net clients created with the legacy > >> 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++; >> } > > Please delete the incorrect comment about compatibility when dropping the > net_hub_id_for_client() call. > > Stefan
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++; } }
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 <akong@redhat.com> --- net/net.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)