Blame SOURCES/kvm-qdev-properties-system.c-Allow-vlan-or-netdev-for-de.patch

958e1b
From f54c8f7db9bca89e9989cbfe1af652f5b4552c92 Mon Sep 17 00:00:00 2001
958e1b
From: Vlad Yasevich <vyasevic@redhat.com>
958e1b
Date: Thu, 4 Sep 2014 20:31:00 +0200
958e1b
Subject: [PATCH 5/6] qdev-properties-system.c: Allow vlan or netdev for -device, not both
958e1b
958e1b
Message-id: <1409862660-30181-1-git-send-email-vyasevic@redhat.com>
958e1b
Patchwork-id: 60839
958e1b
O-Subject: [RHEL7.1 qemu-kvm PATCH] qdev-properties-system.c: Allow vlan or netdev for -device, not both
958e1b
Bugzilla: 996011
958e1b
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
958e1b
RH-Acked-by: Xiao Wang <jasowang@redhat.com>
958e1b
958e1b
From: Vlad Yasevich <vyasevic@redhat.com>
958e1b
958e1b
It is currently possible to specify things like:
958e1b
	-device e1000,netdev=foo,vlan=1
958e1b
With this usage, whichever argument was specified last (vlan or netdev)
958e1b
overwrites what was previousely set and results in a non-working
958e1b
configuration.  Even worse, when used with multiqueue devices,
958e1b
it causes a segmentation fault on exit in qemu_free_net_client.
958e1b
958e1b
That patch treates the above command line options as invalid and
958e1b
generates an error at start-up.
958e1b
958e1b
Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
958e1b
Acked-by: Jason Wang <jasowang@redhat.com>
958e1b
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
958e1b
(cherry picked from commit 30c367ed446b6ea53245589a5cf373578ac075d7)
958e1b
958e1b
Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
958e1b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
---
958e1b
 hw/core/qdev-properties-system.c |    9 +++++++++
958e1b
 1 files changed, 9 insertions(+), 0 deletions(-)
958e1b
958e1b
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
958e1b
index 0eada32..729efa8 100644
958e1b
--- a/hw/core/qdev-properties-system.c
958e1b
+++ b/hw/core/qdev-properties-system.c
958e1b
@@ -205,6 +205,11 @@ static int parse_netdev(DeviceState *dev, const char *str, void **ptr)
958e1b
             goto err;
958e1b
         }
958e1b
 
958e1b
+        if (ncs[i]) {
958e1b
+            ret = -EINVAL;
958e1b
+            goto err;
958e1b
+        }
958e1b
+
958e1b
         ncs[i] = peers[i];
958e1b
         ncs[i]->queue_index = i;
958e1b
     }
958e1b
@@ -301,6 +306,10 @@ static void set_vlan(Object *obj, Visitor *v, void *opaque,
958e1b
         *ptr = NULL;
958e1b
         return;
958e1b
     }
958e1b
+    if (*ptr) {
958e1b
+        error_set_from_qdev_prop_error(errp, -EINVAL, dev, prop, name);
958e1b
+        return;
958e1b
+    }
958e1b
 
958e1b
     hubport = net_hub_port_find(id);
958e1b
     if (!hubport) {
958e1b
-- 
958e1b
1.7.1
958e1b