qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] vl: add -libvirt-caps option for libvirt to stop pa


From: Anthony Liguori
Subject: [Qemu-devel] [PATCH] vl: add -libvirt-caps option for libvirt to stop parsing help output
Date: Wed, 25 Jul 2012 14:47:57 -0500

The help output is going to change dramatically for 0.13.  We've spent too long
waiting for a perfect solution to capabilities handling and the end loser is
the direct consumer of QEMU because the help output is awful.

I will not apply any patches that change help output until 0.13 development
opens up.  This should give libvirt adequate time to implement support for
dealing with this new option.

This capabilities set comes directly from libvirt's source code so it's entirely
adequate for libvirt's purposes.  We can still explore more sophisticated
approaches that are more general purpose but the help output will be changing.

Signed-off-by: Anthony Liguori <address@hidden>
---
 Makefile.objs   |    2 +
 libvirt-caps.c  |  166 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 libvirt-caps.h  |   19 ++++++
 qemu-options.hx |    4 +
 vl.c            |    5 ++
 5 files changed, 196 insertions(+), 0 deletions(-)
 create mode 100644 libvirt-caps.c
 create mode 100644 libvirt-caps.h

diff --git a/Makefile.objs b/Makefile.objs
index 5ebbcfa..0495a88 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -95,6 +95,8 @@ common-obj-y += qemu-timer.o qemu-timer-common.o
 
 common-obj-$(CONFIG_SLIRP) += slirp/
 
+common-obj-y += libvirt-caps.o
+
 ######################################################################
 # libuser
 
diff --git a/libvirt-caps.c b/libvirt-caps.c
new file mode 100644
index 0000000..6d2b74d
--- /dev/null
+++ b/libvirt-caps.c
@@ -0,0 +1,166 @@
+/*
+ * Libvirt capabilities
+ *
+ * Copyright IBM, Corp. 2012
+ *
+ * Authors:
+ *  Anthony Liguori   <address@hidden>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#include "libvirt-caps.h"
+#include "qemu-common.h"
+
+/* Make sure this stays in sync with libvirt/src/qemu/qemu_capabilities.c */
+
+static const char *supported_caps[] = {
+//    "kqemu",
+    "vnc-colon",
+    "no-reboot",
+    "drive",
+    "drive-boot",
+
+    "name",
+    "uuid",
+    "domid",
+    "vnet-hdr",
+//    "migrate-kvm-stdio",
+
+    "migrate-qemu-tcp",
+    "migrate-qemu-exec",
+    "drive-cache-v2",
+    "kvm",
+    "drive-format",
+
+    "vga",
+    "0.10",
+    "pci-device",
+    "mem-path",
+    "drive-serial",
+
+#if defined(CONFIG_XEN)
+    "xen-domid",
+#endif
+    "migrate-qemu-unix",
+    "chardev",
+    "enable-kvm",
+    "monitor-json",
+
+    "balloon",
+    "device",
+    "sdl",
+    "smp-topology",
+    "netdev",
+
+    "rtc",
+    "vhost-net",
+    "rtc-td-hack",
+    "no-hpet",
+//    "no-kvm-pit",
+
+//    "tdf",
+//    "pci-configfd",
+    "nodefconfig",
+    "boot-menu",
+//    "enable-kqemu",
+
+    "fsdev",
+    "nesting",
+    "name-process",
+    "drive-readonly",
+    "smbios-type",
+
+    "vga-qxl",
+    "spice",
+    "vga-none",
+    "migrate-qemu-fd",
+    "boot-index",
+
+    "hda-duplex",
+    "drive-aio",
+    "pci-multibus",
+    "pci-bootindex",
+    "ccid-emulated",
+
+    "ccid-passthru",
+#if defined(CONFIG_SPICE)
+    "chardev-spicevmc",
+    "device-spicevmc",
+#endif
+    "virtio-tx-alg",
+#if defined(CONFIG_SPICE)
+    "device-qxl-vga",
+#endif
+
+    "pci-multifunction",
+    "virtio-blk-pci.ioeventfd",
+    "sga",
+    "virtio-blk-pci.event_idx",
+    "virtio-net-pci.event_idx",
+
+    "cache-directsync",
+    "piix3-usb-uhci",
+    "piix4-usb-uhci",
+    "usb-ehci",
+    "ich9-usb-ehci1",
+
+    "vt82c686b-usb-uhci",
+    "pci-ohci",
+    "usb-redir",
+    "usb-hub",
+    "no-shutdown",
+
+    "cache-unsafe",
+    "rombar",
+    "ich9-ahci",
+    "no-acpi",
+    "fsdev-readonly",
+
+    "virtio-blk-pci.scsi",
+    "blk-sg-io",
+    "drive-copy-on-read",
+    "cpu-host",
+    "fsdev-writeout",
+
+    "drive-iotune",
+    "system_wakeup",
+    "scsi-disk.channel",
+    "scsi-block",
+    "transaction",
+
+    NULL
+};
+
+void qemu_print_capabilities(void)
+{
+    int i;
+    bool new_line = true;
+    int width = 0;
+
+    printf("[\n");
+    for (i = 0; supported_caps[i]; i++) {
+    repeat:
+        if (new_line) {
+            new_line = false;
+            printf("    ");
+            width += 4;
+        } else {
+            printf(", ");
+            width += 2;
+        }
+
+        width += strlen(supported_caps[i]) + 2;
+        if (width >= 78) {
+            printf("\n");
+            new_line = true;
+            width = 0;
+            goto repeat;
+        }
+
+        printf("\"%s\"", supported_caps[i]);
+    }
+    printf("\n]\n");
+}
diff --git a/libvirt-caps.h b/libvirt-caps.h
new file mode 100644
index 0000000..ad89d5b
--- /dev/null
+++ b/libvirt-caps.h
@@ -0,0 +1,19 @@
+/*
+ * Libvirt capabilities
+ *
+ * Copyright IBM, Corp. 2012
+ *
+ * Authors:
+ *  Anthony Liguori   <address@hidden>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef LIBVIRT_CAPS_H
+#define LIBVIRT_CAPS_H
+
+void qemu_print_capabilities(void);
+
+#endif
diff --git a/qemu-options.hx b/qemu-options.hx
index dc68e15..6f74afa 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2783,6 +2783,10 @@ DEF("qtest-log", HAS_ARG, QEMU_OPTION_qtest_log,
     "-qtest-log LOG  specify tracing options\n",
     QEMU_ARCH_ALL)
 
+DEF("libvirt-caps", 0, QEMU_OPTION_libvirt_caps,
+    "-libvirt-caps   dump out a JSON list of capabilities\n",
+    QEMU_ARCH_ALL)
+
 HXCOMM This is the last statement. Insert new options before this line!
 STEXI
 @end table
diff --git a/vl.c b/vl.c
index 54e36ed..24c7596 100644
--- a/vl.c
+++ b/vl.c
@@ -161,6 +161,7 @@ int main(int argc, char **argv)
 #include "arch_init.h"
 
 #include "ui/qemu-spice.h"
+#include "libvirt-caps.h"
 
 //#define DEBUG_NET
 //#define DEBUG_SLIRP
@@ -3198,6 +3199,10 @@ int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_qtest_log:
                 qtest_log = optarg;
                 break;
+            case QEMU_OPTION_libvirt_caps:
+                qemu_print_capabilities();
+                exit(0);
+                break;
             default:
                 os_parse_cmd_args(popt->index, optarg);
             }
-- 
1.7.5.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]