simplify usb enabling logic and fix a Qemu crash
cover simplify usb enabling logic and fix a Qemu crash
Patch e79d5a6 ("machine: remove qemu_machine_opts global list") removed option descriptions from the -machine QemuOptsList to avoid repeating MachineState's QOM properties.
This resulted in a Qemu crash:
$ qemu-system-x86_64 -usb qemu-system-x86_64: util/qemu-option.c:387: qemu_opt_get_bool_helper: Assertion `opt->desc && opt->desc->type == QEMU_OPT_BOOL' failed. Aborted (core dumped)
Fixed it by simplifying usb_enabled usage:
- removed the usb_enabled argument
- call directly to machine's QOM property.
- expose defaults_enabled to calling sites
As part of this series the semantics for some ppc machines to create the default usb controller were changed, but I still think is correct, please let me know if you see a problem there.
Based on the comments I will receive, I will continue to fix the options properties in the same way.
Marcel Apfelbaum (6):
hw/ppc: modified the condition for usb controllers to be created for
some ppc machines
hw/machine: added machine_usb wrapper
hw/usb: simplified usb_enabled
hw/ppc/mac_newworld: QOMified mac99 machines hw/ppc/spapr: simplify usb controller creation logic hw/ppc/mac_newworld: simplify usb controller creation logic
hw/arm/nseries.c | 2 +- hw/arm/pxa2xx.c | 4 ++-- hw/arm/realview.c | 2 +- hw/arm/versatilepb.c | 2 +- hw/core/machine.c | 5 +++++ hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 2 +- hw/ppc/mac_newworld.c | 32 +++++++++++++++++++++----------- hw/ppc/mac_oldworld.c | 2 +- hw/ppc/prep.c | 2 +- hw/ppc/spapr.c | 3 ++- include/hw/boards.h | 2 ++ include/sysemu/sysemu.h | 3 ++- vl.c | 16 ++++++++++------ 14 files changed, 51 insertions(+), 28 deletions(-)
Signature · 1 line
2.1.0
PATCH 2/6 hw/machine: added machine_usb wrapper
Following QOM convention, object properties should not be accessed directly.
--- hw/core/machine.c | 5 +++++ include/hw/boards.h | 2 ++ 2 files changed, 7 insertions(+)
hw/core/machine.c +5 -0
@@ -398,6 +398,11 @@ static void machine_finalize(Object *obj)g_free (ms->firmware); } +bool machine_usb (MachineState *machine) +{ +return machine->usb; +} +static const TypeInfo machine_info = { .name =TYPE_MACHINE , .parent =TYPE_OBJECT ,
include/hw/boards.h +2 -0
@@ -65,6 +65,8 @@ int qemu_register_machine(QEMUMachine *m);MachineClass *find_default_machine (void );extern MachineState *current_machine; +bool machine_usb (MachineState *machine); +/** * MachineClass: * @qemu_machine: #QEMUMachine
Signature · 1 line
2.1.0
PATCH 1/6 hw/ppc: modified the condition for usb controllers to be created for some ppc machines
In reply to Marcel ApfelbaumSome ppc machines create a default usb controller based on a 'machine condition'. Until now the logic was: create the usb controller if:
- the usb option was supplied in cli and value is true or
- the usb option was absent and both set_defaults and the machine condition were true.
Modified the logic to:
Create the usb controller if:
- the machine condition is true and defaults are enabled or
- the usb option is supplied and true.
The main for this is to simplify the usb_enabled method.
--- hw/ppc/mac_newworld.c | 3 ++- hw/ppc/spapr.c | 2 +- include/sysemu/sysemu.h | 1 + vl.c | 7 ++++++- 4 files changed, 10 insertions(+), 3 deletions(-)
hw/ppc/mac_newworld.c +2 -1
@@ -417,7 +417,8 @@ static void ppc_core99_init(MachineState *machine) dev =qdev_create (adb_bus,TYPE_ADB_MOUSE );qdev_init_nofail (dev); -if (usb_enabled (machine_arch ==ARCH_MAC99_U3 )) { +if ((machine_arch ==ARCH_MAC99_U3 &&defaults_enabled ()) || +usb_enabled (false)) {pci_create_simple (pci_bus,-1 ,"pci-ohci" );/* U3 needs to use USB for input because Linux doesn't support via-cuda on PPC64 */
hw/ppc/spapr.c +1 -1
@@ -1486,7 +1486,7 @@ static void ppc_spapr_init(MachineState *machine) spapr->has_graphics = true; } -if (usb_enabled (spapr->has_graphics)) { +if ((spapr->has_graphics &&defaults_enabled ()) ||usb_enabled (false)) {pci_create_simple (phb->bus,-1 ,"pci-ohci" );if (spapr->has_graphics) {usbdevice_create ("keyboard" );
include/sysemu/sysemu.h +1 -0
@@ -227,6 +227,7 @@ void qemu_boot_set(const char *boot_order, Error **errp);QemuOpts *qemu_get_machine_opts (void ); +bool defaults_enabled (void );bool usb_enabled (bool default_usb);extern QemuOptsList qemu_legacy_drive_opts;
vl.c +6 -1
@@ -997,10 +997,15 @@ static int parse_name(QemuOpts *opts, void *opaque)return 0 ; } +bool defaults_enabled (void ) +{ +return has_defaults; +} +bool usb_enabled (bool default_usb) {return qemu_opt_get_bool (qemu_get_machine_opts (),"usb" , - has_defaults && default_usb); + default_usb); }#ifndef _WIN32
Signature · 1 line
2.1.0
PATCH 3/6 hw/usb: simplified usb_enabled
In reply to Marcel ApfelbaumThe argument is not longer used and the implementation uses now QOM instead of QemuOpts.
--- hw/arm/nseries.c | 2 +- hw/arm/pxa2xx.c | 4 ++-- hw/arm/realview.c | 2 +- hw/arm/versatilepb.c | 2 +- hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 2 +- hw/ppc/mac_newworld.c | 2 +- hw/ppc/mac_oldworld.c | 2 +- hw/ppc/prep.c | 2 +- hw/ppc/spapr.c | 2 +- include/sysemu/sysemu.h | 2 +- vl.c | 11 +++++------ 12 files changed, 17 insertions(+), 18 deletions(-)
hw/arm/nseries.c +1 -1
@@ -1344,7 +1344,7 @@ static void n8x0_init(MachineState *machine,n8x0_dss_setup (s);n8x0_cbus_setup (s);n8x0_uart_setup (s); -if (usb_enabled (false)) { +if (usb_enabled ()) {n8x0_usb_setup (s); }
hw/arm/pxa2xx.c +2 -2
@@ -2143,7 +2143,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space, s->ssp[i] = (SSIBus *)qdev_get_child_bus (dev,"ssi" ); } -if (usb_enabled (false)) { +if (usb_enabled ()) {sysbus_create_simple ("sysbus-ohci" ,0x4c000000 ,qdev_get_gpio_in (s->pic,PXA2XX_PIC_USBH1 )); }
@@ -2276,7 +2276,7 @@ PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size) s->ssp[i] = (SSIBus *)qdev_get_child_bus (dev,"ssi" ); } -if (usb_enabled (false)) { +if (usb_enabled ()) {sysbus_create_simple ("sysbus-ohci" ,0x4c000000 ,qdev_get_gpio_in (s->pic,PXA2XX_PIC_USBH1 )); }
hw/arm/realview.c +1 -1
@@ -261,7 +261,7 @@ static void realview_init(MachineState *machine,sysbus_connect_irq (busdev,2 , pic[50 ]);sysbus_connect_irq (busdev,3 , pic[51 ]); pci_bus = (PCIBus *)qdev_get_child_bus (dev,"pci" ); -if (usb_enabled (false)) { +if (usb_enabled ()) {pci_create_simple (pci_bus,-1 ,"pci-ohci" ); } n =drive_get_max_bus (IF_SCSI );
hw/arm/versatilepb.c +1 -1
@@ -281,7 +281,7 @@ static void versatile_init(MachineState *machine, int board_id)pci_nic_init_nofail (nd, pci_bus,"rtl8139" ,NULL ); } } -if (usb_enabled (false)) { +if (usb_enabled ()) {pci_create_simple (pci_bus,-1 ,"pci-ohci" ); } n =drive_get_max_bus (IF_SCSI );
hw/i386/pc_piix.c +1 -1
@@ -274,7 +274,7 @@ static void pc_init1(MachineState *machine,pc_cmos_init (below_4g_mem_size, above_4g_mem_size, machine->boot_order, machine, floppy, idebus[0 ], idebus[1 ], rtc_state); -if (pci_enabled &&usb_enabled (false)) { +if (pci_enabled &&usb_enabled ()) {pci_create_simple (pci_bus, piix3_devfn +2 ,"piix3-usb-uhci" ); }
hw/i386/pc_q35.c +1 -1
@@ -265,7 +265,7 @@ static void pc_q35_init(MachineState *machine)ide_drive_get (hd,ICH_AHCI (ahci)->ahci.ports);ahci_ide_create_devs (ahci, hd); -if (usb_enabled (false)) { +if (usb_enabled ()) {/* Should we create 6 UHCI according to ich9 spec? */ ehci_create_ich9_with_companions (host_bus,0x1d ); }
hw/ppc/mac_newworld.c +1 -1
@@ -418,7 +418,7 @@ static void ppc_core99_init(MachineState *machine)qdev_init_nofail (dev);if ((machine_arch ==ARCH_MAC99_U3 &&defaults_enabled ()) || -usb_enabled (false)) { +usb_enabled ()) {pci_create_simple (pci_bus,-1 ,"pci-ohci" );/* U3 needs to use USB for input because Linux doesn't support via-cuda on PPC64 */
hw/ppc/mac_oldworld.c +1 -1
@@ -304,7 +304,7 @@ static void ppc_heathrow_init(MachineState *machine) dev =qdev_create (adb_bus,TYPE_ADB_MOUSE );qdev_init_nofail (dev); -if (usb_enabled (false)) { +if (usb_enabled ()) {pci_create_simple (pci_bus,-1 ,"pci-ohci" ); }
hw/ppc/prep.c +1 -1
@@ -539,7 +539,7 @@ static void ppc_prep_init(MachineState *machine)memory_region_add_subregion (sysmem,0xFEFF0000 , xcsr);#endif -if (usb_enabled (false)) { +if (usb_enabled ()) {pci_create_simple (pci_bus,-1 ,"pci-ohci" ); }
hw/ppc/spapr.c +1 -1
@@ -1486,7 +1486,7 @@ static void ppc_spapr_init(MachineState *machine) spapr->has_graphics = true; } -if ((spapr->has_graphics &&defaults_enabled ()) ||usb_enabled (false)) { +if ((spapr->has_graphics &&defaults_enabled ()) ||usb_enabled ()) {pci_create_simple (phb->bus,-1 ,"pci-ohci" );if (spapr->has_graphics) {usbdevice_create ("keyboard" );
include/sysemu/sysemu.h +1 -1
@@ -228,7 +228,7 @@ void qemu_boot_set(const char *boot_order, Error **errp);QemuOpts *qemu_get_machine_opts (void );bool defaults_enabled (void ); -bool usb_enabled (bool default_usb); +bool usb_enabled (void );extern QemuOptsList qemu_legacy_drive_opts;extern QemuOptsList qemu_common_drive_opts;
vl.c +5 -6
@@ -1002,10 +1002,9 @@ bool defaults_enabled(void)return has_defaults; } -bool usb_enabled (bool default_usb) +bool usb_enabled (void ) { -return qemu_opt_get_bool (qemu_get_machine_opts (),"usb" , - default_usb); +return machine_usb (current_machine); }#ifndef _WIN32
@@ -1229,7 +1228,7 @@ static int usb_device_add(const char *devname)const char *p;#endif -if (!usb_enabled (false)) { +if (!usb_enabled ()) {return -1 ; }
@@ -1261,7 +1260,7 @@ static int usb_device_del(const char *devname)return -1 ; } -if (!usb_enabled (false)) { +if (!usb_enabled ()) {return -1 ; }
@@ -4230,7 +4229,7 @@ int main(int argc, char **argv, char **envp)set_numa_modes ();/* init USB devices */ -if (usb_enabled (false)) { +if (usb_enabled ()) {if (foreach_device_config (DEV_USB , usb_parse) <0 )exit (1 ); }
Signature · 1 line
2.1.0
PATCH 4/6 hw/ppc/mac_newworld: QOMified mac99 machines
In reply to Marcel Apfelbaum--- hw/ppc/mac_newworld.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)
hw/ppc/mac_newworld.c +19 -10
@@ -502,18 +502,27 @@ static int core99_kvm_type(const char *arg)return 2 ; } -static QEMUMachine core99_machine = { - .name ="mac99" , - .desc ="Mac99 based PowerMAC" , - .init = ppc_core99_init, - .max_cpus =MAX_CPUS , - .default_boot_order ="cd" , - .kvm_type = core99_kvm_type, +static void core99_machine_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + + mc->name ="mac99" ; + mc->desc ="Mac99 based PowerMAC" ; + mc->init = ppc_core99_init; + mc->max_cpus =MAX_CPUS ; + mc->default_boot_order ="cd" ; + mc->kvm_type = core99_kvm_type; +} + +static const TypeInfo core99_machine_info = { + .name ="mac99-machine" , + .parent =TYPE_MACHINE , + .class_init = core99_machine_class_init, }; -static void core99_machine_init (void ) +static void mac_machine_register_types (void ) { -qemu_register_machine (&core99_machine); +type_register_static (&core99_machine_info); } -machine_init (core99_machine_init); +type_init (mac_machine_register_types)
Signature · 1 line
2.1.0
PATCH 5/6 hw/ppc/spapr: simplify usb controller creation logic
In reply to Marcel Apfelbaum--- hw/ppc/spapr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/ppc/spapr.c +2 -1
@@ -1484,9 +1484,10 @@ static void ppc_spapr_init(MachineState *machine)/* Graphics */ if (spapr_vga_init (phb->bus)) { spapr->has_graphics = true; + machine->usb |=defaults_enabled (); } -if ((spapr->has_graphics &&defaults_enabled ()) ||usb_enabled ()) { +if (machine->usb) {pci_create_simple (phb->bus,-1 ,"pci-ohci" );if (spapr->has_graphics) {usbdevice_create ("keyboard" );
Signature · 1 line
2.1.0
PATCH 6/6 hw/ppc/mac_newworld: simplify usb controller creation logic
In reply to Marcel Apfelbaum--- hw/ppc/mac_newworld.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/ppc/mac_newworld.c +2 -2
@@ -371,6 +371,7 @@ static void ppc_core99_init(MachineState *machine)/* 970 gets a U3 bus */ pci_bus =pci_pmac_u3_init (pic,get_system_memory (),get_system_io ()); machine_arch =ARCH_MAC99_U3 ; + machine->usb |=defaults_enabled (); }else { pci_bus =pci_pmac_init (pic,get_system_memory (),get_system_io ()); machine_arch =ARCH_MAC99 ;
@@ -417,8 +418,7 @@ static void ppc_core99_init(MachineState *machine) dev =qdev_create (adb_bus,TYPE_ADB_MOUSE );qdev_init_nofail (dev); -if ((machine_arch ==ARCH_MAC99_U3 &&defaults_enabled ()) || -usb_enabled ()) { +if (machine->usb) {pci_create_simple (pci_bus,-1 ,"pci-ohci" );/* U3 needs to use USB for input because Linux doesn't support via-cuda on PPC64 */
Signature · 1 line
2.1.0
Quoted 30 lines · Marcel Apfelbaum
Patch e79d5a6 ("machine: remove
qemu_machine_optsglobal list") removed option descriptions from the -machine QemuOptsList to avoid repeating MachineState's QOM properties.This resulted in a Qemu crash:
$ qemu-system-x86_64 -usb qemu-system-x86_64: util/qemu-option.c:387: qemu_opt_get_bool_helper: Assertion `opt->desc && opt->desc->type == QEMU_OPT_BOOL' failed. Aborted (core dumped)Fixed it by simplifying
usb_enabledusage:
- removed theusb_enabledargument
- call directly to machine's QOM property.
- exposedefaults_enabledto calling sitesAs part of this series the semantics for some ppc machines to create the default usb controller were changed, but I still think is correct, please let me know if you see a problem there.
Based on the comments I will receive, I will continue to fix the options properties in the same way.
Marcel Apfelbaum (6):
hw/ppc: modified the condition for usb controllers to be created for
some ppc machines
hw/machine: addedmachine_usbwrapper
hw/usb: simplifiedusb_enabled
hw/ppc/mac_newworld: QOMified mac99 machines hw/ppc/spapr: simplify usb controller creation logic hw/ppc/mac_newworld: simplify usb controller creation logic
Quoted 16 lines
hw/arm/nseries.c | 2 +- hw/arm/pxa2xx.c | 4 ++-- hw/arm/realview.c | 2 +- hw/arm/versatilepb.c | 2 +- hw/core/machine.c | 5 +++++ hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 2 +- hw/ppc/mac_newworld.c | 32 +++++++++++++++++++++----------- hw/ppc/mac_oldworld.c | 2 +- hw/ppc/prep.c | 2 +- hw/ppc/spapr.c | 3 ++- include/hw/boards.h | 2 ++ include/sysemu/sysemu.h | 3 ++- vl.c | 16 ++++++++++------ 14 files changed, 51 insertions(+), 28 deletions(-)
I like the way you structured the series!
Quoted 3 lines · Paolo Bonzini
I like the way you structured the series!
Reviewed-by Paolo Bonzini <[email protected]>
Hmm, actually doesn't this break -machine usb=no?
Paolo
Re: [Qemu-devel] [PATCH 5/6] hw/ppc/spapr: simplify usb controller creation logic
In reply to Marcel Apfelbaumhw/ppc/spapr.c static void ppc_spapr_init(MachineState *machine) · line 1488
Quoted 6 lines · Marcel Apfelbaum
hw/ppc/spapr.c +1
-0@@ -1484,9 +1484,10 @@ static void ppc_spapr_init(MachineState *machine)/* Graphics */ if (spapr_vga_init (phb->bus)) { spapr->has_graphics = true; + machine->usb |=defaults_enabled (); }
Could the solution be to do this in instance_init? Then you would have patches 2, 4, 5, 6, 3 (patch 1 would not be needed anymore).
Paolo
Re: [Qemu-devel] [PATCH 1/6] hw/ppc: modified the condition for usb controllers to be created for some ppc machines
In reply to Marcel ApfelbaumQuoted 6 lines · Marcel Apfelbaum
Some ppc machines create a default usb controller based on a 'machine condition'. Until now the logic was: create the usb controller if:
- the usb option was supplied in cli and value is true or
- the usb option was absent and bothset_defaultsand the machine condition were true.
Quoted 8 lines
Modified the logic to:
Create the usb controller if:
- the machine condition is true and defaults are enabled or
- the usb option is supplied and true.The main for this is to simplify the
usb_enabledmethod.Signed-off-by Marcel Apfelbaum <[email protected]>
I think this preserves the logic from a user's perspective quite well.
Alex
Quoted 8 lines · Paolo Bonzini
Quoted 3 lines · Paolo Bonzini
I like the way you structured the series!
Reviewed-by Paolo Bonzini <[email protected]>Hmm, actually doesn't this break -machine usb=no?
I think it does, but I don't think we really need to care. We can just assume that the 64bit mac99 always has USB and it's impossible to turn off.
For sPAPR, we only ever enable USB as convenience option when VGA is enabled. I think it's a pretty fair thing to do there and simply ignore usb=no. If you really need it, just don't use -vga.
At the end of the day, I don't think anyone will notice. I'd definitely prefer to keep the code simple.
However, I think looking forward we'll want to spawn an XHCI adapter rather than OHCI. It's just a lot cheaper to emulate. But that's out of scope of this patch set.
Alex
Quoted 15 lines · Alexander Graf
Quoted 8 lines · Paolo Bonzini
Quoted 3 lines · Paolo Bonzini
I like the way you structured the series!
Reviewed-by Paolo Bonzini <[email protected]>Hmm, actually doesn't this break -machine usb=no?
I think it does, but I don't think we really need to care. We can just assume that the 64bit mac99 always has USB and it's impossible to turn off.
Quoted 6 lines
For sPAPR, we only ever enable USB as convenience option when VGA is enabled. I think it's a pretty fair thing to do there and simply ignore usb=no. If you really need it, just don't use -vga.
At the end of the day, I don't think anyone will notice. I'd definitely prefer to keep the code simple.
Yeah, I agree. If it's hard to fix, this patchset is okay. But if it's not too hard (and I don't think it is, especially if machine_parse is centralized as in my reply to "[PATCH] vl.c: fix regression when reading machine type from config file") the old semantics made more sense.
Paolo
Quoted 3 lines
However, I think looking forward we'll want to spawn an XHCI adapter rather than OHCI. It's just a lot cheaper to emulate. But that's out of scope of this patch set.
Re: [Qemu-devel] [PATCH 5/6] hw/ppc/spapr: simplify usb controller creation logic
In reply to Alexander GrafQuoted 7 lines · Alexander Graf
Quoted 4 lines · Paolo Bonzini
Quoted 1 line · Marcel Apfelbaum
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
While I agree it will be better if we place this in
instance_init, setting themachine_usbtodefaults_enabled()there would be problematic since it depends on
-papr_vga_init(phb->bus)for sparpr andThat's effectively
vga_interface_type==VGA_DEVICE||vga_interface_type==VGA_STD.
That means moving select_vgahw (vl.c) that sets vga_interface_type much much earlier in main, before the current machine is created. And it depends itself on other stuff...
Quoted 14 lines
Quoted 6 lines
Quoted 3 lines
- (
PPC_INPUT(env)==PPC_FLAGS_INPUT_970) for mac99. (The env itself is set inmachine_init)Alex, why is auto-USB disabled for 6xx? Can it use
vga_interface_typelike spapr does?That one's a nasty hack. We basically have 2 different machine types that we expose as a single type to the user: mac99. In reality there's a 64bit mac99 and a 32bit mac99.
32bit mac99 can expose keyboard and mouse via a special apple bus. That driver doesn't work with 64bit Linux guests though, so there we need USB.
Quoted 7 lines
Thinking about it, maybe the best way forward would be to create 2 machine types out of these. Have a mac99 (32bit) and a mac99-g5 target where the g5 target defaults to -cpu G5 and USB enabled.
All of this is pretty frankenstein btw. What we would really want for a G5 guest is something built around U3 or U4, not the U1 that -M mac99 exposes.
Given my (lack of) expertise on ppc, I shouldn't throw myself yet in the above adventure.
Since I will not be able (soon) to get in the stuff Alex mentioned and the implications moving the setting of vga_interface_type earlier in main fall far beyond this series target (fix a bug/simpligu -usb on the way), I suggest putting the above on todo list.
I plan to do the same (access machine's properties instead of quering QemuOpts) for all other machine properties because I am sure we have other hidden bugs there.
Thanks,
Marcel
Quoted 4 lines
Alex
Re: [Qemu-devel] [PATCH 5/6] hw/ppc/spapr: simplify usb controller creation logic
In reply to Marcel ApfelbaumQuoted 5 lines · Marcel Apfelbaum
While I agree it will be better if we place this in
instance_init, setting themachine_usbtodefaults_enabled()there would be problematic since it depends on
-papr_vga_init(phb->bus)for sparpr and
That's effectively vga_interface_type == VGA_DEVICE || vga_interface_type == VGA_STD.
Quoted 2 lines
- (
PPC_INPUT(env)==PPC_FLAGS_INPUT_970) for mac99. (The env itself is set inmachine_init)
Alex, why is auto-USB disabled for 6xx? Can it use vga_interface_type like spapr does?
Paolo
Quoted 2 lines
Both of those conditions may be available only at
machine_inittime, and I am not sure how it would affect those machines.
Quoted 30 lines · Marcel Apfelbaum
Patch e79d5a6 ("machine: remove
qemu_machine_optsglobal list") removed option descriptions from the -machine QemuOptsList to avoid repeating MachineState's QOM properties.This resulted in a Qemu crash:
$ qemu-system-x86_64 -usb qemu-system-x86_64: util/qemu-option.c:387: qemu_opt_get_bool_helper: Assertion `opt->desc && opt->desc->type == QEMU_OPT_BOOL' failed. Aborted (core dumped)Fixed it by simplifying
usb_enabledusage:
- removed theusb_enabledargument
- call directly to machine's QOM property.
- exposedefaults_enabledto calling sitesAs part of this series the semantics for some ppc machines to create the default usb controller were changed, but I still think is correct, please let me know if you see a problem there.
Based on the comments I will receive, I will continue to fix the options properties in the same way.
Marcel Apfelbaum (6):
hw/ppc: modified the condition for usb controllers to be created for
some ppc machines
hw/machine: addedmachine_usbwrapper
hw/usb: simplifiedusb_enabled
hw/ppc/mac_newworld: QOMified mac99 machines hw/ppc/spapr: simplify usb controller creation logic hw/ppc/mac_newworld: simplify usb controller creation logic
Quoted 20 lines
hw/arm/nseries.c | 2 +- hw/arm/pxa2xx.c | 4 ++-- hw/arm/realview.c | 2 +- hw/arm/versatilepb.c | 2 +- hw/core/machine.c | 5 +++++ hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 2 +- hw/ppc/mac_newworld.c | 32 +++++++++++++++++++++----------- hw/ppc/mac_oldworld.c | 2 +- hw/ppc/prep.c | 2 +- hw/ppc/spapr.c | 3 ++- include/hw/boards.h | 2 ++ include/sysemu/sysemu.h | 3 ++- vl.c | 16 ++++++++++------ 14 files changed, 51 insertions(+), 28 deletions(-)Signature · 1 line
2.1.0
Re: [Qemu-devel] [PATCH 5/6] hw/ppc/spapr: simplify usb controller creation logic
In reply to Paolo BonziniQuoted 35 lines · Paolo Bonzini
Quoted 32 lines · Alexander Graf
Quoted 9 lines · Paolo Bonzini
Quoted 5 lines · Marcel Apfelbaum
While I agree it will be better if we place this in
instance_init, setting themachine_usbtodefaults_enabled()there would be problematic since it depends on
-papr_vga_init(phb->bus)for sparpr andQuoted 8 lines
That's effectively
vga_interface_type==VGA_DEVICE||vga_interface_type==VGA_STD.Quoted 2 lines
- (
PPC_INPUT(env)==PPC_FLAGS_INPUT_970) for mac99. (The env itself is set inmachine_init)Alex, why is auto-USB disabled for 6xx? Can it use
vga_interface_typelike spapr does?That one's a nasty hack. We basically have 2 different machine types that we expose as a single type to the user: mac99. In reality there's a 64bit mac99 and a 32bit mac99.
32bit mac99 can expose keyboard and mouse via a special apple bus. That driver doesn't work with 64bit Linux guests though, so there we need USB.
Thinking about it, maybe the best way forward would be to create 2 machine types out of these. Have a mac99 (32bit) and a mac99-g5 target where the g5 target defaults to -cpu G5 and USB enabled.
Quoted 5 lines
Quoted 3 lines
All of this is pretty frankenstein btw. What we would really want for a G5 guest is something built around U3 or U4, not the U1 that -M mac99 exposes.
Hmm, then I guess let's apply these patches and fix things up later?
Certainly works for me ;).
Alex
Re: [Qemu-devel] [PATCH 5/6] hw/ppc/spapr: simplify usb controller creation logic
In reply to Paolo BonziniQuoted 8 lines · Paolo Bonzini
Quoted 3 lines · Alexander Graf
Quoted 1 line
Hmm, then I guess let's apply these patches and fix things up later?
Certainly works for me ;).
Send a pull request then. :)
Ok, applied the patch set to ppc-next. Now let's see how much of my autotest setup fell apart over the holidays ;).
Alex
Re: [Qemu-devel] [PATCH 5/6] hw/ppc/spapr: simplify usb controller creation logic
In reply to Paolo BonziniQuoted 9 lines · Paolo Bonzini
Quoted 5 lines · Marcel Apfelbaum
While I agree it will be better if we place this in
instance_init, setting themachine_usbtodefaults_enabled()there would be problematic since it depends on
-papr_vga_init(phb->bus)for sparpr and
Quoted 8 lines
That's effectively
vga_interface_type==VGA_DEVICE||vga_interface_type==VGA_STD.Quoted 2 lines
- (
PPC_INPUT(env)==PPC_FLAGS_INPUT_970) for mac99. (The env itself is set inmachine_init)Alex, why is auto-USB disabled for 6xx? Can it use
vga_interface_typelike spapr does?
That one's a nasty hack. We basically have 2 different machine types that we expose as a single type to the user: mac99. In reality there's a 64bit mac99 and a 32bit mac99.
32bit mac99 can expose keyboard and mouse via a special apple bus. That driver doesn't work with 64bit Linux guests though, so there we need USB.
Thinking about it, maybe the best way forward would be to create 2 machine types out of these. Have a mac99 (32bit) and a mac99-g5 target where the g5 target defaults to -cpu G5 and USB enabled.
All of this is pretty frankenstein btw. What we would really want for a G5 guest is something built around U3 or U4, not the U1 that -M mac99 exposes.
Alex
Re: [Qemu-devel] [PATCH 5/6] hw/ppc/spapr: simplify usb controller creation logic
Quoted 28 lines · Alexander Graf
Quoted 9 lines · Paolo Bonzini
Quoted 5 lines · Marcel Apfelbaum
While I agree it will be better if we place this in
instance_init, setting themachine_usbtodefaults_enabled()there would be problematic since it depends on
-papr_vga_init(phb->bus)for sparpr andQuoted 8 lines
That's effectively
vga_interface_type==VGA_DEVICE||vga_interface_type==VGA_STD.Quoted 2 lines
- (
PPC_INPUT(env)==PPC_FLAGS_INPUT_970) for mac99. (The env itself is set inmachine_init)Alex, why is auto-USB disabled for 6xx? Can it use
vga_interface_typelike spapr does?That one's a nasty hack. We basically have 2 different machine types that we expose as a single type to the user: mac99. In reality there's a 64bit mac99 and a 32bit mac99.
32bit mac99 can expose keyboard and mouse via a special apple bus. That driver doesn't work with 64bit Linux guests though, so there we need USB.
Quoted 7 lines
Thinking about it, maybe the best way forward would be to create 2 machine types out of these. Have a mac99 (32bit) and a mac99-g5 target where the g5 target defaults to -cpu G5 and USB enabled.
All of this is pretty frankenstein btw. What we would really want for a G5 guest is something built around U3 or U4, not the U1 that -M mac99 exposes.
Hmm, then I guess let's apply these patches and fix things up later?
Paolo
Re: [Qemu-devel] [PATCH 5/6] hw/ppc/spapr: simplify usb controller creation logic
In reply to Alexander GrafQuoted 3 lines · Alexander Graf
Quoted 1 line
Hmm, then I guess let's apply these patches and fix things up later?
Certainly works for me ;).
Send a pull request then. :)
Paolo
Re: [Qemu-devel] [PATCH 5/6] hw/ppc/spapr: simplify usb controller creation logic
In reply to Paolo BonziniQuoted 12 lines · Paolo Bonzini
hw/ppc/spapr.c static void ppc_spapr_init(MachineState *machine) · line 1488
Quoted 6 lines · Marcel Apfelbaum
hw/ppc/spapr.c +1
-0@@ -1484,9 +1484,10 @@ static void ppc_spapr_init(MachineState *machine)/* Graphics */ if (spapr_vga_init (phb->bus)) { spapr->has_graphics = true; + machine->usb |=defaults_enabled (); }Could the solution be to do this in
instance_init? Then you would have patches 2, 4, 5, 6, 3 (patch 1 would not be needed anymore).
Hi Paolo,
Thanks for the review.
While I agree it will be better if we place this in instance_init, setting the machine_usb to defaults_enabled() there would be problematic since it depends on
- papr_vga_init(phb->bus) for sparpr and
- (PPC_INPUT(env) == PPC_FLAGS_INPUT_970) for mac99.
(The env itself is set in machine_init)
Both of those conditions may be available only at machine_init time, and I am not sure how it would affect those machines.
This is why I prefer it this way,
Thanks,
Marcel
Quoted 3 lines
Paolo
Re: [Qemu-devel] [PATCH 5/6] hw/ppc/spapr: simplify usb controller creation logic
In reply to Alexander GrafQuoted 10 lines · Alexander Graf
Quoted 7 lines · Paolo Bonzini
Quoted 3 lines · Alexander Graf
Quoted 1 line
Hmm, then I guess let's apply these patches and fix things up later?
Certainly works for me ;).
Quoted 8 lines
Quoted 1 line
Send a pull request then. :)
Ok, applied the patch set to ppc-next. Now let's see how much of my autotest setup fell apart over the holidays ;).
Alex
Thanks a lot for taking the time to discuss this!
Marcel
Quoted 11 lines · Marcel Apfelbaum
Patch e79d5a6 ("machine: remove
qemu_machine_optsglobal list") removed option descriptions from the -machine QemuOptsList to avoid repeating MachineState's QOM properties.This resulted in a Qemu crash:
$ qemu-system-x86_64 -usb qemu-system-x86_64: util/qemu-option.c:387: qemu_opt_get_bool_helper: Assertion `opt->desc && opt->desc->type == QEMU_OPT_BOOL' failed. Aborted (core dumped)Based on the comments I will receive, I will continue to fix the options properties in the same way.
So does this mean that we still have other broken options? Do we have a timescale for fixing them? I was hoping to be able to commit a patchset fixing these regressions this week; if we can't do that then we should probably revert the original changes instead :-(
-- PMM
Quoted 4 lines · Peter Maydell
So does this mean that we still have other broken options? Do we have a timescale for fixing them? I was hoping to be able to commit a patchset fixing these regressions this week; if we can't do that then we should probably revert the original changes instead :-(
Based on a grep of machine_opts, the following suboptions are broken:
- mem-merge
- dump-guest-core
- phandle_start
- iommu
- kernel_irqchip
- kvm_shadow_mem
None is really as important as -usb, so I would have no problem with unfreezing the tree, but we definitely should have a timeframe for fixing it.
Paolo