hw/ppc: modified the condition for usb controllers to be created for some ppc machines
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 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.
Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
			
			
This commit is contained in:
		
							parent
							
								
									2f285bdd54
								
							
						
					
					
						commit
						c760dbb9dc
					
				| 
						 | 
				
			
			@ -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 */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1530,7 +1530,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");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										7
									
								
								vl.c
								
								
								
								
							
							
						
						
									
										7
									
								
								vl.c
								
								
								
								
							| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue