summaryrefslogtreecommitdiffstats
path: root/include/qemu/option.h
Commit message (Collapse)AuthorAgeFilesLines
* typedef: add typedef for QemuOptsPavel Dovgalyuk2015-09-251-4/+1
| | | | | | | | | | | This patch moves typedefs for QemuOpts and related types to qemu/typedefs.h file. Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru> Message-Id: <20150917162501.8676.85435.stgit@PASHA-ISP.def.inno> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* QemuOpts: Wean off qerror_report_err()Markus Armbruster2015-06-221-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qerror_report_err() is a transitional interface to help with converting existing monitor commands to QMP. It should not be used elsewhere. The only remaining user in qemu-option.c is qemu_opts_parse(). Is it used in QMP context? If not, we can simply replace qerror_report_err() by error_report_err(). The uses in qemu-img.c, qemu-io.c, qemu-nbd.c and under tests/ are clearly not in QMP context. The uses in vl.c aren't either, because the only QMP command handlers there are qmp_query_status() and qmp_query_machines(), and they don't call it. Remaining uses: * drive_def(): Command line -drive and such, HMP drive_add and pci_add * hmp_chardev_add(): HMP chardev-add * monitor_parse_command(): HMP core * tmp_config_parse(): Command line -tpmdev * net_host_device_add(): HMP host_net_add * net_client_parse(): Command line -net and -netdev * qemu_global_option(): Command line -global * vnc_parse_func(): Command line -display, -vnc, default display, HMP change, QMP change. Bummer. * qemu_pci_hot_add_nic(): HMP pci_add * usb_net_init(): Command line -usbdevice, HMP usb_add Propagate errors through qemu_opts_parse(). Create a convenience function qemu_opts_parse_noisily() that passes errors to error_report_err(). Switch all non-QMP users outside tests to it. That leaves vnc_parse_func(). Propagate errors through it. Since I'm touching it anyway, rename it to vnc_parse(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
* QemuOpts: Convert qemu_opt_foreach() to ErrorMarkus Armbruster2015-06-091-2/+5
| | | | | | | | Retain the function value for now, to permit selective conversion of its callers. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* QemuOpts: Drop qemu_opt_foreach() parameter abort_on_failureMarkus Armbruster2015-06-091-2/+1
| | | | | | | | | | | | | | | | | | | | | When the argument is non-zero, qemu_opt_foreach() stops on callback returning non-zero, and returns that value. When the argument is zero, it doesn't stop, and returns the callback's value from the last iteration. The two callers that pass zero could just as well pass one: * qemu_spice_init()'s callback add_channel() either returns zero or exit()s. * config_write_opts()'s callback config_write_opt() always returns zero. Drop the parameter, and always stop. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* QemuOpts: Convert qemu_opts_foreach() to ErrorMarkus Armbruster2015-06-091-2/+2
| | | | | | | | | Retain the function value for now, to permit selective conversion of its callers. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Acked-by: Kevin Wolf <kwolf@redhat.com>
* QemuOpts: Drop qemu_opts_foreach() parameter abort_on_failureMarkus Armbruster2015-06-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | When the argument is non-zero, qemu_opts_foreach() stops on callback returning non-zero, and returns that value. When the argument is zero, it doesn't stop, and returns the bit-wise inclusive or of all the return values. Funky :) The callers that pass zero could just as well pass one, because their callbacks can't return anything but zero: * qemu_add_globals()'s callback qdev_add_one_global() * qemu_config_write()'s callback config_write_opts() * main()'s callbacks default_driver_check(), drive_enable_snapshot(), vnc_init_func() Drop the parameter, and always stop. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Acked-by: Kevin Wolf <kwolf@redhat.com>
* qemu-img: Suppress unhelpful extra errors in convert, amendMarkus Armbruster2015-02-261-1/+2
| | | | | | | | | | | | | | | | | | | | img_convert() and img_amend() use qemu_opts_do_parse(), which reports errors with qerror_report_err(). Its error messages aren't helpful here, the caller reports one that actually makes sense. Reproducer: $ qemu-img convert -o backing_format=raw in.img out.img qemu-img: Invalid parameter 'backing_format' qemu-img: Invalid options for file format 'raw' To fix, propagate errors through qemu_opts_do_parse(). This lifts the error reporting into callers. Drop it from img_convert() and img_amend(), keep it in qemu_chr_parse_compat(), bdrv_img_create(). Since I'm touching qemu_opts_do_parse() anyway, write a function comment for it. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* QemuOpts: Drop qemu_opt_set(), rename qemu_opt_set_err(), fix useMarkus Armbruster2015-02-261-3/+2
| | | | | | | | | | | | | | | | qemu_opt_set() is a wrapper around qemu_opt_set() that reports the error with qerror_report_err(). Most of its users assume the function can't fail. Make them use qemu_opt_set_err() with &error_abort, so that should the assumption ever break, it'll break noisily. Just two users remain, in util/qemu-config.c. Switch them to qemu_opt_set_err() as well, then rename qemu_opt_set_err() to qemu_opt_set(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* QemuOpts: Convert qemu_opts_set() to Error, fix its useMarkus Armbruster2015-02-261-2/+2
| | | | | | | | | | | | | | | | Return the Error object instead of reporting it with qerror_report_err(). Change callers that assume the function can't fail to pass &error_abort, so that should the assumption ever break, it'll break noisily. Turns out all callers outside its unit test assume that. We could drop the Error ** argument, but that would make the interface less regular, so don't. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* QemuOpts: Convert qemu_opt_set_number() to Error, fix its useMarkus Armbruster2015-02-261-1/+2
| | | | | | | | | | | | | | | | Return the Error object instead of reporting it with qerror_report_err(). Change callers that assume the function can't fail to pass &error_abort, so that should the assumption ever break, it'll break noisily. Turns out all callers outside its unit test assume that. We could drop the Error ** argument, but that would make the interface less regular, so don't. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* QemuOpts: Convert qemu_opt_set_bool() to Error, fix its useMarkus Armbruster2015-02-261-1/+2
| | | | | | | | | | | | | | | | Return the Error object instead of reporting it with qerror_report_err(). Change callers that assume the function can't fail to pass &error_abort, so that should the assumption ever break, it'll break noisily. Turns out all callers outside its unit test assume that. We could drop the Error ** argument, but that would make the interface less regular, so don't. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* block: Don't add trailing space in "Formating..." messageFam Zheng2014-12-121-1/+1
| | | | | | | | | | | | | | | | Change the message printing code to output a separator for each option string before it instead of after, then we don't one more extra ' ' in the end. To update qemu-iotests output files, most of the times one would just copy the *.out.bad to *.out. With this change we will not have the space disliked by checkpatch.pl. Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-id: 1418110684-19528-3-git-send-email-famz@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* util: Emancipate id_wellformed() from QemuOptsMarkus Armbruster2014-10-031-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | IDs have long spread beyond QemuOpts: not everything with an ID necessarily goes through QemuOpts. Commit 9aebf3b is about such a case: block layer names are meant to be well-formed IDs, but some of them don't go through QemuOpts, and thus weren't checked. The commit fixed that the straightforward way: rename the internal QemuOpts helper id_wellformed() to qemu_opts_id_wellformed() and give it external linkage. Instead of using it directly in block.c, the commit adds wrapper bdrv_is_valid_name(), probably to hide the connection to QemuOpts. Go one logical step further: emancipate IDs from QemuOpts. Rename the function back to id_wellformed(), and put it in another file. While there, clean up its value to bool. Peel off the bdrv_is_valid_name() wrapper. [Replaced stray return 0 with return false to match bool returns used elsewhere in id_wellformed(). --Stefan] Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* block: Validate node-nameKevin Wolf2014-09-251-0/+1
| | | | | | | | | | | | | | | | | The device_name of a BlockDriverState is currently checked because it is always used as a QemuOpts ID and qemu_opts_create() checks whether such IDs are wellformed. node-name is supposed to share the same namespace, but it isn't checked currently. This patch adds explicit checks both for device_name and node-name so that the same rules will still apply even if QemuOpts won't be used any more at some point. qemu-img used to use names with spaces in them, which isn't allowed any more. Replace them with underscores. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
* QemuOpts: cleanup tmp 'allocated' member from QemuOptsListChunyan Liu2014-06-161-6/+0
| | | | | | | | | | | | Now only qemu_opts_append uses 'allocated' to indicate free memory. For this function only, we can also let result list's (const char *) members point to input list's members, only if the input list has longer lifetime than result list. In current code, that is true. So, we can remove the 'allocated' member from QemuOptsList definition to keep code clean. Signed-off-by: Chunyan Liu <cyliu@suse.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* cleanup QEMUOptionParameterChunyan Liu2014-06-161-47/+1
| | | | | | | | | Now that all backend drivers are using QemuOpts, remove all QEMUOptionParameter related codes. Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Signed-off-by: Chunyan Liu <cyliu@suse.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* QemuOpts: export qemu_opt_findChunyan Liu2014-06-161-0/+1
| | | | | | | | | | Export qemu_opt_find for qcow2 driver using it. After replacing QEMUOptionParameter with QemuOpts, qcow2 driver will use qemu_opt_find to judge if an option is explicitly set, to replace the usage of .assigned in QEMUOptionParameter. Signed-off-by: Chunyan Liu <cyliu@suse.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* QemuOpts: add qemu_opts_append to replace append_option_parametersChunyan Liu2014-06-161-0/+5
| | | | | | | | | | For later merge .create_opts of drv and proto_drv in qemu-img commands. Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Leandro Dorileo <l@dorileo.org> Signed-off-by: Chunyan Liu <cyliu@suse.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* QemuOpts: add conversion between QEMUOptionParameter to QemuOptsChunyan Liu2014-06-161-0/+9
| | | | | | | | | | | | | Add two temp conversion functions between QEMUOptionParameter to QemuOpts, so that next patch can use it. It will simplify later patch for easier review. And will be finally removed after all backend drivers switch to QemuOpts. Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Leandro Dorileo <l@dorileo.org> Signed-off-by: Chunyan Liu <cyliu@suse.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* QemuOpts: add qemu_opts_print_help to replace print_option_helpChunyan Liu2014-06-161-0/+1
| | | | | | | | | | | | print_option_help takes QEMUOptionParameter as parameter, add qemu_opts_print_help to take QemuOptsList as parameter for later replace work. Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Leandro Dorileo <l@dorileo.org> Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Signed-off-by: Chunyan Liu <cyliu@suse.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* QemuOpts: add qemu_opt_get_*_del functions for replace workChunyan Liu2014-06-161-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add qemu_opt_get_del, qemu_opt_get_bool_del, qemu_opt_get_number_del and qemu_opt_get_size_del to replace the same handling of QEMUOptionParameter (get and delete). Several drivers are coded to parse a known subset of options, then remove them from the list before handing all remaining options to a second driver for further option processing. get_*_del makes it easier to retrieve a known option (or its default) and remove it from the list all in one action. Share common helper function: For qemu_opt_get_bool/size/number, they and their get_*_del counterpart could share most of the code except whether or not deleting the opt from option list, so generate common helper functions. For qemu_opt_get and qemu_opt_get_del, keep code duplication, since 1. qemu_opt_get_del returns malloc'd memory while qemu_opt_get returns in-place memory 2. qemu_opt_get_del returns (char *), qemu_opt_get returns (const char *), and could not change to (char *), since in one case, it will return desc->def_value_str, which is (const char *). Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Signed-off-by: Chunyan Liu <cyliu@suse.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* QemuOpts: add def_value_str to QemuOptDescChunyan Liu2014-06-161-0/+1
| | | | | | | | | | | | | | | | | Add def_value_str (default value) to QemuOptDesc, to replace function of the default value in QEMUOptionParameter. Improve qemu_opts_get_* functions: if find opt, return opt->str; otherwise, if desc->def_value_str is set, return desc->def_value_str; otherwise, return input defval. Improve qemu_opts_print: if option is set, print opt->str; otherwise, if desc->def_value_str is set, print it. Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Signed-off-by: Chunyan Liu <cyliu@suse.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* QemuOpts: repurpose qemu_opts_print to replace print_option_parametersChunyan Liu2014-06-161-1/+1
| | | | | | | | | | Currently this function is not used anywhere. In later patches, it will replace print_option_parameters. To avoid print info changes, change qemu_opts_print from fprintf stderr to printf, and remove last printf. Signed-off-by: Chunyan Liu <cyliu@suse.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* qemu-option: has_help_option() and is_valid_option_list()Kevin Wolf2014-02-211-0/+2
| | | | | | | | | | | | | has_help_option() checks if any help option ('help' or '?') occurs anywhere in an option string, so that things like 'cluster_size=4k,help' are recognised. is_valid_option_list() ensures that the option list doesn't have options with leading commas or trailing unescaped commas. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Jeff Cody <jcody@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* qemu-option: Remove qemu_opts_create_nofailPeter Crosthwaite2014-01-061-1/+0
| | | | | | | | | | | | | This is a boiler-plate _nofail variant of qemu_opts_create. Remove and use error_abort in call sites. null/0 arguments needs to be added for the id and fail_if_exists fields in affected callsites due to argument inconsistency between the normal and no_fail variants. Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* blockdev: Separate ID generation from DriveInfo creationKevin Wolf2013-10-111-0/+1
| | | | | | | | | | blockdev-add shouldn't automatically generate IDs, but will keep most of the DriveInfo creation code. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* option: Add assigned flag to QEMUOptionParameterMax Reitz2013-08-301-0/+1
| | | | | | | | | Adds an "assigned" flag to QEMUOptionParameter which is cleared at the beginning of parse_option_parameters and set on (successful) set_option_parameter and set_option_parameter_int. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qdev: Add SIZE type to qdev propertiesVasilis Liaskovitis2013-07-291-0/+2
| | | | | | | | | | | | | This patch adds a 'SIZE' type property to qdev. Signed-off-by: Ian Molton <ian.molton@collabora.co.uk> Signed-off-by: Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Message-id: 1375109277-25561-7-git-send-email-imammedo@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* QemuOpts: Add qemu_opt_unset()Kevin Wolf2013-07-261-0/+1
| | | | | Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* qemu-option: check_params() is now unused, drop itMarkus Armbruster2013-06-191-2/+0
| | | | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Message-id: 1371208516-7857-3-git-send-email-armbru@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu-option: Add qemu_opts_absorb_qdict()Kevin Wolf2013-03-151-0/+1
| | | | | | | | | | | | | | | This adds a function that adds all entries of a QDict to a QemuOpts if the keys are known, and leaves only the rest in the QDict. This way a single QDict of -drive options can be processed in multiple places (generic block layer, block driver, backing file block driver, etc.), where each part picks the options it knows. If at the end of the process the QDict isn't empty, the user specified an invalid option. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* misc: move include files to include/qemu/Paolo Bonzini2012-12-191-0/+158
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
OpenPOWER on IntegriCloud