From patchwork Thu Mar 20 14:51:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amos Kong X-Patchwork-Id: 332212 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E74EB2C084E for ; Fri, 21 Mar 2014 01:51:51 +1100 (EST) Received: from localhost ([::1]:47429 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQeJx-0006e4-35 for incoming@patchwork.ozlabs.org; Thu, 20 Mar 2014 10:51:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47900) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQeJR-0006Ur-0Y for qemu-devel@nongnu.org; Thu, 20 Mar 2014 10:51:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQeJK-00060G-Tp for qemu-devel@nongnu.org; Thu, 20 Mar 2014 10:51:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24561) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQeJK-0005yQ-En for qemu-devel@nongnu.org; Thu, 20 Mar 2014 10:51:10 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2KEp9mj002749 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 20 Mar 2014 10:51:09 -0400 Received: from localhost (vpn1-112-127.nay.redhat.com [10.66.112.127]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s2KEp6H5015522; Thu, 20 Mar 2014 10:51:07 -0400 Date: Thu, 20 Mar 2014 22:51:05 +0800 From: Amos Kong To: Markus Armbruster Message-ID: <20140320145105.GD2693@amosk.info> References: <1394073416-12578-1-git-send-email-akong@redhat.com> <1394073416-12578-3-git-send-email-akong@redhat.com> <5318E743.7070609@redhat.com> <878usms5a6.fsf@blackfin.pond.sub.org> <20140320140312.GA24041@amosk.info> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20140320140312.GA24041@amosk.info> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, lcapitulino@redhat.com, jyang@redhat.com, pbonzini@redhat.com, libvirt-list@redhat.com Subject: Re: [Qemu-devel] [PATCH v4 2/2] query-command-line-options: query all the options in qemu-options.hx X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On Thu, Mar 20, 2014 at 10:03:12PM +0800, Amos Kong wrote: > On Fri, Mar 07, 2014 at 10:54:09AM +0100, Markus Armbruster wrote: > > Eric Blake writes: > > > > > On 03/05/2014 07:36 PM, Amos Kong wrote: > > >> vm_config_groups[] only contains part of the options which have > > >> argument, and all options which have no argument aren't added > > >> to vm_config_groups[]. Current query-command-line-options only > > >> checks options from vm_config_groups[], so some options will > > >> be lost. > > >> > > >> We have macro in qemu-options.hx to generate a table that > > >> contains all the options. This patch tries to query options > > >> from the table. > > >> > > >> Then we won't lose the legacy options that weren't added to > > >> vm_config_groups[] (eg: -vnc, -smbios). The options that have > > >> no argument will also be returned (eg: -enable-fips) > > >> > > >> Some options that have argument have a NULL desc list, some > > >> options don't have argument, and "parameters" is mandatory > > >> in the past. So we add a new field "argument" to present > > >> if the option takes unspecified arguments. > > > > > > I like Markus' suggestion of naming the new field > > > 'unspecified-parameters' rather than 'argument'. > > Hi Markus, > > > Looking again, there are more problems. > > > > 1. Non-parameter argument vs. parameter argument taking unspecified > > parameters > > > > Example: -device takes unspecified parameters. -cdrom doesn't take > > parameters, it takes a file name. Yet, the command reports the same > > for both: "parameters": [], "argument": true. > > > > Looks like we need a tri-state: option takes no argument, QemuOpts > > argument, or other argument. > > '-cdrom' is the 'other argument' == 'Non-parameter argument'? > > We can use a enum state. > > | { 'enum': 'ArgumentStateType', > | 'data': ['no-argument', 'unspecified-parameters-argument', > | 'non-parameter-argument'] > | } > | > | { 'type': 'CommandLineOptionInfo', > | 'data': { 'option': 'str', 'parameters': ['CommandLineParameterInfo'], > | '*argument-state': 'ArgumentStateType' } } > > parameters is [] unless it's a QemuOpts argument. Then it lists the > > recognized parameters. > > How about balloon? we should treat as 'taking unspecified parameters'? > > "-balloon none disable balloon device\n" > "-balloon virtio[,addr=str]\n" I think we should treat as 'unspecified parameters' > I think we can only check this from help message in qemu-options.hx, > is it a stable/acceptable method? > > We introduce query-command-line-options command to avoid libvirt to > check qemu commandline information by scanning qemu's help message, > it's not strict & stable. [not a completed patch] + } } entry = g_malloc0(sizeof(*entry)); ===================== query command output ============ { "return": [ { "parameters": [ { "name": "timestamp", "type": "boolean" } ], "option": "msg" }, { "parameters": [ ], "option": "object", "argument-state": "unspecified-parameters-argument" }, { "parameters": [ ], "option": "tdf", "argument-state": "no-argument" }, { "parameters": [ ], "option": "no-kvm-irqchip", "argument-state": "no-argument" }, { "parameters": [ ], "option": "no-kvm-pit", "argument-state": "no-argument" }, { "parameters": [ ], "option": "no-kvm-pit-reinjection", "argument-state": "no-argument" }, { "parameters": [ ], "option": "no-kvm", "argument-state": "no-argument" }, { "parameters": [ ], "option": "enable-fips", "argument-state": "no-argument" }, { "parameters": [ ], "option": "qtest-log", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "qtest", "argument-state": "no-parameter-argument" }, { "parameters": [ { "name": "file", "type": "string" }, { "name": "events", "type": "string" } ], "option": "trace" }, { "parameters": [ ], "option": "no-user-config", "argument-state": "no-argument" }, { "parameters": [ ], "option": "nodefconfig", "argument-state": "no-argument" }, { "parameters": [ ], "option": "writeconfig", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "readconfig", "argument-state": "no-parameter-argument" }, { "parameters": [ { "name": "enable", "type": "boolean" } ], "option": "sandbox" }, { "parameters": [ ], "option": "old-param", "argument-state": "no-argument" }, { "parameters": [ ], "option": "semihosting", "argument-state": "no-argument" }, { "parameters": [ ], "option": "prom-env", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "runas", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "chroot", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "nodefaults", "argument-state": "no-argument" }, { "parameters": [ ], "option": "incoming", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "tb-size", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "show-cursor", "argument-state": "no-argument" }, { "parameters": [ ], "option": "virtioconsole", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "echr", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "watchdog-action", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "watchdog", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "icount", "argument-state": "no-parameter-argument" }, { "parameters": [ { "name": "driftfix", "type": "string" }, { "name": "clock", "type": "string" }, { "name": "base", "type": "string" } ], "option": "rtc" }, { "parameters": [ ], "option": "startdate", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "localtime", "argument-state": "no-argument" }, { "parameters": [ ], "option": "clock", "argument-state": "no-parameter-argument" }, { "parameters": [ { "name": "romfile", "type": "string" }, { "name": "bootindex", "type": "number" } ], "option": "option-rom" }, { "parameters": [ ], "option": "daemonize", "argument-state": "no-argument" }, { "parameters": [ ], "option": "loadvm", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "no-shutdown", "argument-state": "no-argument" }, { "parameters": [ ], "option": "no-reboot", "argument-state": "no-argument" }, { "parameters": [ ], "option": "xen-attach", "argument-state": "no-argument" }, { "parameters": [ ], "option": "xen-create", "argument-state": "no-argument" }, { "parameters": [ ], "option": "xen-domid", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "enable-kvm", "argument-state": "no-argument" }, { "parameters": [ ], "option": "bios", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "L", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "D", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "d", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "s", "argument-state": "no-argument" }, { "parameters": [ ], "option": "gdb", "argument-state": "no-parameter-argument" }, { "parameters": [ { "name": "mlock", "type": "boolean" } ], "option": "realtime" }, { "parameters": [ ], "option": "S", "argument-state": "no-argument" }, { "parameters": [ ], "option": "singlestep", "argument-state": "no-argument" }, { "parameters": [ ], "option": "pidfile", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "debugcon", "argument-state": "no-parameter-argument" }, { "parameters": [ { "name": "pretty", "type": "boolean" }, { "name": "default", "type": "boolean" }, { "name": "chardev", "type": "string" }, { "name": "mode", "type": "string" } ], "option": "mon" }, { "parameters": [ ], "option": "qmp", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "monitor", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "parallel", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "serial", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "dtb", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "initrd", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "append", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "kernel", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "bt", "argument-state": "unspecified-parameters-argument" }, { "parameters": [ { "name": "initiator-name", "help": "Initiator iqn name to use when connecting", "type": "string" }, { "name": "header-digest", "help": "HeaderDigest setting. {CRC32C|CRC32C-NONE|NONE-CRC32C|NONE}", "type": "string" }, { "name": "password", "help": "password for CHAP authentication to target", "type": "string" }, { "name": "user", "help": "username for CHAP authentication to target", "type": "string" } ], "option": "iscsi" }, { "parameters": [ { "name": "chardev", "type": "string" }, { "name": "size", "type": "size" }, { "name": "debug", "type": "number" }, { "name": "name", "type": "string" }, { "name": "signal", "type": "boolean" }, { "name": "mux", "type": "boolean" }, { "name": "rows", "type": "number" }, { "name": "cols", "type": "number" }, { "name": "height", "type": "number" }, { "name": "width", "type": "number" }, { "name": "telnet", "type": "boolean" }, { "name": "delay", "type": "boolean" }, { "name": "server", "type": "boolean" }, { "name": "wait", "type": "boolean" }, { "name": "ipv6", "type": "boolean" }, { "name": "ipv4", "type": "boolean" }, { "name": "to", "type": "number" }, { "name": "localport", "type": "string" }, { "name": "localaddr", "type": "string" }, { "name": "port", "type": "string" }, { "name": "host", "type": "string" }, { "name": "path", "type": "string" }, { "name": "backend", "type": "string" } ], "option": "chardev" }, { "parameters": [ ], "option": "netdev", "argument-state": "unspecified-parameters-argument" }, { "parameters": [ ], "option": "net", "argument-state": "unspecified-parameters-argument" }, { "parameters": [ ], "option": "smb", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "redir", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "bootp", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "tftp", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "smbios", "argument-state": "unspecified-parameters-argument" }, { "parameters": [ ], "option": "acpitable", "argument-state": "unspecified-parameters-argument" }, { "parameters": [ ], "option": "no-hpet", "argument-state": "no-argument" }, { "parameters": [ ], "option": "no-acpi", "argument-state": "no-argument" }, { "parameters": [ ], "option": "no-fd-bootchk", "argument-state": "no-argument" }, { "parameters": [ ], "option": "rtc-td-hack", "argument-state": "no-argument" }, { "parameters": [ ], "option": "win2k-hack", "argument-state": "no-argument" }, { "parameters": [ ], "option": "vnc", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "g", "argument-state": "unspecified-parameters-argument" }, { "parameters": [ ], "option": "full-screen", "argument-state": "no-argument" }, { "parameters": [ ], "option": "vga", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "rotate", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "portrait", "argument-state": "no-argument" }, { "parameters": [ { "name": "seamless-migration", "type": "boolean" }, { "name": "playback-compression", "type": "boolean" }, { "name": "agent-mouse", "type": "boolean" }, { "name": "streaming-video", "type": "string" }, { "name": "zlib-glz-wan-compression", "type": "string" }, { "name": "jpeg-wan-compression", "type": "string" }, { "name": "image-compression", "type": "string" }, { "name": "plaintext-channel", "type": "string" }, { "name": "tls-channel", "type": "string" }, { "name": "tls-ciphers", "type": "string" }, { "name": "x509-dh-key-file", "type": "string" }, { "name": "x509-cacert-file", "type": "string" }, { "name": "x509-cert-file", "type": "string" }, { "name": "x509-key-password", "type": "string" }, { "name": "x509-key-file", "type": "string" }, { "name": "x509-dir", "type": "string" }, { "name": "sasl", "type": "boolean" }, { "name": "disable-agent-file-xfer", "type": "boolean" }, { "name": "disable-copy-paste", "type": "boolean" }, { "name": "disable-ticketing", "type": "boolean" }, { "name": "password", "type": "string" }, { "name": "ipv6", "type": "boolean" }, { "name": "ipv4", "type": "boolean" }, { "name": "addr", "type": "string" }, { "name": "tls-port", "type": "number" }, { "name": "port", "type": "number" } ], "option": "spice" }, { "parameters": [ ], "option": "sdl", "argument-state": "no-argument" }, { "parameters": [ ], "option": "no-quit", "argument-state": "no-argument" }, { "parameters": [ ], "option": "ctrl-grab", "argument-state": "no-argument" }, { "parameters": [ ], "option": "alt-grab", "argument-state": "no-argument" }, { "parameters": [ ], "option": "no-frame", "argument-state": "no-argument" }, { "parameters": [ ], "option": "curses", "argument-state": "no-argument" }, { "parameters": [ ], "option": "nographic", "argument-state": "no-argument" }, { "parameters": [ ], "option": "display", "argument-state": "unspecified-parameters-argument" }, { "parameters": [ ], "option": "usbdevice", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "usb", "argument-state": "no-argument" }, { "parameters": [ ], "option": "virtfs_synth", "argument-state": "no-argument" }, { "parameters": [ { "name": "sock_fd", "type": "number" }, { "name": "socket", "type": "string" }, { "name": "readonly", "type": "boolean" }, { "name": "writeout", "type": "string" }, { "name": "security_model", "type": "string" }, { "name": "mount_tag", "type": "string" }, { "name": "path", "type": "string" }, { "name": "fsdriver", "type": "string" } ], "option": "virtfs" }, { "parameters": [ { "name": "sock_fd", "type": "number" }, { "name": "socket", "type": "string" }, { "name": "readonly", "type": "boolean" }, { "name": "writeout", "type": "string" }, { "name": "security_model", "type": "string" }, { "name": "path", "type": "string" }, { "name": "fsdriver", "type": "string" } ], "option": "fsdev" }, { "parameters": [ ], "option": "hdachs", "argument-state": "unspecified-parameters-argument" }, { "parameters": [ ], "option": "snapshot", "argument-state": "no-argument" }, { "parameters": [ ], "option": "pflash", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "sd", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "mtdblock", "argument-state": "no-parameter-argument" }, { "parameters": [ { "name": "copy-on-read", "help": "copy read data from backing file into image file", "type": "boolean" }, { "name": "werror", "help": "write error action", "type": "string" }, { "name": "rerror", "help": "read error action", "type": "string" }, { "name": "read-only", "help": "open drive file as read-only", "type": "boolean" }, { "name": "file", "help": "file name", "type": "string" }, { "name": "addr", "help": "pci address (virtio only)", "type": "string" }, { "name": "boot", "help": "(deprecated, ignored)", "type": "boolean" }, { "name": "trans", "help": "chs translation (auto, lba, none)", "type": "string" }, { "name": "secs", "help": "number of sectors (ide disk geometry)", "type": "number" }, { "name": "heads", "help": "number of heads (ide disk geometry)", "type": "number" }, { "name": "cyls", "help": "number of cylinders (ide disk geometry)", "type": "number" }, { "name": "if", "help": "interface (ide, scsi, sd, mtd, floppy, pflash, virtio)", "type": "string" }, { "name": "media", "help": "media type (disk, cdrom)", "type": "string" }, { "name": "index", "help": "index number", "type": "number" }, { "name": "unit", "help": "unit number (i.e. lun for scsi)", "type": "number" }, { "name": "bus", "help": "bus number", "type": "number" }, { "name": "throttling.iops-size", "help": "when limiting by iops max size of an I/O in bytes", "type": "number" }, { "name": "throttling.bps-write-max", "help": "total bytes write burst", "type": "number" }, { "name": "throttling.bps-read-max", "help": "total bytes read burst", "type": "number" }, { "name": "throttling.bps-total-max", "help": "total bytes burst", "type": "number" }, { "name": "throttling.iops-write-max", "help": "I/O operations write burst", "type": "number" }, { "name": "throttling.iops-read-max", "help": "I/O operations read burst", "type": "number" }, { "name": "throttling.iops-total-max", "help": "I/O operations burst", "type": "number" }, { "name": "throttling.bps-write", "help": "limit write bytes per second", "type": "number" }, { "name": "throttling.bps-read", "help": "limit read bytes per second", "type": "number" }, { "name": "throttling.bps-total", "help": "limit total bytes per second", "type": "number" }, { "name": "throttling.iops-write", "help": "limit write operations per second", "type": "number" }, { "name": "throttling.iops-read", "help": "limit read operations per second", "type": "number" }, { "name": "throttling.iops-total", "help": "limit total I/O operations per second", "type": "number" }, { "name": "werror", "help": "write error action", "type": "string" }, { "name": "serial", "help": "disk serial number", "type": "string" }, { "name": "format", "help": "disk format (raw, qcow2, ...)", "type": "string" }, { "name": "aio", "help": "host AIO implementation (threads, native)", "type": "string" }, { "name": "cache.no-flush", "help": "ignore any flush requests for the device", "type": "boolean" }, { "name": "cache.direct", "help": "enables use of O_DIRECT (bypass the host page cache)", "type": "boolean" }, { "name": "cache.writeback", "help": "enables writeback mode for any caches", "type": "boolean" }, { "name": "discard", "help": "discard operation (ignore/off, unmap/on)", "type": "string" }, { "name": "snapshot", "help": "enable/disable snapshot mode", "type": "boolean" } ], "option": "drive" }, { "parameters": [ ], "option": "cdrom", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "hdd", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "hdc", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "hdb", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "hda", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "fdb", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "fda", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "uuid", "argument-state": "no-parameter-argument" }, { "parameters": [ { "name": "debug-threads", "help": "When enabled, name the individual threads; defaults off.\nNOTE: The thread names are for debugging and not a\nstable API.", "type": "boolean" }, { "name": "process", "help": "Sets the name of the QEMU process, as shown in top etc", "type": "string" }, { "name": "guest", "help": "Sets the name of the guest.\nThis name will be displayed in the SDL window caption.\nThe name will also be used for the VNC server", "type": "string" } ], "option": "name" }, { "parameters": [ ], "option": "device", "argument-state": "unspecified-parameters-argument" }, { "parameters": [ ], "option": "balloon", "argument-state": "unspecified-parameters-argument" }, { "parameters": [ ], "option": "soundhw", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "audio-help", "argument-state": "no-argument" }, { "parameters": [ ], "option": "k", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "mem-prealloc", "argument-state": "no-argument" }, { "parameters": [ ], "option": "mem-path", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "m", "argument-state": "no-parameter-argument" }, { "parameters": [ { "name": "strict", "type": "boolean" }, { "name": "reboot-timeout", "type": "string" }, { "name": "splash-time", "type": "string" }, { "name": "splash", "type": "string" }, { "name": "menu", "type": "boolean" }, { "name": "once", "type": "string" }, { "name": "order", "type": "string" } ], "option": "boot" }, { "parameters": [ { "name": "value", "type": "string" }, { "name": "property", "type": "string" }, { "name": "driver", "type": "string" } ], "option": "global" }, { "parameters": [ ], "option": "set", "argument-state": "no-parameter-argument" }, { "parameters": [ { "name": "opaque", "help": "free-form string used to describe fd", "type": "string" }, { "name": "set", "help": "ID of the fd set to add fd to", "type": "number" }, { "name": "fd", "help": "file descriptor of which a duplicate is added to fd set", "type": "number" } ], "option": "add-fd" }, { "parameters": [ ], "option": "numa", "argument-state": "unspecified-parameters-argument" }, { "parameters": [ { "name": "maxcpus", "type": "number" }, { "name": "threads", "type": "number" }, { "name": "cores", "type": "number" }, { "name": "sockets", "type": "number" }, { "name": "cpus", "type": "number" } ], "option": "smp" }, { "parameters": [ ], "option": "cpu", "argument-state": "no-parameter-argument" }, { "parameters": [ ], "option": "M", "argument-state": "no-parameter-argument" }, { "parameters": [ { "name": "kvm-type", "help": "Specifies the KVM virtualization mode (HV, PR)", "type": "string" }, { "name": "firmware", "help": "firmware image", "type": "string" }, { "name": "usb", "help": "Set on/off to enable/disable usb", "type": "boolean" }, { "name": "mem-merge", "help": "enable/disable memory merge support", "type": "boolean" }, { "name": "dump-guest-core", "help": "Include guest memory in a core dump", "type": "boolean" }, { "name": "dt_compatible", "help": "Overrides the \"compatible\" property of the dt root node", "type": "string" }, { "name": "phandle_start", "help": "The first phandle ID we may generate dynamically", "type": "number" }, { "name": "dumpdtb", "help": "Dump current dtb to a file and quit", "type": "string" }, { "name": "dtb", "help": "Linux kernel device tree file", "type": "string" }, { "name": "append", "help": "Linux kernel command line", "type": "string" }, { "name": "initrd", "help": "Linux initial ramdisk file", "type": "string" }, { "name": "kernel", "help": "Linux kernel image file", "type": "string" }, { "name": "kvm_shadow_mem", "help": "KVM shadow MMU size", "type": "size" }, { "name": "kernel_irqchip", "help": "use KVM in-kernel irqchip", "type": "boolean" }, { "name": "accel", "help": "accelerator list", "type": "string" }, { "name": "type", "help": "emulated machine", "type": "string" } ], "option": "machine" }, { "parameters": [ ], "option": "version", "argument-state": "no-argument" }, { "parameters": [ ], "option": "help", "argument-state": "no-argument" }, { "parameters": [ ], "option": "h", "argument-state": "no-argument" } ] } diff --git a/qemu-options.h b/qemu-options.h index 4024487..b08a6dc 100644 --- a/qemu-options.h +++ b/qemu-options.h @@ -41,6 +41,7 @@ typedef struct QEMUOption { const char *name; int flags; int index; + const char *help; uint32_t arch_mask; } QEMUOption; diff --git a/util/qemu-config.c b/util/qemu-config.c index 5bc3c31..e7758e3 100644 --- a/util/qemu-config.c +++ b/util/qemu-config.c @@ -9,7 +9,8 @@ #include "qemu-options.h" const QEMUOption qemu_options[] = { - { "h", 0, QEMU_OPTION_h, QEMU_ARCH_ALL }, + { "h", 0, QEMU_OPTION_h, "-h or -help display this help and exit\n", + QEMU_ARCH_ALL }, #define QEMU_OPTIONS_GENERATE_OPTIONS #include "qemu-options-wrapper.h" { NULL }, @@ -147,6 +148,7 @@ CommandLineOptionInfoList *qmp_query_command_line_options(bool has_ CommandLineOptionInfo *info; QemuOptsList *list; int i; + const char *p; for (i = 0; qemu_options[i].name; i++) { if (!has_option || !strcmp(option, qemu_options[i].name)) { @@ -161,8 +163,23 @@ CommandLineOptionInfoList *qmp_query_command_line_options(bool has } if (!info->parameters) { - info->has_unspecified_parameters = true; - info->unspecified_parameters = qemu_options[i].flags & HAS_ARG; + info->has_argument_state = true; + + if (!qemu_options[i].flags & HAS_ARG) { + info->argument_state = ARGUMENT_STATE_TYPE_NO_ARGUMENT; + } else { + info->argument_state = + ARGUMENT_STATE_TYPE_NO_PARAMETER_ARGUMENT; + } + + p = qemu_options[i].help; + while (*p) { + if (*p != ' ' && *(p + 1) == '[') { ^^^^^ I know the string matching in while loop is too crude ;-) we can make it strict. + info->argument_state = + ARGUMENT_STATE_TYPE_UNSPECIFIED_PARAMETERS_ARGUMENT; + } + p += 1;