Commit 7d4c3d535c6f33e1d6d158aaf2108a27b45d743d
Committed by
Anthony Liguori
1 parent
74efd61a
Replace -no-virtio-balloon by -balloon
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 <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing
4 changed files
with
44 additions
and
10 deletions
hw/pc.c
| @@ -1408,8 +1408,9 @@ static void pc_init1(ram_addr_t ram_size, | @@ -1408,8 +1408,9 @@ static void pc_init1(ram_addr_t ram_size, | ||
| 1408 | } | 1408 | } |
| 1409 | 1409 | ||
| 1410 | /* Add virtio balloon device */ | 1410 | /* Add virtio balloon device */ |
| 1411 | - if (pci_enabled && !no_virtio_balloon) { | ||
| 1412 | - pci_create_simple(pci_bus, -1, "virtio-balloon-pci"); | 1411 | + if (pci_enabled && virtio_balloon) { |
| 1412 | + pci_dev = pci_create("virtio-balloon-pci", virtio_balloon_devaddr); | ||
| 1413 | + qdev_init(&pci_dev->qdev); | ||
| 1413 | } | 1414 | } |
| 1414 | 1415 | ||
| 1415 | /* Add virtio console devices */ | 1416 | /* Add virtio console devices */ |
qemu-options.hx
| @@ -684,12 +684,17 @@ Disable HPET support. | @@ -684,12 +684,17 @@ Disable HPET support. | ||
| 684 | ETEXI | 684 | ETEXI |
| 685 | 685 | ||
| 686 | #ifdef TARGET_I386 | 686 | #ifdef TARGET_I386 |
| 687 | -DEF("no-virtio-balloon", 0, QEMU_OPTION_no_virtio_balloon, | ||
| 688 | - "-no-virtio-balloon disable virtio balloon device\n") | 687 | +DEF("balloon", HAS_ARG, QEMU_OPTION_balloon, |
| 688 | + "-balloon none disable balloon device\n" | ||
| 689 | + "-balloon virtio[,addr=str]\n" | ||
| 690 | + " enable virtio balloon device (default)\n") | ||
| 689 | #endif | 691 | #endif |
| 690 | STEXI | 692 | STEXI |
| 691 | -@item -no-virtio-balloon | ||
| 692 | -Disable virtio-balloon device. | 693 | +@item -balloon none |
| 694 | +Disable balloon device. | ||
| 695 | +@item -balloon virtio[,addr=@var{addr}] | ||
| 696 | +Enable virtio balloon device (default), optionally with PCI address | ||
| 697 | +@var{addr}. | ||
| 693 | ETEXI | 698 | ETEXI |
| 694 | 699 | ||
| 695 | #ifdef TARGET_I386 | 700 | #ifdef TARGET_I386 |
sysemu.h
| @@ -116,7 +116,8 @@ extern int win2k_install_hack; | @@ -116,7 +116,8 @@ extern int win2k_install_hack; | ||
| 116 | extern int rtc_td_hack; | 116 | extern int rtc_td_hack; |
| 117 | extern int alt_grab; | 117 | extern int alt_grab; |
| 118 | extern int usb_enabled; | 118 | extern int usb_enabled; |
| 119 | -extern int no_virtio_balloon; | 119 | +extern int virtio_balloon; |
| 120 | +extern const char *virtio_balloon_devaddr; | ||
| 120 | extern int smp_cpus; | 121 | extern int smp_cpus; |
| 121 | extern int cursor_hide; | 122 | extern int cursor_hide; |
| 122 | extern int graphic_rotate; | 123 | extern int graphic_rotate; |
vl.c
| @@ -242,7 +242,8 @@ int smp_cpus = 1; | @@ -242,7 +242,8 @@ int smp_cpus = 1; | ||
| 242 | const char *vnc_display; | 242 | const char *vnc_display; |
| 243 | int acpi_enabled = 1; | 243 | int acpi_enabled = 1; |
| 244 | int no_hpet = 0; | 244 | int no_hpet = 0; |
| 245 | -int no_virtio_balloon = 0; | 245 | +int virtio_balloon = 1; |
| 246 | +const char *virtio_balloon_devaddr; | ||
| 246 | int fd_bootchk = 1; | 247 | int fd_bootchk = 1; |
| 247 | int no_reboot = 0; | 248 | int no_reboot = 0; |
| 248 | int no_shutdown = 0; | 249 | int no_shutdown = 0; |
| @@ -4762,6 +4763,29 @@ static void select_vgahw (const char *p) | @@ -4762,6 +4763,29 @@ static void select_vgahw (const char *p) | ||
| 4762 | } | 4763 | } |
| 4763 | } | 4764 | } |
| 4764 | 4765 | ||
| 4766 | +#ifdef TARGET_I386 | ||
| 4767 | +static int balloon_parse(const char *arg) | ||
| 4768 | +{ | ||
| 4769 | + char buf[128]; | ||
| 4770 | + const char *p; | ||
| 4771 | + | ||
| 4772 | + if (!strcmp(arg, "none")) { | ||
| 4773 | + virtio_balloon = 0; | ||
| 4774 | + } else if (!strncmp(arg, "virtio", 6)) { | ||
| 4775 | + virtio_balloon = 1; | ||
| 4776 | + if (arg[6] == ',') { | ||
| 4777 | + p = arg + 7; | ||
| 4778 | + if (get_param_value(buf, sizeof(buf), "addr", p)) { | ||
| 4779 | + virtio_balloon_devaddr = strdup(buf); | ||
| 4780 | + } | ||
| 4781 | + } | ||
| 4782 | + } else { | ||
| 4783 | + return -1; | ||
| 4784 | + } | ||
| 4785 | + return 0; | ||
| 4786 | +} | ||
| 4787 | +#endif | ||
| 4788 | + | ||
| 4765 | #ifdef _WIN32 | 4789 | #ifdef _WIN32 |
| 4766 | static BOOL WINAPI qemu_ctrl_handler(DWORD type) | 4790 | static BOOL WINAPI qemu_ctrl_handler(DWORD type) |
| 4767 | { | 4791 | { |
| @@ -5578,8 +5602,11 @@ int main(int argc, char **argv, char **envp) | @@ -5578,8 +5602,11 @@ int main(int argc, char **argv, char **envp) | ||
| 5578 | case QEMU_OPTION_no_hpet: | 5602 | case QEMU_OPTION_no_hpet: |
| 5579 | no_hpet = 1; | 5603 | no_hpet = 1; |
| 5580 | break; | 5604 | break; |
| 5581 | - case QEMU_OPTION_no_virtio_balloon: | ||
| 5582 | - no_virtio_balloon = 1; | 5605 | + case QEMU_OPTION_balloon: |
| 5606 | + if (balloon_parse(optarg) < 0) { | ||
| 5607 | + fprintf(stderr, "Unknown -balloon argument %s\n", optarg); | ||
| 5608 | + exit(1); | ||
| 5609 | + } | ||
| 5583 | break; | 5610 | break; |
| 5584 | #endif | 5611 | #endif |
| 5585 | case QEMU_OPTION_no_reboot: | 5612 | case QEMU_OPTION_no_reboot: |