* [Qemu-devel] [PATCH v2 0/6] Replace has_dynamic_sysbus with list of allowed device types @ 2017-11-25 15:16 Eduardo Habkost 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 1/6] machine: Replace has_dynamic_sysbus with list of allowed devices Eduardo Habkost ` (7 more replies) 0 siblings, 8 replies; 25+ messages in thread From: Eduardo Habkost @ 2017-11-25 15:16 UTC (permalink / raw) To: qemu-devel Cc: jgross, Thomas Huth, sstabellini, Laszlo Ersek, Marcel Apfelbaum, Marc-André Lureau, Paolo Bonzini, Stefan Berger, Alexander Graf Changes v1 (RFC) -> v2: * Patch 1 now just adds TYPE_SYS_BUS_DEVICE to the existing has_dynamic_sysbus=true machines, and other patches make the lists on each machine-type more specific. * Change the name of the new field to allowed_dynamic_sysbus_devices. * The q35 allowed list is much shorter because the list of user-creatable sysbus devices in QEMU is shorter. * Keep the xen_set_dynamic_sysbus() hack, just change it to add 'xen-sysdev" to the allowed list. * Simplified the arm/virt code. Summary ------- This series replaces the existing has_dynamic_sysbus flag (that makes the machine accept every user-creatable sysbus device type on the command-line) with a list of allowed devices. This will be helpful when implementing the new query-device-slots command, because each machine type will include only the sysbus devices it really supports, instead of including a catch-all TYPE_SYS_BUS_DEVICE "slot". This will be useful to add support to new sysbus devices on machines like pc_piix, that don't have has_dynamic_sysbus set today. This also makes the code safer: just compiling a new sysbus device in the same QEMU binary won't make a machine-type automatically start accepting the device. Cc: Marc-André Lureau <marcandre.lureau@redhat.com> Cc: Marcel Apfelbaum <marcel@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Stefan Berger <stefanb@linux.vnet.ibm.com> Cc: Alexander Graf <agraf@suse.de> Eduardo Habkost (6): machine: Replace has_dynamic_sysbus with list of allowed devices hw/arm/virt: Allow only supported dynamic sysbus devices ppc: e500: Allow only supported dynamic sysbus devices spapr: Allow only supported dynamic sysbus devices xen: Add only xen-sysdev to dynamic sysbus device list q35: Allow only supported dynamic sysbus devices include/hw/boards.h | 5 ++++- hw/arm/virt.c | 5 ++++- hw/core/machine.c | 43 +++++++++++++++++++++++++++++-------------- hw/i386/pc_q35.c | 5 ++++- hw/ppc/e500plat.c | 4 +++- hw/ppc/spapr.c | 2 +- hw/xen/xen_backend.c | 2 +- 7 files changed, 46 insertions(+), 20 deletions(-) -- 2.13.6 ^ permalink raw reply [flat|nested] 25+ messages in thread
* [Qemu-devel] [PATCH v2 1/6] machine: Replace has_dynamic_sysbus with list of allowed devices 2017-11-25 15:16 [Qemu-devel] [PATCH v2 0/6] Replace has_dynamic_sysbus with list of allowed device types Eduardo Habkost @ 2017-11-25 15:16 ` Eduardo Habkost 2017-11-25 17:08 ` Greg Kurz ` (3 more replies) 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 2/6] hw/arm/virt: Allow only supported dynamic sysbus devices Eduardo Habkost ` (6 subsequent siblings) 7 siblings, 4 replies; 25+ messages in thread From: Eduardo Habkost @ 2017-11-25 15:16 UTC (permalink / raw) To: qemu-devel Cc: jgross, Thomas Huth, sstabellini, Laszlo Ersek, Marcel Apfelbaum, Peter Maydell, Michael S. Tsirkin, Alexander Graf, David Gibson, Anthony Perard, qemu-arm, qemu-ppc, xen-devel The existing has_dynamic_sysbus flag makes the machine accept every user-creatable sysbus device type on the command-line. Replace it with a list of allowed device types, so machines can easily accept some sysbus devices while rejecting others. To keep exactly the same behavior as before, the existing has_dynamic_sysbus=true assignments are replaced with a TYPE_SYS_BUS_DEVICE entry on the allowed list. Other patches will replace the TYPE_SYS_BUS_DEVICE entries with more specific lists of devices. Cc: Peter Maydell <peter.maydell@linaro.org> Cc: Marcel Apfelbaum <marcel@redhat.com> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Alexander Graf <agraf@suse.de> Cc: David Gibson <david@gibson.dropbear.id.au> Cc: Stefano Stabellini <sstabellini@kernel.org> Cc: Anthony Perard <anthony.perard@citrix.com> Cc: qemu-arm@nongnu.org Cc: qemu-ppc@nongnu.org Cc: xen-devel@lists.xenproject.org Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- Changes v1 -> v2: * Replace "dynamic sysbus whitelist" with "allowed sysbus devices" * Simply add TYPE_SYS_BUS_DEVICE to the list on existing has_dynamic_sysbus=true machines, and make machine-types more strict in separate patches --- include/hw/boards.h | 5 ++++- hw/arm/virt.c | 3 ++- hw/core/machine.c | 43 +++++++++++++++++++++++++++++-------------- hw/i386/pc_q35.c | 3 ++- hw/ppc/e500plat.c | 4 +++- hw/ppc/spapr.c | 3 ++- hw/xen/xen_backend.c | 7 ++++++- 7 files changed, 48 insertions(+), 20 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 156b16f7a6..041bc08971 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -76,6 +76,9 @@ void machine_set_cpu_numa_node(MachineState *machine, const CpuInstanceProperties *props, Error **errp); +void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type); + + /** * CPUArchId: * @arch_id - architecture-dependent CPU ID of present or possible CPU @@ -179,7 +182,6 @@ struct MachineClass { no_floppy:1, no_cdrom:1, no_sdcard:1, - has_dynamic_sysbus:1, pci_allow_0_address:1, legacy_fw_cfg_order:1; int is_default; @@ -197,6 +199,7 @@ struct MachineClass { bool ignore_memory_transaction_failures; int numa_mem_align_shift; const char **valid_cpu_types; + strList *allowed_dynamic_sysbus_devices; bool auto_enable_numa_with_memhp; void (*numa_auto_assign_ram)(MachineClass *mc, NodeInfo *nodes, int nb_nodes, ram_addr_t size); diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 9e18b410d7..fa6dc15fcd 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1591,7 +1591,8 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) * configuration of the particular instance. */ mc->max_cpus = 255; - mc->has_dynamic_sysbus = true; + /*TODO: allow only sysbus devices that really work with this machine */ + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); mc->block_default_type = IF_VIRTIO; mc->no_cdrom = 1; mc->pci_allow_0_address = true; diff --git a/hw/core/machine.c b/hw/core/machine.c index 36c2fb069c..ab2ec292f3 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -335,29 +335,44 @@ static bool machine_get_enforce_config_section(Object *obj, Error **errp) return ms->enforce_config_section; } -static void error_on_sysbus_device(SysBusDevice *sbdev, void *opaque) +void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type) { - error_report("Option '-device %s' cannot be handled by this machine", - object_class_get_name(object_get_class(OBJECT(sbdev)))); - exit(1); + strList *item = g_new0(strList, 1); + + item->value = g_strdup(type); + item->next = mc->allowed_dynamic_sysbus_devices; + mc->allowed_dynamic_sysbus_devices = item; } -static void machine_init_notify(Notifier *notifier, void *data) +static void validate_sysbus_device(SysBusDevice *sbdev, void *opaque) { - Object *machine = qdev_get_machine(); - ObjectClass *oc = object_get_class(machine); - MachineClass *mc = MACHINE_CLASS(oc); + MachineState *machine = opaque; + MachineClass *mc = MACHINE_GET_CLASS(machine); + bool allowed = false; + strList *wl; - if (mc->has_dynamic_sysbus) { - /* Our machine can handle dynamic sysbus devices, we're all good */ - return; + for (wl = mc->allowed_dynamic_sysbus_devices; + !allowed && wl; + wl = wl->next) { + allowed |= !!object_dynamic_cast(OBJECT(sbdev), wl->value); } + if (!allowed) { + error_report("Option '-device %s' cannot be handled by this machine", + object_class_get_name(object_get_class(OBJECT(sbdev)))); + exit(1); + } +} + +static void machine_init_notify(Notifier *notifier, void *data) +{ + MachineState *machine = MACHINE(qdev_get_machine()); + /* - * Loop through all dynamically created devices and check whether there - * are sysbus devices among them. If there are, error out. + * Loop through all dynamically created sysbus devices and check if they are + * all allowed. If a device is not allowed, error out. */ - foreach_dynamic_sysbus_device(error_on_sysbus_device, NULL); + foreach_dynamic_sysbus_device(validate_sysbus_device, machine); } HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine) diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index d6060043ac..d0b0e5b422 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -299,7 +299,8 @@ static void pc_q35_machine_options(MachineClass *m) m->default_machine_opts = "firmware=bios-256k.bin"; m->default_display = "std"; m->no_floppy = 1; - m->has_dynamic_sysbus = true; + /*TODO: allow only sysbus devices that really work with this machine */ + machine_class_allow_dynamic_sysbus_dev(m, TYPE_SYS_BUS_DEVICE); m->max_cpus = 288; } diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c index e59e80fb9e..438118c29b 100644 --- a/hw/ppc/e500plat.c +++ b/hw/ppc/e500plat.c @@ -15,6 +15,7 @@ #include "hw/boards.h" #include "sysemu/device_tree.h" #include "sysemu/kvm.h" +#include "hw/sysbus.h" #include "hw/pci/pci.h" #include "hw/ppc/openpic.h" #include "kvm_ppc.h" @@ -63,7 +64,8 @@ static void e500plat_machine_init(MachineClass *mc) mc->desc = "generic paravirt e500 platform"; mc->init = e500plat_init; mc->max_cpus = 32; - mc->has_dynamic_sysbus = true; + /*TODO: allow only sysbus devices that really work with this machine */ + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("e500v2_v30"); } diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index d682f013d4..82040cc5d1 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3603,7 +3603,8 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->default_boot_order = ""; mc->default_ram_size = 512 * M_BYTE; mc->kvm_type = spapr_kvm_type; - mc->has_dynamic_sysbus = true; + /*TODO: allow only sysbus devices that really work with this machine */ + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); mc->pci_allow_0_address = true; mc->get_hotplug_handler = spapr_get_hotplug_handler; hc->pre_plug = spapr_machine_device_pre_plug; diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c index 0f849a26d2..82380ea9ee 100644 --- a/hw/xen/xen_backend.c +++ b/hw/xen/xen_backend.c @@ -564,7 +564,12 @@ static void xen_set_dynamic_sysbus(void) ObjectClass *oc = object_get_class(machine); MachineClass *mc = MACHINE_CLASS(oc); - mc->has_dynamic_sysbus = true; + /* + * Emulate old mc->has_dynamic_sysbus=true assignment + * + *TODO: add only Xen devices to the list + */ + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); } int xen_be_register(const char *type, struct XenDevOps *ops) -- 2.13.6 ^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/6] machine: Replace has_dynamic_sysbus with list of allowed devices 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 1/6] machine: Replace has_dynamic_sysbus with list of allowed devices Eduardo Habkost @ 2017-11-25 17:08 ` Greg Kurz 2017-11-27 1:51 ` David Gibson ` (2 subsequent siblings) 3 siblings, 0 replies; 25+ messages in thread From: Greg Kurz @ 2017-11-25 17:08 UTC (permalink / raw) To: Eduardo Habkost Cc: qemu-devel, jgross, Peter Maydell, Thomas Huth, sstabellini, Michael S. Tsirkin, Alexander Graf, Anthony Perard, qemu-arm, qemu-ppc, Marcel Apfelbaum, xen-devel, Laszlo Ersek, David Gibson On Sat, 25 Nov 2017 13:16:05 -0200 Eduardo Habkost <ehabkost@redhat.com> wrote: > The existing has_dynamic_sysbus flag makes the machine accept > every user-creatable sysbus device type on the command-line. > Replace it with a list of allowed device types, so machines can > easily accept some sysbus devices while rejecting others. > > To keep exactly the same behavior as before, the existing > has_dynamic_sysbus=true assignments are replaced with a > TYPE_SYS_BUS_DEVICE entry on the allowed list. Other patches > will replace the TYPE_SYS_BUS_DEVICE entries with more specific > lists of devices. > > Cc: Peter Maydell <peter.maydell@linaro.org> > Cc: Marcel Apfelbaum <marcel@redhat.com> > Cc: "Michael S. Tsirkin" <mst@redhat.com> > Cc: Alexander Graf <agraf@suse.de> > Cc: David Gibson <david@gibson.dropbear.id.au> > Cc: Stefano Stabellini <sstabellini@kernel.org> > Cc: Anthony Perard <anthony.perard@citrix.com> > Cc: qemu-arm@nongnu.org > Cc: qemu-ppc@nongnu.org > Cc: xen-devel@lists.xenproject.org > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > --- Reviewed-by: Greg Kurz <groug@kaod.org> > Changes v1 -> v2: > * Replace "dynamic sysbus whitelist" with "allowed sysbus devices" > * Simply add TYPE_SYS_BUS_DEVICE to the list on existing > has_dynamic_sysbus=true machines, and make machine-types more > strict in separate patches > --- > include/hw/boards.h | 5 ++++- > hw/arm/virt.c | 3 ++- > hw/core/machine.c | 43 +++++++++++++++++++++++++++++-------------- > hw/i386/pc_q35.c | 3 ++- > hw/ppc/e500plat.c | 4 +++- > hw/ppc/spapr.c | 3 ++- > hw/xen/xen_backend.c | 7 ++++++- > 7 files changed, 48 insertions(+), 20 deletions(-) > > diff --git a/include/hw/boards.h b/include/hw/boards.h > index 156b16f7a6..041bc08971 100644 > --- a/include/hw/boards.h > +++ b/include/hw/boards.h > @@ -76,6 +76,9 @@ void machine_set_cpu_numa_node(MachineState *machine, > const CpuInstanceProperties *props, > Error **errp); > > +void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type); > + > + > /** > * CPUArchId: > * @arch_id - architecture-dependent CPU ID of present or possible CPU > @@ -179,7 +182,6 @@ struct MachineClass { > no_floppy:1, > no_cdrom:1, > no_sdcard:1, > - has_dynamic_sysbus:1, > pci_allow_0_address:1, > legacy_fw_cfg_order:1; > int is_default; > @@ -197,6 +199,7 @@ struct MachineClass { > bool ignore_memory_transaction_failures; > int numa_mem_align_shift; > const char **valid_cpu_types; > + strList *allowed_dynamic_sysbus_devices; > bool auto_enable_numa_with_memhp; > void (*numa_auto_assign_ram)(MachineClass *mc, NodeInfo *nodes, > int nb_nodes, ram_addr_t size); > diff --git a/hw/arm/virt.c b/hw/arm/virt.c > index 9e18b410d7..fa6dc15fcd 100644 > --- a/hw/arm/virt.c > +++ b/hw/arm/virt.c > @@ -1591,7 +1591,8 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) > * configuration of the particular instance. > */ > mc->max_cpus = 255; > - mc->has_dynamic_sysbus = true; > + /*TODO: allow only sysbus devices that really work with this machine */ > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > mc->block_default_type = IF_VIRTIO; > mc->no_cdrom = 1; > mc->pci_allow_0_address = true; > diff --git a/hw/core/machine.c b/hw/core/machine.c > index 36c2fb069c..ab2ec292f3 100644 > --- a/hw/core/machine.c > +++ b/hw/core/machine.c > @@ -335,29 +335,44 @@ static bool machine_get_enforce_config_section(Object *obj, Error **errp) > return ms->enforce_config_section; > } > > -static void error_on_sysbus_device(SysBusDevice *sbdev, void *opaque) > +void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type) > { > - error_report("Option '-device %s' cannot be handled by this machine", > - object_class_get_name(object_get_class(OBJECT(sbdev)))); > - exit(1); > + strList *item = g_new0(strList, 1); > + > + item->value = g_strdup(type); > + item->next = mc->allowed_dynamic_sysbus_devices; > + mc->allowed_dynamic_sysbus_devices = item; > } > > -static void machine_init_notify(Notifier *notifier, void *data) > +static void validate_sysbus_device(SysBusDevice *sbdev, void *opaque) > { > - Object *machine = qdev_get_machine(); > - ObjectClass *oc = object_get_class(machine); > - MachineClass *mc = MACHINE_CLASS(oc); > + MachineState *machine = opaque; > + MachineClass *mc = MACHINE_GET_CLASS(machine); > + bool allowed = false; > + strList *wl; > > - if (mc->has_dynamic_sysbus) { > - /* Our machine can handle dynamic sysbus devices, we're all good */ > - return; > + for (wl = mc->allowed_dynamic_sysbus_devices; > + !allowed && wl; > + wl = wl->next) { > + allowed |= !!object_dynamic_cast(OBJECT(sbdev), wl->value); > } > > + if (!allowed) { > + error_report("Option '-device %s' cannot be handled by this machine", > + object_class_get_name(object_get_class(OBJECT(sbdev)))); > + exit(1); > + } > +} > + > +static void machine_init_notify(Notifier *notifier, void *data) > +{ > + MachineState *machine = MACHINE(qdev_get_machine()); > + > /* > - * Loop through all dynamically created devices and check whether there > - * are sysbus devices among them. If there are, error out. > + * Loop through all dynamically created sysbus devices and check if they are > + * all allowed. If a device is not allowed, error out. > */ > - foreach_dynamic_sysbus_device(error_on_sysbus_device, NULL); > + foreach_dynamic_sysbus_device(validate_sysbus_device, machine); > } > > HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine) > diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c > index d6060043ac..d0b0e5b422 100644 > --- a/hw/i386/pc_q35.c > +++ b/hw/i386/pc_q35.c > @@ -299,7 +299,8 @@ static void pc_q35_machine_options(MachineClass *m) > m->default_machine_opts = "firmware=bios-256k.bin"; > m->default_display = "std"; > m->no_floppy = 1; > - m->has_dynamic_sysbus = true; > + /*TODO: allow only sysbus devices that really work with this machine */ > + machine_class_allow_dynamic_sysbus_dev(m, TYPE_SYS_BUS_DEVICE); > m->max_cpus = 288; > } > > diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c > index e59e80fb9e..438118c29b 100644 > --- a/hw/ppc/e500plat.c > +++ b/hw/ppc/e500plat.c > @@ -15,6 +15,7 @@ > #include "hw/boards.h" > #include "sysemu/device_tree.h" > #include "sysemu/kvm.h" > +#include "hw/sysbus.h" > #include "hw/pci/pci.h" > #include "hw/ppc/openpic.h" > #include "kvm_ppc.h" > @@ -63,7 +64,8 @@ static void e500plat_machine_init(MachineClass *mc) > mc->desc = "generic paravirt e500 platform"; > mc->init = e500plat_init; > mc->max_cpus = 32; > - mc->has_dynamic_sysbus = true; > + /*TODO: allow only sysbus devices that really work with this machine */ > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("e500v2_v30"); > } > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index d682f013d4..82040cc5d1 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -3603,7 +3603,8 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) > mc->default_boot_order = ""; > mc->default_ram_size = 512 * M_BYTE; > mc->kvm_type = spapr_kvm_type; > - mc->has_dynamic_sysbus = true; > + /*TODO: allow only sysbus devices that really work with this machine */ > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > mc->pci_allow_0_address = true; > mc->get_hotplug_handler = spapr_get_hotplug_handler; > hc->pre_plug = spapr_machine_device_pre_plug; > diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c > index 0f849a26d2..82380ea9ee 100644 > --- a/hw/xen/xen_backend.c > +++ b/hw/xen/xen_backend.c > @@ -564,7 +564,12 @@ static void xen_set_dynamic_sysbus(void) > ObjectClass *oc = object_get_class(machine); > MachineClass *mc = MACHINE_CLASS(oc); > > - mc->has_dynamic_sysbus = true; > + /* > + * Emulate old mc->has_dynamic_sysbus=true assignment > + * > + *TODO: add only Xen devices to the list > + */ > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > } > > int xen_be_register(const char *type, struct XenDevOps *ops) ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/6] machine: Replace has_dynamic_sysbus with list of allowed devices 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 1/6] machine: Replace has_dynamic_sysbus with list of allowed devices Eduardo Habkost 2017-11-25 17:08 ` Greg Kurz @ 2017-11-27 1:51 ` David Gibson 2017-11-27 8:39 ` Marcel Apfelbaum 2017-11-28 16:55 ` Marc-André Lureau 3 siblings, 0 replies; 25+ messages in thread From: David Gibson @ 2017-11-27 1:51 UTC (permalink / raw) To: Eduardo Habkost Cc: qemu-devel, jgross, Thomas Huth, sstabellini, Laszlo Ersek, Marcel Apfelbaum, Peter Maydell, Michael S. Tsirkin, Alexander Graf, Anthony Perard, qemu-arm, qemu-ppc, xen-devel [-- Attachment #1: Type: text/plain, Size: 9054 bytes --] On Sat, Nov 25, 2017 at 01:16:05PM -0200, Eduardo Habkost wrote: > The existing has_dynamic_sysbus flag makes the machine accept > every user-creatable sysbus device type on the command-line. > Replace it with a list of allowed device types, so machines can > easily accept some sysbus devices while rejecting others. > > To keep exactly the same behavior as before, the existing > has_dynamic_sysbus=true assignments are replaced with a > TYPE_SYS_BUS_DEVICE entry on the allowed list. Other patches > will replace the TYPE_SYS_BUS_DEVICE entries with more specific > lists of devices. > > Cc: Peter Maydell <peter.maydell@linaro.org> > Cc: Marcel Apfelbaum <marcel@redhat.com> > Cc: "Michael S. Tsirkin" <mst@redhat.com> > Cc: Alexander Graf <agraf@suse.de> > Cc: David Gibson <david@gibson.dropbear.id.au> > Cc: Stefano Stabellini <sstabellini@kernel.org> > Cc: Anthony Perard <anthony.perard@citrix.com> > Cc: qemu-arm@nongnu.org > Cc: qemu-ppc@nongnu.org > Cc: xen-devel@lists.xenproject.org > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> > --- > Changes v1 -> v2: > * Replace "dynamic sysbus whitelist" with "allowed sysbus devices" > * Simply add TYPE_SYS_BUS_DEVICE to the list on existing > has_dynamic_sysbus=true machines, and make machine-types more > strict in separate patches > --- > include/hw/boards.h | 5 ++++- > hw/arm/virt.c | 3 ++- > hw/core/machine.c | 43 +++++++++++++++++++++++++++++-------------- > hw/i386/pc_q35.c | 3 ++- > hw/ppc/e500plat.c | 4 +++- > hw/ppc/spapr.c | 3 ++- > hw/xen/xen_backend.c | 7 ++++++- > 7 files changed, 48 insertions(+), 20 deletions(-) > > diff --git a/include/hw/boards.h b/include/hw/boards.h > index 156b16f7a6..041bc08971 100644 > --- a/include/hw/boards.h > +++ b/include/hw/boards.h > @@ -76,6 +76,9 @@ void machine_set_cpu_numa_node(MachineState *machine, > const CpuInstanceProperties *props, > Error **errp); > > +void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type); > + > + > /** > * CPUArchId: > * @arch_id - architecture-dependent CPU ID of present or possible CPU > @@ -179,7 +182,6 @@ struct MachineClass { > no_floppy:1, > no_cdrom:1, > no_sdcard:1, > - has_dynamic_sysbus:1, > pci_allow_0_address:1, > legacy_fw_cfg_order:1; > int is_default; > @@ -197,6 +199,7 @@ struct MachineClass { > bool ignore_memory_transaction_failures; > int numa_mem_align_shift; > const char **valid_cpu_types; > + strList *allowed_dynamic_sysbus_devices; > bool auto_enable_numa_with_memhp; > void (*numa_auto_assign_ram)(MachineClass *mc, NodeInfo *nodes, > int nb_nodes, ram_addr_t size); > diff --git a/hw/arm/virt.c b/hw/arm/virt.c > index 9e18b410d7..fa6dc15fcd 100644 > --- a/hw/arm/virt.c > +++ b/hw/arm/virt.c > @@ -1591,7 +1591,8 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) > * configuration of the particular instance. > */ > mc->max_cpus = 255; > - mc->has_dynamic_sysbus = true; > + /*TODO: allow only sysbus devices that really work with this machine */ > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > mc->block_default_type = IF_VIRTIO; > mc->no_cdrom = 1; > mc->pci_allow_0_address = true; > diff --git a/hw/core/machine.c b/hw/core/machine.c > index 36c2fb069c..ab2ec292f3 100644 > --- a/hw/core/machine.c > +++ b/hw/core/machine.c > @@ -335,29 +335,44 @@ static bool machine_get_enforce_config_section(Object *obj, Error **errp) > return ms->enforce_config_section; > } > > -static void error_on_sysbus_device(SysBusDevice *sbdev, void *opaque) > +void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type) > { > - error_report("Option '-device %s' cannot be handled by this machine", > - object_class_get_name(object_get_class(OBJECT(sbdev)))); > - exit(1); > + strList *item = g_new0(strList, 1); > + > + item->value = g_strdup(type); > + item->next = mc->allowed_dynamic_sysbus_devices; > + mc->allowed_dynamic_sysbus_devices = item; > } > > -static void machine_init_notify(Notifier *notifier, void *data) > +static void validate_sysbus_device(SysBusDevice *sbdev, void *opaque) > { > - Object *machine = qdev_get_machine(); > - ObjectClass *oc = object_get_class(machine); > - MachineClass *mc = MACHINE_CLASS(oc); > + MachineState *machine = opaque; > + MachineClass *mc = MACHINE_GET_CLASS(machine); > + bool allowed = false; > + strList *wl; > > - if (mc->has_dynamic_sysbus) { > - /* Our machine can handle dynamic sysbus devices, we're all good */ > - return; > + for (wl = mc->allowed_dynamic_sysbus_devices; > + !allowed && wl; > + wl = wl->next) { > + allowed |= !!object_dynamic_cast(OBJECT(sbdev), wl->value); > } > > + if (!allowed) { > + error_report("Option '-device %s' cannot be handled by this machine", > + object_class_get_name(object_get_class(OBJECT(sbdev)))); > + exit(1); > + } > +} > + > +static void machine_init_notify(Notifier *notifier, void *data) > +{ > + MachineState *machine = MACHINE(qdev_get_machine()); > + > /* > - * Loop through all dynamically created devices and check whether there > - * are sysbus devices among them. If there are, error out. > + * Loop through all dynamically created sysbus devices and check if they are > + * all allowed. If a device is not allowed, error out. > */ > - foreach_dynamic_sysbus_device(error_on_sysbus_device, NULL); > + foreach_dynamic_sysbus_device(validate_sysbus_device, machine); > } > > HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine) > diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c > index d6060043ac..d0b0e5b422 100644 > --- a/hw/i386/pc_q35.c > +++ b/hw/i386/pc_q35.c > @@ -299,7 +299,8 @@ static void pc_q35_machine_options(MachineClass *m) > m->default_machine_opts = "firmware=bios-256k.bin"; > m->default_display = "std"; > m->no_floppy = 1; > - m->has_dynamic_sysbus = true; > + /*TODO: allow only sysbus devices that really work with this machine */ > + machine_class_allow_dynamic_sysbus_dev(m, TYPE_SYS_BUS_DEVICE); > m->max_cpus = 288; > } > > diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c > index e59e80fb9e..438118c29b 100644 > --- a/hw/ppc/e500plat.c > +++ b/hw/ppc/e500plat.c > @@ -15,6 +15,7 @@ > #include "hw/boards.h" > #include "sysemu/device_tree.h" > #include "sysemu/kvm.h" > +#include "hw/sysbus.h" > #include "hw/pci/pci.h" > #include "hw/ppc/openpic.h" > #include "kvm_ppc.h" > @@ -63,7 +64,8 @@ static void e500plat_machine_init(MachineClass *mc) > mc->desc = "generic paravirt e500 platform"; > mc->init = e500plat_init; > mc->max_cpus = 32; > - mc->has_dynamic_sysbus = true; > + /*TODO: allow only sysbus devices that really work with this machine */ > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("e500v2_v30"); > } > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index d682f013d4..82040cc5d1 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -3603,7 +3603,8 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) > mc->default_boot_order = ""; > mc->default_ram_size = 512 * M_BYTE; > mc->kvm_type = spapr_kvm_type; > - mc->has_dynamic_sysbus = true; > + /*TODO: allow only sysbus devices that really work with this machine */ > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > mc->pci_allow_0_address = true; > mc->get_hotplug_handler = spapr_get_hotplug_handler; > hc->pre_plug = spapr_machine_device_pre_plug; > diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c > index 0f849a26d2..82380ea9ee 100644 > --- a/hw/xen/xen_backend.c > +++ b/hw/xen/xen_backend.c > @@ -564,7 +564,12 @@ static void xen_set_dynamic_sysbus(void) > ObjectClass *oc = object_get_class(machine); > MachineClass *mc = MACHINE_CLASS(oc); > > - mc->has_dynamic_sysbus = true; > + /* > + * Emulate old mc->has_dynamic_sysbus=true assignment > + * > + *TODO: add only Xen devices to the list > + */ > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > } > > int xen_be_register(const char *type, struct XenDevOps *ops) -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/6] machine: Replace has_dynamic_sysbus with list of allowed devices 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 1/6] machine: Replace has_dynamic_sysbus with list of allowed devices Eduardo Habkost 2017-11-25 17:08 ` Greg Kurz 2017-11-27 1:51 ` David Gibson @ 2017-11-27 8:39 ` Marcel Apfelbaum 2017-11-28 16:55 ` Marc-André Lureau 3 siblings, 0 replies; 25+ messages in thread From: Marcel Apfelbaum @ 2017-11-27 8:39 UTC (permalink / raw) To: Eduardo Habkost, qemu-devel Cc: jgross, Thomas Huth, sstabellini, Laszlo Ersek, Peter Maydell, Michael S. Tsirkin, Alexander Graf, David Gibson, Anthony Perard, qemu-arm, qemu-ppc, xen-devel On 25/11/2017 17:16, Eduardo Habkost wrote: > The existing has_dynamic_sysbus flag makes the machine accept > every user-creatable sysbus device type on the command-line. > Replace it with a list of allowed device types, so machines can > easily accept some sysbus devices while rejecting others. > > To keep exactly the same behavior as before, the existing > has_dynamic_sysbus=true assignments are replaced with a > TYPE_SYS_BUS_DEVICE entry on the allowed list. Other patches > will replace the TYPE_SYS_BUS_DEVICE entries with more specific > lists of devices. > > Cc: Peter Maydell <peter.maydell@linaro.org> > Cc: Marcel Apfelbaum <marcel@redhat.com> > Cc: "Michael S. Tsirkin" <mst@redhat.com> > Cc: Alexander Graf <agraf@suse.de> > Cc: David Gibson <david@gibson.dropbear.id.au> > Cc: Stefano Stabellini <sstabellini@kernel.org> > Cc: Anthony Perard <anthony.perard@citrix.com> > Cc: qemu-arm@nongnu.org > Cc: qemu-ppc@nongnu.org > Cc: xen-devel@lists.xenproject.org > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > --- > Changes v1 -> v2: > * Replace "dynamic sysbus whitelist" with "allowed sysbus devices" > * Simply add TYPE_SYS_BUS_DEVICE to the list on existing > has_dynamic_sysbus=true machines, and make machine-types more > strict in separate patches > --- > include/hw/boards.h | 5 ++++- > hw/arm/virt.c | 3 ++- > hw/core/machine.c | 43 +++++++++++++++++++++++++++++-------------- > hw/i386/pc_q35.c | 3 ++- > hw/ppc/e500plat.c | 4 +++- > hw/ppc/spapr.c | 3 ++- > hw/xen/xen_backend.c | 7 ++++++- > 7 files changed, 48 insertions(+), 20 deletions(-) > > diff --git a/include/hw/boards.h b/include/hw/boards.h > index 156b16f7a6..041bc08971 100644 > --- a/include/hw/boards.h > +++ b/include/hw/boards.h > @@ -76,6 +76,9 @@ void machine_set_cpu_numa_node(MachineState *machine, > const CpuInstanceProperties *props, > Error **errp); > > +void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type); > + > + > /** > * CPUArchId: > * @arch_id - architecture-dependent CPU ID of present or possible CPU > @@ -179,7 +182,6 @@ struct MachineClass { > no_floppy:1, > no_cdrom:1, > no_sdcard:1, > - has_dynamic_sysbus:1, > pci_allow_0_address:1, > legacy_fw_cfg_order:1; > int is_default; > @@ -197,6 +199,7 @@ struct MachineClass { > bool ignore_memory_transaction_failures; > int numa_mem_align_shift; > const char **valid_cpu_types; > + strList *allowed_dynamic_sysbus_devices; > bool auto_enable_numa_with_memhp; > void (*numa_auto_assign_ram)(MachineClass *mc, NodeInfo *nodes, > int nb_nodes, ram_addr_t size); > diff --git a/hw/arm/virt.c b/hw/arm/virt.c > index 9e18b410d7..fa6dc15fcd 100644 > --- a/hw/arm/virt.c > +++ b/hw/arm/virt.c > @@ -1591,7 +1591,8 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) > * configuration of the particular instance. > */ > mc->max_cpus = 255; > - mc->has_dynamic_sysbus = true; > + /*TODO: allow only sysbus devices that really work with this machine */ > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > mc->block_default_type = IF_VIRTIO; > mc->no_cdrom = 1; > mc->pci_allow_0_address = true; > diff --git a/hw/core/machine.c b/hw/core/machine.c > index 36c2fb069c..ab2ec292f3 100644 > --- a/hw/core/machine.c > +++ b/hw/core/machine.c > @@ -335,29 +335,44 @@ static bool machine_get_enforce_config_section(Object *obj, Error **errp) > return ms->enforce_config_section; > } > > -static void error_on_sysbus_device(SysBusDevice *sbdev, void *opaque) > +void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type) > { > - error_report("Option '-device %s' cannot be handled by this machine", > - object_class_get_name(object_get_class(OBJECT(sbdev)))); > - exit(1); > + strList *item = g_new0(strList, 1); > + > + item->value = g_strdup(type); > + item->next = mc->allowed_dynamic_sysbus_devices; > + mc->allowed_dynamic_sysbus_devices = item; > } > > -static void machine_init_notify(Notifier *notifier, void *data) > +static void validate_sysbus_device(SysBusDevice *sbdev, void *opaque) > { > - Object *machine = qdev_get_machine(); > - ObjectClass *oc = object_get_class(machine); > - MachineClass *mc = MACHINE_CLASS(oc); > + MachineState *machine = opaque; > + MachineClass *mc = MACHINE_GET_CLASS(machine); > + bool allowed = false; > + strList *wl; > > - if (mc->has_dynamic_sysbus) { > - /* Our machine can handle dynamic sysbus devices, we're all good */ > - return; > + for (wl = mc->allowed_dynamic_sysbus_devices; > + !allowed && wl; > + wl = wl->next) { > + allowed |= !!object_dynamic_cast(OBJECT(sbdev), wl->value); > } > > + if (!allowed) { > + error_report("Option '-device %s' cannot be handled by this machine", > + object_class_get_name(object_get_class(OBJECT(sbdev)))); > + exit(1); > + } > +} > + > +static void machine_init_notify(Notifier *notifier, void *data) > +{ > + MachineState *machine = MACHINE(qdev_get_machine()); > + > /* > - * Loop through all dynamically created devices and check whether there > - * are sysbus devices among them. If there are, error out. > + * Loop through all dynamically created sysbus devices and check if they are > + * all allowed. If a device is not allowed, error out. > */ > - foreach_dynamic_sysbus_device(error_on_sysbus_device, NULL); > + foreach_dynamic_sysbus_device(validate_sysbus_device, machine); > } > > HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine) > diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c > index d6060043ac..d0b0e5b422 100644 > --- a/hw/i386/pc_q35.c > +++ b/hw/i386/pc_q35.c > @@ -299,7 +299,8 @@ static void pc_q35_machine_options(MachineClass *m) > m->default_machine_opts = "firmware=bios-256k.bin"; > m->default_display = "std"; > m->no_floppy = 1; > - m->has_dynamic_sysbus = true; > + /*TODO: allow only sysbus devices that really work with this machine */ > + machine_class_allow_dynamic_sysbus_dev(m, TYPE_SYS_BUS_DEVICE); > m->max_cpus = 288; > } > > diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c > index e59e80fb9e..438118c29b 100644 > --- a/hw/ppc/e500plat.c > +++ b/hw/ppc/e500plat.c > @@ -15,6 +15,7 @@ > #include "hw/boards.h" > #include "sysemu/device_tree.h" > #include "sysemu/kvm.h" > +#include "hw/sysbus.h" > #include "hw/pci/pci.h" > #include "hw/ppc/openpic.h" > #include "kvm_ppc.h" > @@ -63,7 +64,8 @@ static void e500plat_machine_init(MachineClass *mc) > mc->desc = "generic paravirt e500 platform"; > mc->init = e500plat_init; > mc->max_cpus = 32; > - mc->has_dynamic_sysbus = true; > + /*TODO: allow only sysbus devices that really work with this machine */ > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("e500v2_v30"); > } > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index d682f013d4..82040cc5d1 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -3603,7 +3603,8 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) > mc->default_boot_order = ""; > mc->default_ram_size = 512 * M_BYTE; > mc->kvm_type = spapr_kvm_type; > - mc->has_dynamic_sysbus = true; > + /*TODO: allow only sysbus devices that really work with this machine */ > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > mc->pci_allow_0_address = true; > mc->get_hotplug_handler = spapr_get_hotplug_handler; > hc->pre_plug = spapr_machine_device_pre_plug; > diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c > index 0f849a26d2..82380ea9ee 100644 > --- a/hw/xen/xen_backend.c > +++ b/hw/xen/xen_backend.c > @@ -564,7 +564,12 @@ static void xen_set_dynamic_sysbus(void) > ObjectClass *oc = object_get_class(machine); > MachineClass *mc = MACHINE_CLASS(oc); > > - mc->has_dynamic_sysbus = true; > + /* > + * Emulate old mc->has_dynamic_sysbus=true assignment > + * > + *TODO: add only Xen devices to the list > + */ > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > } > > int xen_be_register(const char *type, struct XenDevOps *ops) > Reviewed-by: Marcel Apfelbaum <marcel@redhat.com> Thanks, Marcel ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/6] machine: Replace has_dynamic_sysbus with list of allowed devices 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 1/6] machine: Replace has_dynamic_sysbus with list of allowed devices Eduardo Habkost ` (2 preceding siblings ...) 2017-11-27 8:39 ` Marcel Apfelbaum @ 2017-11-28 16:55 ` Marc-André Lureau 2017-11-28 18:34 ` Eduardo Habkost 3 siblings, 1 reply; 25+ messages in thread From: Marc-André Lureau @ 2017-11-28 16:55 UTC (permalink / raw) To: Eduardo Habkost Cc: QEMU, jgross, Peter Maydell, Thomas Huth, Stefano Stabellini, Michael S. Tsirkin, Alexander Graf, Anthony Perard, open list:ARM, open list:sPAPR pseries, Marcel Apfelbaum, xen-devel, Laszlo Ersek, David Gibson Hi On Sat, Nov 25, 2017 at 4:16 PM, Eduardo Habkost <ehabkost@redhat.com> wrote: > The existing has_dynamic_sysbus flag makes the machine accept > every user-creatable sysbus device type on the command-line. > Replace it with a list of allowed device types, so machines can > easily accept some sysbus devices while rejecting others. > > To keep exactly the same behavior as before, the existing > has_dynamic_sysbus=true assignments are replaced with a > TYPE_SYS_BUS_DEVICE entry on the allowed list. Other patches > will replace the TYPE_SYS_BUS_DEVICE entries with more specific > lists of devices. > > Cc: Peter Maydell <peter.maydell@linaro.org> > Cc: Marcel Apfelbaum <marcel@redhat.com> > Cc: "Michael S. Tsirkin" <mst@redhat.com> > Cc: Alexander Graf <agraf@suse.de> > Cc: David Gibson <david@gibson.dropbear.id.au> > Cc: Stefano Stabellini <sstabellini@kernel.org> > Cc: Anthony Perard <anthony.perard@citrix.com> > Cc: qemu-arm@nongnu.org > Cc: qemu-ppc@nongnu.org > Cc: xen-devel@lists.xenproject.org > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> > --- > Changes v1 -> v2: > * Replace "dynamic sysbus whitelist" with "allowed sysbus devices" > * Simply add TYPE_SYS_BUS_DEVICE to the list on existing > has_dynamic_sysbus=true machines, and make machine-types more > strict in separate patches > --- > include/hw/boards.h | 5 ++++- > hw/arm/virt.c | 3 ++- > hw/core/machine.c | 43 +++++++++++++++++++++++++++++-------------- > hw/i386/pc_q35.c | 3 ++- > hw/ppc/e500plat.c | 4 +++- > hw/ppc/spapr.c | 3 ++- > hw/xen/xen_backend.c | 7 ++++++- > 7 files changed, 48 insertions(+), 20 deletions(-) > > diff --git a/include/hw/boards.h b/include/hw/boards.h > index 156b16f7a6..041bc08971 100644 > --- a/include/hw/boards.h > +++ b/include/hw/boards.h > @@ -76,6 +76,9 @@ void machine_set_cpu_numa_node(MachineState *machine, > const CpuInstanceProperties *props, > Error **errp); > > +void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type); > + > + > /** > * CPUArchId: > * @arch_id - architecture-dependent CPU ID of present or possible CPU > @@ -179,7 +182,6 @@ struct MachineClass { > no_floppy:1, > no_cdrom:1, > no_sdcard:1, > - has_dynamic_sysbus:1, > pci_allow_0_address:1, > legacy_fw_cfg_order:1; > int is_default; > @@ -197,6 +199,7 @@ struct MachineClass { > bool ignore_memory_transaction_failures; > int numa_mem_align_shift; > const char **valid_cpu_types; > + strList *allowed_dynamic_sysbus_devices; > bool auto_enable_numa_with_memhp; > void (*numa_auto_assign_ram)(MachineClass *mc, NodeInfo *nodes, > int nb_nodes, ram_addr_t size); > diff --git a/hw/arm/virt.c b/hw/arm/virt.c > index 9e18b410d7..fa6dc15fcd 100644 > --- a/hw/arm/virt.c > +++ b/hw/arm/virt.c > @@ -1591,7 +1591,8 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) > * configuration of the particular instance. > */ > mc->max_cpus = 255; > - mc->has_dynamic_sysbus = true; > + /*TODO: allow only sysbus devices that really work with this machine */ cosmetic: why do you not leave a space between * and TODO ? (you did that repeatedly) > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > mc->block_default_type = IF_VIRTIO; > mc->no_cdrom = 1; > mc->pci_allow_0_address = true; > diff --git a/hw/core/machine.c b/hw/core/machine.c > index 36c2fb069c..ab2ec292f3 100644 > --- a/hw/core/machine.c > +++ b/hw/core/machine.c > @@ -335,29 +335,44 @@ static bool machine_get_enforce_config_section(Object *obj, Error **errp) > return ms->enforce_config_section; > } > > -static void error_on_sysbus_device(SysBusDevice *sbdev, void *opaque) > +void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type) > { > - error_report("Option '-device %s' cannot be handled by this machine", > - object_class_get_name(object_get_class(OBJECT(sbdev)))); > - exit(1); > + strList *item = g_new0(strList, 1); > + > + item->value = g_strdup(type); > + item->next = mc->allowed_dynamic_sysbus_devices; > + mc->allowed_dynamic_sysbus_devices = item; > } > > -static void machine_init_notify(Notifier *notifier, void *data) > +static void validate_sysbus_device(SysBusDevice *sbdev, void *opaque) > { > - Object *machine = qdev_get_machine(); > - ObjectClass *oc = object_get_class(machine); > - MachineClass *mc = MACHINE_CLASS(oc); > + MachineState *machine = opaque; > + MachineClass *mc = MACHINE_GET_CLASS(machine); > + bool allowed = false; > + strList *wl; > > - if (mc->has_dynamic_sysbus) { > - /* Our machine can handle dynamic sysbus devices, we're all good */ > - return; > + for (wl = mc->allowed_dynamic_sysbus_devices; > + !allowed && wl; > + wl = wl->next) { > + allowed |= !!object_dynamic_cast(OBJECT(sbdev), wl->value); > } > > + if (!allowed) { > + error_report("Option '-device %s' cannot be handled by this machine", > + object_class_get_name(object_get_class(OBJECT(sbdev)))); > + exit(1); > + } > +} > + > +static void machine_init_notify(Notifier *notifier, void *data) > +{ > + MachineState *machine = MACHINE(qdev_get_machine()); > + > /* > - * Loop through all dynamically created devices and check whether there > - * are sysbus devices among them. If there are, error out. > + * Loop through all dynamically created sysbus devices and check if they are > + * all allowed. If a device is not allowed, error out. > */ > - foreach_dynamic_sysbus_device(error_on_sysbus_device, NULL); > + foreach_dynamic_sysbus_device(validate_sysbus_device, machine); > } > > HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine) > diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c > index d6060043ac..d0b0e5b422 100644 > --- a/hw/i386/pc_q35.c > +++ b/hw/i386/pc_q35.c > @@ -299,7 +299,8 @@ static void pc_q35_machine_options(MachineClass *m) > m->default_machine_opts = "firmware=bios-256k.bin"; > m->default_display = "std"; > m->no_floppy = 1; > - m->has_dynamic_sysbus = true; > + /*TODO: allow only sysbus devices that really work with this machine */ > + machine_class_allow_dynamic_sysbus_dev(m, TYPE_SYS_BUS_DEVICE); > m->max_cpus = 288; > } > > diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c > index e59e80fb9e..438118c29b 100644 > --- a/hw/ppc/e500plat.c > +++ b/hw/ppc/e500plat.c > @@ -15,6 +15,7 @@ > #include "hw/boards.h" > #include "sysemu/device_tree.h" > #include "sysemu/kvm.h" > +#include "hw/sysbus.h" > #include "hw/pci/pci.h" > #include "hw/ppc/openpic.h" > #include "kvm_ppc.h" > @@ -63,7 +64,8 @@ static void e500plat_machine_init(MachineClass *mc) > mc->desc = "generic paravirt e500 platform"; > mc->init = e500plat_init; > mc->max_cpus = 32; > - mc->has_dynamic_sysbus = true; > + /*TODO: allow only sysbus devices that really work with this machine */ > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("e500v2_v30"); > } > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index d682f013d4..82040cc5d1 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -3603,7 +3603,8 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) > mc->default_boot_order = ""; > mc->default_ram_size = 512 * M_BYTE; > mc->kvm_type = spapr_kvm_type; > - mc->has_dynamic_sysbus = true; > + /*TODO: allow only sysbus devices that really work with this machine */ > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > mc->pci_allow_0_address = true; > mc->get_hotplug_handler = spapr_get_hotplug_handler; > hc->pre_plug = spapr_machine_device_pre_plug; > diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c > index 0f849a26d2..82380ea9ee 100644 > --- a/hw/xen/xen_backend.c > +++ b/hw/xen/xen_backend.c > @@ -564,7 +564,12 @@ static void xen_set_dynamic_sysbus(void) > ObjectClass *oc = object_get_class(machine); > MachineClass *mc = MACHINE_CLASS(oc); > > - mc->has_dynamic_sysbus = true; > + /* > + * Emulate old mc->has_dynamic_sysbus=true assignment > + * > + *TODO: add only Xen devices to the list > + */ > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > } > > int xen_be_register(const char *type, struct XenDevOps *ops) > -- > 2.13.6 > > -- Marc-André Lureau ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/6] machine: Replace has_dynamic_sysbus with list of allowed devices 2017-11-28 16:55 ` Marc-André Lureau @ 2017-11-28 18:34 ` Eduardo Habkost 0 siblings, 0 replies; 25+ messages in thread From: Eduardo Habkost @ 2017-11-28 18:34 UTC (permalink / raw) To: Marc-André Lureau Cc: QEMU, jgross, Peter Maydell, Thomas Huth, Stefano Stabellini, Michael S. Tsirkin, Alexander Graf, Anthony Perard, open list:ARM, open list:sPAPR pseries, Marcel Apfelbaum, xen-devel, Laszlo Ersek, David Gibson On Tue, Nov 28, 2017 at 05:55:15PM +0100, Marc-André Lureau wrote: [...] > Hi > > On Sat, Nov 25, 2017 at 4:16 PM, Eduardo Habkost <ehabkost@redhat.com> wrote: > > The existing has_dynamic_sysbus flag makes the machine accept > > every user-creatable sysbus device type on the command-line. > > Replace it with a list of allowed device types, so machines can > > easily accept some sysbus devices while rejecting others. > > > > To keep exactly the same behavior as before, the existing > > has_dynamic_sysbus=true assignments are replaced with a > > TYPE_SYS_BUS_DEVICE entry on the allowed list. Other patches > > will replace the TYPE_SYS_BUS_DEVICE entries with more specific > > lists of devices. > > > > Cc: Peter Maydell <peter.maydell@linaro.org> > > Cc: Marcel Apfelbaum <marcel@redhat.com> > > Cc: "Michael S. Tsirkin" <mst@redhat.com> > > Cc: Alexander Graf <agraf@suse.de> > > Cc: David Gibson <david@gibson.dropbear.id.au> > > Cc: Stefano Stabellini <sstabellini@kernel.org> > > Cc: Anthony Perard <anthony.perard@citrix.com> > > Cc: qemu-arm@nongnu.org > > Cc: qemu-ppc@nongnu.org > > Cc: xen-devel@lists.xenproject.org > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > > Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Thanks! [...] > > - mc->has_dynamic_sysbus = true; > > + /*TODO: allow only sysbus devices that really work with this machine */ > > cosmetic: why do you not leave a space between * and TODO ? (you did > that repeatedly) Good question. :) For reasons I can't explain, I thought "/*TODO:" was more common than "/* TODO:", but I was mistaken. I will change this to "/* TODO:" when committing the patches. -- Eduardo ^ permalink raw reply [flat|nested] 25+ messages in thread
* [Qemu-devel] [PATCH v2 2/6] hw/arm/virt: Allow only supported dynamic sysbus devices 2017-11-25 15:16 [Qemu-devel] [PATCH v2 0/6] Replace has_dynamic_sysbus with list of allowed device types Eduardo Habkost 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 1/6] machine: Replace has_dynamic_sysbus with list of allowed devices Eduardo Habkost @ 2017-11-25 15:16 ` Eduardo Habkost 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 3/6] ppc: e500: " Eduardo Habkost ` (5 subsequent siblings) 7 siblings, 0 replies; 25+ messages in thread From: Eduardo Habkost @ 2017-11-25 15:16 UTC (permalink / raw) To: qemu-devel Cc: jgross, Thomas Huth, sstabellini, Laszlo Ersek, Marcel Apfelbaum, Peter Maydell, qemu-arm Replace the TYPE_SYS_BUS_DEVICE entry in the allowed sysbus device list with the two device types that are really supported by the virt machine: vfio-amd-xgbe and vfio-calxeda-xgmac. Cc: Peter Maydell <peter.maydell@linaro.org> Cc: qemu-arm@nongnu.org Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- Changes series v1 -> v2: * New patch added to series --- hw/arm/virt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index fa6dc15fcd..f267ef0ff5 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -34,6 +34,8 @@ #include "hw/arm/arm.h" #include "hw/arm/primecell.h" #include "hw/arm/virt.h" +#include "hw/vfio/vfio-calxeda-xgmac.h" +#include "hw/vfio/vfio-amd-xgbe.h" #include "hw/devices.h" #include "net/net.h" #include "sysemu/block-backend.h" @@ -1591,8 +1593,8 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) * configuration of the particular instance. */ mc->max_cpus = 255; - /*TODO: allow only sysbus devices that really work with this machine */ - machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_VFIO_CALXEDA_XGMAC); + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_VFIO_AMD_XGBE); mc->block_default_type = IF_VIRTIO; mc->no_cdrom = 1; mc->pci_allow_0_address = true; -- 2.13.6 ^ permalink raw reply related [flat|nested] 25+ messages in thread
* [Qemu-devel] [PATCH v2 3/6] ppc: e500: Allow only supported dynamic sysbus devices 2017-11-25 15:16 [Qemu-devel] [PATCH v2 0/6] Replace has_dynamic_sysbus with list of allowed device types Eduardo Habkost 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 1/6] machine: Replace has_dynamic_sysbus with list of allowed devices Eduardo Habkost 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 2/6] hw/arm/virt: Allow only supported dynamic sysbus devices Eduardo Habkost @ 2017-11-25 15:16 ` Eduardo Habkost 2017-11-25 18:31 ` Greg Kurz 2017-11-27 1:52 ` David Gibson 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 4/6] spapr: " Eduardo Habkost ` (4 subsequent siblings) 7 siblings, 2 replies; 25+ messages in thread From: Eduardo Habkost @ 2017-11-25 15:16 UTC (permalink / raw) To: qemu-devel Cc: jgross, Thomas Huth, sstabellini, Laszlo Ersek, Marcel Apfelbaum, Alexander Graf, David Gibson, qemu-ppc platform_bus_create_devtree() already rejects all dynamic sysbus devices except TYPE_ETSEC_COMMON, so register it as the only allowed dynamic sysbus device for the ppce500 machine-type. Cc: Alexander Graf <agraf@suse.de> Cc: David Gibson <david@gibson.dropbear.id.au> Cc: qemu-ppc@nongnu.org Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- Changes series v1 -> v2: * New patch added to series --- hw/ppc/e500plat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c index 438118c29b..81d03e1038 100644 --- a/hw/ppc/e500plat.c +++ b/hw/ppc/e500plat.c @@ -12,6 +12,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" #include "e500.h" +#include "hw/net/fsl_etsec/etsec.h" #include "hw/boards.h" #include "sysemu/device_tree.h" #include "sysemu/kvm.h" @@ -64,8 +65,7 @@ static void e500plat_machine_init(MachineClass *mc) mc->desc = "generic paravirt e500 platform"; mc->init = e500plat_init; mc->max_cpus = 32; - /*TODO: allow only sysbus devices that really work with this machine */ - machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_ETSEC_COMMON); mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("e500v2_v30"); } -- 2.13.6 ^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [Qemu-devel] [PATCH v2 3/6] ppc: e500: Allow only supported dynamic sysbus devices 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 3/6] ppc: e500: " Eduardo Habkost @ 2017-11-25 18:31 ` Greg Kurz 2017-11-28 1:11 ` Eduardo Habkost 2017-11-27 1:52 ` David Gibson 1 sibling, 1 reply; 25+ messages in thread From: Greg Kurz @ 2017-11-25 18:31 UTC (permalink / raw) To: Eduardo Habkost Cc: qemu-devel, jgross, Thomas Huth, sstabellini, Alexander Graf, qemu-ppc, Marcel Apfelbaum, Laszlo Ersek, David Gibson On Sat, 25 Nov 2017 13:16:07 -0200 Eduardo Habkost <ehabkost@redhat.com> wrote: > platform_bus_create_devtree() already rejects all dynamic sysbus > devices except TYPE_ETSEC_COMMON, so register it as the only > allowed dynamic sysbus device for the ppce500 machine-type. > Maybe drop the code that rejects unsupported sysbus devices, but this can be done in a followup patch. Anyway, Reviewed-by: Greg Kurz <groug@kaod.org> > Cc: Alexander Graf <agraf@suse.de> > Cc: David Gibson <david@gibson.dropbear.id.au> > Cc: qemu-ppc@nongnu.org > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > --- > Changes series v1 -> v2: > * New patch added to series > --- > hw/ppc/e500plat.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c > index 438118c29b..81d03e1038 100644 > --- a/hw/ppc/e500plat.c > +++ b/hw/ppc/e500plat.c > @@ -12,6 +12,7 @@ > #include "qemu/osdep.h" > #include "qemu-common.h" > #include "e500.h" > +#include "hw/net/fsl_etsec/etsec.h" > #include "hw/boards.h" > #include "sysemu/device_tree.h" > #include "sysemu/kvm.h" > @@ -64,8 +65,7 @@ static void e500plat_machine_init(MachineClass *mc) > mc->desc = "generic paravirt e500 platform"; > mc->init = e500plat_init; > mc->max_cpus = 32; > - /*TODO: allow only sysbus devices that really work with this machine */ > - machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_ETSEC_COMMON); > mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("e500v2_v30"); > } > ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [Qemu-devel] [PATCH v2 3/6] ppc: e500: Allow only supported dynamic sysbus devices 2017-11-25 18:31 ` Greg Kurz @ 2017-11-28 1:11 ` Eduardo Habkost 0 siblings, 0 replies; 25+ messages in thread From: Eduardo Habkost @ 2017-11-28 1:11 UTC (permalink / raw) To: Greg Kurz Cc: qemu-devel, jgross, Thomas Huth, sstabellini, Alexander Graf, qemu-ppc, Marcel Apfelbaum, Laszlo Ersek, David Gibson On Sat, Nov 25, 2017 at 07:31:19PM +0100, Greg Kurz wrote: > On Sat, 25 Nov 2017 13:16:07 -0200 > Eduardo Habkost <ehabkost@redhat.com> wrote: > > > platform_bus_create_devtree() already rejects all dynamic sysbus > > devices except TYPE_ETSEC_COMMON, so register it as the only > > allowed dynamic sysbus device for the ppce500 machine-type. > > > > Maybe drop the code that rejects unsupported sysbus devices, but this > can be done in a followup patch. Yes, that's a good idea. Probably an opportunity to provide a better API to handle dynamic sysbus devices. > > Anyway, > > Reviewed-by: Greg Kurz <groug@kaod.org> Thanks! > > > Cc: Alexander Graf <agraf@suse.de> > > Cc: David Gibson <david@gibson.dropbear.id.au> > > Cc: qemu-ppc@nongnu.org > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > > --- > > Changes series v1 -> v2: > > * New patch added to series > > --- > > hw/ppc/e500plat.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c > > index 438118c29b..81d03e1038 100644 > > --- a/hw/ppc/e500plat.c > > +++ b/hw/ppc/e500plat.c > > @@ -12,6 +12,7 @@ > > #include "qemu/osdep.h" > > #include "qemu-common.h" > > #include "e500.h" > > +#include "hw/net/fsl_etsec/etsec.h" > > #include "hw/boards.h" > > #include "sysemu/device_tree.h" > > #include "sysemu/kvm.h" > > @@ -64,8 +65,7 @@ static void e500plat_machine_init(MachineClass *mc) > > mc->desc = "generic paravirt e500 platform"; > > mc->init = e500plat_init; > > mc->max_cpus = 32; > > - /*TODO: allow only sysbus devices that really work with this machine */ > > - machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_ETSEC_COMMON); > > mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("e500v2_v30"); > > } > > > -- Eduardo ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [Qemu-devel] [PATCH v2 3/6] ppc: e500: Allow only supported dynamic sysbus devices 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 3/6] ppc: e500: " Eduardo Habkost 2017-11-25 18:31 ` Greg Kurz @ 2017-11-27 1:52 ` David Gibson 2017-11-28 1:12 ` Eduardo Habkost 1 sibling, 1 reply; 25+ messages in thread From: David Gibson @ 2017-11-27 1:52 UTC (permalink / raw) To: Eduardo Habkost Cc: qemu-devel, jgross, Thomas Huth, sstabellini, Laszlo Ersek, Marcel Apfelbaum, Alexander Graf, qemu-ppc [-- Attachment #1: Type: text/plain, Size: 1822 bytes --] On Sat, Nov 25, 2017 at 01:16:07PM -0200, Eduardo Habkost wrote: > platform_bus_create_devtree() already rejects all dynamic sysbus > devices except TYPE_ETSEC_COMMON, so register it as the only > allowed dynamic sysbus device for the ppce500 machine-type. > > Cc: Alexander Graf <agraf@suse.de> > Cc: David Gibson <david@gibson.dropbear.id.au> > Cc: qemu-ppc@nongnu.org > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Acked-by: David Gibson <david@gibson.dropbear.id.au> Do you need me to take this through my tree (for 2.12), or do you have another merge patch in mind? > --- > Changes series v1 -> v2: > * New patch added to series > --- > hw/ppc/e500plat.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c > index 438118c29b..81d03e1038 100644 > --- a/hw/ppc/e500plat.c > +++ b/hw/ppc/e500plat.c > @@ -12,6 +12,7 @@ > #include "qemu/osdep.h" > #include "qemu-common.h" > #include "e500.h" > +#include "hw/net/fsl_etsec/etsec.h" > #include "hw/boards.h" > #include "sysemu/device_tree.h" > #include "sysemu/kvm.h" > @@ -64,8 +65,7 @@ static void e500plat_machine_init(MachineClass *mc) > mc->desc = "generic paravirt e500 platform"; > mc->init = e500plat_init; > mc->max_cpus = 32; > - /*TODO: allow only sysbus devices that really work with this machine */ > - machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_ETSEC_COMMON); > mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("e500v2_v30"); > } > -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [Qemu-devel] [PATCH v2 3/6] ppc: e500: Allow only supported dynamic sysbus devices 2017-11-27 1:52 ` David Gibson @ 2017-11-28 1:12 ` Eduardo Habkost 2017-11-28 4:54 ` David Gibson 0 siblings, 1 reply; 25+ messages in thread From: Eduardo Habkost @ 2017-11-28 1:12 UTC (permalink / raw) To: David Gibson Cc: qemu-devel, jgross, Thomas Huth, sstabellini, Laszlo Ersek, Marcel Apfelbaum, Alexander Graf, qemu-ppc On Mon, Nov 27, 2017 at 12:52:09PM +1100, David Gibson wrote: > On Sat, Nov 25, 2017 at 01:16:07PM -0200, Eduardo Habkost wrote: > > platform_bus_create_devtree() already rejects all dynamic sysbus > > devices except TYPE_ETSEC_COMMON, so register it as the only > > allowed dynamic sysbus device for the ppce500 machine-type. > > > > Cc: Alexander Graf <agraf@suse.de> > > Cc: David Gibson <david@gibson.dropbear.id.au> > > Cc: qemu-ppc@nongnu.org > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > > Acked-by: David Gibson <david@gibson.dropbear.id.au> Thanks! > > Do you need me to take this through my tree (for 2.12), or do you have > another merge patch in mind? As this patch requires patch 1/6 to be applied first and there are patches touching other machines in this series, I can merge this through my machine core tree if you don't mind. > > > --- > > Changes series v1 -> v2: > > * New patch added to series > > --- > > hw/ppc/e500plat.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c > > index 438118c29b..81d03e1038 100644 > > --- a/hw/ppc/e500plat.c > > +++ b/hw/ppc/e500plat.c > > @@ -12,6 +12,7 @@ > > #include "qemu/osdep.h" > > #include "qemu-common.h" > > #include "e500.h" > > +#include "hw/net/fsl_etsec/etsec.h" > > #include "hw/boards.h" > > #include "sysemu/device_tree.h" > > #include "sysemu/kvm.h" > > @@ -64,8 +65,7 @@ static void e500plat_machine_init(MachineClass *mc) > > mc->desc = "generic paravirt e500 platform"; > > mc->init = e500plat_init; > > mc->max_cpus = 32; > > - /*TODO: allow only sysbus devices that really work with this machine */ > > - machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_ETSEC_COMMON); > > mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("e500v2_v30"); > > } > > > > -- > David Gibson | I'll have my music baroque, and my code > david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ > | _way_ _around_! > http://www.ozlabs.org/~dgibson -- Eduardo ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [Qemu-devel] [PATCH v2 3/6] ppc: e500: Allow only supported dynamic sysbus devices 2017-11-28 1:12 ` Eduardo Habkost @ 2017-11-28 4:54 ` David Gibson 0 siblings, 0 replies; 25+ messages in thread From: David Gibson @ 2017-11-28 4:54 UTC (permalink / raw) To: Eduardo Habkost Cc: qemu-devel, jgross, Thomas Huth, sstabellini, Laszlo Ersek, Marcel Apfelbaum, Alexander Graf, qemu-ppc [-- Attachment #1: Type: text/plain, Size: 2389 bytes --] On Mon, Nov 27, 2017 at 11:12:43PM -0200, Eduardo Habkost wrote: > On Mon, Nov 27, 2017 at 12:52:09PM +1100, David Gibson wrote: > > On Sat, Nov 25, 2017 at 01:16:07PM -0200, Eduardo Habkost wrote: > > > platform_bus_create_devtree() already rejects all dynamic sysbus > > > devices except TYPE_ETSEC_COMMON, so register it as the only > > > allowed dynamic sysbus device for the ppce500 machine-type. > > > > > > Cc: Alexander Graf <agraf@suse.de> > > > Cc: David Gibson <david@gibson.dropbear.id.au> > > > Cc: qemu-ppc@nongnu.org > > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > > > > Acked-by: David Gibson <david@gibson.dropbear.id.au> > > Thanks! > > > > > Do you need me to take this through my tree (for 2.12), or do you have > > another merge patch in mind? > > As this patch requires patch 1/6 to be applied first and there > are patches touching other machines in this series, I can merge > this through my machine core tree if you don't mind. Sounds good, thanks. > > > > > > --- > > > Changes series v1 -> v2: > > > * New patch added to series > > > --- > > > hw/ppc/e500plat.c | 4 ++-- > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c > > > index 438118c29b..81d03e1038 100644 > > > --- a/hw/ppc/e500plat.c > > > +++ b/hw/ppc/e500plat.c > > > @@ -12,6 +12,7 @@ > > > #include "qemu/osdep.h" > > > #include "qemu-common.h" > > > #include "e500.h" > > > +#include "hw/net/fsl_etsec/etsec.h" > > > #include "hw/boards.h" > > > #include "sysemu/device_tree.h" > > > #include "sysemu/kvm.h" > > > @@ -64,8 +65,7 @@ static void e500plat_machine_init(MachineClass *mc) > > > mc->desc = "generic paravirt e500 platform"; > > > mc->init = e500plat_init; > > > mc->max_cpus = 32; > > > - /*TODO: allow only sysbus devices that really work with this machine */ > > > - machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > > > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_ETSEC_COMMON); > > > mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("e500v2_v30"); > > > } > > > > > > > > -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 25+ messages in thread
* [Qemu-devel] [PATCH v2 4/6] spapr: Allow only supported dynamic sysbus devices 2017-11-25 15:16 [Qemu-devel] [PATCH v2 0/6] Replace has_dynamic_sysbus with list of allowed device types Eduardo Habkost ` (2 preceding siblings ...) 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 3/6] ppc: e500: " Eduardo Habkost @ 2017-11-25 15:16 ` Eduardo Habkost 2017-11-25 17:43 ` Greg Kurz 2017-11-27 1:52 ` David Gibson 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 5/6] xen: Add only xen-sysdev to dynamic sysbus device list Eduardo Habkost ` (3 subsequent siblings) 7 siblings, 2 replies; 25+ messages in thread From: Eduardo Habkost @ 2017-11-25 15:16 UTC (permalink / raw) To: qemu-devel Cc: jgross, Thomas Huth, sstabellini, Laszlo Ersek, Marcel Apfelbaum, David Gibson, Alexander Graf, qemu-ppc TYPE_SPAPR_PCI_HOST_BRIDGE is the only dynamic sysbus device not rejected by ppc_spapr_reset(), so it can be the only entry on the allowed list. Cc: David Gibson <david@gibson.dropbear.id.au> Cc: Alexander Graf <agraf@suse.de> Cc: qemu-ppc@nongnu.org Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- Changes series v1 -> v2: * New patch added to series --- hw/ppc/spapr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 82040cc5d1..3c6d6f2cea 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3603,8 +3603,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->default_boot_order = ""; mc->default_ram_size = 512 * M_BYTE; mc->kvm_type = spapr_kvm_type; - /*TODO: allow only sysbus devices that really work with this machine */ - machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SPAPR_PCI_HOST_BRIDGE); mc->pci_allow_0_address = true; mc->get_hotplug_handler = spapr_get_hotplug_handler; hc->pre_plug = spapr_machine_device_pre_plug; -- 2.13.6 ^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [Qemu-devel] [PATCH v2 4/6] spapr: Allow only supported dynamic sysbus devices 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 4/6] spapr: " Eduardo Habkost @ 2017-11-25 17:43 ` Greg Kurz 2017-11-27 1:52 ` David Gibson 1 sibling, 0 replies; 25+ messages in thread From: Greg Kurz @ 2017-11-25 17:43 UTC (permalink / raw) To: Eduardo Habkost Cc: qemu-devel, jgross, Thomas Huth, sstabellini, Alexander Graf, qemu-ppc, Marcel Apfelbaum, Laszlo Ersek, David Gibson On Sat, 25 Nov 2017 13:16:08 -0200 Eduardo Habkost <ehabkost@redhat.com> wrote: > TYPE_SPAPR_PCI_HOST_BRIDGE is the only dynamic sysbus device not > rejected by ppc_spapr_reset(), so it can be the only entry on the > allowed list. > So we don't need the code that rejects other sysbus devices anymore, right ? We should drop the related code then, but I guess this can be done in a followup patch. Reviewed-by: Greg Kurz <groug@kaod.org> > Cc: David Gibson <david@gibson.dropbear.id.au> > Cc: Alexander Graf <agraf@suse.de> > Cc: qemu-ppc@nongnu.org > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > --- > Changes series v1 -> v2: > * New patch added to series > --- > hw/ppc/spapr.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index 82040cc5d1..3c6d6f2cea 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -3603,8 +3603,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) > mc->default_boot_order = ""; > mc->default_ram_size = 512 * M_BYTE; > mc->kvm_type = spapr_kvm_type; > - /*TODO: allow only sysbus devices that really work with this machine */ > - machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SPAPR_PCI_HOST_BRIDGE); > mc->pci_allow_0_address = true; > mc->get_hotplug_handler = spapr_get_hotplug_handler; > hc->pre_plug = spapr_machine_device_pre_plug; ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [Qemu-devel] [PATCH v2 4/6] spapr: Allow only supported dynamic sysbus devices 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 4/6] spapr: " Eduardo Habkost 2017-11-25 17:43 ` Greg Kurz @ 2017-11-27 1:52 ` David Gibson 1 sibling, 0 replies; 25+ messages in thread From: David Gibson @ 2017-11-27 1:52 UTC (permalink / raw) To: Eduardo Habkost Cc: qemu-devel, jgross, Thomas Huth, sstabellini, Laszlo Ersek, Marcel Apfelbaum, Alexander Graf, qemu-ppc [-- Attachment #1: Type: text/plain, Size: 1594 bytes --] On Sat, Nov 25, 2017 at 01:16:08PM -0200, Eduardo Habkost wrote: > TYPE_SPAPR_PCI_HOST_BRIDGE is the only dynamic sysbus device not > rejected by ppc_spapr_reset(), so it can be the only entry on the > allowed list. > > Cc: David Gibson <david@gibson.dropbear.id.au> > Cc: Alexander Graf <agraf@suse.de> > Cc: qemu-ppc@nongnu.org > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Acked-by: David Gibson <david@gibson.dropbear.id.au> Again, do you need me to take this through my tree? > --- > Changes series v1 -> v2: > * New patch added to series > --- > hw/ppc/spapr.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index 82040cc5d1..3c6d6f2cea 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -3603,8 +3603,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) > mc->default_boot_order = ""; > mc->default_ram_size = 512 * M_BYTE; > mc->kvm_type = spapr_kvm_type; > - /*TODO: allow only sysbus devices that really work with this machine */ > - machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SPAPR_PCI_HOST_BRIDGE); > mc->pci_allow_0_address = true; > mc->get_hotplug_handler = spapr_get_hotplug_handler; > hc->pre_plug = spapr_machine_device_pre_plug; -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 25+ messages in thread
* [Qemu-devel] [PATCH v2 5/6] xen: Add only xen-sysdev to dynamic sysbus device list 2017-11-25 15:16 [Qemu-devel] [PATCH v2 0/6] Replace has_dynamic_sysbus with list of allowed device types Eduardo Habkost ` (3 preceding siblings ...) 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 4/6] spapr: " Eduardo Habkost @ 2017-11-25 15:16 ` Eduardo Habkost 2017-12-22 13:36 ` Marc-André Lureau 2018-01-05 14:12 ` Anthony PERARD 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 6/6] q35: Allow only supported dynamic sysbus devices Eduardo Habkost ` (2 subsequent siblings) 7 siblings, 2 replies; 25+ messages in thread From: Eduardo Habkost @ 2017-11-25 15:16 UTC (permalink / raw) To: qemu-devel Cc: jgross, Thomas Huth, sstabellini, Laszlo Ersek, Marcel Apfelbaum, Anthony Perard, xen-devel There's no need to make the machine allow every possible sysbus device. We can now just add xen-sysdev to the allowed list. Cc: Stefano Stabellini <sstabellini@kernel.org> Cc: Anthony Perard <anthony.perard@citrix.com> Cc: xen-devel@lists.xenproject.org Cc: Juergen Gross <jgross@suse.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- Changes series v1 -> v2: * New patch added to series --- hw/xen/xen_backend.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c index 82380ea9ee..7445b506ac 100644 --- a/hw/xen/xen_backend.c +++ b/hw/xen/xen_backend.c @@ -564,12 +564,7 @@ static void xen_set_dynamic_sysbus(void) ObjectClass *oc = object_get_class(machine); MachineClass *mc = MACHINE_CLASS(oc); - /* - * Emulate old mc->has_dynamic_sysbus=true assignment - * - *TODO: add only Xen devices to the list - */ - machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_XENSYSDEV); } int xen_be_register(const char *type, struct XenDevOps *ops) -- 2.13.6 ^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [Qemu-devel] [PATCH v2 5/6] xen: Add only xen-sysdev to dynamic sysbus device list 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 5/6] xen: Add only xen-sysdev to dynamic sysbus device list Eduardo Habkost @ 2017-12-22 13:36 ` Marc-André Lureau 2018-01-05 14:12 ` Anthony PERARD 1 sibling, 0 replies; 25+ messages in thread From: Marc-André Lureau @ 2017-12-22 13:36 UTC (permalink / raw) To: Eduardo Habkost Cc: QEMU, jgross, Thomas Huth, Stefano Stabellini, Anthony Perard, Marcel Apfelbaum, xen-devel, Laszlo Ersek Hi, On Sat, Nov 25, 2017 at 4:16 PM, Eduardo Habkost <ehabkost@redhat.com> wrote: > There's no need to make the machine allow every possible sysbus > device. We can now just add xen-sysdev to the allowed list. > > Cc: Stefano Stabellini <sstabellini@kernel.org> > Cc: Anthony Perard <anthony.perard@citrix.com> > Cc: xen-devel@lists.xenproject.org > Cc: Juergen Gross <jgross@suse.com> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > --- > Changes series v1 -> v2: > * New patch added to series > --- > hw/xen/xen_backend.c | 7 +------ > 1 file changed, 1 insertion(+), 6 deletions(-) > > diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c > index 82380ea9ee..7445b506ac 100644 > --- a/hw/xen/xen_backend.c > +++ b/hw/xen/xen_backend.c > @@ -564,12 +564,7 @@ static void xen_set_dynamic_sysbus(void) > ObjectClass *oc = object_get_class(machine); > MachineClass *mc = MACHINE_CLASS(oc); > > - /* > - * Emulate old mc->has_dynamic_sysbus=true assignment > - * > - *TODO: add only Xen devices to the list > - */ > - machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_XENSYSDEV); It looks like it's the last patch in the series without review. It would be nice if a Xen maintainer could look at it, or test it, as I dont know how to test it tbh. Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> > } > > int xen_be_register(const char *type, struct XenDevOps *ops) > -- > 2.13.6 > > -- Marc-André Lureau ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [Qemu-devel] [PATCH v2 5/6] xen: Add only xen-sysdev to dynamic sysbus device list 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 5/6] xen: Add only xen-sysdev to dynamic sysbus device list Eduardo Habkost 2017-12-22 13:36 ` Marc-André Lureau @ 2018-01-05 14:12 ` Anthony PERARD 1 sibling, 0 replies; 25+ messages in thread From: Anthony PERARD @ 2018-01-05 14:12 UTC (permalink / raw) To: Eduardo Habkost Cc: qemu-devel, jgross, Thomas Huth, sstabellini, Laszlo Ersek, Marcel Apfelbaum, xen-devel On Sat, Nov 25, 2017 at 01:16:09PM -0200, Eduardo Habkost wrote: > There's no need to make the machine allow every possible sysbus > device. We can now just add xen-sysdev to the allowed list. > > Cc: Stefano Stabellini <sstabellini@kernel.org> > Cc: Anthony Perard <anthony.perard@citrix.com> > Cc: xen-devel@lists.xenproject.org > Cc: Juergen Gross <jgross@suse.com> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> I've tested the patch series with every hotplug things I could think of, and it worked fine. Acked-by: Anthony PERARD <anthony.perard@citrix.com> > --- > Changes series v1 -> v2: > * New patch added to series > --- > hw/xen/xen_backend.c | 7 +------ > 1 file changed, 1 insertion(+), 6 deletions(-) > > diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c > index 82380ea9ee..7445b506ac 100644 > --- a/hw/xen/xen_backend.c > +++ b/hw/xen/xen_backend.c > @@ -564,12 +564,7 @@ static void xen_set_dynamic_sysbus(void) > ObjectClass *oc = object_get_class(machine); > MachineClass *mc = MACHINE_CLASS(oc); > > - /* > - * Emulate old mc->has_dynamic_sysbus=true assignment > - * > - *TODO: add only Xen devices to the list > - */ > - machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SYS_BUS_DEVICE); > + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_XENSYSDEV); > } > > int xen_be_register(const char *type, struct XenDevOps *ops) -- Anthony PERARD ^ permalink raw reply [flat|nested] 25+ messages in thread
* [Qemu-devel] [PATCH v2 6/6] q35: Allow only supported dynamic sysbus devices 2017-11-25 15:16 [Qemu-devel] [PATCH v2 0/6] Replace has_dynamic_sysbus with list of allowed device types Eduardo Habkost ` (4 preceding siblings ...) 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 5/6] xen: Add only xen-sysdev to dynamic sysbus device list Eduardo Habkost @ 2017-11-25 15:16 ` Eduardo Habkost 2017-11-27 8:44 ` Marcel Apfelbaum 2017-12-22 13:37 ` [Qemu-devel] [PATCH v2 0/6] Replace has_dynamic_sysbus with list of allowed device types Marc-André Lureau 2018-01-09 20:12 ` Eduardo Habkost 7 siblings, 1 reply; 25+ messages in thread From: Eduardo Habkost @ 2017-11-25 15:16 UTC (permalink / raw) To: qemu-devel Cc: jgross, Thomas Huth, sstabellini, Laszlo Ersek, Marcel Apfelbaum, Michael S. Tsirkin, Marcel Apfelbaum The only user-creatable sysbus devices in qemu-system-x86_64 are amd-iommu, intel-iommu, and xen-backend. xen-backend is handled by xen_set_dynamic_sysbus(), so we only need to add amd-iommu and intel-iommu. Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Marcel Apfelbaum <marcel.a@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- Changes series v1 -> v2: * New patch added to series --- hw/i386/pc_q35.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index d0b0e5b422..db2bebb357 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -42,6 +42,8 @@ #include "exec/address-spaces.h" #include "hw/i386/pc.h" #include "hw/i386/ich9.h" +#include "hw/i386/amd_iommu.h" +#include "hw/i386/intel_iommu.h" #include "hw/smbios/smbios.h" #include "hw/ide/pci.h" #include "hw/ide/ahci.h" @@ -299,8 +301,8 @@ static void pc_q35_machine_options(MachineClass *m) m->default_machine_opts = "firmware=bios-256k.bin"; m->default_display = "std"; m->no_floppy = 1; - /*TODO: allow only sysbus devices that really work with this machine */ - machine_class_allow_dynamic_sysbus_dev(m, TYPE_SYS_BUS_DEVICE); + machine_class_allow_dynamic_sysbus_dev(m, TYPE_AMD_IOMMU_DEVICE); + machine_class_allow_dynamic_sysbus_dev(m, TYPE_INTEL_IOMMU_DEVICE); m->max_cpus = 288; } -- 2.13.6 ^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [Qemu-devel] [PATCH v2 6/6] q35: Allow only supported dynamic sysbus devices 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 6/6] q35: Allow only supported dynamic sysbus devices Eduardo Habkost @ 2017-11-27 8:44 ` Marcel Apfelbaum 2017-11-28 1:18 ` Eduardo Habkost 0 siblings, 1 reply; 25+ messages in thread From: Marcel Apfelbaum @ 2017-11-27 8:44 UTC (permalink / raw) To: Eduardo Habkost, qemu-devel Cc: jgross, Thomas Huth, sstabellini, Laszlo Ersek, Michael S. Tsirkin, Marcel Apfelbaum On 25/11/2017 17:16, Eduardo Habkost wrote: > The only user-creatable sysbus devices in qemu-system-x86_64 are > amd-iommu, intel-iommu, and xen-backend. xen-backend is handled > by xen_set_dynamic_sysbus(), so we only need to add amd-iommu and > intel-iommu. > > Cc: "Michael S. Tsirkin" <mst@redhat.com> > Cc: Marcel Apfelbaum <marcel.a@redhat.com> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > --- > Changes series v1 -> v2: > * New patch added to series > --- > hw/i386/pc_q35.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c > index d0b0e5b422..db2bebb357 100644 > --- a/hw/i386/pc_q35.c > +++ b/hw/i386/pc_q35.c > @@ -42,6 +42,8 @@ > #include "exec/address-spaces.h" > #include "hw/i386/pc.h" > #include "hw/i386/ich9.h" > +#include "hw/i386/amd_iommu.h" > +#include "hw/i386/intel_iommu.h" Is a pity we have to add the AMD/Intel header files only for the type, maybe we should have a header only with the type names, anyway out of the scope of this series. Another question, what about I440FX? I think the AMD vIOMMU can theoretically work with the conventional PCI machines, I am not sure if it was tested or intended to work with it. Reviewed-by: Marcel Apfelbaum <marcel@redhat.com> Thanks, Marcel > #include "hw/smbios/smbios.h" > #include "hw/ide/pci.h" > #include "hw/ide/ahci.h" > @@ -299,8 +301,8 @@ static void pc_q35_machine_options(MachineClass *m) > m->default_machine_opts = "firmware=bios-256k.bin"; > m->default_display = "std"; > m->no_floppy = 1; > - /*TODO: allow only sysbus devices that really work with this machine */ > - machine_class_allow_dynamic_sysbus_dev(m, TYPE_SYS_BUS_DEVICE); > + machine_class_allow_dynamic_sysbus_dev(m, TYPE_AMD_IOMMU_DEVICE); > + machine_class_allow_dynamic_sysbus_dev(m, TYPE_INTEL_IOMMU_DEVICE); > m->max_cpus = 288; > } > > ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [Qemu-devel] [PATCH v2 6/6] q35: Allow only supported dynamic sysbus devices 2017-11-27 8:44 ` Marcel Apfelbaum @ 2017-11-28 1:18 ` Eduardo Habkost 0 siblings, 0 replies; 25+ messages in thread From: Eduardo Habkost @ 2017-11-28 1:18 UTC (permalink / raw) To: Marcel Apfelbaum Cc: qemu-devel, jgross, Thomas Huth, sstabellini, Laszlo Ersek, Michael S. Tsirkin, Marcel Apfelbaum On Mon, Nov 27, 2017 at 10:44:34AM +0200, Marcel Apfelbaum wrote: > On 25/11/2017 17:16, Eduardo Habkost wrote: > > The only user-creatable sysbus devices in qemu-system-x86_64 are > > amd-iommu, intel-iommu, and xen-backend. xen-backend is handled > > by xen_set_dynamic_sysbus(), so we only need to add amd-iommu and > > intel-iommu. > > > > Cc: "Michael S. Tsirkin" <mst@redhat.com> > > Cc: Marcel Apfelbaum <marcel.a@redhat.com> > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > > --- > > Changes series v1 -> v2: > > * New patch added to series > > --- > > hw/i386/pc_q35.c | 6 ++++-- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c > > index d0b0e5b422..db2bebb357 100644 > > --- a/hw/i386/pc_q35.c > > +++ b/hw/i386/pc_q35.c > > @@ -42,6 +42,8 @@ > > #include "exec/address-spaces.h" > > #include "hw/i386/pc.h" > > #include "hw/i386/ich9.h" > > +#include "hw/i386/amd_iommu.h" > > +#include "hw/i386/intel_iommu.h" > > Is a pity we have to add the AMD/Intel header files > only for the type, maybe we should have a header only > with the type names, anyway out of the scope of this series. Another option is to use the type name strings directly instead of the TYPE_* macros (which I never really liked). But I don't want to deviate from the current practice. > > Another question, what about I440FX? > I think the AMD vIOMMU can theoretically work with the > conventional PCI machines, I am not sure if it was tested > or intended to work with it. i440fx still has has_dynamic_sysbus=false. With this series, we can now add amd-iommu to its allowed list, if somebody is willing to support/test it. > > Reviewed-by: Marcel Apfelbaum <marcel@redhat.com> Thanks! > > Thanks, > Marcel > > > #include "hw/smbios/smbios.h" > > #include "hw/ide/pci.h" > > #include "hw/ide/ahci.h" > > @@ -299,8 +301,8 @@ static void pc_q35_machine_options(MachineClass *m) > > m->default_machine_opts = "firmware=bios-256k.bin"; > > m->default_display = "std"; > > m->no_floppy = 1; > > - /*TODO: allow only sysbus devices that really work with this machine */ > > - machine_class_allow_dynamic_sysbus_dev(m, TYPE_SYS_BUS_DEVICE); > > + machine_class_allow_dynamic_sysbus_dev(m, TYPE_AMD_IOMMU_DEVICE); > > + machine_class_allow_dynamic_sysbus_dev(m, TYPE_INTEL_IOMMU_DEVICE); > > m->max_cpus = 288; > > } > > > -- Eduardo ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [Qemu-devel] [PATCH v2 0/6] Replace has_dynamic_sysbus with list of allowed device types 2017-11-25 15:16 [Qemu-devel] [PATCH v2 0/6] Replace has_dynamic_sysbus with list of allowed device types Eduardo Habkost ` (5 preceding siblings ...) 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 6/6] q35: Allow only supported dynamic sysbus devices Eduardo Habkost @ 2017-12-22 13:37 ` Marc-André Lureau 2018-01-09 20:12 ` Eduardo Habkost 7 siblings, 0 replies; 25+ messages in thread From: Marc-André Lureau @ 2017-12-22 13:37 UTC (permalink / raw) To: Eduardo Habkost Cc: QEMU, jgross, Thomas Huth, Stefano Stabellini, Stefan Berger, Alexander Graf, Paolo Bonzini, Marcel Apfelbaum, Laszlo Ersek Hi On Sat, Nov 25, 2017 at 4:16 PM, Eduardo Habkost <ehabkost@redhat.com> wrote: > Changes v1 (RFC) -> v2: > * Patch 1 now just adds TYPE_SYS_BUS_DEVICE to the existing > has_dynamic_sysbus=true machines, and other patches make > the lists on each machine-type more specific. > * Change the name of the new field to > allowed_dynamic_sysbus_devices. > * The q35 allowed list is much shorter because the list of > user-creatable sysbus devices in QEMU is shorter. > * Keep the xen_set_dynamic_sysbus() hack, just change it > to add 'xen-sysdev" to the allowed list. > * Simplified the arm/virt code. > > Summary > ------- > > This series replaces the existing has_dynamic_sysbus flag (that > makes the machine accept every user-creatable sysbus device type > on the command-line) with a list of allowed devices. > > This will be helpful when implementing the new query-device-slots > command, because each machine type will include only the sysbus > devices it really supports, instead of including a catch-all > TYPE_SYS_BUS_DEVICE "slot". > > This will be useful to add support to new sysbus devices on > machines like pc_piix, that don't have has_dynamic_sysbus set > today. > > This also makes the code safer: just compiling a new sysbus > device in the same QEMU binary won't make a machine-type > automatically start accepting the device. Anything left for the series? (besides review of patch 5?) I need this to be solved for the pending TPM CRB device to work with piix. Thanks > > Cc: Marc-André Lureau <marcandre.lureau@redhat.com> > Cc: Marcel Apfelbaum <marcel@redhat.com> > Cc: Paolo Bonzini <pbonzini@redhat.com> > Cc: Stefan Berger <stefanb@linux.vnet.ibm.com> > Cc: Alexander Graf <agraf@suse.de> > > Eduardo Habkost (6): > machine: Replace has_dynamic_sysbus with list of allowed devices > hw/arm/virt: Allow only supported dynamic sysbus devices > ppc: e500: Allow only supported dynamic sysbus devices > spapr: Allow only supported dynamic sysbus devices > xen: Add only xen-sysdev to dynamic sysbus device list > q35: Allow only supported dynamic sysbus devices > > include/hw/boards.h | 5 ++++- > hw/arm/virt.c | 5 ++++- > hw/core/machine.c | 43 +++++++++++++++++++++++++++++-------------- > hw/i386/pc_q35.c | 5 ++++- > hw/ppc/e500plat.c | 4 +++- > hw/ppc/spapr.c | 2 +- > hw/xen/xen_backend.c | 2 +- > 7 files changed, 46 insertions(+), 20 deletions(-) > > -- > 2.13.6 > > -- Marc-André Lureau ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [Qemu-devel] [PATCH v2 0/6] Replace has_dynamic_sysbus with list of allowed device types 2017-11-25 15:16 [Qemu-devel] [PATCH v2 0/6] Replace has_dynamic_sysbus with list of allowed device types Eduardo Habkost ` (6 preceding siblings ...) 2017-12-22 13:37 ` [Qemu-devel] [PATCH v2 0/6] Replace has_dynamic_sysbus with list of allowed device types Marc-André Lureau @ 2018-01-09 20:12 ` Eduardo Habkost 7 siblings, 0 replies; 25+ messages in thread From: Eduardo Habkost @ 2018-01-09 20:12 UTC (permalink / raw) To: qemu-devel Cc: jgross, Thomas Huth, sstabellini, Stefan Berger, Alexander Graf, Paolo Bonzini, Marcel Apfelbaum, Marc-André Lureau, Laszlo Ersek Queued on machine-next. -- Eduardo ^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2018-01-09 20:12 UTC | newest] Thread overview: 25+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-11-25 15:16 [Qemu-devel] [PATCH v2 0/6] Replace has_dynamic_sysbus with list of allowed device types Eduardo Habkost 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 1/6] machine: Replace has_dynamic_sysbus with list of allowed devices Eduardo Habkost 2017-11-25 17:08 ` Greg Kurz 2017-11-27 1:51 ` David Gibson 2017-11-27 8:39 ` Marcel Apfelbaum 2017-11-28 16:55 ` Marc-André Lureau 2017-11-28 18:34 ` Eduardo Habkost 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 2/6] hw/arm/virt: Allow only supported dynamic sysbus devices Eduardo Habkost 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 3/6] ppc: e500: " Eduardo Habkost 2017-11-25 18:31 ` Greg Kurz 2017-11-28 1:11 ` Eduardo Habkost 2017-11-27 1:52 ` David Gibson 2017-11-28 1:12 ` Eduardo Habkost 2017-11-28 4:54 ` David Gibson 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 4/6] spapr: " Eduardo Habkost 2017-11-25 17:43 ` Greg Kurz 2017-11-27 1:52 ` David Gibson 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 5/6] xen: Add only xen-sysdev to dynamic sysbus device list Eduardo Habkost 2017-12-22 13:36 ` Marc-André Lureau 2018-01-05 14:12 ` Anthony PERARD 2017-11-25 15:16 ` [Qemu-devel] [PATCH v2 6/6] q35: Allow only supported dynamic sysbus devices Eduardo Habkost 2017-11-27 8:44 ` Marcel Apfelbaum 2017-11-28 1:18 ` Eduardo Habkost 2017-12-22 13:37 ` [Qemu-devel] [PATCH v2 0/6] Replace has_dynamic_sysbus with list of allowed device types Marc-André Lureau 2018-01-09 20:12 ` 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).