Received: from eggs.gnu.org ([208.118.235.92]:49993) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Snszn-0006pa-Uk for qemu-devel@nongnu.org; Sun, 08 Jul 2012 11:02:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Snszm-0002jF-1d for qemu-devel@nongnu.org; Sun, 08 Jul 2012 11:01:59 -0400 References: <8035D2DA-91B8-4F15-890A-EAC2113847BF@suse.de> <4FF70B30.2090902@suse.de> In-Reply-To: Mime-Version: 1.0 (1.0) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Message-Id: <6813EC7E-3A23-4F6A-9C3F-C1CDFCDA8334@suse.de> From: Alexander Graf Date: Sun, 8 Jul 2012 17:02:29 +0200 Subject: Re: [Qemu-devel] [Qemu-ppc][PATCH v5 1/4] Add usb option in machine options List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Li Zhang Cc: "benh@au1.ibm.com" , "shangw@linux.vnet.ibm.com" , "qemu-devel@nongnu.org" , Li Zhang , "qemu-ppc@nongnu.org" , =?utf-8?Q?Andreas_F=C3=A4rber?= On 08.07.2012, at 16:46, Li Zhang wrote: > On Sat, Jul 7, 2012 at 12:03 AM, Alexander Graf wrote: >>=20 >> On 06.07.2012, at 17:58, Andreas F=C3=A4rber wrote: >>=20 >>> Am 06.07.2012 15:43, schrieb Alexander Graf: >>>>=20 >>>> On 02.07.2012, at 07:25, zhlcindy@gmail.com wrote: >>>>=20 >>>>> From: Li Zhang >>>>>=20 >>>>> pSeries machine needs to enable USB to add a USB >>>>> keyboard or USB mouse. -usb option won't be used in >>>>> the future, and machine options are a better way to >>>>> enable USB. >>>>>=20 >>>>> So this patch is to add USB option to machine options >>>>> (-machine type=3Dpseries,usb=3Don/off) to enable/disable >>>>> USB controller. And machines will get the machine option >>>>> and create a USB controller if USB is on. >>>>>=20 >>>>> By the way, USB is on by default on pSeries machine. >>>>> So USB controller should be turned off explicitly through >>>>> the command line for "-nodefault" case as the following: >>>>> -machine type=3Dpseries,usb=3Doff. >>>>>=20 >>>>> Signed-off-by: Li Zhang >>>>> Reviewed-by: Andreas F=C3=A4rber >>>>> --- >>>>> hw/spapr.c | 11 +++++++++++ >>>>> qemu-config.c | 4 ++++ >>>>> 2 files changed, 15 insertions(+) >>>>>=20 >>>>> diff --git a/hw/spapr.c b/hw/spapr.c >>>>> index 81c9343..973de1b 100644 >>>>> --- a/hw/spapr.c >>>>> +++ b/hw/spapr.c >>> [...] >>>>> @@ -710,6 +712,15 @@ static void ppc_spapr_init(ram_addr_t ram_size, >>>>> spapr_vscsi_create(spapr->vio_bus); >>>>> } >>>>>=20 >>>>> + machine_opts =3D qemu_opts_find(qemu_find_opts("machine"), 0); >>>>> + if (machine_opts) { >>>>> + add_usb =3D qemu_opt_get_bool(machine_opts, "usb", true); >>>>> + } >>>>> + >>>>> + if (add_usb) { >>>>> + pci_create_simple(QLIST_FIRST(&spapr->phbs)->host_state.bus, >>>>> + -1, "pci-ohci"); >>>>> + } >>>>=20 >>>> Didn't I ask you to extract this out to generic code? I don't want to h= ave a "usb" machine opt that is only available for -M pseries. >>>=20 >>> Isn't the mapping from "usb=3Don" to device-level actions >>> machine-specific? We have ohci, uhci, ehci, xhci to choose from. And the= >>> bus to place it on is machine-specific, too. >>>=20 >>> So did you rather mean adding usb=3D awareness to more machines? If we >>> generalize usb=3Don to usb=3Dnone/ohci/... plus some usbbus=3D we get -d= evice. >>=20 >> I was thinking of replacing usb_enabled with >>=20 >> static inline int usb_enabled(bool default) { >> machine_opts =3D qemu_opts_find(qemu_find_opts("machine"), 0); >> if (machine_opts) { >> return qemu_opt_get_bool(machine_opts, "usb", default); >> } >> return default; >> } >>=20 >> Whereas -usb in vl.c would set machine.usb =3D on. Then all users of usb_= enabled would automatically be converted to the new syntax and we could even= use the same logic in spapr.c. >>=20 >=20 > I see, you mean global varible usb_enabled is still used, and when > -usb is passed to qemu command line, > use_enabled will be assigned by the above function and set machine.usb=3Do= n. >=20 > So all the places where usb_enabled is used still can work correctly. I mean convert usb_enabled into a function that checks machine.usb :). The o= nly global state should live in machine opts. Alex