Skip to contentSkip to conversation

qdev-properties-system.c: Allow vlan or netdev for -device, not both

PATCH Applied Vlad Yasevich 4 participants 6 messages Nov 8, 2013 – Nov 22, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qdev-properties-system.c: Allow vlan or netdev for -device, not both

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.

---
 hw/core/qdev-properties-system.c | 9 +++++++++
 1 file changed, 9 insertions(+)
hw/core/qdev-properties-system.c +9 -0
index 0eada32..729efa8 100644
@@ -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) {
Signature · 1 line
1.8.3.1
Acked-by on v1 1/1
#1 lore raw
Quoted 32 lines · 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.

---
 hw/core/qdev-properties-system.c | 9 +++++++++
 1 file changed, 9 insertions(+)
hw/core/qdev-properties-system.c +5 -0
index 0eada32..729efa8 100644
@@ -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;
     }

hw/core/qdev-properties-system.c static void set_vlan(Object *obj, Visitor *v, void *opaque, · line 315

Quoted 10 lines
hw/core/qdev-properties-system.c +4 -0
@@ -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) {
#2 lore raw

Il 11/11/2013 06:18, Jason Wang ha scritto:

Quoted 41 lines · Vlad Yasevich
Quoted 40 lines

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.

---
 hw/core/qdev-properties-system.c | 9 +++++++++
 1 file changed, 9 insertions(+)
hw/core/qdev-properties-system.c +9 -0
index 0eada32..729efa8 100644
@@ -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;
+    }
 
Quoted 4 lines

hw/core/qdev-properties-system.c static void set_vlan(Object *obj, Visitor *v, void *opaque, · line 315

Quoted 2 lines
hw/core/qdev-properties-system.c +0 -0
     hubport = net_hub_port_find(id);
     if (!hubport) {

This patch is good for 1.7.

Paolo

#3 lore raw
Quoted 42 lines · Paolo Bonzini

Il 11/11/2013 06:18, Jason Wang ha scritto:

Quoted 41 lines · Vlad Yasevich
Quoted 40 lines

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.

---
 hw/core/qdev-properties-system.c | 9 +++++++++
 1 file changed, 9 insertions(+)
hw/core/qdev-properties-system.c +9 -0
index 0eada32..729efa8 100644
@@ -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;
+    }
 
Quoted 9 lines
Quoted 4 lines

hw/core/qdev-properties-system.c static void set_vlan(Object *obj, Visitor *v, void *opaque, · line 315

Quoted 2 lines
hw/core/qdev-properties-system.c +0 -0
     hubport = net_hub_port_find(id);
     if (!hubport) {

This patch is good for 1.7.

Paolo

Hi All

Just wondering what's to become of this patch? It has an ACK, but has been abandoned. It does a fix a crash in qemu.

Thanks
-vlad

#4 lore raw

Il 21/11/2013 20:47, Vlad Yasevich ha scritto:

Quoted 50 lines · Paolo Bonzini
Quoted 49 lines

Il 11/11/2013 06:18, Jason Wang ha scritto:

Quoted 41 lines · Vlad Yasevich
Quoted 40 lines

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.

---
 hw/core/qdev-properties-system.c | 9 +++++++++
 1 file changed, 9 insertions(+)
hw/core/qdev-properties-system.c +9 -0
index 0eada32..729efa8 100644
@@ -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;
+    }
 
Quoted 4 lines

hw/core/qdev-properties-system.c static void set_vlan(Object *obj, Visitor *v, void *opaque, · line 315

Quoted 2 lines
hw/core/qdev-properties-system.c +0 -0
     hubport = net_hub_port_find(id);
     if (!hubport) {

This patch is good for 1.7.

Quoted 7 lines
Quoted 2 lines

Paolo

Hi All

Just wondering what's to become of this patch? It has an ACK, but has been abandoned. It does a fix a crash in qemu.

I missed this when going through pending patches. Stefan, are you picking it up?

Paolo

#5 lore raw
In reply to Vlad Yasevich
Quoted 7 lines · 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.

Quoted 7 lines

That patch treates the above command line options as invalid and generates an error at start-up.

---
 hw/core/qdev-properties-system.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Thanks, applied to my net tree:
https://github.com/stefanha/qemu/commits/net

Stefan