From 27f3f8a362570c5e9eb89b36b6c6d5db7b6e70e3 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 26 Feb 2010 15:50:51 +0100 Subject: qdev: Catch attempt to attach more than one device to a netdev 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 Signed-off-by: Anthony Liguori --- net.c | 1 + 1 file changed, 1 insertion(+) (limited to 'net.c') diff --git a/net.c b/net.c index dd3962e..e47f727 100644 --- a/net.c +++ b/net.c @@ -246,6 +246,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; } -- cgit v1.1