From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: markmc@redhat.com, aliguori@us.ibm.com
Subject: [Qemu-devel] [PATCH 1/2] Fix automatically assigned network names for netdev
Date: Thu, 16 Jun 2011 18:45:36 +0200 [thread overview]
Message-ID: <1308242737-15449-2-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1308242737-15449-1-git-send-email-armbru@redhat.com>
If a network client doesn't have a name, we make one up, with
assign_name(). assign_name() creates a name MODEL.NUM, where MODEL is
the client's model, and NUM is the number of MODELs that already
exist.
Bug: it misses clients that are not on a VLAN, i.e. netdevs and the
NICs using them:
$ qemu-system-x86_64 -nodefaults -vnc :0 -S -monitor stdio -netdev user,id=hostnet0 -net nic,netdev=hostnet0 -netdev user,id=hostnet1 -net nic,netdev=hostnet1
QEMU 0.14.50 monitor - type 'help' for more information
(qemu) info network
Devices not on any VLAN:
hostnet0: net=10.0.2.0, restricted=n peer=e1000.0
hostnet1: net=10.0.2.0, restricted=n peer=e1000.0
e1000.0: model=e1000,macaddr=52:54:00:12:34:56 peer=hostnet0
e1000.0: model=e1000,macaddr=52:54:00:12:34:57 peer=hostnet1
Fix that.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
net.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/net.c b/net.c
index 4f777c3..8754627 100644
--- a/net.c
+++ b/net.c
@@ -150,12 +150,11 @@ void qemu_macaddr_default_if_unset(MACAddr *macaddr)
static char *assign_name(VLANClientState *vc1, const char *model)
{
VLANState *vlan;
+ VLANClientState *vc;
char buf[256];
int id = 0;
QTAILQ_FOREACH(vlan, &vlans, next) {
- VLANClientState *vc;
-
QTAILQ_FOREACH(vc, &vlan->clients, next) {
if (vc != vc1 && strcmp(vc->model, model) == 0) {
id++;
@@ -163,6 +162,12 @@ static char *assign_name(VLANClientState *vc1, const char *model)
}
}
+ QTAILQ_FOREACH(vc, &non_vlan_clients, next) {
+ if (vc != vc1 && strcmp(vc->model, model) == 0) {
+ id++;
+ }
+ }
+
snprintf(buf, sizeof(buf), "%s.%d", model, id);
return qemu_strdup(buf);
--
1.7.2.3
next prev parent reply other threads:[~2011-06-16 16:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-16 16:45 [Qemu-devel] [PATCH 0/2] netdev fixes Markus Armbruster
2011-06-16 16:45 ` Markus Armbruster [this message]
2011-06-16 16:45 ` [Qemu-devel] [PATCH 2/2] Fix netdev name lookup in -device, device_add, netdev_del Markus Armbruster
2011-06-28 11:54 ` [Qemu-devel] [PATCH 0/2] netdev fixes Markus Armbruster
2011-07-11 12:01 ` Markus Armbruster
2011-07-19 12:10 ` Michael S. Tsirkin
2011-07-19 17:52 ` Jan Kiszka
2011-07-20 8:19 ` Michael S. Tsirkin
2011-07-20 8:22 ` Mark McLoughlin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1308242737-15449-2-git-send-email-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=markmc@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).