sdk/emulator/qemu.git
9 years agomigration: Split save_zero_page from ram_save_page
Liang Li [Mon, 23 Mar 2015 08:32:22 +0000 (16:32 +0800)]
migration: Split save_zero_page from ram_save_page

Split the function save_zero_page from ram_save_page so that we can
reuse it later.

Signed-off-by: Liang Li <liang.z.li@intel.com>
Signed-off-by: Yang Zhang <yang.z.zhang@intel.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
9 years agoarch_init: Add and free data struct for decompression
Liang Li [Mon, 23 Mar 2015 08:32:21 +0000 (16:32 +0800)]
arch_init: Add and free data struct for decompression

Define the data structure and variables used to do multiple thread
decompression, and add the code to initialize and free them.

Signed-off-by: Liang Li <liang.z.li@intel.com>
Signed-off-by: Yang Zhang <yang.z.zhang@intel.com>
Reviewed-by: Dr.David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
9 years agoarch_init: Alloc and free data struct for compression
Liang Li [Mon, 23 Mar 2015 08:32:20 +0000 (16:32 +0800)]
arch_init: Alloc and free data struct for compression

Define the data structure and variables used to do multiple thread
compression, and add the code to initialize and free them.

Signed-off-by: Liang Li <liang.z.li@intel.com>
Signed-off-by: Yang Zhang <yang.z.zhang@intel.com>
Reviewed-by: Dr.David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
9 years agoqemu-file: Add compression functions to QEMUFile
Liang Li [Mon, 23 Mar 2015 08:32:19 +0000 (16:32 +0800)]
qemu-file: Add compression functions to QEMUFile

qemu_put_compression_data() compress the data and put it to QEMUFile.
qemu_put_qemu_file() put the data in the buffer of source QEMUFile to
destination QEMUFile.

Signed-off-by: Liang Li <liang.z.li@intel.com>
Signed-off-by: Yang Zhang <yang.z.zhang@intel.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
9 years agomigration: Add the framework of multi-thread decompression
Liang Li [Mon, 23 Mar 2015 08:32:18 +0000 (16:32 +0800)]
migration: Add the framework of multi-thread decompression

Add the code to create and destroy the multiple threads those will be
used to do data decompression. Left some functions empty just to keep
clearness, and the code will be added later.

Signed-off-by: Liang Li <liang.z.li@intel.com>
Signed-off-by: Yang Zhang <yang.z.zhang@intel.com>
Reviewed-by: Dr.David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
9 years agomigration: Add the framework of multi-thread compression
Liang Li [Mon, 23 Mar 2015 08:32:17 +0000 (16:32 +0800)]
migration: Add the framework of multi-thread compression

Add the code to create and destroy the multiple threads those will
be used to do data compression. Left some functions empty to keep
clearness, and the code will be added later.

Signed-off-by: Liang Li <liang.z.li@intel.com>
Signed-off-by: Yang Zhang <yang.z.zhang@intel.com>
Reviewed-by: Dr.David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
9 years agodocs: Add a doc about multiple thread compression
Liang Li [Mon, 23 Mar 2015 08:32:16 +0000 (16:32 +0800)]
docs: Add a doc about multiple thread compression

Give some details about the multiple thread (de)compression and
how to use it in live migration.

Signed-off-by: Liang Li <liang.z.li@intel.com>
Signed-off-by: Yang Zhang <yang.z.zhang@intel.com>
Reviewed-by: Dr.David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
9 years agoMerge remote-tracking branch 'remotes/rth/tags/tcg-next-20150505' into staging
Peter Maydell [Wed, 6 May 2015 10:16:35 +0000 (11:16 +0100)]
Merge remote-tracking branch 'remotes/rth/tags/tcg-next-20150505' into staging

size reduction merge

# gpg: Signature made Wed May  6 00:21:43 2015 BST using RSA key ID 4DD0279B
# gpg: Good signature from "Richard Henderson <rth7680@gmail.com>"
# gpg:                 aka "Richard Henderson <rth@redhat.com>"
# gpg:                 aka "Richard Henderson <rth@twiddle.net>"

* remotes/rth/tags/tcg-next-20150505:
  tcg: optimise memory layout of TCGTemp

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agoMerge remote-tracking branch 'remotes/armbru/tags/pull-qmp-2015-05-05' into staging
Peter Maydell [Tue, 5 May 2015 17:22:12 +0000 (18:22 +0100)]
Merge remote-tracking branch 'remotes/armbru/tags/pull-qmp-2015-05-05' into staging

drop qapi nested structs

# gpg: Signature made Tue May  5 17:40:40 2015 BST using RSA key ID EB918653
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>"

* remotes/armbru/tags/pull-qmp-2015-05-05: (40 commits)
  qapi: Check for member name conflicts with a base class
  qapi: Support (subset of) \u escapes in strings
  qapi: Tweak doc references to QMP when QGA is also meant
  qapi: Drop dead visitor code related to nested structs
  qapi: Drop support for inline nested types
  qapi: Drop inline nested structs in query-pci
  qapi: Drop inline nested struct in query-version
  qapi: Drop tests for inline nested structs
  qapi: Merge UserDefTwo and UserDefNested in tests
  qapi: Forbid 'type' in schema
  qapi: Use 'struct' instead of 'type' in schema
  qapi: Document 'struct' metatype
  qapi: Prefer 'struct' over 'type' in generator
  qapi: More rigorous checking for type safety bypass
  qapi: Whitelist commands that don't return dictionary
  qapi: Require valid names
  qapi: More rigourous checking of types
  qapi: Add some type check tests
  qapi: Unify type bypass and add tests
  qapi: Allow true, false and null in schema json
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agoqapi: Check for member name conflicts with a base class
Eric Blake [Mon, 4 May 2015 15:05:37 +0000 (09:05 -0600)]
qapi: Check for member name conflicts with a base class

Our type inheritance for both 'struct' and for flat 'union' merges
key/value pairs from the base class with those from the type in
question.  Although the C code currently boxes things so that there
is a distinction between which member is referred to, the QMP wire
format does not allow passing a key more than once in a single
object.  Besides, if we ever change the generated C code to not be
quite so boxy, we'd want to avoid duplicate member names there,
too.

Fix a testsuite entry added in an earlier patch, as well as adding
a couple more tests to ensure we have appropriate coverage.  Ensure
that collisions are detected, regardless of whether there is a
difference in opinion on whether the member name is optional.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Support (subset of) \u escapes in strings
Eric Blake [Mon, 4 May 2015 15:05:36 +0000 (09:05 -0600)]
qapi: Support (subset of) \u escapes in strings

The handling of \ inside QAPI strings was less than ideal, and
really only worked JSON's \/, \\, \", and our extension of \'
(an obvious extension, when you realize we use '' instead of ""
for strings).  For other things, like '\n', it resulted in a
literal 'n' instead of a newline.

Of course, at the moment, we really have no use for escaped
characters, as QAPI has to map to C identifiers, and we currently
support ASCII only for that.  But down the road, we may add
support for default values for string parameters to a command
or struct; if that happens, it would be nice to correctly support
all JSON escape sequences, such as \n or \uXXXX.  This gets us
closer, by supporting Unicode escapes in the ASCII range.

Since JSON does not require \OCTAL or \xXX escapes, and our QMP
implementation does not understand them either, I intentionally
reject it here, but it would be an easy addition if we desired it.
Likewise, intentionally refusing the NUL byte means we don't have
to worry about C strings being shorter than the qapi input.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Tweak doc references to QMP when QGA is also meant
Eric Blake [Mon, 4 May 2015 15:05:35 +0000 (09:05 -0600)]
qapi: Tweak doc references to QMP when QGA is also meant

We have more than one qapi schema in use by more than one protocol.
Add a new term 'Client JSON Protocol' for use throughout the
document, to avoid confusion on whether something refers only to
QMP and not QGA.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Drop dead visitor code related to nested structs
Eric Blake [Mon, 4 May 2015 15:05:34 +0000 (09:05 -0600)]
qapi: Drop dead visitor code related to nested structs

Now that we no longer have nested structs to visit, the use of
prefix strings is no longer required.  Remove the code that is
no longer reachable.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Drop support for inline nested types
Eric Blake [Mon, 4 May 2015 15:05:33 +0000 (09:05 -0600)]
qapi: Drop support for inline nested types

A future patch will be using a 'name':{dictionary} entry in the
QAPI schema to specify a default value for an optional argument
(see previous commit messages for more details why); but existing
use of inline nested structs conflicts with that goal. Now that
all commands have been changed to avoid inline nested structs,
nuke support for them, and turn it into a hard error. Update the
testsuite to reflect tighter parsing rules.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Drop inline nested structs in query-pci
Eric Blake [Mon, 4 May 2015 15:05:32 +0000 (09:05 -0600)]
qapi: Drop inline nested structs in query-pci

A future patch will be using a 'name':{dictionary} entry in the
QAPI schema to specify a default value for an optional argument
(see previous commit message for more details why); but existing
use of inline nested structs conflicts with that goal. This patch
fixes one of only two commands relying on nested types, by
breaking the nesting into an explicit type; it means that the
type is now boxed instead of unboxed in C code, but the QMP wire
format is unaffected by this change.

Prefer the safer g_new0() while making the conversion, and reduce
some long lines.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Drop inline nested struct in query-version
Eric Blake [Mon, 4 May 2015 15:05:31 +0000 (09:05 -0600)]
qapi: Drop inline nested struct in query-version

A future patch will be using a 'name':{dictionary} entry in the
QAPI schema to specify a default value for an optional argument
(see previous commit message for more details why); but existing
use of inline nested structs conflicts with that goal. This patch
fixes one of only two commands relying on nested types, by
breaking the nesting into an explicit type; it means that the
type is now boxed instead of unboxed in C code, but the QMP wire
format is unaffected by this change.

Prefer the safer g_new0() while making the conversion.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Drop tests for inline nested structs
Eric Blake [Mon, 4 May 2015 15:05:30 +0000 (09:05 -0600)]
qapi: Drop tests for inline nested structs

A future patch will be using a 'name':{dictionary} entry in the
QAPI schema to specify a default value for an optional argument;
but existing use of inline nested structs conflicts with that goal.

More precisely, a definition in the QAPI schema associates a name
with a set of properties:

Example 1: { 'struct': 'Foo', 'data': { MEMBERS... } }
associates the global name 'Foo' with properties (meta-type struct)
and MEMBERS...

Example 2: 'mumble': TYPE
within MEMBERS... above associates 'mumble' with properties (type
TYPE) and (optional false) within type Foo

The syntax of example 1 is extensible; if we need another property,
we add another name/value pair to the dictionary (such as
'base':TYPE).  The syntax of example 2 is not extensible, because
the right hand side can only be a type.

We have used name encoding to add a property: "'*mumble': 'int'"
associates 'mumble' with (type int) and (optional true).  Nice,
but doesn't scale.  So the solution is to change our existing uses
to be syntactic sugar to an extensible form:

   NAME: TYPE   --> NAME:  { 'type': TYPE, 'optional': false }
   *ONAME: TYPE --> ONAME: { 'type': TYPE, 'optional': true }

This patch fixes the testsuite to avoid inline nested types, by
breaking the nesting into explicit types; it means that the type
is now boxed instead of unboxed in C code, but makes no difference
on the wire (and if desired, a later patch could change the
generator to not do so much boxing in C).  When touching code to
add new allocations, also convert existing allocations to
consistently prefer typesafe g_new0 over g_malloc0 when a type
name is involved.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Merge UserDefTwo and UserDefNested in tests
Eric Blake [Mon, 4 May 2015 15:05:29 +0000 (09:05 -0600)]
qapi: Merge UserDefTwo and UserDefNested in tests

In the testsuite, UserDefTwo and UserDefNested were identical
structs other than the member names.  Reduce code duplication by
having just one type, and choose names that also favor reuse.
This will also make it easier for a later patch to get rid of
inline nested types in QAPI.  When touching code related to
allocations, convert g_malloc0(sizeof(Type)) to the more typesafe
g_new0(Type, 1).

Ensure that 'make check-qapi-schema check-unit' still passes.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Forbid 'type' in schema
Eric Blake [Mon, 4 May 2015 15:05:28 +0000 (09:05 -0600)]
qapi: Forbid 'type' in schema

Referring to "type" as both a meta-type (built-in, enum, union,
alternate, or struct) and a specific type (the name that the
schema uses for declaring structs) is confusing.  Finish up the
conversion to using "struct" in qapi schema by removing the hack
in the generator that allowed 'type'.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Use 'struct' instead of 'type' in schema
Eric Blake [Mon, 4 May 2015 15:05:27 +0000 (09:05 -0600)]
qapi: Use 'struct' instead of 'type' in schema

Referring to "type" as both a meta-type (built-in, enum, union,
alternate, or struct) and a specific type (the name that the
schema uses for declaring structs) is confusing.  Do the bulk of
the conversion to "struct" in qapi schema, with a fairly
mechanical:

for f in `find -name '*.json'; do sed -i "s/'type'/'struct'/"; done

followed by manually filtering out the places where we have a
'type' embedded in 'data'.  Then tweak a couple of tests whose
output changes slightly due to longer lines.

I also verified that the generated files for QMP and QGA (such
as qmp-commands.h) are the same before and after, as assurance
that I didn't leave in any accidental member name changes.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Document 'struct' metatype
Eric Blake [Mon, 4 May 2015 15:05:26 +0000 (09:05 -0600)]
qapi: Document 'struct' metatype

Referring to "type" as both a meta-type (built-in, enum, union,
alternate, or struct) and a specific type (the name that the
schema uses for declaring structs) is confusing.  Now that the
generator accepts 'struct' as a synonym for 'type', update all
documentation to use saner wording.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Prefer 'struct' over 'type' in generator
Eric Blake [Mon, 4 May 2015 15:05:25 +0000 (09:05 -0600)]
qapi: Prefer 'struct' over 'type' in generator

Referring to "type" as both a meta-type (built-in, enum, union,
alternate, or struct) and a specific type (the name that the
schema uses for declaring structs) is confusing.  The confusion
is only made worse by the fact that the generator mostly already
refers to struct even when dealing with expr['type'].  This
commit changes the generator to consistently refer to it as
struct everywhere, plus a single back-compat tweak that allows
accepting the existing .json files as-is, so that the meat of
this change is separate from the mindless churn of that change.

Fix the testsuite fallout for error messages that change, and
in some cases, become more legible.  Improve comments to better
match our intentions where a struct (rather than any complex
type) is required.  Note that in some cases, an error message
now refers to 'struct' while the schema still refers to 'type';
that will be cleaned up in the later commit to the schema.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: More rigorous checking for type safety bypass
Eric Blake [Mon, 4 May 2015 15:05:24 +0000 (09:05 -0600)]
qapi: More rigorous checking for type safety bypass

Now that we have a way to validate every type, we can also be
stricter about enforcing that callers that want to bypass
type safety in generated code.  Prior to this patch, it didn't
matter what value was associated with the key 'gen', but it
looked odd that 'gen':'yes' could result in bypassing the
generated code.  These changes also enforce the changes made
earlier in the series for documentation and consolidation of
using '**' as the wildcard type, as well as 'gen':false as the
canonical spelling for requesting type bypass.

Note that 'gen':false is a one-way switch away from the default;
we do not support 'gen':true (similar for 'success-response').
In practice, this doesn't matter.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Whitelist commands that don't return dictionary
Eric Blake [Mon, 4 May 2015 15:05:23 +0000 (09:05 -0600)]
qapi: Whitelist commands that don't return dictionary

...or an array of dictionaries.  Although we have to cater to
existing commands, returning a non-dictionary means the command
is not extensible (no new name/value pairs can be added if more
information must be returned in parallel).  By making the
whitelist explicit, any new command that falls foul of this
practice will have to be self-documenting, which will encourage
developers to either justify the action or rework the design to
use a dictionary after all.

It's a little bit sloppy that we share a single whitelist among
three clients (it's too permissive for each).  If this is a
problem, a future patch could tighten things by having the
generator take the whitelist as an argument (as in
scripts/qapi-commands.py --legacy-returns=...), or by having
the generator output C code that requires explicit use of the
whitelist (as in:
 #ifndef FROBNICATE_LEGACY_RETURN_OK
 # error Command 'frobnicate' should return a dictionary
 #endif
then having the callers define appropriate macros).  But until
we need such fine-grained separation (if ever), this patch does
the job just fine.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Require valid names
Eric Blake [Mon, 4 May 2015 15:05:22 +0000 (09:05 -0600)]
qapi: Require valid names

Previous commits demonstrated that the generator overlooked various
bad naming situations:
- types, commands, and events need a valid name
- enum members must be valid names, when combined with prefix
- union and alternate branches cannot be marked optional

Valid upstream names match [a-zA-Z][a-zA-Z0-9_-]*; valid downstream
names match __[a-zA-Z][a-zA-Z0-9._-]*.  Enumerations match the
weaker [a-zA-Z0-9._-]+ (in part thanks to QKeyCode picking an enum
that starts with a digit, which we can't change now due to
backwards compatibility).  Rather than call out three separate
regex, this patch just uses a broader combination that allows both
upstream and downstream names, as well as a small hack that
realizes that any enum name is merely a suffix to an already valid
name prefix (that is, any enum name is valid if prepending _ fits
the normal rules).

We could reject new enumeration names beginning with a digit by
whitelisting existing exceptions.  We could also be stricter
about the distinction between upstream names (no leading
underscore, no use of dot) and downstream (mandatory leading
double underscore), but it is probably not worth the bother.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: More rigourous checking of types
Eric Blake [Mon, 4 May 2015 15:05:21 +0000 (09:05 -0600)]
qapi: More rigourous checking of types

Now that we know every expression is valid with regards to
its keys, we can add further tests that those keys refer to
valid types.  With this patch, all uses of a type (the 'data':
of command, type, union, alternate, and event; the 'returns':
of command; the 'base': of type and union) must resolve to an
appropriate subset of metatypes  declared by the current qapi
parse; this includes recursing into each member of a data
dictionary.  Dealing with '**' and nested anonymous structs
will be done in later patches.

Update the testsuite to match improved output.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Add some type check tests
Eric Blake [Mon, 4 May 2015 15:05:20 +0000 (09:05 -0600)]
qapi: Add some type check tests

Demonstrate that the qapi generator silently parses confusing
types, which may cause other errors later on. Later patches
will update the expected results as the generator is made stricter.

Most of the new tests focus on blatant errors.  But
returns-whitelist is a case where we have historically allowed
returning something other than a JSON object from particular
commands; we have to keep that behavior to avoid breaking clients,
but it would be nicer to avoid adding such commands in the future,
because any return that is not an (array of) object cannot be
easily extended if future qemu wants to return additional
information.  The QMP protocol already documents that clients
should ignore unknown dictionary keys, but does not require
clients to have to handle more than one type of JSON object.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Unify type bypass and add tests
Eric Blake [Mon, 4 May 2015 15:05:19 +0000 (09:05 -0600)]
qapi: Unify type bypass and add tests

For a few QMP commands, we are forced to pass an arbitrary type
without tracking it properly in QAPI.  Among the existing clients,
this unnamed type was spelled 'dict', 'visitor', and '**'; this
patch standardizes on '**', matching the documentation changes
earlier in the series.

Meanwhile, for the 'gen' key, we have been ignoring the value,
although the schema consistently used "'no'" ('success-response'
was hard-coded to checking for 'no').  But now that we can support
a literal "false" in the schema, we might as well use that rather
than ignoring the value or special-casing a random string.  Note
that these are one-way switches (use of 'gen':true is not the same
as omitting 'gen'). Also, the use of '**' requires 'gen':false,
but the use of 'gen':false does not mandate the use of '**'.

There is no difference to the generated code.  Add some tests on
what we'd like to guarantee, although it will take later patches
to clean up test results and actually enforce the use of a bool
parameter.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Allow true, false and null in schema json
Fam Zheng [Mon, 4 May 2015 15:05:18 +0000 (09:05 -0600)]
qapi: Allow true, false and null in schema json

In the near term, we will use it for a sensible-looking
'gen':false inside command declarations, instead of the
current ugly 'gen':'no'.

In the long term, it will allow conversion from shorthand
with defaults mentioned only in side-band documentation:
 'data':{'*flag':'bool', '*string':'str'}
into an explicit default value documentation, as in:
 'data':{'flag':{'type':'bool', 'optional':true, 'default':true},
         'string':{'type':'str', 'optional':true, 'default':null}}

We still don't parse integer values (also necessary before
we can allow explicit defaults), but that can come in a later
series.

Update the testsuite to match an improved error message.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Better error messages for duplicated expressions
Eric Blake [Mon, 4 May 2015 15:05:17 +0000 (09:05 -0600)]
qapi: Better error messages for duplicated expressions

The previous commit demonstrated that the generator overlooked
duplicate expressions:
- a complex type or command reusing a built-in type name
- redeclaration of a type name, whether by the same or different
metatype
- redeclaration of a command or event
- collision of a type with implicit 'Kind' enum for a union
- collision with an implicit MAX enum constant

Since the c_type() function in the generator treats all names
as being in the same namespace, this patch adds a global array
to track all known names and their source, to prevent collisions
before it can cause further problems.  While valid .json files
won't trigger any of these cases, we might as well be nicer to
developers that make a typo while trying to add new QAPI code.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Add tests of redefined expressions
Eric Blake [Mon, 4 May 2015 15:05:16 +0000 (09:05 -0600)]
qapi: Add tests of redefined expressions

Demonstrate that the qapi generator doesn't deal very well with
redefined expressions.  At the parse level, they are silently
accepted; and while the testsuite just stops at parsing, I've
further tested that many of them cause generator crashes or
invalid C code if they were appended to qapi-schema-test.json.
A later patch will tighten things up and adjust the testsuite
to match.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Better error messages for bad expressions
Eric Blake [Mon, 4 May 2015 15:05:15 +0000 (09:05 -0600)]
qapi: Better error messages for bad expressions

The previous commit demonstrated that the generator overlooked some
fairly basic broken expressions:
- missing metataype
- metatype key has a non-string value
- unknown key in relation to the metatype
- conflicting metatype (this patch treats the second metatype as an
unknown key of the first key visited, which is not necessarily the
first key the user typed)

Add check_keys to cover these situations, and update testcases to
match.  A couple other tests (enum-missing-data, indented-expr) had
to change since the validation added here occurs so early.
Conversely, changes to ident-with-escape results show that we still
have problems where our handling of escape sequences differs from
true JSON, which will matter down the road if we allow arbitrary
default string values for optional parameters (but for now is not
too bad, as we currently can avoid unicode escaping as we don't
need to represent anything beyond C identifier material).

While valid .json files won't trigger any of these cases, we might
as well be nicer to developers that make a typo while trying to add
new QAPI code.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Add some expr tests
Eric Blake [Mon, 4 May 2015 15:05:14 +0000 (09:05 -0600)]
qapi: Add some expr tests

Demonstrate that the qapi generator doesn't deal well with
expressions that aren't up to par. Later patches will improve
the expected results as the generator is made stricter.  Only
a few of the the added tests actually behave sanely at
rejecting obvious problems or demonstrating success.

Note that in some cases, we reject bad QAPI merely because our
pseudo-JSON parser does not yet know how to parse numbers.  This
series does not address that, but when a later series adds support
for numeric defaults of integer fields, the testsuite will ensure
that we don't lose the error (and hopefully that the error
message quality is improved).

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Use 'alternate' to replace anonymous union
Eric Blake [Mon, 4 May 2015 15:05:13 +0000 (09:05 -0600)]
qapi: Use 'alternate' to replace anonymous union

Previous patches have led up to the point where I create the
new meta-type "'alternate':'Foo'".  See the previous patches
for documentation; I intentionally split as much work into
earlier patches to minimize the size of this patch, but a lot
of it is churn due to testsuite fallout after updating to the
new type.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Document new 'alternate' meta-type
Eric Blake [Mon, 4 May 2015 15:05:12 +0000 (09:05 -0600)]
qapi: Document new 'alternate' meta-type

The next patch will quit special-casing "'union':'Foo',
'discriminator':{}" and instead use "'alternate':'Foo'".

Separating docs from implementation makes it easier to focus
on wording without holding up code.  In particular, making
alternate a separate type makes for a nice type hierarchy:

          /-------- meta-type ------\
         /              |            \
    simple types    alternate     complex types
    |         |                   |           |
 built-in   enum             type(struct)   union
 |       \    /                            /    \
numeric  string                         simple  flat

A later patch will then clean up 'type' vs. 'struct'
confusion.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Rename anonymous union type in test
Eric Blake [Mon, 4 May 2015 15:05:11 +0000 (09:05 -0600)]
qapi: Rename anonymous union type in test

Reduce churn in the future patch that replaces anonymous unions
with a new metatype 'alternate' by changing 'AnonUnion' to
'Alternate'.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Segregate anonymous unions into alternates in generator
Eric Blake [Mon, 4 May 2015 15:05:10 +0000 (09:05 -0600)]
qapi: Segregate anonymous unions into alternates in generator

Special-casing 'discriminator == {}' for handling anonymous unions
is getting awkward; since this particular type is not always a
dictionary on the wire, it is easier to treat it as a completely
different class of type, "alternate", so that if a type is listed
in the union_types array, we know it is not an anonymous union.

This patch just further segregates union handling, to make sure that
anonymous unions are not stored in union_types, and splitting up
check_union() into separate functions.  A future patch will change
the qapi grammar, and having the segregation already in place will
make it easier to deal with the distinct meta-type.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Prepare for catching more semantic parse errors
Eric Blake [Mon, 4 May 2015 15:05:09 +0000 (09:05 -0600)]
qapi: Prepare for catching more semantic parse errors

This patch widens the scope of a try block (with the attending
reindentation required by Python) in preparation for a future
patch adding more instances of QAPIExprError inside the block.
It's easier to separate indentation from semantic changes, so
this patch has no real behavior change.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Tighten checking of unions
Eric Blake [Mon, 4 May 2015 15:05:08 +0000 (09:05 -0600)]
qapi: Tighten checking of unions

Previous commits demonstrated that the generator had several
flaws with less-than-perfect unions:
- a simple union that listed the same branch twice (or two variant
names that map to the same C enumerator, including the implicit
MAX sentinel) ended up generating invalid C code
- an anonymous union that listed two branches with the same qtype
ended up generating invalid C code
- the generator crashed on anonymous union attempts to use an
array type
- the generator was silently ignoring a base type for anonymous
unions
- the generator allowed unknown types or nested anonymous unions
as a branch in an anonymous union

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Forbid base without discriminator in unions
Eric Blake [Mon, 4 May 2015 15:05:07 +0000 (09:05 -0600)]
qapi: Forbid base without discriminator in unions

None of the existing QMP or QGA interfaces uses a union with a
base type but no discriminator; it is easier to avoid this in the
generator to save room for other future extensions more likely to
be useful.  An earlier commit added a union-base-no-discriminator
test to ensure that we eventually give a decent error message;
likewise, removing UserDefUnion outright is okay, because we moved
all the tests we wish to keep into the tests of the simple union
UserDefNativeListUnion in the previous commit.  Now is the time to
actually forbid simple union with base, and remove the last
vestiges from the testsuite.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Clean up test coverage of simple unions
Eric Blake [Mon, 4 May 2015 15:05:06 +0000 (09:05 -0600)]
qapi: Clean up test coverage of simple unions

The tests of UserDefNativeListUnion serve to validate code
generation of simple unions without a base type, except that it
did not have full coverage in the strict test.  The next commits
will remove tests and support for simple unions with a base type,
so there is no real loss at repurposing that test here as
opposed to churn of adding a new test then deleting the old one.

Fix some indentation and long lines while at it.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Add some union tests
Eric Blake [Mon, 4 May 2015 15:05:05 +0000 (09:05 -0600)]
qapi: Add some union tests

Demonstrate that the qapi generator doesn't deal well with unions
that aren't up to par. Later patches will update the expected
reseults as the generator is made stricter.  A few tests work
as planned, but most show poor or missing error messages.

Of particular note, qapi-code-gen.txt documents 'base' only for
flat unions, but the tests here demonstrate that we currently allow
a 'base' to a simple union, although it is exercised only in the
testsuite.  Later patches will remove this undocumented feature, to
give us more flexibility in adding other future extensions to union
types.  For example, one possible extension is the idea of a
type-safe simple enum, where added fields tie the discriminator to
a user-defined enum type rather than creating an implicit enum from
the names in 'data'.  But adding such safety on top of a simple
enum with a base type could look ambiguous with a flat enum;
besides, the documentation also mentions how any simple union can
be represented by an equivalent flat union.  So it will be simpler
to just outlaw support for something we aren't using.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Better error messages for bad enums
Eric Blake [Mon, 4 May 2015 15:05:04 +0000 (09:05 -0600)]
qapi: Better error messages for bad enums

The previous commit demonstrated that the generator had several
flaws with less-than-perfect enums:
- an enum that listed the same string twice (or two variant
strings that map to the same C enumerator) ended up generating
an invalid C enum
- because the generator adds a _MAX terminator to each enum,
the use of an enum member 'max' can also cause this clash
- if an enum omits 'data', the generator left a python stack
trace rather than a graceful message
- an enum that used a non-array 'data' was silently accepted by
the parser
- an enum that used non-string members in the 'data' member
was silently accepted by the parser

Add check_enum to cover these situations, and update testcases
to match.  While valid .json files won't trigger any of these
cases, we might as well be nicer to developers that make a typo
while trying to add new QAPI code.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Add some enum tests
Eric Blake [Mon, 4 May 2015 15:05:03 +0000 (09:05 -0600)]
qapi: Add some enum tests

Demonstrate that the qapi generator doesn't deal well with enums
that aren't up to par. Later patches will update the expected
results as the generator is made stricter.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Require ASCII in schema
Eric Blake [Mon, 4 May 2015 15:05:02 +0000 (09:05 -0600)]
qapi: Require ASCII in schema

Python 2 and Python 3 have a wild history of whether strings
default to ascii or unicode, where Python 3 requires checking
isinstance(foo, basestr) to cover all strings, but where that
code is not portable to Python 2.  It's simpler to just state
that we don't care about Unicode strings, and to just always
use the simpler isinstance(foo, str) everywhere.

I'm no python expert, so I'm basing it on this conversation:
https://lists.gnu.org/archive/html/qemu-devel/2014-09/msg05278.html

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Fix generation of 'size' builtin type
Eric Blake [Mon, 4 May 2015 15:05:01 +0000 (09:05 -0600)]
qapi: Fix generation of 'size' builtin type

We were missing the 'size' builtin type (which means that QAPI using
[ 'size' ] would fail to compile).

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Simplify builtin type handling
Eric Blake [Mon, 4 May 2015 15:05:00 +0000 (09:05 -0600)]
qapi: Simplify builtin type handling

There was some redundancy between builtin_types[] and
builtin_type_qtypes{}.  Merge them into one.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Document type-safety considerations
Eric Blake [Mon, 4 May 2015 15:04:59 +0000 (09:04 -0600)]
qapi: Document type-safety considerations

Go into more details about the various types of valid expressions
in a qapi schema, including tweaks to document fixes being done
later in the current patch series.  Also fix some stale and missing
documentation in the QMP specification.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoqapi: Add copyright declaration on docs
Eric Blake [Mon, 4 May 2015 15:04:58 +0000 (09:04 -0600)]
qapi: Add copyright declaration on docs

While our top-level COPYING with its GPLv2+ license applies to
any documentation file that omits explicit instructions, these
days it's better to be a good example of calling out our
intentions.  Correct use of GPL requires the use of a copyright
statement, so I'm adding notice to two QAPI documents, by
attributing these files to the initial authors and major
contributors.  I used:

$ git blame --line-porcelain $file \
  | sed -n 's/^author //p' | sort | uniq -c | sort -rn

to determine authorship of these two files.  qmp-spec.txt blames
entirely to Red Hat (easy, since my contribution falls in that
category); while qapi-code-gen.txt has multiple contributors
representing multiple entities.  But since it was originally
supplied by Michael Roth, the notice I added there copies the
notice he has used in other files.  As there is no intended
change in license from the implicit one previously present from
the top level, I have not bothered to CC other contributors;
if we want to weaken things to something looser (such as LGPL)
so that there is no question that someone re-implementing the
spec is not forced to use GPL, that would be a different commit.

CC: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agotcg: optimise memory layout of TCGTemp
Emilio G. Cota [Fri, 3 Apr 2015 00:07:53 +0000 (20:07 -0400)]
tcg: optimise memory layout of TCGTemp

This brings down the size of the struct from 56 to 32 bytes on 64-bit,
and to 20 bytes on 32-bit. This leads to memory savings:

Before:
$ find . -name 'tcg.o' | xargs size
   text    data     bss     dec     hex filename
  41131   29800      88   71019   1156b ./aarch64-softmmu/tcg/tcg.o
  37969   29416      96   67481   10799 ./x86_64-linux-user/tcg/tcg.o
  39354   28816      96   68266   10aaa ./arm-linux-user/tcg/tcg.o
  40802   29096      88   69986   11162 ./arm-softmmu/tcg/tcg.o
  39417   29672      88   69177   10e39 ./x86_64-softmmu/tcg/tcg.o

After:
$ find . -name 'tcg.o' | xargs size
   text    data     bss     dec     hex filename
  40883   29800      88   70771   11473 ./aarch64-softmmu/tcg/tcg.o
  37473   29416      96   66985   105a9 ./x86_64-linux-user/tcg/tcg.o
  38858   28816      96   67770   108ba ./arm-linux-user/tcg/tcg.o
  40554   29096      88   69738   1106a ./arm-softmmu/tcg/tcg.o
  39169   29672      88   68929   10d41 ./x86_64-softmmu/tcg/tcg.o

Note that using an entire byte for some enums that need less than
that wastes a few bits (noticeable in 32 bits, where we use
20 bytes instead of 16) but avoids extraction code, which overall
is a win--I've tested several variations of the patch, and the appended
is the best performer for OpenSSL's bntest by a very small margin:

Before:
$ taskset -c 0 perf stat -r 15 -- x86_64-linux-user/qemu-x86_64 img/bntest-x86_64 >/dev/null
[...]
 Performance counter stats for 'x86_64-linux-user/qemu-x86_64 img/bntest-x86_64' (15 runs):

      10538.479833 task-clock (msec)  # 0.999 CPUs utilized  ( +-  0.38% )
               772 context-switches   # 0.073 K/sec          ( +-  2.03% )
                 0 cpu-migrations     # 0.000 K/sec          ( +-100.00% )
             2,207 page-faults        # 0.209 K/sec          ( +-  0.08% )
      10.552871687 seconds time elapsed                      ( +-  0.39% )

After:
$ taskset -c 0 perf stat -r 15 -- x86_64-linux-user/qemu-x86_64 img/bntest-x86_64 >/dev/null
 Performance counter stats for 'x86_64-linux-user/qemu-x86_64 img/bntest-x86_64' (15 runs):

      10459.968847 task-clock (msec)  # 0.999 CPUs utilized  ( +-  0.30% )
               739 context-switches   # 0.071 K/sec          ( +-  1.71% )
                 0 cpu-migrations     # 0.000 K/sec          ( +- 68.14% )
             2,204 page-faults        # 0.211 K/sec          ( +-  0.10% )
      10.473900411 seconds time elapsed                      ( +-  0.30% )

Suggested-by: Stefan Weil <sw@weilnetz.de>
Suggested-by: Richard Henderson <rth@twiddle.net>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
9 years agoMerge remote-tracking branch 'remotes/kraxel/tags/pull-sdl-20150505-1' into staging
Peter Maydell [Tue, 5 May 2015 13:06:12 +0000 (14:06 +0100)]
Merge remote-tracking branch 'remotes/kraxel/tags/pull-sdl-20150505-1' into staging

sdl2: add opengl support

# gpg: Signature made Tue May  5 10:36:25 2015 BST using RSA key ID D3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"

* remotes/kraxel/tags/pull-sdl-20150505-1:
  sdl2: Fix RGB555
  sdl2: add support for display rendering using opengl.
  sdl2: move SDL_* includes to sdl2.h
  console-gl: add opengl rendering helper functions
  opengl: add shader helper functions.
  opengl: add shader build infrastructure

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agoMerge remote-tracking branch 'remotes/armbru/tags/pull-cov-model-2015-05-05' into...
Peter Maydell [Tue, 5 May 2015 09:23:22 +0000 (10:23 +0100)]
Merge remote-tracking branch 'remotes/armbru/tags/pull-cov-model-2015-05-05' into staging

coverity: fix address_space_rw model

# gpg: Signature made Tue May  5 09:44:26 2015 BST using RSA key ID EB918653
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>"

* remotes/armbru/tags/pull-cov-model-2015-05-05:
  coverity: fix address_space_rw model

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agosdl2: Fix RGB555
Max Reitz [Tue, 3 Mar 2015 17:25:27 +0000 (12:25 -0500)]
sdl2: Fix RGB555

Reproducable with:

$ x86_64-softmmu/qemu-system-x86_64 \
    -kernel $vmlinuz_of_your_choice \
    -append vga=0x313 -sdl

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agosdl2: add support for display rendering using opengl.
Gerd Hoffmann [Tue, 11 Nov 2014 15:54:45 +0000 (16:54 +0100)]
sdl2: add support for display rendering using opengl.

Add new sdl2-gl.c file, with display
rendering functions using opengl.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
9 years agosdl2: move SDL_* includes to sdl2.h
Gerd Hoffmann [Wed, 19 Nov 2014 13:19:49 +0000 (14:19 +0100)]
sdl2: move SDL_* includes to sdl2.h

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
9 years agoconsole-gl: add opengl rendering helper functions
Gerd Hoffmann [Fri, 9 Jan 2015 10:40:23 +0000 (11:40 +0100)]
console-gl: add opengl rendering helper functions

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
9 years agoopengl: add shader helper functions.
Gerd Hoffmann [Fri, 24 Apr 2015 05:48:45 +0000 (07:48 +0200)]
opengl: add shader helper functions.

Helper functions to compile, link and run opengl shader programs.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agocoverity: fix address_space_rw model
Paolo Bonzini [Mon, 4 May 2015 12:18:09 +0000 (14:18 +0200)]
coverity: fix address_space_rw model

If the is_write argument is true, address_space_rw writes to memory
and thus reads from the buffer.  The opposite holds if is_write is
false.  Fix the model.

Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9 years agoopengl: add shader build infrastructure
Gerd Hoffmann [Fri, 16 Jan 2015 12:59:17 +0000 (13:59 +0100)]
opengl: add shader build infrastructure

perl script to transform shader programs into c include files with
static string constands containing the shader programs, so we can
easily embed them into qemu.  Also some Makefile logic for them.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
9 years agoMerge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Peter Maydell [Thu, 30 Apr 2015 19:34:54 +0000 (20:34 +0100)]
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging

Block patches

# gpg: Signature made Thu Apr 30 19:51:16 2015 BST using RSA key ID C88F2FD6
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>"

* remotes/kevin/tags/for-upstream:
  Enable NVMe start controller for Windows guest.
  MAINTAINERS: Add qemu-block list where missing
  MAINTAINERS: make block layer core Kevin Wolf's responsibility
  MAINTAINERS: make image fuzzer Stefan Hajnoczi's responsibility
  MAINTAINERS: make block I/O path Stefan Hajnoczi's responsibility
  MAINTAINERS: split out image formats
  MAINTAINERS: make virtio-blk Stefan Hajnoczi's responsibility

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agoMerge remote-tracking branch 'remotes/mjt/tags/pull-trivial-patches-2015-04-30' into...
Peter Maydell [Thu, 30 Apr 2015 14:18:30 +0000 (15:18 +0100)]
Merge remote-tracking branch 'remotes/mjt/tags/pull-trivial-patches-2015-04-30' into staging

trivial patches for 2015-04-30

# gpg: Signature made Thu Apr 30 14:07:50 2015 BST using RSA key ID A4C3D7DB
# gpg: Good signature from "Michael Tokarev <mjt@tls.msk.ru>"
# gpg:                 aka "Michael Tokarev <mjt@corpit.ru>"
# gpg:                 aka "Michael Tokarev <mjt@debian.org>"

* remotes/mjt/tags/pull-trivial-patches-2015-04-30: (42 commits)
  openrisc: cpu: Remove unused cpu_get_pc
  microblaze: fix memory leak
  tcg: Delete unused cpu_pc_from_tb()
  kvm: Silence warning from valgrind
  vhost-user: remove superfluous '\n' around error_report()
  target-mips: fix memory leak
  qmp-commands: Fix typo
  linux-user/elfload: use QTAILQ_FOREACH instead of open-coding it
  coroutine: remove unnecessary parentheses in qemu_co_queue_empty
  qemu-char: remove unused list node from FDCharDriver
  input: remove unused mouse_handlers list
  cpus: use first_cpu macro instead of QTAILQ_FIRST(&cpus)
  microblaze: cpu: delete unused cpu_interrupts_enabled
  microblaze: cpu: Renumber EXCP_* constants to close gap
  microblaze: cpu: Delete EXCP_NMI
  microblaze: cpu: Remove unused CC_OP enum
  microblaze: cpu: Remote unused cpu_get_pc
  microblaze: mmu: Delete flip_um fn prototype
  defconfigs: Piggyback microblazeel on microblaze
  libcacard: do not use full paths for include files in the same dir
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agoEnable NVMe start controller for Windows guest.
Daniel Stekloff [Fri, 24 Apr 2015 18:55:42 +0000 (11:55 -0700)]
Enable NVMe start controller for Windows guest.

Windows seems to send two separate calls to NVMe controller configuration. The
first sends configuration info and the second the enable bit. I couldn't
enable the Windows 8.1 in-box NVMe driver with base Qemu. I made the
following change to store the configuration data and then handle enable and
NVMe driver works on Windows 8.1.

I am not a Windows expert and I'm not entirely sure this is the correct
approach. I'm offering it for anyone who wishes to use NVMe on Windows 8.1
using Qemu.

I have tested this change with Linux and Windows guests with NVMe devices.

Signed-off-by: Daniel Stekloff <dan@wendan.org>
Acked-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9 years agoMerge remote-tracking branch 'remotes/cohuck/tags/s390x-20150430' into staging
Peter Maydell [Thu, 30 Apr 2015 13:15:56 +0000 (14:15 +0100)]
Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20150430' into staging

First pile of s390x patches for 2.4, including:
- some cleanup patches
- sort most of the s390x devices into categories
- support for the new STSI post handler, used to insert vm name and
  friends
- support for the new MEM_OP ioctl (including access register mode)
  for accessing guest memory

# gpg: Signature made Thu Apr 30 12:56:58 2015 BST using RSA key ID C6F02FAF
# gpg: Good signature from "Cornelia Huck <huckc@linux.vnet.ibm.com>"
# gpg:                 aka "Cornelia Huck <cornelia.huck@de.ibm.com>"

* remotes/cohuck/tags/s390x-20150430:
  kvm: better advice for failed s390x startup
  s390x/kvm: Support access register mode for KVM_S390_MEM_OP ioctl
  s390x/mmu: Use ioctl for reading and writing from/to guest memory
  s390x/kvm: Put vm name, extended name and UUID into STSI322 SYSIB
  linux-headers: update
  s390x/mmu: Use access type definitions instead of magic values
  s390x/ipl: sort into categories
  sclp: sort into categories
  s390-virtio: sort into categories
  virtio-ccw: sort into categories

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agoMAINTAINERS: Add qemu-block list where missing
Kevin Wolf [Thu, 30 Apr 2015 13:15:13 +0000 (15:15 +0200)]
MAINTAINERS: Add qemu-block list where missing

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9 years agoMAINTAINERS: make block layer core Kevin Wolf's responsibility
Stefan Hajnoczi [Wed, 29 Apr 2015 14:13:29 +0000 (15:13 +0100)]
MAINTAINERS: make block layer core Kevin Wolf's responsibility

Kevin is now sole maintainer of the core block layer, including
BlockDriverState graphs and monitor commands.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9 years agoMAINTAINERS: make image fuzzer Stefan Hajnoczi's responsibility
Stefan Hajnoczi [Wed, 29 Apr 2015 14:13:28 +0000 (15:13 +0100)]
MAINTAINERS: make image fuzzer Stefan Hajnoczi's responsibility

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9 years agoMAINTAINERS: make block I/O path Stefan Hajnoczi's responsibility
Stefan Hajnoczi [Wed, 29 Apr 2015 14:13:27 +0000 (15:13 +0100)]
MAINTAINERS: make block I/O path Stefan Hajnoczi's responsibility

The block I/O path includes the asynchronous I/O machinery and
read/write/flush/discard processing.  It somewhat arbitrarily also
includes block migration, which I've found myself reviewing patches for
over the years.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9 years agoMAINTAINERS: split out image formats
Stefan Hajnoczi [Wed, 29 Apr 2015 14:13:26 +0000 (15:13 +0100)]
MAINTAINERS: split out image formats

Block driver submaintainers has proven to be a good model.  Kevin and
Stefan are splitting up the unclaimed block drivers so each has a
dedicated maintainer.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9 years agoMAINTAINERS: make virtio-blk Stefan Hajnoczi's responsibility
Stefan Hajnoczi [Wed, 29 Apr 2015 14:13:25 +0000 (15:13 +0100)]
MAINTAINERS: make virtio-blk Stefan Hajnoczi's responsibility

Cc: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9 years agoopenrisc: cpu: Remove unused cpu_get_pc
Peter Crosthwaite [Thu, 30 Apr 2015 07:38:52 +0000 (00:38 -0700)]
openrisc: cpu: Remove unused cpu_get_pc

This function is not used by anything. Remove.

Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agomicroblaze: fix memory leak
Gonglei [Thu, 5 Mar 2015 03:05:20 +0000 (11:05 +0800)]
microblaze: fix memory leak

When not assign a -dtb argument, the variable dtb_filename
storage returned from qemu_find_file(), which should be freed
after use. Alternatively we define a local variable filename,
with 'char *' type, free after use.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agotcg: Delete unused cpu_pc_from_tb()
Peter Crosthwaite [Wed, 29 Apr 2015 07:52:21 +0000 (00:52 -0700)]
tcg: Delete unused cpu_pc_from_tb()

No code uses the cpu_pc_from_tb() function. Delete from tricore and
arm which each provide an unused implementation. Update the comment
in tcg.h to reflect that this is obsoleted by synchronize_from_tb.

Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agokvm: Silence warning from valgrind
Thomas Huth [Mon, 27 Apr 2015 16:59:04 +0000 (18:59 +0200)]
kvm: Silence warning from valgrind

valgrind complains here about uninitialized bytes with the following message:

==17814== Syscall param ioctl(generic) points to uninitialised byte(s)
==17814==    at 0x466A780: ioctl (in /usr/lib64/power8/libc-2.17.so)
==17814==    by 0x100735B7: kvm_vm_ioctl (kvm-all.c:1920)
==17814==    by 0x10074583: kvm_set_ioeventfd_mmio (kvm-all.c:574)

Let's fix it by using a proper struct initializer in kvm_set_ioeventfd_mmio().

Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agovhost-user: remove superfluous '\n' around error_report()
Gonglei [Tue, 28 Apr 2015 09:11:04 +0000 (17:11 +0800)]
vhost-user: remove superfluous '\n' around error_report()

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agotarget-mips: fix memory leak
Gonglei [Tue, 28 Apr 2015 09:11:02 +0000 (17:11 +0800)]
target-mips: fix memory leak

Coveristy reports that variable prom_buf/params_buf going
out of scope leaks the storage it points to.

Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Leon Alrae <leon.alrae@imgtec.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agoqmp-commands: Fix typo
John Snow [Tue, 28 Apr 2015 19:20:41 +0000 (15:20 -0400)]
qmp-commands: Fix typo

Just a trivial patch to correct a QMP example in qmp-commands.hx.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agolinux-user/elfload: use QTAILQ_FOREACH instead of open-coding it
Emilio G. Cota [Mon, 27 Apr 2015 16:45:33 +0000 (12:45 -0400)]
linux-user/elfload: use QTAILQ_FOREACH instead of open-coding it

Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agocoroutine: remove unnecessary parentheses in qemu_co_queue_empty
Emilio G. Cota [Mon, 27 Apr 2015 16:45:32 +0000 (12:45 -0400)]
coroutine: remove unnecessary parentheses in qemu_co_queue_empty

Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agoqemu-char: remove unused list node from FDCharDriver
Emilio G. Cota [Mon, 27 Apr 2015 16:45:30 +0000 (12:45 -0400)]
qemu-char: remove unused list node from FDCharDriver

Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agoinput: remove unused mouse_handlers list
Emilio G. Cota [Mon, 27 Apr 2015 16:45:29 +0000 (12:45 -0400)]
input: remove unused mouse_handlers list

Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agocpus: use first_cpu macro instead of QTAILQ_FIRST(&cpus)
Emilio G. Cota [Mon, 27 Apr 2015 16:45:28 +0000 (12:45 -0400)]
cpus: use first_cpu macro instead of QTAILQ_FIRST(&cpus)

Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agomicroblaze: cpu: delete unused cpu_interrupts_enabled
Peter Crosthwaite [Sun, 26 Apr 2015 19:10:24 +0000 (12:10 -0700)]
microblaze: cpu: delete unused cpu_interrupts_enabled

This function is unused. Remove.

Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agomicroblaze: cpu: Renumber EXCP_* constants to close gap
Michael Tokarev [Wed, 29 Apr 2015 05:34:29 +0000 (08:34 +0300)]
microblaze: cpu: Renumber EXCP_* constants to close gap

After removal of EXCP_NMI there's a gap in EXCP_*
numbering. Let's remove it.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
9 years agomicroblaze: cpu: Delete EXCP_NMI
Peter Crosthwaite [Sun, 26 Apr 2015 19:10:23 +0000 (12:10 -0700)]
microblaze: cpu: Delete EXCP_NMI

This define is unused. Remove.

Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agomicroblaze: cpu: Remove unused CC_OP enum
Peter Crosthwaite [Sun, 26 Apr 2015 19:10:22 +0000 (12:10 -0700)]
microblaze: cpu: Remove unused CC_OP enum

This enum is not used by anything. Remove.

Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agomicroblaze: cpu: Remote unused cpu_get_pc
Peter Crosthwaite [Sun, 26 Apr 2015 19:10:21 +0000 (12:10 -0700)]
microblaze: cpu: Remote unused cpu_get_pc

This function is not used by anything. Remove.

Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agomicroblaze: mmu: Delete flip_um fn prototype
Peter Crosthwaite [Sun, 26 Apr 2015 19:10:20 +0000 (12:10 -0700)]
microblaze: mmu: Delete flip_um fn prototype

This is not implemented or used.

Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agodefconfigs: Piggyback microblazeel on microblaze
Peter Crosthwaite [Sun, 26 Apr 2015 19:10:19 +0000 (12:10 -0700)]
defconfigs: Piggyback microblazeel on microblaze

Theres no difference in defconfig. Going forward microblazeel should
superset microblaze so use an include.

Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agolibcacard: do not use full paths for include files in the same dir
Michael Tokarev [Mon, 27 Apr 2015 13:29:58 +0000 (16:29 +0300)]
libcacard: do not use full paths for include files in the same dir

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
9 years agolibcacard: stop including qemu-common.h
Paolo Bonzini [Mon, 27 Apr 2015 10:34:18 +0000 (12:34 +0200)]
libcacard: stop including qemu-common.h

This is a small step towards making libcacard standalone.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agodocs/atomics.txt: fix two typos
Laszlo Ersek [Mon, 27 Apr 2015 11:32:35 +0000 (13:32 +0200)]
docs/atomics.txt: fix two typos

Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agoconfigure: alphabetize tricore in target list
Peter Crosthwaite [Mon, 27 Apr 2015 02:14:26 +0000 (19:14 -0700)]
configure: alphabetize tricore in target list

tricore was out of alphabetical order in the target list. Fix.

Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Acked-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agoarm: cpu.h: Remove unused typdefs
Peter Crosthwaite [Mon, 27 Apr 2015 01:38:18 +0000 (18:38 -0700)]
arm: cpu.h: Remove unused typdefs

These CP accessor function prototypes are unused. Remove them.

Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agoutil: Remove unused functions
Thomas Huth [Sat, 14 Mar 2015 06:19:33 +0000 (07:19 +0100)]
util: Remove unused functions

Delete the unused functions qemu_signalfd_available(),
qemu_send_full() and qemu_recv_full().

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agousb: Remove unused functions
Thomas Huth [Sat, 14 Mar 2015 06:19:32 +0000 (07:19 +0100)]
usb: Remove unused functions

Delete set_usb_string(), usb_ep_get_ifnum(), usb_ep_get_max_packet_size()
usb_ep_get_max_streams() and usb_ep_set_pipeline() since they are
not used anymore.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agomonitor: Remove unused functions
Thomas Huth [Sat, 14 Mar 2015 06:19:31 +0000 (07:19 +0100)]
monitor: Remove unused functions

The functions ringbuf_read_completion() and monitor_get_rs()
are not used anywhere anymore, so let's remove them.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Cc: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agopci: Remove unused function ich9_d2pbr_init()
Thomas Huth [Sat, 14 Mar 2015 06:19:30 +0000 (07:19 +0100)]
pci: Remove unused function ich9_d2pbr_init()

The function ich9_d2pbr_init() is completely unused and
thus can be deleted.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agovmxnet: Remove unused function vmxnet_rx_pkt_get_num_frags()
Thomas Huth [Sat, 14 Mar 2015 06:19:29 +0000 (07:19 +0100)]
vmxnet: Remove unused function vmxnet_rx_pkt_get_num_frags()

The function is not used anymore and thus can be deleted.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Cc: Dmitry Fleytman <dmitry@daynix.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agoqemu-options: trivial spelling fix (messsage)
Michael Tokarev [Mon, 27 Apr 2015 08:12:49 +0000 (11:12 +0300)]
qemu-options: trivial spelling fix (messsage)

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Eric Blake <eblake@redhat.com>
9 years agohostmem: Fix mem-path property name in error report
Jan Kiszka [Fri, 24 Apr 2015 17:41:26 +0000 (19:41 +0200)]
hostmem: Fix mem-path property name in error report

The subtle difference between "property not found" and "property not
set" is already confusing enough.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>