Skip to contentSkip to conversation

qdev: Make "hotplugged" property read-only

PATCH RESEND In review Eduardo Habkost 3 participants 5 messages Feb 22, 2017 – Mar 3, 2017

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 qdev: Make "hotplugged" property read-only

The "hotplugged" property is user visible, but it was never meant to be set by the user. There are probably multiple ways to break or crash device code by overriding the property. For example, we recently fixed a crash in rtc_set_memory() related to the property (commit 26ef65beab852caf2b1ef4976e3473f2d525164d).

There has been some discussion about making management software use "hotplugged=on" on migration, to indicate devices that were hotplugged in the migration source. There were other suggestions to address this, like including the "hotplugged" field in the migration stream instead of requiring it to be set propertly.

Whatever solution we choose in the future, this patch disables setting "hotplugged" explicitly in the command-line by now, because the ability to set the property is unused, untested, and undocumented.

---
 hw/core/qdev.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
hw/core/qdev.c +1 -8
index 06ba02e2a3..800c9ca23f 100644
@@ -1016,13 +1016,6 @@ static bool device_get_hotplugged(Object *obj, Error **err)
     return dev->hotplugged;
 }
 
-static void device_set_hotplugged(Object *obj, bool value, Error **err)
-{
-    DeviceState *dev = DEVICE(obj);
-
-    dev->hotplugged = value;
-}
-
 static void device_initfn(Object *obj)
 {
     DeviceState *dev = DEVICE(obj);
@@ -1042,7 +1035,7 @@ static void device_initfn(Object *obj)
     object_property_add_bool(obj, "hotpluggable",
                              device_get_hotpluggable, NULL, NULL);
     object_property_add_bool(obj, "hotplugged",
-                             device_get_hotplugged, device_set_hotplugged,
+                             device_get_hotplugged, NULL,
                              &error_abort);
 
     class = object_get_class(OBJECT(dev));
Signature · 1 line
2.11.0.259.g40922b1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Eduardo Habkost

The "hotplugged" property is user visible, but it was never meant to be set by the user. There are probably multiple ways to break or crash device code by overriding the property. For example, we recently fixed a crash in rtc_set_memory() related to the property (commit 26ef65beab852caf2b1ef4976e3473f2d525164d).

There has been some discussion about making management software use "hotplugged=on" on migration, to indicate devices that were hotplugged in the migration source. There were other suggestions to address this, like including the "hotplugged" field in the migration stream instead of requiring it to be set propertly.

s/propertly/properly/

Quoted 10 lines

Whatever solution we choose in the future, this patch disables setting "hotplugged" explicitly in the command-line by now, because the ability to set the property is unused, untested, and undocumented.

---
 hw/core/qdev.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
Quoted 29 lines
hw/core/qdev.c +1 -8
index 06ba02e2a3..800c9ca23f 100644
@@ -1016,13 +1016,6 @@ static bool device_get_hotplugged(Object *obj, Error **err)
     return dev->hotplugged;
 }
 
-static void device_set_hotplugged(Object *obj, bool value, Error **err)
-{
-    DeviceState *dev = DEVICE(obj);
-
-    dev->hotplugged = value;
-}
-
 static void device_initfn(Object *obj)
 {
     DeviceState *dev = DEVICE(obj);
@@ -1042,7 +1035,7 @@ static void device_initfn(Object *obj)
     object_property_add_bool(obj, "hotpluggable",
                              device_get_hotpluggable, NULL, NULL);
     object_property_add_bool(obj, "hotplugged",
-                             device_get_hotplugged, device_set_hotplugged,
+                             device_get_hotplugged, NULL,
                              &error_abort);
 
     class = object_get_class(OBJECT(dev));
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#2 lore raw
Quoted 7 lines · Eric Blake
Quoted 6 lines · Eduardo Habkost

The "hotplugged" property is user visible, but it was never meant to be set by the user. There are probably multiple ways to break or crash device code by overriding the property. For example, we recently fixed a crash in rtc_set_memory() related to the property (commit 26ef65beab852caf2b1ef4976e3473f2d525164d).

Quoted 7 lines
Quoted 5 lines

There has been some discussion about making management software use "hotplugged=on" on migration, to indicate devices that were hotplugged in the migration source. There were other suggestions to address this, like including the "hotplugged" field in the migration stream instead of requiring it to be set propertly.

s/propertly/properly/

Actually, I think I meant "requiring it to be set explicitly". I will fix this in my branch. Thanks!

Quoted 7 lines
Quoted 7 lines

Whatever solution we choose in the future, this patch disables setting "hotplugged" explicitly in the command-line by now, because the ability to set the property is unused, untested, and undocumented.

Quoted 6 lines
Quoted 4 lines
---
 hw/core/qdev.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

Thanks!

Quoted 35 lines
Quoted 30 lines
hw/core/qdev.c +1 -8
index 06ba02e2a3..800c9ca23f 100644
@@ -1016,13 +1016,6 @@ static bool device_get_hotplugged(Object *obj, Error **err)
     return dev->hotplugged;
 }
 
-static void device_set_hotplugged(Object *obj, bool value, Error **err)
-{
-    DeviceState *dev = DEVICE(obj);
-
-    dev->hotplugged = value;
-}
-
 static void device_initfn(Object *obj)
 {
     DeviceState *dev = DEVICE(obj);
@@ -1042,7 +1035,7 @@ static void device_initfn(Object *obj)
     object_property_add_bool(obj, "hotpluggable",
                              device_get_hotpluggable, NULL, NULL);
     object_property_add_bool(obj, "hotplugged",
-                             device_get_hotplugged, device_set_hotplugged,
+                             device_get_hotplugged, NULL,
                              &error_abort);
 
     class = object_get_class(OBJECT(dev));
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Signature · 1 line
Eduardo
Reviewed-by on v1 1/1
#3 lore raw
In reply to Eduardo Habkost
Quoted 12 lines · Eduardo Habkost

The "hotplugged" property is user visible, but it was never meant to be set by the user. There are probably multiple ways to break or crash device code by overriding the property. For example, we recently fixed a crash in rtc_set_memory() related to the property (commit 26ef65beab852caf2b1ef4976e3473f2d525164d).

There has been some discussion about making management software use "hotplugged=on" on migration, to indicate devices that were hotplugged in the migration source. There were other suggestions to address this, like including the "hotplugged" field in the migration stream instead of requiring it to be set propertly.

Quoted 6 lines

Whatever solution we choose in the future, this patch disables setting "hotplugged" explicitly in the command-line by now, because the ability to set the property is unused, untested, and undocumented.

I figure this is the safe thing to do for 2.9.

#4 lore raw
Quoted 19 lines · Markus Armbruster
Quoted 17 lines · Eduardo Habkost

The "hotplugged" property is user visible, but it was never meant to be set by the user. There are probably multiple ways to break or crash device code by overriding the property. For example, we recently fixed a crash in rtc_set_memory() related to the property (commit 26ef65beab852caf2b1ef4976e3473f2d525164d).

There has been some discussion about making management software use "hotplugged=on" on migration, to indicate devices that were hotplugged in the migration source. There were other suggestions to address this, like including the "hotplugged" field in the migration stream instead of requiring it to be set propertly.

Whatever solution we choose in the future, this patch disables setting "hotplugged" explicitly in the command-line by now, because the ability to set the property is unused, untested, and undocumented.

Quoted 5 lines
Quoted 1 line

I figure this is the safe thing to do for 2.9.

Thanks. I have merged it to my "machine" branch, and I plan to include it in a pull request next week.

Signature · 1 line
Eduardo