From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45425) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjocJ-0000VE-HY for qemu-devel@nongnu.org; Fri, 22 Nov 2013 06:09:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VjocC-00018H-4v for qemu-devel@nongnu.org; Fri, 22 Nov 2013 06:09:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50091) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjocB-000182-TY for qemu-devel@nongnu.org; Fri, 22 Nov 2013 06:09:36 -0500 From: Stefan Hajnoczi Date: Fri, 22 Nov 2013 12:09:04 +0100 Message-Id: <1385118544-28482-2-git-send-email-stefanha@redhat.com> In-Reply-To: <1385118544-28482-1-git-send-email-stefanha@redhat.com> References: <1385118544-28482-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL 1/1] qdev-properties-system.c: Allow vlan or netdev for -device, not both List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Vlad Yasevich , Stefan Hajnoczi , Anthony Liguori From: Vlad Yasevich It is currently possible to specify things like: -device e1000,netdev=foo,vlan=1 With this usage, whichever argument was specified last (vlan or netdev) overwrites what was previousely set and results in a non-working configuration. Even worse, when used with multiqueue devices, it causes a segmentation fault on exit in qemu_free_net_client. That patch treates the above command line options as invalid and generates an error at start-up. Signed-off-by: Vlad Yasevich Acked-by: Jason Wang Signed-off-by: Stefan Hajnoczi --- hw/core/qdev-properties-system.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index 0eada32..729efa8 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -205,6 +205,11 @@ static int parse_netdev(DeviceState *dev, const char *str, void **ptr) goto err; } + if (ncs[i]) { + ret = -EINVAL; + goto err; + } + ncs[i] = peers[i]; ncs[i]->queue_index = i; } @@ -301,6 +306,10 @@ static void set_vlan(Object *obj, Visitor *v, void *opaque, *ptr = NULL; return; } + if (*ptr) { + error_set_from_qdev_prop_error(errp, -EINVAL, dev, prop, name); + return; + } hubport = net_hub_port_find(id); if (!hubport) { -- 1.8.4.2