aboutsummaryrefslogtreecommitdiff
path: root/net.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2011-08-04 17:15:22 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2011-08-04 17:15:22 -0500
commit81e34a2401f7ffd519bb7f093e833cb48734169f (patch)
tree146a7b6eebbee1367453fde501d4462ac6d9f8b4 /net.c
parente06516f565dca3636a4cbef770b191a5fcdf63ab (diff)
parentcb4b4fde82b064472c13fb9d983ca36a70e560aa (diff)
Merge remote-tracking branch 'mst/for_anthony' into staging
Diffstat (limited to 'net.c')
-rw-r--r--net.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/net.c b/net.c
index 31c23389c8..cb6a2b03d8 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);
@@ -653,6 +658,8 @@ VLANClientState *qemu_find_netdev(const char *id)
VLANClientState *vc;
QTAILQ_FOREACH(vc, &non_vlan_clients, next) {
+ if (vc->info->type == NET_CLIENT_TYPE_NIC)
+ continue;
if (!strcmp(vc->name, id)) {
return vc;
}
@@ -1212,7 +1219,7 @@ int do_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
VLANClientState *vc;
vc = qemu_find_netdev(id);
- if (!vc || vc->info->type == NET_CLIENT_TYPE_NIC) {
+ if (!vc) {
qerror_report(QERR_DEVICE_NOT_FOUND, id);
return -1;
}
@@ -1270,7 +1277,11 @@ int do_set_link(Monitor *mon, const QDict *qdict, QObject **ret_data)
}
}
}
- vc = qemu_find_netdev(name);
+ QTAILQ_FOREACH(vc, &non_vlan_clients, next) {
+ if (!strcmp(vc->name, name)) {
+ goto done;
+ }
+ }
done:
if (!vc) {