[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] qdev: Catch attempt to attach more than one device
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PATCH] qdev: Catch attempt to attach more than one device to a netdev |
Date: |
Thu, 25 Feb 2010 11:10:15 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
Guest device and host netdev are peers, i.e. it's a 1:1 relation.
However, we fail to enforce that:
$ qemu -nodefaults --nographic -netdev user,id=net0 -device
e1000,netdev=net0 -device virtio-net-pci,netdev=net0 -monitor stdio
QEMU 0.12.50 monitor - type 'help' for more information
(qemu) info network
Devices not on any VLAN:
net0: net=10.0.2.0, restricted=n peer=virtio-net-pci.0
e1000.0: model=e1000,macaddr=52:54:00:12:34:56 peer=net0
virtio-net-pci.0: model=virtio-net-pci,macaddr=52:54:00:12:34:57 peer=net0
It's all downhill from there.
Signed-off-by: Markus Armbruster <address@hidden>
---
hw/qdev-properties.c | 3 +++
net.c | 1 +
2 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 277ff9e..89efd91 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -341,6 +341,9 @@ static int parse_netdev(DeviceState *dev, Property *prop,
const char *str)
*ptr = qemu_find_netdev(str);
if (*ptr == NULL)
return -1;
+ if ((*ptr)->peer) {
+ return -1;
+ }
return 0;
}
diff --git a/net.c b/net.c
index a1bf49f..e6c96d3 100644
--- a/net.c
+++ b/net.c
@@ -245,6 +245,7 @@ VLANClientState *qemu_new_net_client(NetClientInfo *info,
QTAILQ_INSERT_TAIL(&vc->vlan->clients, vc, next);
} else {
if (peer) {
+ assert(!peer->peer);
vc->peer = peer;
peer->peer = vc;
}
--
1.6.6
- [Qemu-devel] [PATCH] qdev: Catch attempt to attach more than one device to a netdev,
Markus Armbruster <=
- [Qemu-devel] Re: [PATCH] qdev: Catch attempt to attach more than one device to a netdev, Michael S. Tsirkin, 2010/02/25
- [Qemu-devel] Re: [PATCH] qdev: Catch attempt to attach more than one device to a netdev, Markus Armbruster, 2010/02/25
- [Qemu-devel] Re: [PATCH] qdev: Catch attempt to attach more than one device to a netdev, Michael S. Tsirkin, 2010/02/25
- [Qemu-devel] Re: [PATCH] qdev: Catch attempt to attach more than one device to a netdev, Markus Armbruster, 2010/02/25
- [Qemu-devel] Re: [PATCH] qdev: Catch attempt to attach more than one device to a netdev, Markus Armbruster, 2010/02/25
- [Qemu-devel] Re: [PATCH] qdev: Catch attempt to attach more than one device to a netdev, Gerd Hoffmann, 2010/02/25
- [Qemu-devel] Re: [PATCH] qdev: Catch attempt to attach more than one device to a netdev, Markus Armbruster, 2010/02/26
- [Qemu-devel] Re: [PATCH] qdev: Catch attempt to attach more than one device to a netdev, Gerd Hoffmann, 2010/02/26
- [Qemu-devel] Re: [PATCH] qdev: Catch attempt to attach more than one device to a netdev, Markus Armbruster, 2010/02/26