From e4f4fb1eca795e36f363b4647724221e774523c1 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 3 May 2017 17:35:45 -0300 Subject: sysbus: Set user_creatable=false by default on TYPE_SYS_BUS_DEVICE commit 33cd52b5d7b9adfd009e95f07e6c64dd88ae2a31 unset cannot_instantiate_with_device_add_yet in TYPE_SYSBUS, making all sysbus devices appear on "-device help" and lack the "no-user" flag in "info qdm". To fix this, we can set user_creatable=false by default on TYPE_SYS_BUS_DEVICE, but this requires setting user_creatable=true explicitly on the sysbus devices that actually work with -device. Fortunately today we have just a few has_dynamic_sysbus=1 machines: virt, pc-q35-*, ppce500, and spapr. virt, ppce500, and spapr have extra checks to ensure just a few device types can be instantiated: * virt supports only TYPE_VFIO_CALXEDA_XGMAC, TYPE_VFIO_AMD_XGBE. * ppce500 supports only TYPE_ETSEC_COMMON. * spapr supports only TYPE_SPAPR_PCI_HOST_BRIDGE. This patch sets user_creatable=true explicitly on those 4 device classes. Now, the more complex cases: pc-q35-*: q35 has no sysbus device whitelist yet (which is a separate bug). We are in the process of fixing it and building a sysbus whitelist on q35, but in the meantime we can fix the "-device help" and "info qdm" bugs mentioned above. Also, despite not being strictly necessary for fixing the q35 bug, reducing the list of user_creatable=true devices will help us be more confident when building the q35 whitelist. xen: We also have a hack at xen_set_dynamic_sysbus(), that sets has_dynamic_sysbus=true at runtime when using the Xen accelerator. This hack is only used to allow xen-backend devices to be dynamically plugged/unplugged. This means today we can use -device with the following 22 device types, that are the ones compiled into the qemu-system-x86_64 and qemu-system-i386 binaries: * allwinner-ahci * amd-iommu * cfi.pflash01 * esp * fw_cfg_io * fw_cfg_mem * generic-sdhci * hpet * intel-iommu * ioapic * isabus-bridge * kvmclock * kvm-ioapic * kvmvapic * SUNW,fdtwo * sysbus-ahci * sysbus-fdc * sysbus-ohci * unimplemented-device * virtio-mmio * xen-backend * xen-sysdev This patch adds user_creatable=true explicitly to those devices, temporarily, just to keep 100% compatibility with existing behavior of q35. Subsequent patches will remove user_creatable=true from the devices that are really not meant to user-creatable on any machine, and remove the FIXME comment from the ones that are really supposed to be user-creatable. This is being done in separate patches because we still don't have an obvious list of devices that will be whitelisted by q35, and I would like to get each device reviewed individually. Cc: Alexander Graf Cc: Alex Williamson Cc: Alistair Francis Cc: Beniamino Galvani Cc: Christian Borntraeger Cc: Cornelia Huck Cc: David Gibson Cc: "Edgar E. Iglesias" Cc: Eduardo Habkost Cc: Frank Blaschka Cc: Gabriel L. Somlo Cc: Gerd Hoffmann Cc: Igor Mammedov Cc: Jason Wang Cc: John Snow Cc: Juergen Gross Cc: Kevin Wolf Cc: Laszlo Ersek Cc: Marcel Apfelbaum Cc: Markus Armbruster Cc: Max Reitz Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Peter Maydell Cc: Pierre Morel Cc: Prasad J Pandit Cc: qemu-arm@nongnu.org Cc: qemu-block@nongnu.org Cc: qemu-ppc@nongnu.org Cc: Richard Henderson Cc: Rob Herring Cc: Shannon Zhao Cc: sstabellini@kernel.org Cc: Thomas Huth Cc: Yi Min Zhao Acked-by: John Snow Acked-by: Juergen Gross Acked-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost Message-Id: <20170503203604.31462-3-ehabkost@redhat.com> Reviewed-by: Markus Armbruster [ehabkost: Small changes at sysbus_device_class_init() comments] Signed-off-by: Eduardo Habkost --- hw/xen/xen_backend.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'hw/xen/xen_backend.c') diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c index 2cac47d..2df102a 100644 --- a/hw/xen/xen_backend.c +++ b/hw/xen/xen_backend.c @@ -619,6 +619,11 @@ static void xendev_class_init(ObjectClass *klass, void *data) dc->props = xendev_properties; set_bit(DEVICE_CATEGORY_MISC, dc->categories); + /* + * FIXME: Set only because we are not sure yet if this device + * will be outside the q35 sysbus whitelist. + */ + dc->user_creatable = true; } static const TypeInfo xendev_type_info = { @@ -662,6 +667,11 @@ static void xen_sysdev_class_init(ObjectClass *klass, void *data) k->init = xen_sysdev_init; dc->props = xen_sysdev_properties; dc->bus_type = TYPE_XENSYSBUS; + /* + * FIXME: Set only because we are not sure yet if this device + * will be outside the q35 sysbus whitelist. + */ + dc->user_creatable = true; } static const TypeInfo xensysdev_info = { -- cgit v1.1 From 950b31dd17fccc42ecddc9528408b00a20c9be3c Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 3 May 2017 17:35:46 -0300 Subject: xen-backend: Remove FIXME comment about user_creatable flag xen-backend can be plugged/unplugged dynamically when using the Xen accelerator, so keep the user_creatable flag on the device class and remove the FIXME comment. Cc: Juergen Gross , Cc: Peter Maydell , Cc: Thomas Huth Cc: sstabellini@kernel.org Cc: Markus Armbruster , Cc: Marcel Apfelbaum , Cc: Laszlo Ersek Acked-by: Juergen Gross Acked-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost Message-Id: <20170503203604.31462-4-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/xen/xen_backend.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'hw/xen/xen_backend.c') diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c index 2df102a..8cc0e1e 100644 --- a/hw/xen/xen_backend.c +++ b/hw/xen/xen_backend.c @@ -619,10 +619,7 @@ static void xendev_class_init(ObjectClass *klass, void *data) dc->props = xendev_properties; set_bit(DEVICE_CATEGORY_MISC, dc->categories); - /* - * FIXME: Set only because we are not sure yet if this device - * will be outside the q35 sysbus whitelist. - */ + /* xen-backend devices can be plugged/unplugged dynamically */ dc->user_creatable = true; } -- cgit v1.1 From 74c505c6fde4bd129d7b41efda16d74f254eb0d5 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 3 May 2017 17:36:03 -0300 Subject: xen-sysdev: Remove user_creatable flag TYPE_XENSYSDEV is only used internally by xen_be_init(), and is not supposed to be plugged/unplugged dynamically. Remove the user_creatable flag from the device class. Cc: Juergen Gross , Cc: Peter Maydell , Cc: Thomas Huth Cc: sstabellini@kernel.org Cc: Markus Armbruster , Cc: Marcel Apfelbaum , Cc: Laszlo Ersek Acked-by: Juergen Gross Acked-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost Message-Id: <20170503203604.31462-21-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/xen/xen_backend.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'hw/xen/xen_backend.c') diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c index 8cc0e1e..3570f37 100644 --- a/hw/xen/xen_backend.c +++ b/hw/xen/xen_backend.c @@ -664,11 +664,6 @@ static void xen_sysdev_class_init(ObjectClass *klass, void *data) k->init = xen_sysdev_init; dc->props = xen_sysdev_properties; dc->bus_type = TYPE_XENSYSBUS; - /* - * FIXME: Set only because we are not sure yet if this device - * will be outside the q35 sysbus whitelist. - */ - dc->user_creatable = true; } static const TypeInfo xensysdev_info = { -- cgit v1.1