qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 11/13] switch balloon initialization to -device.
Date: Fri,  3 Jul 2009 12:22:56 +0200	[thread overview]
Message-ID: <1246616578-6560-12-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1246616578-6560-1-git-send-email-kraxel@redhat.com>

With that patch applied "-balloon virtio,args" becomes a shortcut for
"-device virtio-balloon-pci,args".

Side effects:
 - ballon device gains support for id=<tag>.
 - ballon device is off by default now.
 - initialization order changes, which may in different pci slot
   assignment depending on the VM configuration.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/pc.c  |    6 -----
 sysemu.h |    2 -
 vl.c     |   65 +++++++++++++++++++++++++++++++++++++------------------------
 3 files changed, 39 insertions(+), 34 deletions(-)

diff --git a/hw/pc.c b/hw/pc.c
index 2b89356..ccd2fed 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1407,12 +1407,6 @@ static void pc_init1(ram_addr_t ram_size,
         }
     }
 
-    /* Add virtio balloon device */
-    if (pci_enabled && virtio_balloon) {
-        qdev = pci_create("virtio-balloon-pci", virtio_balloon_devaddr);
-        qdev_init(qdev);
-    }
-
     /* Add virtio console devices */
     if (pci_enabled) {
         for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) {
diff --git a/sysemu.h b/sysemu.h
index 06dc4c6..9a83bfe 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -116,8 +116,6 @@ extern int win2k_install_hack;
 extern int rtc_td_hack;
 extern int alt_grab;
 extern int usb_enabled;
-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 ca82f80..b455cfc 100644
--- a/vl.c
+++ b/vl.c
@@ -236,8 +236,6 @@ int smp_cpus = 1;
 const char *vnc_display;
 int acpi_enabled = 1;
 int no_hpet = 0;
-int virtio_balloon = 1;
-const char *virtio_balloon_devaddr;
 int fd_bootchk = 1;
 int no_reboot = 0;
 int no_shutdown = 0;
@@ -4762,29 +4760,6 @@ 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)
 {
@@ -4990,6 +4965,24 @@ static void add_device_config(int type, const char *cmdline)
     TAILQ_INSERT_TAIL(&device_configs, conf, next);
 }
 
+#ifdef TARGET_I386
+static void add_device_config_params(int type, const char *driver,
+                                     const char *params)
+{
+    char *buf;
+    size_t len,pos;
+
+    len = strlen(driver) + 1;
+    if (params)
+        len += strlen(params) + 1;
+    buf = qemu_mallocz(len);
+    pos = snprintf(buf, len, "%s", driver);
+    if (params)
+        pos += snprintf(buf+pos, len-pos, ",%s", params);
+    add_device_config(type, buf);
+}
+#endif
+
 static int foreach_device_config(int type, int (*func)(const char *cmdline))
 {
     struct device_config *conf;
@@ -5015,6 +5008,26 @@ static int generic_parse(const char *cmdline)
     return 0;
 }
 
+#ifdef TARGET_I386
+static int add_device_balloon(const char *arg)
+{
+    const char *name = NULL, *params = NULL;
+
+    if (!strcmp(arg, "none"))
+        return 0;
+    if (!strncmp(arg, "virtio", 6)) {
+        name = "virtio-balloon-pci";
+        if (arg[6] == ',')
+            params = arg+7;
+    }
+    if (!name)
+        return -1;
+
+    add_device_config_params(DEV_GENERIC, name, params);
+    return 0;
+}
+#endif
+
 int main(int argc, char **argv, char **envp)
 {
     const char *gdbstub_dev = NULL;
@@ -5635,7 +5648,7 @@ int main(int argc, char **argv, char **envp)
                 no_hpet = 1;
                 break;
             case QEMU_OPTION_balloon:
-                if (balloon_parse(optarg) < 0) {
+                if (add_device_balloon(optarg) < 0) {
                     fprintf(stderr, "Unknown -balloon argument %s\n", optarg);
                     exit(1);
                 }
-- 
1.6.2.5

  parent reply	other threads:[~2009-07-03 10:23 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-03 10:22 [Qemu-devel] [PATCH 0/13] qdev patches: properties, -device switch, id=<tag> & more Gerd Hoffmann
2009-07-03 10:22 ` [Qemu-devel] [PATCH 01/13] qdev: rework device properties Gerd Hoffmann
2009-07-03 10:22 ` [Qemu-devel] [PATCH 02/13] qdev: factor out driver search to qdev_find_info() Gerd Hoffmann
2009-07-03 10:22 ` [Qemu-devel] [PATCH 03/13] qdev/pci: make pci_create return DeviceState instead of PCIDevice Gerd Hoffmann
2009-07-03 10:22 ` [Qemu-devel] [PATCH 04/13] qdev: add generic qdev_device_add() Gerd Hoffmann
2009-07-03 10:22 ` [Qemu-devel] [PATCH 05/13] qdev: add -device command line option Gerd Hoffmann
2009-07-07 15:38   ` Gerd Hoffmann
2009-07-03 10:22 ` [Qemu-devel] [PATCH 06/13] qdev: add no_user, alias and desc Gerd Hoffmann
2009-07-03 10:22 ` [Qemu-devel] [PATCH 07/13] qdev: es1370 description Gerd Hoffmann
2009-07-03 10:22 ` [Qemu-devel] [PATCH 08/13] qdev: convert all vga Gerd Hoffmann
2009-07-03 10:22 ` [Qemu-devel] [PATCH 09/13] qdev/pci: hook up i440fx Gerd Hoffmann
2009-07-03 10:22 ` [Qemu-devel] [PATCH 10/13] qdev: add user-specified identifier to devices Gerd Hoffmann
2009-07-03 10:22 ` Gerd Hoffmann [this message]
2009-07-03 10:22 ` [Qemu-devel] [PATCH 12/13] qdev: add id= support for pci nics Gerd Hoffmann
2009-07-03 10:22 ` [Qemu-devel] [PATCH 13/13] qdev: print device id in "info pci" Gerd Hoffmann
  -- strict thread matches above, loose matches on Subject: below --
2009-07-10 11:26 [Qemu-devel] [PATCH v2 0/13] qdev patches: properties, -device switch, id=<tag> & more Gerd Hoffmann
2009-07-10 11:26 ` [Qemu-devel] [PATCH 11/13] switch balloon initialization to -device Gerd Hoffmann

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=1246616578-6560-12-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).