From: Markus Armbruster <armbru@redhat.com>
To: Li Zhang <zhlcindy@gmail.com>
Cc: aliguori@us.ibm.com, benh@au1.ibm.com, qemu-ppc@nongnu.org,
qemu-devel@nongnu.org, Li Zhang <zhlcindy@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCHv2 1/1] Add usb option in machine options to enable/disable usb
Date: Fri, 15 Jun 2012 16:34:01 +0200 [thread overview]
Message-ID: <m3d350abl2.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <CAD8of+q3CNHxxE00dd2ALb8wb_RsTF5VJM=DsU0vB8og=xu6zg@mail.gmail.com> (Li Zhang's message of "Fri, 15 Jun 2012 21:08:56 +0800")
Li Zhang <zhlcindy@gmail.com> writes:
> On Fri, Jun 15, 2012 at 8:04 PM, Markus Armbruster <armbru@redhat.com> wrote:
>> Li Zhang <zhlcindy@linux.vnet.ibm.com> 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=psereis,usb=on/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 == 1) {
>>> pci_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:
>>> -machine type=pseries,usb=off.
>>>
>>> Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
>>>
>>> ---
>>> hw/spapr.c | 5 +++++
>>> sysemu.h | 1 +
>>> vl.c | 17 +++++++++++++++++
>>> 3 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,
>>> spapr_vscsi_create(spapr->vio_bus);
>>> }
>>>
>>> + if (usb_on == 1) {
>>> + pci_create_simple(QLIST_FIRST(&spapr->phbs)->host_state.bus,
>>> + -1, "pci-ohci");
>>> + }
>>> +
>>> if (rma_size < (MIN_RMA_SLOF << 20)) {
>>> fprintf(stderr, "qemu: pSeries SLOF firmware requires >= "
>>> "%ldM guest 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;
>>> #define vmsvga_enabled (vga_interface_type == VGA_VMWARE)
>>> #define qxl_enabled (vga_interface_type == VGA_QXL)
>>>
>>> +extern int usb_on;
>>> extern int graphic_width;
>>> extern int graphic_height;
>>> extern 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 = 1;
>>> int max_cpus = 0;
>>> int smp_cores = 1;
>>> int smp_threads = 1;
>>> +int usb_on = 0;
>>> #ifdef CONFIG_VNC
>>> const char *vnc_display;
>>> #endif
>>> @@ -758,6 +759,21 @@ static int bt_parse(const char *opt)
>>> return 1;
>>> }
>>>
>>> +static int get_usb_opt(QemuOpts *opts)
>>> +{
>>> + const char *usb_opt = NULL;
>>
>> Useless initializer.
> Thanks. I will remove it.
>>
>>> + int usb_on = 0;
>>> +
>>> + if (NULL == qemu_opt_get(opts, "usb"))
>>> + qemu_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 # qemu-system-ppc64 -machine type=pseries
> There is no usb option, but usb is set on.
Isn't it off by default for at least some machines now?
Anyway, I don't see why we need to update opts. Who's using the updated
opts?
>>> +
>>> + usb_opt = qemu_opt_get(opts, "usb");
>>> + if (usb_opt && strcmp(usb_opt, "on") == 0)
>>
>> Please don't duplicate parsing of bools; use qemu_opt_get_bool().
> OK.
>>
>>> + usb_on = 1;
>>> +
>>> + return usb_on;
>>> +}
>>> +
>>> /***********************************************************/
>>> /* QEMU Block devices */
>>>
>>> @@ -3356,6 +3372,7 @@ int main(int argc, char **argv, char **envp)
>>> kernel_filename = qemu_opt_get(machine_opts, "kernel");
>>> initrd_filename = qemu_opt_get(machine_opts, "initrd");
>>> kernel_cmdline = qemu_opt_get(machine_opts, "append");
>>> + usb_on = get_usb_opt(machine_opts);
>>
>> Anything wrong with
>>
>> usb_on = qemu_opt_get_bool(machine_opts, "usb", 0);
>>
>> ?
>>
>>> } else {
>>> kernel_filename = initrd_filename = kernel_cmdline = NULL;
>>> }
>>
>> Your new global usb_on is still unused, and it's not integrated with
>> -usb. I doubt it can be merged that way.
>>
> It is used in spapr.c. In the front of this patch, it is used.
> It seems that this is not good.
> Maybe it is better to move the options setting to spapr.c.
Dang, I missed that. Sorry for the noise.
next prev parent reply other threads:[~2012-06-15 18:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-15 10:06 [Qemu-devel] [PATCHv2 1/1] Add usb option in machine options to enable/disable usb Li Zhang
2012-06-15 12:04 ` Markus Armbruster
2012-06-15 13:08 ` Li Zhang
2012-06-15 14:34 ` Markus Armbruster [this message]
2012-06-18 2:17 ` Li Zhang
2012-06-18 7:29 ` Markus Armbruster
2012-06-18 7:54 ` Peter Crosthwaite
2012-06-18 8:24 ` Li Zhang
2012-06-18 9:22 ` [Qemu-devel] [PATCH 1/2] " Li Zhang
2012-06-18 9:26 ` 陳韋任 (Wei-Ren Chen)
2012-06-18 8:10 ` [Qemu-devel] [PATCHv2 1/1] " Li Zhang
2012-06-15 12:30 ` Andreas Färber
2012-06-15 13:11 ` Li Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3d350abl2.fsf@blackfin.pond.sub.org \
--to=armbru@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=benh@au1.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=zhlcindy@gmail.com \
--cc=zhlcindy@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.