qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qdev: Make "hotplugged" property read-only
@ 2016-12-29 22:38 Eduardo Habkost
  2016-12-30 14:28 ` Igor Mammedov
  0 siblings, 1 reply; 10+ messages in thread
From: Eduardo Habkost @ 2016-12-29 22:38 UTC (permalink / raw)
  To: qemu-devel
  Cc: Markus Armbruster, Andreas Färber, Michael S. Tsirkin,
	Paolo Bonzini, Igor Mammedov

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. One example:

  $ qemu-system-x86_64 -cpu qemu64,hotplugged=true
  Segmentation fault (core dumped)

The DeviceState::hotplugged struct field is set directly by
device_initfn(), there's no need to provide a setter for the
property.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/core/qdev.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 57834423b9..f5989c41cb 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -1013,13 +1013,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);
@@ -1039,7 +1032,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));
-- 
2.11.0.259.g40922b1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-02-22 19:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-29 22:38 [Qemu-devel] [PATCH] qdev: Make "hotplugged" property read-only Eduardo Habkost
2016-12-30 14:28 ` Igor Mammedov
2016-12-30 18:23   ` Eduardo Habkost
2017-01-03 13:02     ` Igor Mammedov
2017-01-03 14:22       ` Eduardo Habkost
2017-01-03 15:07         ` Igor Mammedov
2017-01-03 16:10         ` Paolo Bonzini
2017-01-03 16:53           ` Igor Mammedov
2017-01-03 17:06             ` Eduardo Habkost
2017-02-22 19:21               ` Eduardo Habkost

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).