Received: from eggs.gnu.org ([208.118.235.92]:33737) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SgWPa-0007lb-Ip for qemu-devel@nongnu.org; Mon, 18 Jun 2012 03:30:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SgWPU-0007U9-3H for qemu-devel@nongnu.org; Mon, 18 Jun 2012 03:30:10 -0400 From: Markus Armbruster References: <1339754783-14341-1-git-send-email-zhlcindy@linux.vnet.ibm.com> Date: Mon, 18 Jun 2012 09:29:51 +0200 In-Reply-To: (Li Zhang's message of "Mon, 18 Jun 2012 10:17:33 +0800") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCHv2 1/1] Add usb option in machine options to enable/disable usb List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Li Zhang Cc: aliguori@us.ibm.com, benh@au1.ibm.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, Li Zhang Li Zhang writes: > On Fri, Jun 15, 2012 at 10:34 PM, Markus Armbruster w= rote: >> Li Zhang writes: >> >>> On Fri, Jun 15, 2012 at 8:04 PM, Markus Armbruster = wrote: >>>> Li Zhang writes: >>>> >>>>> For pseries machine, it needs to enable usb to add >>>>> keyboard or usb mouse. -usb option won't be used in >>>>> the future, and machine options is a better way to >>>>> enable usb. >>>>> >>>>> So this patch is to add usb option to machine options >>>>> (-machine type=3Dpsereis,usb=3Don/off)to enable/disable >>>>> usb controller. >>>>> >>>>> In this patch, usb_on is an global option which can >>>>> be checked by machines. >>>>> For example, on pseries, it will check if usb_on is 1, >>>>> if it is 1, it will create one usb ohci controller. >>>>> As the following: >>>>> if (usb_on =3D=3D 1) { >>>>> =C2=A0 =C2=A0 =C2=A0pci_create_simple(bus, -1, "pci-ohci"); >>>>> } >>>>> >>>>> In this patch, usb is on by default. So, for -nodefault, >>>>> usb should be set off in the command line as the following: >>>>> =C2=A0-machine type=3Dpseries,usb=3Doff. >>>>> >>>>> Signed-off-by: Li Zhang >>>>> >>>>> --- >>>>> =C2=A0hw/spapr.c | =C2=A0 =C2=A05 +++++ >>>>> =C2=A0sysemu.h =C2=A0 | =C2=A0 =C2=A01 + >>>>> =C2=A0vl.c =C2=A0 =C2=A0 =C2=A0 | =C2=A0 17 +++++++++++++++++ >>>>> =C2=A03 files changed, 23 insertions(+) >>>>> >>>>> diff --git a/hw/spapr.c b/hw/spapr.c >>>>> index d0bddbc..1feb739 100644 >>>>> --- a/hw/spapr.c >>>>> +++ b/hw/spapr.c >>>>> @@ -661,6 +661,11 @@ static void ppc_spapr_init(ram_addr_t ram_size, >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0spapr_vscsi_create(spapr->vio_bus); >>>>> =C2=A0 =C2=A0 =C2=A0} >>>>> >>>>> + =C2=A0 =C2=A0if (usb_on =3D=3D 1) { >>>>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0pci_create_simple(QLIST_FIRST(&spapr->ph= bs)->host_state.bus, >>>>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0-1, "pci-ohci"); >>>>> + =C2=A0 =C2=A0} >>>>> + >>>>> =C2=A0 =C2=A0 =C2=A0if (rma_size < (MIN_RMA_SLOF << 20)) { >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fprintf(stderr, "qemu: pSeries SLOF= firmware requires >=3D " >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"%ldM g= uest RMA (Real Mode Area memory)\n", MIN_RMA_SLOF); >>>>> diff --git a/sysemu.h b/sysemu.h >>>>> index bc2c788..08134ae 100644 >>>>> --- a/sysemu.h >>>>> +++ b/sysemu.h >>>>> @@ -109,6 +109,7 @@ extern int vga_interface_type; >>>>> =C2=A0#define vmsvga_enabled (vga_interface_type =3D=3D VGA_VMWARE) >>>>> =C2=A0#define qxl_enabled (vga_interface_type =3D=3D VGA_QXL) >>>>> >>>>> +extern int usb_on; >>>>> =C2=A0extern int graphic_width; >>>>> =C2=A0extern int graphic_height; >>>>> =C2=A0extern int graphic_depth; >>>>> diff --git a/vl.c b/vl.c >>>>> index 204d85b..b200203 100644 >>>>> --- a/vl.c >>>>> +++ b/vl.c >>>>> @@ -202,6 +202,7 @@ int smp_cpus =3D 1; >>>>> =C2=A0int max_cpus =3D 0; >>>>> =C2=A0int smp_cores =3D 1; >>>>> =C2=A0int smp_threads =3D 1; >>>>> +int usb_on =3D 0; >>>>> =C2=A0#ifdef CONFIG_VNC >>>>> =C2=A0const char *vnc_display; >>>>> =C2=A0#endif >>>>> @@ -758,6 +759,21 @@ static int bt_parse(const char *opt) >>>>> =C2=A0 =C2=A0 =C2=A0return 1; >>>>> =C2=A0} >>>>> >>>>> +static int get_usb_opt(QemuOpts *opts) >>>>> +{ >>>>> + =C2=A0 =C2=A0const char *usb_opt =3D NULL; >>>> >>>> Useless initializer. >>> Thanks. I will remove it. >>>> >>>>> + =C2=A0 =C2=A0int usb_on =3D 0; >>>>> + >>>>> + =C2=A0 =C2=A0if (NULL =3D=3D qemu_opt_get(opts, "usb")) >>>>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0qemu_opt_set(opts, "usb", "on"); >>>> >>>> Why are you changing opts? >>> USB is enabled by default when there is no usb option setting. >>> For example, >>> using =C2=A0# qemu-system-ppc64 -machine type=3Dpseries >>> There is no usb option, but usb is set on. >> >> Isn't it off by default for at least some machines now? >> > OK. This default setting is decided by the machine. > In the new version, I put this setting in machine. > It can be set off or on. > For psereis it sets on. Makes sense. Perhaps we really have three kinds of machines, not just two: 1. Must have USB: main() sets usb_enabled to true. 2. May have USB: usb_enabled =3D -usb or -usbdevice given 3. Can't have USB: fail if the user tries to enable it. Code sketch: /* init USB devices */ if (!machine->has_usb) { if (usb_enabled) [report error; should point to the offending options] exit(1); } } else { if (machine->has_usb > 0) { usb_enabled =3D 1; } if (usb_enabled) { if (foreach_device_config(DEV_USB, usb_parse) < 0) exit(1); } } >> Anyway, I don't see why we need to update opts. =C2=A0Who's using the up= dated >> opts? >> > psereis will use this opts. > usb kbd and mouse will be needed with vga enabled. Do they use the updated QemuOpts *opts? I'd expect them to use usb_on, or whatever flag variable governs USB (now: usb_enabled). [...]