From patchwork Thu Jun 14 05:17:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhang X-Patchwork-Id: 164817 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6A567B7046 for ; Thu, 14 Jun 2012 15:17:50 +1000 (EST) Received: from localhost ([::1]:36502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sf2RI-0001Hs-7y for incoming@patchwork.ozlabs.org; Thu, 14 Jun 2012 01:17:48 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57565) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sf2RB-0001Hn-6O for qemu-devel@nongnu.org; Thu, 14 Jun 2012 01:17:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sf2R8-0002O7-Dn for qemu-devel@nongnu.org; Thu, 14 Jun 2012 01:17:40 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:60217) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sf2R8-0002NX-7I for qemu-devel@nongnu.org; Thu, 14 Jun 2012 01:17:38 -0400 Received: from /spool/local by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 13 Jun 2012 23:17:33 -0600 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 13 Jun 2012 23:17:31 -0600 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id D27771FF001F for ; Thu, 14 Jun 2012 05:17:28 +0000 (WET) Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q5E5HSP9140162 for ; Wed, 13 Jun 2012 23:17:28 -0600 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q5E5HS2N007253 for ; Wed, 13 Jun 2012 23:17:28 -0600 Received: from zhlbj-host (zhlbj-host.cn.ibm.com [9.115.122.77]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q5E5HRZp007180; Wed, 13 Jun 2012 23:17:28 -0600 Received: by zhlbj-host (Postfix, from userid 1000) id 8905E3C03BD; Thu, 14 Jun 2012 13:17:25 +0800 (CST) From: zhlcindy@gmail.com To: qemu-devel@nongnu.org Date: Thu, 14 Jun 2012 13:17:19 +0800 Message-Id: <1339651039-15290-1-git-send-email-zhlcindy@gmail.com> X-Mailer: git-send-email 1.7.9.5 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12061405-1780-0000-0000-0000066C929D X-IBM-ISS-SpamDetectors: X-IBM-ISS-DetailInfo: BY=3.00000281; HX=3.00000190; KW=3.00000007; PH=3.00000001; SC=3.00000002; SDB=6.00147883; UDB=6.00033735; UTC=2012-06-14 05:17:32 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 32.97.110.152 Cc: aliguori@us.ibm.com, benh@au1.ibm.com, zhlcindy@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 1/1] Add usb option in machine options. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Li Zhang For pseries machine, it needs to enable usb to add kbd 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_opt is an global option which can be checked by machines. For example, on pseries, it will check if usb_opt is on, if it is on, it will create one usb ohci controller. As the following: if (usb_opts && strcmp(usb_opts, "on") == 0) 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 reviewed-by: Anthony Liguori reviewed-by: Benjamin Herrenschmidt reviewed-by: lines ! You put them in if and only if you've had them --- qemu-config.c | 4 ++++ sysemu.h | 1 + vl.c | 12 ++++++++++++ 3 files changed, 17 insertions(+) diff --git a/qemu-config.c b/qemu-config.c index bb3bff4..258712a 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -583,6 +583,10 @@ static QemuOptsList qemu_machine_opts = { .name = "dtb", .type = QEMU_OPT_STRING, .help = "Linux kernel device tree file", + }, { + .name = "usb", + .type = QEMU_OPT_BOOL, + .help = "Set on/off to enable/disable usb", }, { /* End of list */ } }, diff --git a/sysemu.h b/sysemu.h index bc2c788..c5ea10d 100644 --- a/sysemu.h +++ b/sysemu.h @@ -13,6 +13,7 @@ /* vl.c */ extern const char *bios_name; +extern const char *usb_opt; extern const char *qemu_name; extern uint8_t qemu_uuid[]; diff --git a/vl.c b/vl.c index 204d85b..10f8e4c 100644 --- a/vl.c +++ b/vl.c @@ -171,6 +171,7 @@ int main(int argc, char **argv) static const char *data_dir; const char *bios_name = NULL; +const char *usb_opt = NULL; enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB; DisplayType display_type = DT_DEFAULT; int display_remote = 0; @@ -758,6 +759,15 @@ static int bt_parse(const char *opt) return 1; } +static int default_enable_usb(QemuOpts *opts) +{ + if (NULL == qemu_opt_get(opts, "usb")) { + qemu_opt_set(opts, "usb", "on"); + } + + return 0; +} + /***********************************************************/ /* QEMU Block devices */ @@ -3356,6 +3366,8 @@ 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"); + default_enable_usb(machine_opts); + usb_opt = qemu_opt_get(machine_opts, "usb"); } else { kernel_filename = initrd_filename = kernel_cmdline = NULL; }