summaryrefslogtreecommitdiffstats
path: root/qemu-option.c
Commit message (Collapse)AuthorAgeFilesLines
* error: New qemu_opts_loc_restore()Markus Armbruster2010-07-061-0/+5
| | | | | | | | | Needed for decent error locations when complaining about options outside of qemu_opts_foreach(). That one sets the location already. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qemu-option: New qemu_opts_reset()Markus Armbruster2010-07-021-0/+9
| | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qemu-option: Reject anti-social IDsMarkus Armbruster2010-06-141-0/+20
| | | | | | | | | | Restrict IDs to letters, digits, '-', '.', '_', starting with a letter. This takes care of '/' in qdev IDs breaking qbus_find(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu-option: Fix uninitialized value in append_option_parameterKevin Wolf2010-06-141-0/+1
| | | | | | | | When dest is NULL, i.e. a new copy of the list is created, we don't get a properly terminated list after the realloc. Initialize it as an empty list. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* add support for protocol driver create_optionsMORITA Kazutaka2010-05-281-7/+46
| | | | | | | | | This patch enables protocol drivers to use their create options which are not supported by the format. For example, protcol drivers can use a backing_file option with raw format. Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* Fix tiny leak in qemu_opts_parseJan Kiszka2010-05-031-2/+2
| | | | | | | | | qemu_opts_create duplicates the id we pass in case it shall be stored in the opts. So we do not need to dup it in qemu_opts_parse, leaking a few bytes this way. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* error: Convert qemu_opts_validate() to QErrorMarkus Armbruster2010-04-181-2/+1
| | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* error: Convert qemu_opts_set() to QErrorMarkus Armbruster2010-04-181-10/+7
| | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* error: Convert qemu_opts_create() to QErrorMarkus Armbruster2010-04-181-2/+2
| | | | | | | | Fixes device_add to report duplicate ID properly in QMP, as DuplicateId instead of UndefinedError. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* Fix OpenBSD linker warningBlue Swirl2010-03-181-1/+2
| | | | | | | qemu-option.o(.text+0x20f8): In function `qemu_opts_from_qdict_1': /src/qemu/qemu-option.c:813: warning: strcpy() is almost always misused, please use strlcpy() Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* qemu-option: Move the implied first name into QemuOptsListMarkus Armbruster2010-03-161-1/+6
| | | | | | | | | | | We sometimes permit omitting the first option name, for example -device foo is short for -device driver=foo. The name to use ("driver" in the example) is passed as argument to qemu_opts_parse(). For each QemuOptsList, we use at most one such name. Move the name into QemuOptsList, and pass whether to permit the abbreviation. This ensures continued consistency, and simplifies the commit after next in this series.
* qemu-option: Functions to convert to/from QDictMarkus Armbruster2010-03-161-0/+79
| | | | | The functions are somewhat restricted. Good enough for the job at hand. We'll extend them when we need more.
* error: Infrastructure to track locations for error reportingMarkus Armbruster2010-03-161-0/+7
| | | | | | | | | | | | | | | | | | New struct Location holds a location. So far, the only location is LOC_NONE, so this doesn't do anything useful yet. Passing the current location all over the place would be too cumbersome. Hide it away in static cur_loc instead, and provide accessors. Print it in error_report(). Store it in QError, and print it in qerror_print(). Store it in QemuOpt, for use by qemu_opts_foreach(). This makes error_report() do the right thing when it runs within qemu_opts_foreach(). We may still have to store it in other data structures holding user input for better error messages. Left for another day.
* Allow const QemuOptDescBlue Swirl2010-02-211-3/+3
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* qemu-option: Make qemu_opts_foreach() accumulate return valuesMarkus Armbruster2010-02-031-1/+1
| | | | | | | | | | | | | Return the bitwise inclusive or of all return values instead of the last call's value. This lets you find out whether any of the calls returned a non-zero value. No functional change, as existing users either don't care for the value, or pass non-zero abort_on_failure, which breaks the loop on the first non-zero return value. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* QemuOpts: allow larger option values.Gerd Hoffmann2009-12-121-2/+2
| | | | | | | Use case: loooooooooooooooooong file names for -drive file=... Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu-opts: Release id on deletionJan Kiszka2009-12-031-1/+2
| | | | | | | | The opts id is always allocated via qemu_strdup, so it need not be const, but it has to be released on opts deletion. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Never overwrite a QemuOptMark McLoughlin2009-10-061-28/+23
| | | | | | | | | | | | | Rather than overwriting a QemuOpt, just add a new one to the tail and always do a reverse search for parameters to preserve the same behaviour. We use this order so that foreach() iterates over the opts in their original order. This will allow us handle options where multiple values for the same parameter is allowed - e.g. -net user,hostfwd= Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Add qemu_opts_validate() for post parsing validationMark McLoughlin2009-10-061-0/+33
| | | | | | | | | | | | | Several qemu command line options have a parameter whose value affects what other parameters are accepted for the option. In these cases, we can have an empty description table in the QemuOptsList and once the option has been parsed we can use a suitable description table to validate the other parameters based on the value of that parameter. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Make qemu_opts_parse() handle empty stringsMark McLoughlin2009-10-061-3/+1
| | | | | | | | | Rather than making callers explicitly handle empty strings by using qemu_opts_create(), we can easily have qemu_opts_parse() handle empty parameter strings. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Remove bogus error message from qemu_opts_set()Mark McLoughlin2009-10-061-2/+0
| | | | | | | | | The only way qemu_opts_create() can fail is if a QemuOpts with that id already exists and fail_if_exists=1. In that case, we already print an error which makes more sense than the one in qemu_opts_set(). Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu-option: rename bool -> booleanJuan Quintela2009-09-261-3/+3
| | | | | | | | We need this to allow the use of <stdbool.h> Signed-off-by: Juan Quintela <quintela@redhat.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Fix coding style issueMark McLoughlin2009-09-251-3/+3
| | | | | | | | | | | | | | | | | | | | | | | Replace: if (-1 == foo()) with: if (foo() == -1) While this coding style is not in direct contravention of our currently ratified CODING_STYLE treaty, it could be argued that the Article 3 of the European Convention on Human Rights (prohibiting torture and "inhuman or degrading treatment") reads on the matter. [This commit message was brought to you without humour, as is evidenced by the absence of any emoticons] Signed-off-by: Mark McLoughlin <markmc@redhat.com> Cc: Avi Kivity <avi@redhat.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Fix sys-queue.h conflict for goodBlue Swirl2009-09-121-14/+14
| | | | | | | | | | | | | | | Problem: Our file sys-queue.h is a copy of the BSD file, but there are some additions and it's not entirely compatible. Because of that, there have been conflicts with system headers on BSD systems. Some hacks have been introduced in the commits 15cc9235840a22c289edbe064a9b3c19c5f49896, f40d753718c72693c5f520f0d9899f6e50395e94, 96555a96d724016e13190b28cffa3bc929ac60dc and 3990d09adf4463eca200ad964cc55643c33feb50 but the fixes were fragile. Solution: Avoid the conflict entirely by renaming the functions and the file. Revert the previous hacks. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* QemuOpts: split option parser into two functions.Gerd Hoffmann2009-09-111-17/+29
| | | | | | | | | looking for id= and creating a new QemuOpts instance is splitted from the actual option parser code now, so the parser can be called from other contexts too. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* mv from strdup to qemu_strdup in qemu-option.cJean-Christophe DUBOIS2009-09-091-3/+3
| | | | | | | | | one place is using strdup() instead of qemu_strdup Fix it Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* QemuOpts: qemu_opts_parse: fix id= parsingGerd Hoffmann2009-08-101-1/+6
| | | | | | | | | | | | We can't use get_param_value(), it can't handle parameters without '=' in there. Examples not working because of that: -device foo,id=bar -device file=/path/image,format=qcow2,snapshot,id=disk0 Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Message-Id:
* QemuOpts: add some functionsGerd Hoffmann2009-08-101-0/+19
| | | | | | | | | qemu_opt_foreach: loop over all QemuOpts entries. qemu_opts_id: return QemuOpts id. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Message-Id:
* qemu-option: fix parse_option_number().Gerd Hoffmann2009-07-301-0/+1
| | | | | | | | | | | | | It works much better when parse_option_number actually returns the number parsed ... Common breakage resulting from this bug is that 'qemu -hda foo.img -cdrom bar.iso' stops working (cdrom isn't there). Cc: Avi Kivity <avi@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* QemuOpts: framework for storing and parsing options.Gerd Hoffmann2009-07-271-0/+314
| | | | | | | | | | | | | | | | | | | This stores device parameters in a better way than unparsed strings. New types: QemuOpt - one key-value pair. QemuOpts - group of key-value pairs, belonging to one device, i.e. one drive. QemuOptsList - list of some kind of devices, i.e. all drives. Functions are provided to work with these types. The plan is that some day we will pass around QemuOpts pointers instead of strings filled with "key1=value1,key2=value2". Check out the next patch to see all this in action ;) Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu-option: factor out parse_option_sizeGerd Hoffmann2009-07-271-26/+36
| | | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu-option: factor out parse_option_boolGerd Hoffmann2009-07-271-12/+22
| | | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* move parser functions from vl.c to qemu-option.cGerd Hoffmann2009-07-271-0/+64
| | | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu-img: Print available options with -o ?Kevin Wolf2009-06-061-0/+13
| | | | | | | This patch adds a small help text to each of the options in the block drivers which can be displayed by using qemu-img create -f fmt -o ? Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* Create qemu-option.hKevin Wolf2009-05-221-0/+349
This patch creates a new header file and the corresponding implementation file for parsing of parameter strings for options (like used in -drive). Part of this is code moved from vl.c (so qemu-img can use it later). The idea is to have a data structure describing all accepted parameters. When parsing a parameter string, the structure is copied and filled with the parameter values. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
OpenPOWER on IntegriCloud