From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nkd9k-00087Y-Q3 for qemu-devel@nongnu.org; Thu, 25 Feb 2010 07:49:28 -0500 Received: from [199.232.76.173] (port=53907 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nkd9j-00085u-Kz for qemu-devel@nongnu.org; Thu, 25 Feb 2010 07:49:27 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nkd9h-00043H-QL for qemu-devel@nongnu.org; Thu, 25 Feb 2010 07:49:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:19920) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nkd9h-000439-6V for qemu-devel@nongnu.org; Thu, 25 Feb 2010 07:49:25 -0500 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1PCnNOE014845 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 25 Feb 2010 07:49:24 -0500 From: Markus Armbruster References: <20100225114256.GC9116@redhat.com> <20100225120848.GA9223@redhat.com> Date: Thu, 25 Feb 2010 13:49:22 +0100 In-Reply-To: <20100225120848.GA9223@redhat.com> (Michael S. Tsirkin's message of "Thu, 25 Feb 2010 14:08:48 +0200") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: [Qemu-devel] Re: [PATCH] qdev: Catch attempt to attach more than one device to a netdev List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: Mark McLoughlin , qemu-devel@nongnu.org, Gerd Hoffmann "Michael S. Tsirkin" writes: > On Thu, Feb 25, 2010 at 01:07:54PM +0100, Markus Armbruster wrote: >> "Michael S. Tsirkin" writes: >> >> > On Thu, Feb 25, 2010 at 11:10:15AM +0100, Markus Armbruster wrote: >> >> 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 >> >> --- >> >> 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; >> >> + } >> > >> > Not even -EBUSY? >> > Can this produce a helpful diagnostic message? >> >> Callers take care of that. It's how property parse methods work. >> In this case: >> >> property "virtio-net-pci.netdev": failed to parse "net0" >> can't set property "netdev" to "net0" for "virtio-net-pci" > > Yes, but does not tell you why. If parse_netdev even just returned a meaningful > error code, we could see: > can't set property "netdev" to "net0" for "virtio-net-pci": > device or resource busy. > > which is at least a hint that something else uses it. > > As it is, it looks like qemu could not parse "net0" > which is not really right. Yes, but that's really a separate problem, namely that parse methods need a way to indicate what went wrong.