From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MKGnl-0003H5-4M for qemu-devel@nongnu.org; Fri, 26 Jun 2009 15:09:33 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MKGng-0003FY-Ge for qemu-devel@nongnu.org; Fri, 26 Jun 2009 15:09:32 -0400 Received: from [199.232.76.173] (port=40600 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MKGng-0003FS-9Y for qemu-devel@nongnu.org; Fri, 26 Jun 2009 15:09:28 -0400 Received: from mx2.redhat.com ([66.187.237.31]:55702) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MKGnf-00049f-O8 for qemu-devel@nongnu.org; Fri, 26 Jun 2009 15:09:28 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n5QJ9Qoh023606 for ; Fri, 26 Jun 2009 15:09:26 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n5QJ9PbD006377 for ; Fri, 26 Jun 2009 15:09:25 -0400 Received: from pike.pond.sub.org (vpn-10-44.str.redhat.com [10.32.10.44]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n5QJ9O4H031888 for ; Fri, 26 Jun 2009 15:09:24 -0400 References: <1244661817-3293-1-git-send-email-ehabkost@redhat.com> <4A300891.4060500@codemonkey.ws> <20090610193408.GE18045@blackpad> <4A30D748.8070507@redhat.com> <4A36138C.4060306@redhat.com> <87vdmx69na.fsf@pike.pond.sub.org> <4A36447B.6030509@codemonkey.ws> <87ab49z7yp.fsf@pike.pond.sub.org> <4A368F6A.3070601@codemonkey.ws> From: Markus Armbruster Date: Fri, 26 Jun 2009 19:15:14 +0200 In-Reply-To: <4A368F6A.3070601@codemonkey.ws> (Anthony Liguori's message of "Mon\, 15 Jun 2009 13\:14\:02 -0500") Message-ID: <87skhmor19.fsf_-_@pike.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: [Qemu-devel] [PATCH] Replace -no-virtio-balloon by -balloon List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org We want to do (at least) two things to the virtio-balloon device: suppress it, and control its PCI address. Option -no-virtio-balloon lets us do only the former. To get the latter, replace -no-virtio-balloon with -balloon none disable balloon device -balloon virtio[,addr=str] enable virtio balloon device (default) Syntax suggested by Anthony Liguori. Signed-off-by: Markus Armbruster --- hw/pc.c | 5 +++-- qemu-options.hx | 13 +++++++++---- sysemu.h | 3 ++- vl.c | 33 ++++++++++++++++++++++++++++++--- 4 files changed, 44 insertions(+), 10 deletions(-) diff --git a/hw/pc.c b/hw/pc.c index 86e5cfe..6a314a7 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -1166,8 +1166,9 @@ static void pc_init1(ram_addr_t ram_size, } /* Add virtio balloon device */ - if (pci_enabled && !no_virtio_balloon) { - pci_create_simple(pci_bus, -1, "virtio-balloon-pci"); + if (pci_enabled && virtio_balloon) { + pci_dev = pci_create("virtio-balloon-pci", virtio_balloon_devaddr); + qdev_init(&pci_dev->qdev); } /* Add virtio console devices */ diff --git a/qemu-options.hx b/qemu-options.hx index 503da33..153ad7c 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -684,12 +684,17 @@ Disable HPET support. ETEXI #ifdef TARGET_I386 -DEF("no-virtio-balloon", 0, QEMU_OPTION_no_virtio_balloon, - "-no-virtio-balloon disable virtio balloon device\n") +DEF("balloon", HAS_ARG, QEMU_OPTION_balloon, + "-balloon none disable balloon device\n" + "-balloon virtio[,addr=str]\n" + " enable virtio balloon device (default)\n") #endif STEXI -@item -no-virtio-balloon -Disable virtio-balloon device. +@item -balloon none +Disable balloon device. +@item -balloon virtio[,addr=@var{addr}] +Enable virtio balloon device (default), optionally with PCI address +@var{addr}. ETEXI #ifdef TARGET_I386 diff --git a/sysemu.h b/sysemu.h index d77de09..f6ab3e8 100644 --- a/sysemu.h +++ b/sysemu.h @@ -116,7 +116,8 @@ extern int win2k_install_hack; extern int rtc_td_hack; extern int alt_grab; extern int usb_enabled; -extern int no_virtio_balloon; +extern int virtio_balloon; +extern const char *virtio_balloon_devaddr; extern int smp_cpus; extern int cursor_hide; extern int graphic_rotate; diff --git a/vl.c b/vl.c index 60a00e1..5b53baa 100644 --- a/vl.c +++ b/vl.c @@ -244,7 +244,8 @@ int smp_cpus = 1; const char *vnc_display; int acpi_enabled = 1; int no_hpet = 0; -int no_virtio_balloon = 0; +int virtio_balloon = 1; +const char *virtio_balloon_devaddr; int fd_bootchk = 1; int no_reboot = 0; int no_shutdown = 0; @@ -4769,6 +4770,29 @@ static void select_vgahw (const char *p) } } +#ifdef TARGET_I386 +static int balloon_parse(const char *arg) +{ + char buf[128]; + const char *p; + + if (!strcmp(arg, "none")) { + virtio_balloon = 0; + } else if (!strncmp(arg, "virtio", 6)) { + virtio_balloon = 1; + if (arg[6] == ',') { + p = arg + 7; + if (get_param_value(buf, sizeof(buf), "addr", p)) { + virtio_balloon_devaddr = strdup(buf); + } + } + } else { + return -1; + } + return 0; +} +#endif + #ifdef _WIN32 static BOOL WINAPI qemu_ctrl_handler(DWORD type) { @@ -5585,8 +5609,11 @@ int main(int argc, char **argv, char **envp) case QEMU_OPTION_no_hpet: no_hpet = 1; break; - case QEMU_OPTION_no_virtio_balloon: - no_virtio_balloon = 1; + case QEMU_OPTION_balloon: + if (balloon_parse(optarg) < 0) { + fprintf(stderr, "Unknown -balloon argument %s\n", optarg); + exit(1); + } break; #endif case QEMU_OPTION_no_reboot: -- 1.6.2.5