Skip to contentSkip to conversation

Nic devices' name are wrongly repeated

Qemu-devel In review Amos Kong 6 participants 13 messages Apr 10, 2013 – Apr 18, 2013 Networking

lore
Share & tools
lore

Amos Kong

author
#0 lore raw

Hi Stefan,

If we don't assign 'id' for nic device, device name will be $model.$idx. The $idx are always 0 if we set nic by new style.

# 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

it's introduced by commit d33d93b2

If we set links down by 'set_link virtio-net-pci.0', the first nic will be set down. But how to set the second link down by id?

Signature · 1 line
			Amos.
#1 lore raw

Hi,

Am 10.04.2013 14:05, schrieb Amos Kong:

Quoted 10 lines

If we don't assign 'id' for nic device, device name will be $model.$idx. The $idx are always 0 if we set nic by new style.

# 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

it's introduced by commit d33d93b2

I can see that's inconvenient, but...

Quoted 2 lines

If we set links down by 'set_link virtio-net-pci.0', the first nic will be set down. But how to set the second link down by id?

As you would do for all devices? I.e., add ,id=youruniqueid to -device.

Having said that, in a different context (USB) I was made aware that we don't know the bus name at QOM initialization time yet and, if we want to create a bus at that point, will need to rename it later. Thus we'd need an overridable ID setter hook to propagate to busses, and if we had such a settable ID property it would be convenient for your use case to have a matching monitor command as well to be able to resolve name conflicts at runtime rather than with a QEMU restart.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
author
#2 lore raw
Quoted 12 lines · Andreas Färber

Hi,

Am 10.04.2013 14:05, schrieb Amos Kong:

Quoted 9 lines

If we don't assign 'id' for nic device, device name will be $model.$idx. The $idx are always 0 if we set nic by new style.

# 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
Quoted 8 lines
Quoted 1 line

it's introduced by commit d33d93b2

I can see that's inconvenient, but...

Quoted 2 lines

If we set links down by 'set_link virtio-net-pci.0', the first nic will be set down. But how to set the second link down by id?

As you would do for all devices? I.e., add ,id=youruniqueid to -device.

If we also assigned unique ids for nic devices, it works.

Quoted 7 lines

Having said that, in a different context (USB) I was made aware that we don't know the bus name at QOM initialization time yet and, if we want to create a bus at that point, will need to rename it later. Thus we'd need an overridable ID setter hook to propagate to busses, and if we had such a settable ID property it would be convenient for your use case to have a matching monitor command as well to be able to resolve name conflicts at runtime rather than with a QEMU restart.

It's better to allocate an increased & uniqued index suffix automatically as past. monitor command is good for human, but it's difficult for management tools to identify & resolve the conflicts.

Quoted 5 lines

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Signature · 1 line
			Amos.
#3 lore raw
Quoted 15 lines · Amos Kong
Quoted 14 lines · Andreas Färber

Hi,

Am 10.04.2013 14:05, schrieb Amos Kong:

Quoted 10 lines

If we don't assign 'id' for nic device, device name will be $model.$idx. The $idx are always 0 if we set nic by new style.

# 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

it's introduced by commit d33d93b2

Quoted 8 lines
Quoted 6 lines

I can see that's inconvenient, but...

Quoted 2 lines

If we set links down by 'set_link virtio-net-pci.0', the first nic will be set down. But how to set the second link down by id?

As you would do for all devices? I.e., add ,id=youruniqueid to -device.

If we also assigned unique ids for nic devices, it works.

I was unaware of this issue. Do you want to send a fix so NICs get unique names?

Stefan

author
#4 lore raw

PATCH 1/1 net: make nic name unique

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.

---
 net/net.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/net.c +1 -2
index 67032f5..631e7d0 100644
@@ -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++;
         }
     }
Signature · 1 line
1.8.1.4
#5 lore raw

Re: [Qemu-devel] [PATCH] net: make nic name unique

Quoted 13 lines · Amos Kong

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
Quoted 7 lines

This patch remove the check of hub, allocate increased id for all devices that have same model.

---
 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".

net/net.c static char *assign_name(NetClientState *nc1, const char *model) · line 176

Quoted 13 lines
net/net.c +1 -2
index 67032f5..631e7d0 100644
@@ -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

#6 lore raw

Re: [Qemu-devel] [PATCH] net: make nic name unique

Quoted 5 lines · Stefan Hajnoczi
Quoted 4 lines · Amos Kong

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.

Quoted 8 lines
Quoted 8 lines

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" %-/

Quoted 11 lines
Quoted 8 lines

This patch remove the check of hub, allocate increased id for all devices that have same model.

---
 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.

Quoted 35 lines

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/net.c static char *assign_name(NetClientState *nc1, const char *model) · line 176

Quoted 13 lines
net/net.c +1 -2
index 67032f5..631e7d0 100644
@@ -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

author
#7 lore raw

PATCH v2 1/1 net: make network client name unique

In reply to 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

---
 net/net.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
net/net.c +2 -5
index 67032f5..9011174 100644
@@ -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++;
         }
     }
Signature · 1 line
1.8.1.4
#8 lore raw

Re: [Qemu-devel] [PATCH v2] net: make network client name unique

Quoted 19 lines · 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.

Quoted 6 lines

v2: update commitlog & comments

---
 net/net.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Thanks, applied to my net tree:
https://github.com/stefanha/qemu/commits/net

Stefan

author Tested-by Cornelia Huck Tested-by Cornelia Huck Tested-by Cornelia Huck Tested-by Cornelia Huck Tested-by Cornelia Huck Tested-by Cornelia Huck Tested-by Cornelia Huck
#9 lore raw

[Qemu-devel] 'id' assigned to -device could not be set as net-client name (was Re: Nic devices' name are wrongly repeated)

In reply to Andreas Färber
Quoted 12 lines · Andreas Färber

Hi,

Am 10.04.2013 14:05, schrieb Amos Kong:

Quoted 9 lines

If we don't assign 'id' for nic device, device name will be $model.$idx. The $idx are always 0 if we set nic by new style.

# 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
Quoted 8 lines
Quoted 1 line

it's introduced by commit d33d93b2

I can see that's inconvenient, but...

Quoted 2 lines

If we set links down by 'set_link virtio-net-pci.0', the first nic will be set down. But how to set the second link down by id?

As you would do for all devices? I.e., add ,id=youruniqueid to -device.

Hi KONRAD,

Your following patch just introduced a regression, 'id' assigned to -device could not be set as net-client name.

qemu -device virtio-net-pci,netdev=ndev1,id=id1 -netdev tap,id=ndev1 \
              -device e1000,netdev=ndev2,id=id2 -netdev tap,id=ndev2

(qemu) info network
virtio-net-device.0: index=0,type=nic,model=virtio-net-device,macaddr=52:54:00:12:34:56
\ ndev1: index=0,type=tap,ifname=tap0,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown
id2: index=0,type=nic,model=e1000,macaddr=52:54:00:12:34:57
\ ndev2: index=0,type=tap,ifname=tap1,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown

===============================================
commit 1773d9ee6e7138e3956081670215e8bc0ae14828

Author: KONRAD Frederic <[email protected]>
Date:   Thu Apr 11 16:30:02 2013 +0200

virtio-net: cleanup: init and exit function.

This remove old init and exit function as they are no longer needed.

Message-id: [email protected]

commit 17a0ca55657114c055cb407291c1163e09b29973

Author: KONRAD Frederic <[email protected]>
Date:   Thu Apr 11 16:30:01 2013 +0200

virtio-net: cleanup: use QOM cast.

As the virtio-net-pci and virtio-net-s390 are switched to the new API, we can use QOM casts.

Message-id: [email protected]

commit 89334c8b6baebb1e84cd9bb6e796683e53391769

Author: KONRAD Frederic <[email protected]>
Date:   Thu Apr 11 16:30:00 2013 +0200

virtio-net-ccw: switch to the new API.

Here the virtio-net-ccw is modified for the new API. The device virtio-net-ccw extends virtio-ccw-device as before. It creates and connects a virtio-net-device during the init. The properties are not modified.

Message-id: [email protected]

commit 74b4fe3d79098b72813e461af565557bb5d35649

Author: KONRAD Frederic <[email protected]>
Date:   Thu Apr 11 16:29:59 2013 +0200

virtio-net-s390: switch to the new API.

Here the virtio-net-s390 is modified for the new API. The device virtio-net-s390 extends virtio-s390-device as before. It creates and connects a virtio-net-device during the init. The properties are not modified.

Message-id: [email protected]

commit e37da3945fa2fde161e1b217f937fc318c4b7639

Author: KONRAD Frederic <[email protected]>
Date:   Thu Apr 11 16:29:58 2013 +0200

virtio-net-pci: switch to the new API.

Here the virtio-net-pci is modified for the new API. The device virtio-net-pci extends virtio-pci. It creates and connects a virtio-net-device during the init. The properties are not changed.

Message-id: [email protected]

commit 17ec5a8686143da66208273d355f2eeb09807614

Author: KONRAD Frederic <[email protected]>
Date:   Thu Apr 11 16:29:57 2013 +0200

virtio-net: add the virtio-net device.

Create virtio-net-device which extends virtio-device, so it can be connected on virtio-bus.

Message-id: [email protected]

commit 6a87acf7df4b31ca0896b95b86dac9698420a9ed

Author: KONRAD Frederic <[email protected]>
Date:   Thu Apr 11 16:29:56 2013 +0200

virtio: add two functions to VirtioDeviceClass.

Recent changes need two functions to VirtioDevice. This just add them into VirtioDeviceClass.

Message-id: [email protected]

Signature · 1 line
			Amos.
#10 lore raw

Re: [Qemu-devel] 'id' assigned to -device could not be set as net-client name (was Re: Nic devices' name are wrongly repeated)

Quoted 16 lines · Amos Kong
Quoted 15 lines · Andreas Färber

Hi,

Am 10.04.2013 14:05, schrieb Amos Kong:

Quoted 10 lines

If we don't assign 'id' for nic device, device name will be $model.$idx. The $idx are always 0 if we set nic by new style.

# 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

it's introduced by commit d33d93b2

I can see that's inconvenient, but...

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

If we set links down by 'set_link virtio-net-pci.0', the first nic will be set down. But how to set the second link down by id?

As you would do for all devices? I.e., add ,id=youruniqueid to -device.

Hi KONRAD,

Your following patch just introduced a regression, 'id' assigned to -device could not be set as net-client name.

A regression from "net: make nic name unique" ?

Quoted 9 lines
qemu -device virtio-net-pci,netdev=ndev1,id=id1 -netdev tap,id=ndev1 \
               -device e1000,netdev=ndev2,id=id2 -netdev tap,id=ndev2

(qemu) info network
virtio-net-device.0: index=0,type=nic,model=virtio-net-device,macaddr=52:54:00:12:34:56
\ ndev1: index=0,type=tap,ifname=tap0,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown
id2: index=0,type=nic,model=e1000,macaddr=52:54:00:12:34:57
\ ndev2: index=0,type=tap,ifname=tap1,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown

yes :/, that seems to be the side effect of cutting virtio-net-pci in

virtio-net-pci + virtio-net-device.

Here virtio-net-device is the network device as you see in info network.

virtio-net-pci isn't anymore.

I wonder how to solve that as we can't duplicate the id.

I will take a look.

Fred

Quoted 104 lines

===============================================
commit 1773d9ee6e7138e3956081670215e8bc0ae14828

Author: KONRAD Frederic <[email protected]>
Date:   Thu Apr 11 16:30:02 2013 +0200

virtio-net: cleanup: init and exit function.

This remove old init and exit function as they are no longer needed.

Message-id: [email protected]

commit 17a0ca55657114c055cb407291c1163e09b29973

Author: KONRAD Frederic <[email protected]>
Date:   Thu Apr 11 16:30:01 2013 +0200

virtio-net: cleanup: use QOM cast.

As the virtio-net-pci and virtio-net-s390 are switched to the new API, we can use QOM casts.

Message-id: [email protected]

commit 89334c8b6baebb1e84cd9bb6e796683e53391769

Author: KONRAD Frederic <[email protected]>
Date:   Thu Apr 11 16:30:00 2013 +0200

virtio-net-ccw: switch to the new API.

Here the virtio-net-ccw is modified for the new API. The device virtio-net-ccw extends virtio-ccw-device as before. It creates and connects a virtio-net-device during the init. The properties are not modified.

Message-id: [email protected]

commit 74b4fe3d79098b72813e461af565557bb5d35649

Author: KONRAD Frederic <[email protected]>
Date:   Thu Apr 11 16:29:59 2013 +0200

virtio-net-s390: switch to the new API.

Here the virtio-net-s390 is modified for the new API. The device virtio-net-s390 extends virtio-s390-device as before. It creates and connects a virtio-net-device during the init. The properties are not modified.

Message-id: [email protected]

commit e37da3945fa2fde161e1b217f937fc318c4b7639

Author: KONRAD Frederic <[email protected]>
Date:   Thu Apr 11 16:29:58 2013 +0200

virtio-net-pci: switch to the new API.

Here the virtio-net-pci is modified for the new API. The device virtio-net-pci extends virtio-pci. It creates and connects a virtio-net-device during the init. The properties are not changed.

Message-id: [email protected]

commit 17ec5a8686143da66208273d355f2eeb09807614

Author: KONRAD Frederic <[email protected]>
Date:   Thu Apr 11 16:29:57 2013 +0200

virtio-net: add the virtio-net device.

Create virtio-net-device which extends virtio-device, so it can be connected on virtio-bus.

Message-id: [email protected]

commit 6a87acf7df4b31ca0896b95b86dac9698420a9ed

Author: KONRAD Frederic <[email protected]>
Date:   Thu Apr 11 16:29:56 2013 +0200

virtio: add two functions to VirtioDeviceClass.

Recent changes need two functions to VirtioDevice. This just add them into VirtioDeviceClass.

Message-id: [email protected]

author
#11 lore raw

Re: [Qemu-devel] 'id' assigned to -device could not be set as net-client name (was Re: Nic devices' name are wrongly repeated)

Quoted 19 lines · KONRAD Frédéric
Quoted 18 lines · Amos Kong
Quoted 17 lines · Andreas Färber

Hi,

Am 10.04.2013 14:05, schrieb Amos Kong:

Quoted 10 lines

If we don't assign 'id' for nic device, device name will be $model.$idx. The $idx are always 0 if we set nic by new style.

# 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

it's introduced by commit d33d93b2

I can see that's inconvenient, but...

Quoted 2 lines

If we set links down by 'set_link virtio-net-pci.0', the first nic will be set down. But how to set the second link down by id?

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

As you would do for all devices? I.e., add ,id=youruniqueid to -device.

Hi KONRAD,

Your following patch just introduced a regression, 'id' assigned to -device could not be set as net-client name.

A regression from "net: make nic name unique" ?

No, regression caused by commit: e37da3945fa2fde161e1b217f937fc318c4b7639

Quoted 11 lines
Quoted 8 lines
qemu -device virtio-net-pci,netdev=ndev1,id=id1 -netdev tap,id=ndev1 \
              -device e1000,netdev=ndev2,id=id2 -netdev tap,id=ndev2

(qemu) info network
virtio-net-device.0: index=0,type=nic,model=virtio-net-device,macaddr=52:54:00:12:34:56
\ ndev1: index=0,type=tap,ifname=tap0,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown
id2: index=0,type=nic,model=e1000,macaddr=52:54:00:12:34:57
\ ndev2: index=0,type=tap,ifname=tap1,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown

yes :/, that seems to be the side effect of cutting virtio-net-pci in

Quoted 7 lines

virtio-net-pci + virtio-net-device.

Here virtio-net-device is the network device as you see in info network.

virtio-net-pci isn't anymore.

I wonder how to solve that as we can't duplicate the id.

If we don't assign 'id' for -device, the net-client name will be auto generated (not duplicated).

Before your commit e37da394, user assigned 'id' will be record to (DeviceState *)dev->id, it will be used in qemu_new_nic().

Quoted 2 lines

I will take a look.

Quoted 1 line

Fred

Signature · 1 line
			Amos.
#12 lore raw

Re: [Qemu-devel] 'id' assigned to -device could not be set as net-client name (was Re: Nic devices' name are wrongly repeated)

Quoted 42 lines · Amos Kong
Quoted 17 lines · KONRAD Frédéric
Quoted 16 lines · Amos Kong
Quoted 15 lines · Andreas Färber

Hi,

Am 10.04.2013 14:05, schrieb Amos Kong:

Quoted 10 lines

If we don't assign 'id' for nic device, device name will be $model.$idx. The $idx are always 0 if we set nic by new style.

# 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

it's introduced by commit d33d93b2

I can see that's inconvenient, but...

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

If we set links down by 'set_link virtio-net-pci.0', the first nic will be set down. But how to set the second link down by id?

As you would do for all devices? I.e., add ,id=youruniqueid to -device.

Hi KONRAD,

Your following patch just introduced a regression, 'id' assigned to -device could not be set as net-client name.

A regression from "net: make nic name unique" ?

No, regression caused by commit: e37da3945fa2fde161e1b217f937fc318c4b7639

Quoted 14 lines
Quoted 8 lines
qemu -device virtio-net-pci,netdev=ndev1,id=id1 -netdev tap,id=ndev1 \
               -device e1000,netdev=ndev2,id=id2 -netdev tap,id=ndev2

(qemu) info network
virtio-net-device.0: index=0,type=nic,model=virtio-net-device,macaddr=52:54:00:12:34:56
\ ndev1: index=0,type=tap,ifname=tap0,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown
id2: index=0,type=nic,model=e1000,macaddr=52:54:00:12:34:57
\ ndev2: index=0,type=tap,ifname=tap1,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown

yes :/, that seems to be the side effect of cutting virtio-net-pci in

virtio-net-pci + virtio-net-device.

Here virtio-net-device is the network device as you see in info network.

Quoted 8 lines
Quoted 3 lines

virtio-net-pci isn't anymore.

I wonder how to solve that as we can't duplicate the id.

If we don't assign 'id' for -device, the net-client name will be auto generated (not duplicated).

Before your commit e37da394, user assigned 'id' will be record to (DeviceState *)dev->id, it will be used in qemu_new_nic().

Yes sure, what I mean, is:

virtio-net-pci actually get the id and is not the nic device anymore.

and virtio-net-pci create the new virtio-net-device which has no id (so it is autogenerated).

That's why you didn't the id in info network.

Quoted 2 lines
Quoted 2 lines

I will take a look.

Quoted 1 line

Fred