Statistics
| Branch: | Revision:

root / qemu-option.c @ 992aeb8e

History | View | Annotate | Download (28.6 kB)

# Date Author Comment
1de7afc9 12/19/2012 09:32 am Paolo Bonzini

misc: move include files to include/qemu/

Signed-off-by: Paolo Bonzini <>

7b1b5d19 12/19/2012 09:31 am Paolo Bonzini

qapi: move include files to include/qobject/

Signed-off-by: Paolo Bonzini <>

b83c18e2 12/11/2012 05:37 pm Dong Xu Wang

create new function: qemu_opt_set_number

Signed-off-by: Dong Xu Wang <>
Signed-off-by: Kevin Wolf <>

dd392449 12/11/2012 05:34 pm Dong Xu Wang

introduce qemu_opts_create_nofail function

While id is NULL, qemu_opts_create can not fail, so ignore
errors is fine.

Signed-off-by: Dong Xu Wang <>
Signed-off-by: Kevin Wolf <>

ad718d01 12/11/2012 05:33 pm Dong Xu Wang

qemu-option: qemu_opt_set_bool(): fix code duplication

It will set opt->str in qemu_opt_set_bool, without opt->str, there
will be some potential bugs.

These are uses of opt->str, and what happens when it isn't set:

  • qemu_opt_get(): returns NULL, which means "not set". Bug can bite...
db97ceba 12/11/2012 05:30 pm Dong Xu Wang

qemu-option: qemu_opts_validate(): fix duplicated code

Use opts_accepts_any() and find_desc_by_name().

Signed-off-by: Luiz Capitulino <>
Signed-off-by: Dong Xu Wang <>
Signed-off-by: Kevin Wolf <>

c474ced8 12/11/2012 05:28 pm Dong Xu Wang

qemu-option: opt_set(): split it up into more functions

The new functions are opts_accepts_any() and find_desc_by_name(), which
are also going to be used by qemu_opts_validate() (see next commit).

This also makes opt_set() slightly more readable.

Signed-off-by: Luiz Capitulino <>...

c8057f95 08/02/2012 09:16 pm Peter Maydell

Support 'help' as a synonym for '?' in command line options

For command line options which permit '?' meaning 'please list the
permitted values', add support for 'help' as a synonym, by abstracting
the check out into a helper function.

This change means that in some cases where we were being lazy in...

fdb17976 07/23/2012 01:55 pm Laszlo Ersek

expose QemuOpt and QemuOpts struct definitions to interested parties

The only clients should be the existent "qemu-option.c", and the upcoming
"qapi/opts-visitor.c".

Signed-off-by: Laszlo Ersek <>
Signed-off-by: Stefan Hajnoczi <>

8be7e7e4 06/04/2012 07:49 pm Luiz Capitulino

qemu-option: qemu_opts_create(): use error_set()

This commit converts qemu_opts_create() from qerror_report() to
error_set().

Currently, most calls to qemu_opts_create() can't fail, so most
callers don't need any changes.

The two cases where code checks for qemu_opts_create() erros are:...

2f39df5b 06/04/2012 07:49 pm Luiz Capitulino

qemu-option: parse_option_number(): use error_set()

Note that qemu_opt_parse() callers still expect automatic error reporting
with QError, so qemu_opts_parse() calls qerror_report_err() to keep the
same semantics.

Signed-off-by: Luiz Capitulino <>...

cf62adfa 06/04/2012 07:49 pm Luiz Capitulino

qemu-option: parse_option_bool(): use error_set()

Note that set_option_parameter() callers still expect automatic error
reporting with QError, so set_option_parameter() calls
qerror_report_err() to keep the same semantics.

Signed-off-by: Luiz Capitulino <>...

ec7b2ccb 06/04/2012 07:49 pm Luiz Capitulino

qemu-option: parse_option_size(): use error_set()

Signed-off-by: Luiz Capitulino <>
Reviewed-By: Laszlo Ersek <>

6c519404 06/04/2012 07:49 pm Luiz Capitulino

qemu-option: qemu_opt_parse(): use error_set()

The functions opt_set() and qemu_opts_validate() both call qemu_opt_parse(),
but their callers expect QError semantics. Thus, both functions call
qerro_report_err() to keep the expected semantics.

Signed-off-by: Luiz Capitulino <>...

29952866 06/04/2012 07:49 pm Luiz Capitulino

qemu-option: qemu_opts_validate(): use error_set()

net_client_init() propagates the error up by calling qerror_report_err(),
because its users expect QError semantics.

Signed-off-by: Luiz Capitulino <>
Reviewed-By: Laszlo Ersek <>

584d4064 06/04/2012 07:49 pm Luiz Capitulino

qemu-option: opt_set(): use error_set()

The functions qemu_opt_set() and opts_do_parse() both call opt_set(),
but their callers expect QError semantics. Thus, both functions call
qerro_report_err() to keep the expected semantics.

Signed-off-by: Luiz Capitulino <>...

384f2139 06/04/2012 07:49 pm Luiz Capitulino

qemu-option: introduce qemu_opt_set_err()

This is like qemu_opt_set(), except that it takes an Error argument.

This new function allows for a incremental conversion of code using
qemu_opt_set().

Signed-off-by: Luiz Capitulino <>
Reviewed-By: Laszlo Ersek <>

4e89978e 06/04/2012 07:49 pm Luiz Capitulino

qemu-option: qemu_opts_from_qdict(): use error_set()

do_device_add() and do_netdev_add() call qerror_report_err() to maintain
their QError semantics.

Signed-off-by: Luiz Capitulino <>
Reviewed-By: Laszlo Ersek <>

da93318a 02/17/2012 10:08 am Peter Maydell

qemu-option: Add support for merged QemuOptsLists

Add support for option lists which are merged together, so that
"-listname foo=bar -listname bar=baz" is equivalent to "-listname
foo=bar,bar=baz" rather than generating two separate lists of options.

Signed-off-by: Peter Maydell <>...

4f6dd9af 02/01/2012 10:45 pm Jan Kiszka

qemu-option: Introduce default mechanism

This adds qemu_opts_set_defaults, an interface provide default values
for a QemuOpts set. Default options are parsed from a string and then
prepended to the list of existing options, or they serve as the sole
QemuOpts set....

0b0404bf 01/13/2012 12:36 pm Stefan Weil

Add 'fall through' comments to case statements without break

These comments are used by static code analysis tools and in code reviews
to avoid false warnings because of missing break statements.

The case statements handled here were reported by coverity....

07f35073 12/02/2011 12:50 pm Dong Xu Wang

fix spelling in main directory

Signed-off-by: Dong Xu Wang <>
Signed-off-by: Stefan Hajnoczi <>

f02b77c9 10/31/2011 09:04 am M. Mohan Kumar

qemu: Add opt_set_bool functionality

Signed-off-by: M. Mohan Kumar <>
Signed-off-by: Aneesh Kumar K.V <>

7267c094 08/21/2011 07:01 am Anthony Liguori

Use glib memory allocation and free functions

qemu_malloc/qemu_free no longer exist after this commit.

Signed-off-by: Anthony Liguori <>

898c257b 12/14/2010 04:44 pm Stefan Hajnoczi

qemu-option: Don't reinvent append_option_parameters()

parse_option_parameters() may need to create a new option parameter list
from a template list. Use append_option_parameters() instead of
duplicating the code.

Signed-off-by: Stefan Hajnoczi <>...

0e72e753 12/14/2010 04:44 pm Stefan Hajnoczi

qemu-option: Fix parse_option_parameters() documentation typo

Yoda said, "list is the templace is". Fix this.

Signed-off-by: Stefan Hajnoczi <>
Signed-off-by: Kevin Wolf <>

94ac7268 07/06/2010 06:05 pm Markus Armbruster

error: New qemu_opts_loc_restore()

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 <>
Signed-off-by: Kevin Wolf <>

bb67ab02 07/02/2010 02:18 pm Markus Armbruster

qemu-option: New qemu_opts_reset()

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

b560a9ab 06/14/2010 11:46 pm Markus Armbruster

qemu-option: Reject anti-social IDs

Restrict IDs to letters, digits, '-', '.', '_', starting with a
letter.

This takes care of '/' in qdev IDs breaking qbus_find().

Signed-off-by: Markus Armbruster <>
Signed-off-by: Anthony Liguori <>

bd69fe84 06/14/2010 07:12 pm Kevin Wolf

qemu-option: Fix uninitialized value in append_option_parameter

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 <>...

b50cbabc 05/28/2010 02:14 pm MORITA Kazutaka

add support for protocol driver create_options

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 <>...

d510c5cf 05/03/2010 08:09 pm Jan Kiszka

Fix tiny leak in qemu_opts_parse

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 <>
Signed-off-by: Anthony Liguori <>

975b63a4 04/19/2010 12:46 am Markus Armbruster

error: Convert qemu_opts_create() to QError

Fixes device_add to report duplicate ID properly in QMP, as
DuplicateId instead of UndefinedError.

Signed-off-by: Markus Armbruster <>
Signed-off-by: Luiz Capitulino <>

c64f27d4 04/19/2010 12:46 am Markus Armbruster

error: Convert qemu_opts_set() to QError

Signed-off-by: Markus Armbruster <>
Signed-off-by: Luiz Capitulino <>

db716e9c 04/19/2010 12:46 am Markus Armbruster

error: Convert qemu_opts_validate() to QError

Signed-off-by: Markus Armbruster <>
Signed-off-by: Luiz Capitulino <>

d35215f8 03/18/2010 10:48 pm Blue Swirl

Fix OpenBSD linker warning

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 <>

01e7f188 03/16/2010 06:45 pm Markus Armbruster

qemu-option: Functions to convert to/from QDict

The functions are somewhat restricted. Good enough for the job at
hand. We'll extend them when we need more.

8212c64f 03/16/2010 06:45 pm Markus Armbruster

qemu-option: Move the implied first name into QemuOptsList

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()....

827b0813 03/16/2010 05:58 pm Markus Armbruster

error: Infrastructure to track locations for error reporting

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...

238431a9 02/21/2010 06:01 pm Blue Swirl

Allow const QemuOptDesc

Signed-off-by: Blue Swirl <>

4a2594dd 02/03/2010 08:39 pm Markus Armbruster

qemu-option: Make qemu_opts_foreach() accumulate return values

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...

d318ff99 12/12/2009 03:59 pm Gerd Hoffmann

QemuOpts: allow larger option values.

Use case: loooooooooooooooooong file names for -drive file=...

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

b09417b9 12/03/2009 07:45 pm Jan Kiszka

qemu-opts: Release id on deletion

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 <>
Signed-off-by: Anthony Liguori <>

a676968b 10/06/2009 10:36 pm Mark McLoughlin

Remove bogus error message from qemu_opts_set()

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 <>...

2cfa571f 10/06/2009 10:36 pm Mark McLoughlin

Make qemu_opts_parse() handle empty strings

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 <>
Signed-off-by: Anthony Liguori <>

5dc519ef 10/06/2009 10:36 pm Mark McLoughlin

Add qemu_opts_validate() for post parsing validation

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...

dc9ca4ba 10/06/2009 10:36 pm Mark McLoughlin

Never overwrite a QemuOpt

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.
...

1f5c1775 09/26/2009 10:34 pm Juan Quintela

qemu-option: rename bool -> boolean

We need this to allow the use of <stdbool.h>

Signed-off-by: Juan Quintela <>
Acked-by: Gerd Hoffmann <>
Signed-off-by: Aurelien Jarno <>

3df04ac3 09/25/2009 10:57 pm Mark McLoughlin

Fix coding style issue

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...

72cf2d4f 09/12/2009 10:36 am Blue Swirl

Fix sys-queue.h conflict for good

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,...

96729cbd 09/11/2009 06:19 pm Gerd Hoffmann

QemuOpts: split option parser into two functions.

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 <>...

d4c3fddd 09/09/2009 10:57 pm Jean-Christophe DUBOIS

mv from strdup to qemu_strdup in qemu-option.c

one place is using strdup() instead of qemu_strdup

Fix it

Signed-off-by: Jean-Christophe Dubois <>
Signed-off-by: Anthony Liguori <>

6d378185 08/10/2009 09:05 pm Gerd Hoffmann

QemuOpts: qemu_opts_parse: fix id= parsing

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 <>...

48026075 08/10/2009 09:05 pm Gerd Hoffmann

QemuOpts: add some functions

qemu_opt_foreach: loop over all QemuOpts entries.
qemu_opts_id: return QemuOpts id.

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>
Message-Id:

21c9f4cd 07/30/2009 05:50 pm Gerd Hoffmann

qemu-option: fix parse_option_number().

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 <>...

62c5802e 07/27/2009 10:08 pm Gerd Hoffmann

move parser functions from vl.c to qemu-option.c

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

67b1355b 07/27/2009 10:08 pm Gerd Hoffmann

qemu-option: factor out parse_option_bool

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

7695019b 07/27/2009 10:08 pm Gerd Hoffmann

qemu-option: factor out parse_option_size

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

e27c88fe 07/27/2009 10:08 pm Gerd Hoffmann

QemuOpts: framework for storing and parsing options.

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....

db08adf5 06/06/2009 06:38 pm Kevin Wolf

qemu-img: Print available options with -o ?

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 <>

d3f24367 05/22/2009 06:50 pm Kevin Wolf

Create qemu-option.h

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...