Commit 382f0743 authored by Gerd Hoffmann's avatar Gerd Hoffmann Committed by Anthony Liguori
Browse files

switch balloon initialization to -device.



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: default avatarGerd Hoffmann <kraxel@redhat.com>
Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
parent 59f2a787
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -1123,7 +1123,6 @@ static void pc_init1(ram_addr_t ram_size,
    ram_addr_t below_4g_mem_size, above_4g_mem_size = 0;
    int bios_size, isa_bios_size, oprom_area_size;
    PCIBus *pci_bus;
    PCIDevice *pci_dev;
    ISADevice *isa_dev;
    int piix3_devfn = -1;
    CPUState *env;
@@ -1423,12 +1422,6 @@ static void pc_init1(ram_addr_t ram_size,
        }
    }

    /* Add virtio balloon device */
    if (pci_enabled && virtio_balloon) {
        pci_dev = pci_create("virtio-balloon-pci", virtio_balloon_devaddr);
        qdev_init(&pci_dev->qdev);
    }

    /* Add virtio console devices */
    if (pci_enabled) {
        for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) {
+0 −2
Original line number Diff line number Diff line
@@ -125,8 +125,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 max_cpus;
extern int cursor_hide;
+18 −16
Original line number Diff line number Diff line
@@ -222,8 +222,6 @@ int smp_threads = 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;
@@ -4586,24 +4584,28 @@ static void select_vgahw (const char *p)
#ifdef TARGET_I386
static int balloon_parse(const char *arg)
{
    char buf[128];
    const char *p;
    QemuOpts *opts;

    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);
            }
    if (strcmp(arg, "none") == 0) {
        return 0;
    }
    } else {

    if (!strncmp(arg, "virtio", 6)) {
        if (arg[6] == ',') {
            /* have params -> parse them */
            opts = qemu_opts_parse(&qemu_device_opts, arg+7, NULL);
            if (!opts)
                return  -1;
        } else {
            /* create empty opts */
            opts = qemu_opts_create(&qemu_device_opts, NULL, 0);
        }
        qemu_opt_set(opts, "driver", "virtio-balloon-pci");
        return 0;
    }

    return -1;
}
#endif

#ifdef _WIN32