From patchwork Fri Jun 15 10:06:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhang X-Patchwork-Id: 165077 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 D0079B707D for ; Fri, 15 Jun 2012 20:07:01 +1000 (EST) Received: from localhost ([::1]:47882 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfTQh-0003N1-L8 for incoming@patchwork.ozlabs.org; Fri, 15 Jun 2012 06:06:59 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57300) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfTQU-0003Kd-BP for qemu-devel@nongnu.org; Fri, 15 Jun 2012 06:06:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SfTQO-0004tC-01 for qemu-devel@nongnu.org; Fri, 15 Jun 2012 06:06:45 -0400 Received: from e33.co.us.ibm.com ([32.97.110.151]:43583) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfTQN-0004s4-Pk for qemu-devel@nongnu.org; Fri, 15 Jun 2012 06:06:39 -0400 Received: from /spool/local by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 15 Jun 2012 04:06:33 -0600 Received: from d01dlp03.pok.ibm.com (9.56.224.17) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 15 Jun 2012 04:06:31 -0600 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id 2D82AC9005C; Fri, 15 Jun 2012 06:06:29 -0400 (EDT) Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q5FA6Tau167098; Fri, 15 Jun 2012 06:06:30 -0400 Received: from d03av05.boulder.ibm.com (loopback [127.0.0.1]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q5FA6SAc002421; Fri, 15 Jun 2012 04:06:29 -0600 Received: from zhlbj-host (zhlbj-host.cn.ibm.com [9.115.122.49] (may be forged)) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q5FA6STc002304; Fri, 15 Jun 2012 04:06:28 -0600 Received: by zhlbj-host (Postfix, from userid 1000) id 5B3983C055E; Fri, 15 Jun 2012 18:06:25 +0800 (CST) From: Li Zhang To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Date: Fri, 15 Jun 2012 18:06:23 +0800 Message-Id: <1339754783-14341-1-git-send-email-zhlcindy@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12061510-2398-0000-0000-00000785940F X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 32.97.110.151 Cc: aliguori@us.ibm.com, benh@au1.ibm.com, Li Zhang Subject: [Qemu-devel] [PATCHv2 1/1] Add usb option in machine options to enable/disable usb 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 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 --- 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; + int usb_on = 0; + + if (NULL == qemu_opt_get(opts, "usb")) + qemu_opt_set(opts, "usb", "on"); + + usb_opt = qemu_opt_get(opts, "usb"); + if (usb_opt && strcmp(usb_opt, "on") == 0) + 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); } else { kernel_filename = initrd_filename = kernel_cmdline = NULL; }