OSDN Git Service

qmiga/qemu.git
8 years agoiotests: Respect -nodefaults in tests 41 and 55
Max Reitz [Wed, 2 Sep 2015 18:52:26 +0000 (20:52 +0200)]
iotests: Respect -nodefaults in tests 41 and 55

While -nodefaults is set in $QEMU_OPTIONS, this is currently (wrongly)
ignored for Python iotests. In order to be prepared for when this is
fixed, we should explicitly add an IDE CD-ROM drive instead of relying
on it being created automatically.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoiotests: More options for VM.add_drive()
Max Reitz [Wed, 2 Sep 2015 18:52:25 +0000 (20:52 +0200)]
iotests: More options for VM.add_drive()

This patch allows specifying the interface to be used for the drive, and
makes specifying a path optional (if the path is None, the "file" option
will be omitted, thus creating an empty drive).

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoqemu-img: Fix crash in amend invocation
Max Reitz [Thu, 20 Aug 2015 23:00:38 +0000 (16:00 -0700)]
qemu-img: Fix crash in amend invocation

Example:
$ ./qemu-img create -f qcow2 /tmp/t.qcow2 64M
$ ./qemu-img amend -f qcow2 -o backing_file=/tmp/t.qcow2, -o help \
    /tmp/t.qcow2

This should not crash. This actually is tested by iotest 082, but not
caught due to the segmentation fault being silent (which is something
that needs to be fixed, too).

Reported-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Cc: qemu-stable <qemu-stable@nongnu.org>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock/raw-posix: Use raw_normalize_devicepath()
Max Reitz [Wed, 12 Aug 2015 15:33:31 +0000 (17:33 +0200)]
block/raw-posix: Use raw_normalize_devicepath()

The filename given to qemu_open() in block/raw-posix.c should generally
have been processed by raw_normalize_devicepath(); unless we are only
probing (in which case the caller often checks whether the file is a
block device or not, and this property will be changed by
raw_normalize_devicepath() on NetBSD) or it is about a deprecated device
(i.e. floppy).

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoqemu-iotests: s390x: fix test 130
Bo Tu [Fri, 3 Jul 2015 07:28:50 +0000 (15:28 +0800)]
qemu-iotests: s390x: fix test 130

The default device id of hard disk on the s390 platform is "virtio0"
which differs to the "ide0-hd0" for the x86 platform. Setting id in
the drive definition, ie:"qemu -drive id=testdisk", will be the same
on all platforms.

Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Bo Tu <tubo@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoqemu-iotests: s390x: fix test 049, reject negative sizes in QemuOpts
Bo Tu [Fri, 3 Jul 2015 07:28:49 +0000 (15:28 +0800)]
qemu-iotests: s390x: fix test 049, reject negative sizes in QemuOpts

when creating an image qemu-img enable us specifying the size of the
image using -o size=xx options. But when we specify an invalid size
such as a negtive size then different platform gives different result.

parse_option_size() function in util/qemu-option.c will be called to
parse the size, a cast was called in the function to cast the input
(saved as a double in the function) size to an unsigned int64 value,
when the input is a negtive value or exceeds the maximum of uint64, then
the result is undefined.

According to C99 6.3.1.4, the result of converting a floating point
number to an integer that cannot represent the (integer part of) number
is undefined.  And sure enough the results are different on x86 and
s390.

C99 Language spec 6.3.1.4 Real floating and integers:
the result of this assignment/cast is undefined if the float is not
in the open interval (-1, U<type>_MAX+1).

Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
Signed-off-by: Bo Tu <tubo@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoqemu-iotests: s390x: fix test 041 and 055
Bo Tu [Fri, 3 Jul 2015 07:28:48 +0000 (15:28 +0800)]
qemu-iotests: s390x: fix test 041 and 055

There is no 'ide-cd' device defined on non-pc platform, so
test_medium_not_found() test should be skipped.

Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Michael Mueller <mimu@linux.vnet.ibm.com>
Reviewed-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
Signed-off-by: Xiao Guang Chen <chenxg@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoqemu-iotests: disable default qemu devices for cross-platform compatibility
Bo Tu [Fri, 3 Jul 2015 07:28:47 +0000 (15:28 +0800)]
qemu-iotests: disable default qemu devices for cross-platform compatibility

This patch fixes an io test suite issue that was introduced with the
commit c88930a6866e74953e931ae749781e98e486e5c8 'qemu-char: Permit only
a single "stdio" character device'. The option supresses the creation of
default devices such as the floopy and cdrom. Output files for test case
067, 071, 081 and 087 need to be updated to accommodate this change.
Use virtio-blk instead of virtio-blk-pci as the device driver for test
case 067. For virtio-blk-pci is the same with virtio-blk as device
driver but other platform such as s390 may not recognize the virtio-blk-pci.

The default devices differ across machines. As the qemu output often
contains these devices (or events for them, like opening a CD tray on
reset), the reference output currently is rather machine-specific.

All existing qemu tests explicitly configure the devices they're working
with, so just pass -nodefaults to qemu by default to disable the default
devices. Update the reference outputs accordingly.

Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Michael Mueller <mimu@linux.vnet.ibm.com>
Reviewed-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
Signed-off-by: Xiao Guang Chen <chenxg@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoqemu-iotests: qemu machine type support
Bo Tu [Fri, 3 Jul 2015 07:28:46 +0000 (15:28 +0800)]
qemu-iotests: qemu machine type support

This patch adds qemu machine type support to the io test suite.
Based on the qemu default machine type and alias of the default machine
type the reference output file can now vary from the default to a
machine specific output file if necessary. When using a machine specific
reference file if the default machine has an alias then use the alias as the output
file name otherwise use the default machine name as the output file name.

Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Michael Mueller <mimu@linux.vnet.ibm.com>
Reviewed-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
Signed-off-by: Xiao Guang Chen <chenxg@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoMerge remote-tracking branch 'remotes/armbru/tags/pull-monitor-2015-09-04' into staging
Peter Maydell [Fri, 4 Sep 2015 16:37:50 +0000 (17:37 +0100)]
Merge remote-tracking branch 'remotes/armbru/tags/pull-monitor-2015-09-04' into staging

Monitor patches

# gpg: Signature made Fri 04 Sep 2015 12:40:11 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-monitor-2015-09-04:
  hmp: add info iothreads command
  qmp-shell: add documentation

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2015-09-04' into staging
Peter Maydell [Fri, 4 Sep 2015 14:53:48 +0000 (15:53 +0100)]
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2015-09-04' into staging

qapi: Another round of fixes and cleanups

# gpg: Signature made Fri 04 Sep 2015 14:48:54 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-qapi-2015-09-04: (33 commits)
  qapi: Generators crash when --output-dir isn't given, fix
  docs/qapi-code-gen.txt: Fix QAPI schema examples
  qapi: Simplify error reporting for array types
  qapi: Fix errors for non-string, non-dictionary members
  tests/qapi-schema: Cover non-string, non-dictionary members
  tests/qapi-schema: Cover two more syntax errors
  qapi: Drop one of two "simple union must not have base" checks
  qapi: Generated code cleanup
  qapi-commands: Drop useless initialization
  qapi-commands: Don't feed output of mcgen() to mcgen() again
  qapi-commands: Inline gen_marshal_output_call()
  qapi-commands: Fix gen_err_check(e) for e and e != 'local_err'
  qapi: Command returning anonymous type doesn't work, outlaw
  qapi: Fix to reject union command and event arguments
  qapi-tests: New tests for union, alternate command arguments
  tests/qapi-schema: Rename tests from data- to args-
  tests/qapi-schema: Restore test case for flat union base bug
  qapi: Document flaws in checking of names
  qapi: Document shortcoming with union 'data' branch
  qapi: Document that input visitor semantics are prone to leaks
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoqapi: Generators crash when --output-dir isn't given, fix
Markus Armbruster [Thu, 3 Sep 2015 08:24:25 +0000 (10:24 +0200)]
qapi: Generators crash when --output-dir isn't given, fix

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agodocs/qapi-code-gen.txt: Fix QAPI schema examples
Markus Armbruster [Thu, 3 Sep 2015 08:18:06 +0000 (10:18 +0200)]
docs/qapi-code-gen.txt: Fix QAPI schema examples

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi: Simplify error reporting for array types
Markus Armbruster [Mon, 31 Aug 2015 11:54:39 +0000 (13:54 +0200)]
qapi: Simplify error reporting for array types

check_type() first checks and peels off the array type, then checks
the element type.  For two out of four error messages, it takes pains
to report errors for "array of T" instead of just T.  Odd.  Let's
examine the errors.

* Unknown element type, e.g.
  tests/qapi-schema/args-array-unknown.json:

      Member 'array' of 'data' for command 'oops' uses unknown type
      'array of NoSuchType'

  To make sense of this, you need to know that 'array of NoSuchType'
  refers to '[NoSuchType]'.  Easy enough.  However, simply reporting

      Member 'array' of 'data' for command 'oops' uses unknown type
      'NoSuchType'

  is at least as easy to understand.

* Element type's meta-type is inadmissible, e.g.
  tests/qapi-schema/returns-whitelist.json:

      'returns' for command 'no-way-this-will-get-whitelisted' cannot
      use built-in type 'array of int'

  'array of int' is technically not a built-in type, but that's
  pedantry.  However, simply reporting

      'returns' for command 'no-way-this-will-get-whitelisted' cannot
      use built-in type 'int'

  avoids the issue, and is at least as easy to understand.

* The remaining two errors are unreachable, because the array checking
  ensures that value is a string.

Thus, reporting some errors for "array of T" instead of just T works,
but doesn't really improve things.  Drop it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi: Fix errors for non-string, non-dictionary members
Markus Armbruster [Mon, 31 Aug 2015 15:28:52 +0000 (17:28 +0200)]
qapi: Fix errors for non-string, non-dictionary members

Fixes the errors demonstrated by the previous commit.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agotests/qapi-schema: Cover non-string, non-dictionary members
Markus Armbruster [Mon, 31 Aug 2015 15:17:42 +0000 (17:17 +0200)]
tests/qapi-schema: Cover non-string, non-dictionary members

We always report "should be a dictionary" then.  This is misleading:
when allow_dict, it can be a dictionary or a type name string, else it
can only be a type name.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agotests/qapi-schema: Cover two more syntax errors
Markus Armbruster [Mon, 31 Aug 2015 13:47:55 +0000 (15:47 +0200)]
tests/qapi-schema: Cover two more syntax errors

Syntax error coverage should now be complete.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi: Drop one of two "simple union must not have base" checks
Markus Armbruster [Mon, 31 Aug 2015 13:37:42 +0000 (15:37 +0200)]
qapi: Drop one of two "simple union must not have base" checks

The first check ensures the second one can't trigger.  Drop the first
one, because the second one is in a more logical place, and emits a
nicer error message.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi: Generated code cleanup
Markus Armbruster [Wed, 1 Jul 2015 14:55:15 +0000 (16:55 +0200)]
qapi: Generated code cleanup

Clean up white-space, brace placement, and superfluous #ifdef
QAPI_TYPES_BUILTIN_CLEANUP_DEF.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi-commands: Drop useless initialization
Markus Armbruster [Fri, 31 Jul 2015 16:51:18 +0000 (18:51 +0200)]
qapi-commands: Drop useless initialization

In generated command handlers, the assignment to retval dominates its
only use.  Therefore, its initialization is useless.  Drop it.

Suggested-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi-commands: Don't feed output of mcgen() to mcgen() again
Markus Armbruster [Sat, 27 Jun 2015 15:49:34 +0000 (17:49 +0200)]
qapi-commands: Don't feed output of mcgen() to mcgen() again

Multiple passes through mcgen() is prone to produce unwanted blank
lines, which we then combat by sprinkling .rstrip() on top.  Just
don't do it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi-commands: Inline gen_marshal_output_call()
Markus Armbruster [Sat, 27 Jun 2015 15:21:12 +0000 (17:21 +0200)]
qapi-commands: Inline gen_marshal_output_call()

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi-commands: Fix gen_err_check(e) for e and e != 'local_err'
Markus Armbruster [Sat, 27 Jun 2015 14:48:14 +0000 (16:48 +0200)]
qapi-commands: Fix gen_err_check(e) for e and e != 'local_err'

gen_err_check() hard-codes 'local_err' instead of substituting the
argument.  Currently harmless, since all callers pass either None or
'local_err'.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi: Command returning anonymous type doesn't work, outlaw
Markus Armbruster [Fri, 31 Jul 2015 15:59:38 +0000 (17:59 +0200)]
qapi: Command returning anonymous type doesn't work, outlaw

Reproducer: with

    { 'command': 'user_def_cmd4', 'returns': { 'a': 'int' } }

added to qapi-schema-test.json, qapi-commands.py dies when it tries to
generate the command handler function

    Traceback (most recent call last):
      File "/work/armbru/qemu/scripts/qapi-commands.py", line 359, in <module>
        ret = generate_command_decl(cmd['command'], arglist, ret_type) + "\n"
      File "/work/armbru/qemu/scripts/qapi-commands.py", line 29, in generate_command_decl
        ret_type=c_type(ret_type), name=c_name(name),
      File "/work/armbru/qemu/scripts/qapi.py", line 927, in c_type
        assert isinstance(value, str) and value != ""
    AssertionError

because the return type doesn't exist.

Simply outlaw this usage, and drop or dumb down test cases accordingly.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi: Fix to reject union command and event arguments
Markus Armbruster [Wed, 1 Jul 2015 08:12:24 +0000 (10:12 +0200)]
qapi: Fix to reject union command and event arguments

A command's or event's 'data' must be a struct type, given either as a
dictionary, or as struct type name.

Commit dd883c6 tightened the checking there, but not enough: we still
accept 'union'.  Fix to reject it.

We may want to support union types there, but we'll have to extend
qapi-commands.py and qapi-events.py for it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi-tests: New tests for union, alternate command arguments
Markus Armbruster [Wed, 1 Jul 2015 07:54:11 +0000 (09:54 +0200)]
qapi-tests: New tests for union, alternate command arguments

A command's 'data' must be a struct type, given either as a
dictionary, or as struct type name.

Existing test case data-int.json covers simple type 'int'.  Add test
cases for type names referring to union and alternate types.

The latter is caught (good), but the former is not (bug).

Events have the same problem, but since they get checked by the same
code, we don't bother to duplicate the tests.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agotests/qapi-schema: Rename tests from data- to args-
Markus Armbruster [Fri, 31 Jul 2015 11:30:50 +0000 (13:30 +0200)]
tests/qapi-schema: Rename tests from data- to args-

Since every schema entity has 'data', the data- prefix conveys no
information.  These tests actually exercise commands.  Only commands
have arguments, so change the prefix to to args-.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agotests/qapi-schema: Restore test case for flat union base bug
Markus Armbruster [Fri, 26 Jun 2015 11:21:10 +0000 (13:21 +0200)]
tests/qapi-schema: Restore test case for flat union base bug

Test case added in commit 2fc0043, and messed up in commit 5223070.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi: Document flaws in checking of names
Markus Armbruster [Fri, 31 Jul 2015 09:33:52 +0000 (11:33 +0200)]
qapi: Document flaws in checking of names

We don't actually enforce our "other than downstream extensions [...],
all names should begin with a letter" rule.  Add a FIXME.

We should reject names that differ only in '_' vs. '.'  vs. '-',
because they're liable to clash in generated C.  Add a FIXME.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi: Document shortcoming with union 'data' branch
Eric Blake [Thu, 30 Jul 2015 23:07:17 +0000 (17:07 -0600)]
qapi: Document shortcoming with union 'data' branch

Add a FIXME to remind us to fully audit whether removing the
'void *data' branch of each qapi union type can be done safely.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1438297637-26789-1-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
8 years agoqapi: Document that input visitor semantics are prone to leaks
Eric Blake [Thu, 30 Jul 2015 22:33:07 +0000 (16:33 -0600)]
qapi: Document that input visitor semantics are prone to leaks

Most functions that can return a pointer or set an Error ** value
are decent enough to guarantee a NULL return when reporting an error.
Not so with our generated qapi visitor functions.  If the caller
is not careful to clean up partially-allocated objects on error,
then the caller suffers a memory leak.

Properly fixing it is probably complex enough to save for a later
day, so merely document it for now.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1438295587-19069-1-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
8 years agotests/qapi-schema: Document events with base don't work
Markus Armbruster [Fri, 26 Jun 2015 11:14:02 +0000 (13:14 +0200)]
tests/qapi-schema: Document events with base don't work

When event FOO's 'data' is a struct with a base, we consider only the
struct's direct members, and ignore its base.  The generated
qapi_event_send_foo() doesn't take arguments for base members.

No such events currently exist in the QMP schema.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agotests/qapi-schema: Document alternate's enum lacks visit function
Markus Armbruster [Fri, 26 Jun 2015 15:52:45 +0000 (17:52 +0200)]
tests/qapi-schema: Document alternate's enum lacks visit function

We generate a declaration, but no definition.

The QMP schema has two: Qcow2OverlapChecks and BlockdevRef.  Neither
visit_type_Qcow2OverlapChecksKind() nor visit_type_BlockdevRefKind()
is actually used.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi-visit: Fix two name arguments passed to visitors
Markus Armbruster [Fri, 26 Jun 2015 15:21:42 +0000 (17:21 +0200)]
qapi-visit: Fix two name arguments passed to visitors

The generated code passes mangled schema names to visit_type_enum()
and union's visit_start_struct().  Fix it to pass the names
unadulterated, like we do everywhere else.

Only qapi-schema-test.json actually has names where this makes a
difference: enum __org.qemu_x-Enum, flat union __org.qemu_x-Union2,
simple union __org.qemu_x-Union1 and its implicit enum
__org.qemu_x-Union1Kind.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi-visit: Replace list implicit_structs by set
Markus Armbruster [Tue, 30 Jun 2015 07:27:04 +0000 (09:27 +0200)]
qapi-visit: Replace list implicit_structs by set

Use set because that's what it is.  While there, rename to
implicit_structs_seen.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi-visit: Fix generated code when schema has forward refs
Markus Armbruster [Fri, 26 Jun 2015 08:19:11 +0000 (10:19 +0200)]
qapi-visit: Fix generated code when schema has forward refs

The visit_type_implicit_FOO() are generated on demand, right before
their first use.  Used by visit_type_STRUCT_fields() when STRUCT has
base FOO, and by visit_type_UNION() when flat UNION has member a FOO.

If the schema defines FOO after its first use as struct base or flat
union member, visit_type_implicit_FOO() calls
visit_type_implicit_FOO() before its definition, which doesn't
compile.

Rearrange qapi-schema-test.json to demonstrate the bug.

Fix by generating the necessary forward declaration.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi: Generate a nicer struct for flat unions
Markus Armbruster [Sun, 28 Jun 2015 18:05:53 +0000 (20:05 +0200)]
qapi: Generate a nicer struct for flat unions

The struct generated for a flat union is weird: the members of its
base are at the end, except for the union tag, which is at the
beginning.

Example: qapi-schema-test.json has

    { 'struct': 'UserDefUnionBase',
      'data': { 'string': 'str', 'enum1': 'EnumOne' } }

    { 'union': 'UserDefFlatUnion',
      'base': 'UserDefUnionBase',
      'discriminator': 'enum1',
      'data': { 'value1' : 'UserDefA',
                'value2' : 'UserDefB',
                'value3' : 'UserDefB' } }

We generate:

    struct UserDefFlatUnion
    {
        EnumOne enum1;
        union {
            void *data;
            UserDefA *value1;
            UserDefB *value2;
            UserDefB *value3;
        };
        char *string;
    };

Change to put all base members at the beginning, unadulterated.  Not
only is this easier to understand, it also permits casting the flat
union to its base, if that should become useful.

We now generate:

    struct UserDefFlatUnion
    {
        /* Members inherited from UserDefUnionBase: */
        char *string;
        EnumOne enum1;
        /* Own members: */
        union { /* union tag is @enum1 */
            void *data;
            UserDefA *value1;
            UserDefB *value2;
            UserDefB *value3;
        };
    };

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi: Fix generated code when flat union has member 'kind'
Markus Armbruster [Fri, 31 Jul 2015 08:30:04 +0000 (10:30 +0200)]
qapi: Fix generated code when flat union has member 'kind'

A flat union's tag member gets renamed to 'kind' in the generated
code.  Breaks when another member named 'kind' exists.

Example, adapted from qapi-schema-test.json:

    { 'struct': 'UserDefUnionBase',
      'data': { 'kind': 'str', 'enum1': 'EnumOne' } }

We generate:

    struct UserDefFlatUnion
    {
        EnumOne kind;
        union {
            void *data;
            UserDefA *value1;
            UserDefB *value2;
            UserDefB *value3;
        };
        char *kind;
    };

Kill the silly rename.

Reported-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi: Drop unused and useless parameters and variables
Markus Armbruster [Sun, 28 Jun 2015 19:36:26 +0000 (21:36 +0200)]
qapi: Drop unused and useless parameters and variables

gen_sync_call()'s parameter indent is useless: gen_sync_call() uses it
only as optional argument for push_indent() and pop_indent(), their
default is four, and gen_sync_call()'s only caller passes four.  Drop
the parameter.

gen_visitor_input_containers_decl()'s parameter obj is always
"QOBJECT(args)".  Use that, and drop the parameter.

Drop unused parameters of gen_marshal_output(),
gen_marshal_input_decl(), generate_visit_struct_body(),
generate_visit_list(), generate_visit_enum(), generate_declaration(),
generate_enum_declaration(), generate_decl_enum().

Drop unused variables in generate_event_enum_lookup(),
generate_enum_lookup(), generate_visit_struct_fields(), check_event().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi: Reject -p arguments that break qapi-event.py
Markus Armbruster [Wed, 1 Jul 2015 11:13:54 +0000 (13:13 +0200)]
qapi: Reject -p arguments that break qapi-event.py

qapi-event.py breaks when you ask for a funny prefix like '@'.
Protect it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi-event: Clean up how name of enum QAPIEvent is made
Markus Armbruster [Wed, 1 Jul 2015 10:59:40 +0000 (12:59 +0200)]
qapi-event: Clean up how name of enum QAPIEvent is made

Use c_name() instead of ad hoc code.  Doesn't upcase the -p prefix,
which is an improvement in my book.  Unbreaks prefix containing '.',
but other funny characters remain broken.  To be fixed next.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi: Simplify guardname()
Markus Armbruster [Sat, 27 Jun 2015 05:27:21 +0000 (07:27 +0200)]
qapi: Simplify guardname()

The guards around built-in declarations lose their _H.  It never made
much sense anyway.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi: Clean up cgen() and mcgen()
Markus Armbruster [Wed, 24 Jun 2015 17:27:32 +0000 (19:27 +0200)]
qapi: Clean up cgen() and mcgen()

Commit 05dfb26 added eatspace stripping to mcgen().  Move it to
cgen(), just in case somebody gets tempted to use cgen() directly
instead of via mcgen().

cgen() indents blank lines.  No such lines get generated right now,
but fix it anyway.

We use triple-quoted strings for program text, like this:

    '''
    Program text
    any number of lines
    '''

Keeps the program text relatively readable, but puts an extra newline
at either end.  mcgen() "fixes" that by dropping the first and last
line outright.  Drop only the newlines.

This unmasks a bug in qapi-commands.py: four quotes instead of three.
Fix it up.

Output doesn't change

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi: Clarify docs on including the same file multiple times
Markus Armbruster [Tue, 9 Jun 2015 13:24:36 +0000 (15:24 +0200)]
qapi: Clarify docs on including the same file multiple times

It's idempotent.

While there, update examples to current code.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agohmp: add info iothreads command
Ting Wang [Fri, 26 Jun 2015 08:07:13 +0000 (16:07 +0800)]
hmp: add info iothreads command

Make "info iothreads" available on the HMP monitor.

For example, the results are as follows when executing qemu
command with "-object iothread,id=iothread-1 -object
iothread,id=iothread-2".
(qemu) info iothreads
iothread-1: thread_id=123
iothread-2: thread_id=456

Signed-off-by: Ting Wang <kathy.wangting@huawei.com>
Message-Id: <1435306033-58372-1-git-send-email-kathy.wangting@huawei.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Amos Jianjun Kong <kongjianjun@gmail.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
8 years agoqmp-shell: add documentation
John Snow [Wed, 1 Jul 2015 18:25:49 +0000 (14:25 -0400)]
qmp-shell: add documentation

I should probably document the changes that were made.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-Id: <1435775149-17285-1-git-send-email-jsnow@redhat.com>
Reviewed-By: Kashyap Chamarthy <kchamart@redhat.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
8 years agoMerge remote-tracking branch 'remotes/stefanha/tags/tracing-pull-request' into staging
Peter Maydell [Thu, 3 Sep 2015 15:17:28 +0000 (16:17 +0100)]
Merge remote-tracking branch 'remotes/stefanha/tags/tracing-pull-request' into staging

# gpg: Signature made Thu 03 Sep 2015 15:46:52 BST using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"

* remotes/stefanha/tags/tracing-pull-request:
  trace-events: Add hmp completion

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agotrace-events: Add hmp completion
Dr. David Alan Gilbert [Fri, 14 Aug 2015 10:27:43 +0000 (11:27 +0100)]
trace-events: Add hmp completion

Add completion for the trace event names in the hmp trace-event
command.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-id: 1439548063-18410-1-git-send-email-dgilbert@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agoMerge remote-tracking branch 'remotes/cohuck/tags/s390x-20150903' into staging
Peter Maydell [Thu, 3 Sep 2015 13:33:03 +0000 (14:33 +0100)]
Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20150903' into staging

First batch of s390x patches for 2.5:
- introduce 2.5 compat machine
- support for migration of storage keys

# gpg: Signature made Thu 03 Sep 2015 11:28:06 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-20150903:
  s390x: Disable storage key migration on old machine type
  s390x: Migrate guest storage keys (initial memory only)
  s390x: Info skeys sub-command
  s390x: Dump-skeys hmp support
  s390x: Dump storage keys qmp command
  s390x: Enable new s390-storage-keys device
  s390x: Create QOM device for s390 storage keys
  s390x: add 2.5 compat s390-ccw-virtio machine

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/rth/tags/pull-tcg-20150902' into staging
Peter Maydell [Thu, 3 Sep 2015 12:05:45 +0000 (13:05 +0100)]
Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20150902' into staging

queued tcg patches

# gpg: Signature made Wed 02 Sep 2015 22:35:37 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/pull-tcg-20150902:
  tcg/i386: omit a few REXW prefixes in softmmu code
  tcg/aarch64: Fix tcg_out_qemu_{ld, st} for guest_base == 0

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/rth/tags/pull-axp-20150902' into staging
Peter Maydell [Thu, 3 Sep 2015 11:09:41 +0000 (12:09 +0100)]
Merge remote-tracking branch 'remotes/rth/tags/pull-axp-20150902' into staging

cmpbge emulation improvements

# gpg: Signature made Wed 02 Sep 2015 20:25:10 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/pull-axp-20150902:
  target-alpha: Special case cmpbge with zero
  target-alpha: Rewrite helper_cmpbge using bit tests

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agos390x: Disable storage key migration on old machine type
Jason J. Herne [Thu, 9 Jul 2015 17:56:44 +0000 (13:56 -0400)]
s390x: Disable storage key migration on old machine type

This code disables storage key migration when an older machine type is
specified.

Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agos390x: Migrate guest storage keys (initial memory only)
Jason J. Herne [Fri, 26 Jun 2015 18:11:23 +0000 (14:11 -0400)]
s390x: Migrate guest storage keys (initial memory only)

Routines to save/load guest storage keys are provided. register_savevm is
called to register them as migration handlers.

We prepare the protocol to support more complex parameters. So we will
later be able to support standby memory (having empty holes), compression
and "state live migration" like done for ram.

Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agos390x: Info skeys sub-command
Jason J. Herne [Fri, 26 Jun 2015 18:10:16 +0000 (14:10 -0400)]
s390x: Info skeys sub-command

Provide an  info skeys hmp sub-command to allow the end user to dump a storage
key for a given address. This is useful for guest operating system developers.

Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agos390x: Dump-skeys hmp support
Jason J. Herne [Fri, 26 Jun 2015 18:07:21 +0000 (14:07 -0400)]
s390x: Dump-skeys hmp support

Add dump-skeys command to the human monitor.

Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agos390x: Dump storage keys qmp command
Jason J. Herne [Fri, 26 Jun 2015 18:03:16 +0000 (14:03 -0400)]
s390x: Dump storage keys qmp command

Provide a dump-skeys qmp command to allow the end user to dump storage
keys. This is useful for debugging problems with guest storage key support
within Qemu and for guest operating system developers.

Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agos390x: Enable new s390-storage-keys device
Jason J. Herne [Fri, 26 Jun 2015 18:01:00 +0000 (14:01 -0400)]
s390x: Enable new s390-storage-keys device

s390 guest initialization is modified to make use of new s390-storage-keys
device. Old code that globally allocated storage key array is removed.
The new device enables storage key access for kvm guests.

Cache storage key QOM objects in frequently used helper functions to avoid a
performance hit every time we use one of these functions.

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agos390x: Create QOM device for s390 storage keys
Jason J. Herne [Fri, 26 Jun 2015 15:54:51 +0000 (11:54 -0400)]
s390x: Create QOM device for s390 storage keys

A new QOM style device is provided to back guest storage keys. A special
version for KVM is created, which handles the storage key access via
KVM_S390_GET_SKEYS and KVM_S390_SET_SKEYS ioctl.

Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agos390x: add 2.5 compat s390-ccw-virtio machine
Cornelia Huck [Fri, 17 Jul 2015 11:16:52 +0000 (13:16 +0200)]
s390x: add 2.5 compat s390-ccw-virtio machine

Reviewed-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
8 years agoMerge remote-tracking branch 'remotes/stefanha/tags/net-pull-request' into staging
Peter Maydell [Thu, 3 Sep 2015 10:15:01 +0000 (11:15 +0100)]
Merge remote-tracking branch 'remotes/stefanha/tags/net-pull-request' into staging

# gpg: Signature made Wed 02 Sep 2015 17:14:40 BST using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"

* remotes/stefanha/tags/net-pull-request:
  ne2000: Drop ne2000_can_receive
  vmxnet3: Drop net_vmxnet3_info.can_receive
  rtl8139: Do not consume the packet during overflow in standard mode.
  rtl8139: Fix receive buffer overflow check
  rtl8139: use ldl/stl wrapper for unaligned 32-bit access
  rtl8139: use net/eth.h macros instead of custom macros
  rtl8139: remove duplicate net/eth.h definitions

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
Peter Maydell [Thu, 3 Sep 2015 08:50:37 +0000 (09:50 +0100)]
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging

# gpg: Signature made Wed 02 Sep 2015 17:01:33 BST using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"

* remotes/stefanha/tags/block-pull-request:
  block: more check for replaced node
  MAINTAINERS: add responsible person for Parallels format driver

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agotcg/i386: omit a few REXW prefixes in softmmu code
Aurelien Jarno [Sun, 19 Jul 2015 11:50:32 +0000 (13:50 +0200)]
tcg/i386: omit a few REXW prefixes in softmmu code

When computing the TLB address we are likely to mask out the high
32-bits by using shr + and. We can use 32-bit instructions in that
case. This saves 2 bytes per TLB access.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Message-Id: <1437306632-20655-1-git-send-email-aurelien@aurel32.net>
Signed-off-by: Richard Henderson <rth@twiddle.net>
8 years agotcg/aarch64: Fix tcg_out_qemu_{ld, st} for guest_base == 0
Richard Henderson [Tue, 1 Sep 2015 19:58:02 +0000 (15:58 -0400)]
tcg/aarch64: Fix tcg_out_qemu_{ld, st} for guest_base == 0

In ffc6372851d8631a9f9fa56ec613b3244dc635b9, we swapped the guest
base to the address base register from the address index register.
Except that 31 in the base slot is SP not XZR, so we need to be
more intelligent about which reg gets placed in which slot.

Cc: qemu-stable@nongnu.org (v2.4.0)
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reported-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Richard Henderson <rth@twiddle.net>
8 years agoblock: more check for replaced node
Wen Congyang [Fri, 17 Jul 2015 02:12:22 +0000 (10:12 +0800)]
block: more check for replaced node

We use mirror+replace to fix quorum's broken child. bs/s->common.bs
is quorum, and to_replace is the broken child. The new child is target_bs.
Without this patch, the replace node can be any node, and it can be
top BDS with BB, or another quorum's child. We just check if the broken
child is part of the quorum BDS in this patch.

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Message-id: 55A86486.1000404@cn.fujitsu.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agoMAINTAINERS: add responsible person for Parallels format driver
Denis V. Lunev [Fri, 21 Aug 2015 17:44:16 +0000 (20:44 +0300)]
MAINTAINERS: add responsible person for Parallels format driver

Denis has spent 6 years working with this format in Parallels and QEMU
code was rewritten almost completely by his. Thus it would be quite
natural to add him as a maintainer and point of contact.

Patches are going to flow though Stefan's tree.

Signed-off-by: Denis V. Lunev <den@openvz.org>
Message-id: 1440179056-12934-1-git-send-email-den@openvz.org
CC: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agone2000: Drop ne2000_can_receive
Fam Zheng [Wed, 1 Jul 2015 05:25:05 +0000 (13:25 +0800)]
ne2000: Drop ne2000_can_receive

ne2000_receive already checks the same conditions and drops the packet
if it's not ready, removing the .can_receive callback avoids the
necessity to add explicit flushes when the conditions turn true (which
is required by the new semantics of .can_receive since 6e99c63
"net/socket: Drop net_socket_can_send").

Plus the "return 1" if E8390_STOP is also suspicious.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agovmxnet3: Drop net_vmxnet3_info.can_receive
Fam Zheng [Wed, 1 Jul 2015 02:26:27 +0000 (10:26 +0800)]
vmxnet3: Drop net_vmxnet3_info.can_receive

Commit 6e99c63 ("net/socket: Drop net_socket_can_send") changed the
semantics around .can_receive for sockets to now require the device to
flush queued pkts when transitioning to a .can_receive=true state. But
it's OK to drop incoming packets when the link is not active.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agortl8139: Do not consume the packet during overflow in standard mode.
Vladislav Yasevich [Tue, 1 Sep 2015 15:26:46 +0000 (11:26 -0400)]
rtl8139: Do not consume the packet during overflow in standard mode.

When operation in standard mode, we currently return the size
of packet during buffer overflow.  This consumes the overflow
packet.  Return 0 instead so we can re-process the overflow packet
when we have room.

This fixes issues with lost/dropped fragments of large messages.

Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
Reviewed-by: Jason Wang <jasowang@redhat.com>
Message-id: 1441121206-6997-3-git-send-email-vyasevic@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agortl8139: Fix receive buffer overflow check
Vladislav Yasevich [Tue, 1 Sep 2015 15:26:45 +0000 (11:26 -0400)]
rtl8139: Fix receive buffer overflow check

rtl8139_do_receive() tries to check for the overflow condition
by making sure that packet_size + 8 does not exceed the
available buffer space.  The issue here is that RxBuffAddr,
used to calculate available buffer space, is aligned to a
a 4 byte boundry after every update.  So it is possible that
every packet ends up being slightly padded when written
to the receive buffer.  This padding is not taken into
account when checking for overflow and we may end up missing
the overflow condition can causing buffer overwrite.

This patch takes alignment into consideration when
checking for overflow condition.

Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
Reviewed-by: Jason Wang <jasowang@redhat.com>
Message-id: 1441121206-6997-2-git-send-email-vyasevic@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agortl8139: use ldl/stl wrapper for unaligned 32-bit access
Stefan Hajnoczi [Mon, 3 Aug 2015 12:15:57 +0000 (13:15 +0100)]
rtl8139: use ldl/stl wrapper for unaligned 32-bit access

The tx offload feature accesses a 16-bit aligned TCP header struct.  The
32-bit fields must be accessed using ldl/stl wrappers since some host
architectures fault on unaligned access.

Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Jason Wang <jasowang@redhat.com>
Message-id: 1438604157-29664-4-git-send-email-stefanha@redhat.com

8 years agortl8139: use net/eth.h macros instead of custom macros
Stefan Hajnoczi [Mon, 3 Aug 2015 12:15:56 +0000 (13:15 +0100)]
rtl8139: use net/eth.h macros instead of custom macros

Eliminate the following "custom" macros since they are just duplicates
of net/eth.h macros under a different name:

  ETHER_ADDR_LEN -> ETH_ALEN
  ETH_P_8021Q -> ETH_P_VLAN
  IP_HEADER_LENGTH -> IP_HDR_GET_LEN
  TCP_FLAG_FIN -> TH_FIN
  TCP_FLAG_PUSH -> TH_PUSH

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Jason Wang <jasowang@redhat.com>
Message-id: 1438604157-29664-3-git-send-email-stefanha@redhat.com

8 years agortl8139: remove duplicate net/eth.h definitions
Stefan Hajnoczi [Mon, 3 Aug 2015 12:15:55 +0000 (13:15 +0100)]
rtl8139: remove duplicate net/eth.h definitions

The transmit offload features inspect Ethernet, IP, TCP, and UDP
headers.  Avoid redefining these net/eth.h structs.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Jason Wang <jasowang@redhat.com>
Message-id: 1438604157-29664-2-git-send-email-stefanha@redhat.com

8 years agoMerge remote-tracking branch 'remotes/mdroth/tags/qga-pull-2015-09-01-v2-tag' into...
Peter Maydell [Tue, 1 Sep 2015 18:42:43 +0000 (19:42 +0100)]
Merge remote-tracking branch 'remotes/mdroth/tags/qga-pull-2015-09-01-v2-tag' into staging

qemu-ga patch queue

* add config file dump/load support for qemu-ga
* various w32 build fixes, particularly WRT to msi package creation
* fixes for msi installer
* w32 support for guest-set-user-password

v2:
* replaced g_list_free_full with g_list_foreach to maintain glib 2.22
  compatibility

# gpg: Signature made Tue 01 Sep 2015 19:34:15 BST using RSA key ID F108B584
# gpg: Good signature from "Michael Roth <flukshun@gmail.com>"
# gpg:                 aka "Michael Roth <mdroth@utexas.edu>"
# gpg:                 aka "Michael Roth <mdroth@linux.vnet.ibm.com>"

* remotes/mdroth/tags/qga-pull-2015-09-01-v2-tag: (26 commits)
  Makefile: qemu-ga: fix msi target error message
  build: qemu-ga: fix VSS dependencies
  configure: qemu-ga: explicitly enable qemu-ga MSI support when probed
  configure: qemu-ga: move MSI installer probe after qga probe
  qemu-ga: implement win32 guest-set-user-password
  qga: start a man page
  qga: add --dump-conf option
  qga: add an optional qemu-ga.conf system configuration
  qga: free a bit more
  qga: move agent run in a separate function
  qga: fill default options in main()
  qga: move option parsing to separate function
  qga: copy argument strings
  qga: rename 'path' to 'channel_path'
  qga: make split_list() return allocated strings
  qga: move string split in separate function
  qga: use exit() when parsing options
  qga: misc spelling
  configure: qemu-ga: report MSI install support in summary
  qemu-ga: Fixed paths issue with MSI build
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMakefile: qemu-ga: fix msi target error message
Michael Roth [Wed, 26 Aug 2015 22:05:01 +0000 (17:05 -0500)]
Makefile: qemu-ga: fix msi target error message

'msi' target reports error if we attempt to use it when QEMU hasn't
been ./configure'd to enable it. The parenthesis cause an interpreter
error if we don't enclose the error in quotes.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agobuild: qemu-ga: fix VSS dependencies
Michael Roth [Wed, 26 Aug 2015 21:19:41 +0000 (16:19 -0500)]
build: qemu-ga: fix VSS dependencies

Currently VSS dll/tlb files for use in w32 builds are only built as a
result of having been added to the general 'tools' target alongside
qemu-ga. This is fine for default make target, but if we build
qemu-ga directly via `make qemu-ga.exe`, the VSS files are not
created.

Fix this by moving the VSS dependencies to qemu-ga.exe directly.
With this move we can move the VSS files back out of 'tools',
and drop the extra handling from MSI target in Makefile.

Now we can build qemu-ga MSI package with:
  ./configure ...
  make qemu-ga.exe
  make msi

or simply:
  ./configure ...
  make msi

and no longer need to do a full build beforehand.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoconfigure: qemu-ga: explicitly enable qemu-ga MSI support when probed
Michael Roth [Wed, 26 Aug 2015 16:14:31 +0000 (11:14 -0500)]
configure: qemu-ga: explicitly enable qemu-ga MSI support when probed

Currently, if we don't explicitly disable support for MSI installer
via --disable-guest-agent-msi, the configure variable that tracks
the flag, 'guest_agent_msi', never gets set unless one of the probes
fails. Subsequent code then treats this unset value the same as if it
were a "yes" value (via != "no" style checks).

Instead, set the default "yes" value explicitly after the probes, then
make subsequent code expect the values to be set.

This makes it easier to report on whether or not MSI support was
enabled via probe by looking at the ./configure summary.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoconfigure: qemu-ga: move MSI installer probe after qga probe
Michael Roth [Wed, 26 Aug 2015 15:49:13 +0000 (10:49 -0500)]
configure: qemu-ga: move MSI installer probe after qga probe

MSI probe assumes that qemu-ga support has been probed already, but in
cases where --enable-guest-agent/--disable-guest-agent have not been
passed to configure, qemu-ga support may end up getting enabled later,
as is the case with w32 builds. This leads to MSI probe prematurely
reporting error due to lack of qemu-ga support.

Fix this by moving MSI installer probe after the final qga probes.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqemu-ga: implement win32 guest-set-user-password
Marc-André Lureau [Tue, 30 Jun 2015 14:37:13 +0000 (16:37 +0200)]
qemu-ga: implement win32 guest-set-user-password

Use NetUserSetInfo() to set the user password.

This function is notoriously known to be problematic for users with EFS
encrypted files. But the alternative, NetUserChangePassword() requires
the old password. Nevertheless, The EFS file should be recovered by
changing back to the old password.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqga: start a man page
Marc-André Lureau [Wed, 26 Aug 2015 23:34:59 +0000 (01:34 +0200)]
qga: start a man page

Add a simple man page for the qemu agent.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
*squashed in review comments from Eric Blake <eblake@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqga: add --dump-conf option
Marc-André Lureau [Wed, 26 Aug 2015 23:34:58 +0000 (01:34 +0200)]
qga: add --dump-conf option

This new option allows to review the agent configuration,
and ease the task of writing a configuration file.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
* removed unecessary keyfile != NULL prior to free
* documented --dump-conf is qemu-ga --help output
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqga: add an optional qemu-ga.conf system configuration
Marc-André Lureau [Wed, 26 Aug 2015 23:34:57 +0000 (01:34 +0200)]
qga: add an optional qemu-ga.conf system configuration

Learn to configure the agent with a system configuration.

This may simplify command-line handling, especially when the blacklist
is long.

Among the other benefits, this may standardize the configuration of an
init service (instead of distro-specific init keys/files)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
* removed unecessary keyfile != NULL prior to free
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqga: free a bit more
Marc-André Lureau [Wed, 26 Aug 2015 23:34:56 +0000 (01:34 +0200)]
qga: free a bit more

Now that main() has a single exit point, we can free a few
more allocations.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqga: move agent run in a separate function
Marc-André Lureau [Wed, 26 Aug 2015 23:34:55 +0000 (01:34 +0200)]
qga: move agent run in a separate function

Once the options are populated, move the running state to
a run_agent() function.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
* fixed up an s/ga_state/s/ artifact causing segfault
* replaced g_list_free_full with g_list_foreach to maintain glib
  2.22 compatibility
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqga: fill default options in main()
Marc-André Lureau [Wed, 26 Aug 2015 23:34:54 +0000 (01:34 +0200)]
qga: fill default options in main()

Fill all default options during main(). This is a preparation patch
to allow to dump the configuration.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqga: move option parsing to separate function
Marc-André Lureau [Wed, 26 Aug 2015 23:34:53 +0000 (01:34 +0200)]
qga: move option parsing to separate function

Move option parsing out of giant main().

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqga: copy argument strings
Marc-André Lureau [Wed, 26 Aug 2015 23:34:52 +0000 (01:34 +0200)]
qga: copy argument strings

Following patch will return allocated strings, so we must correctly
initialize alloc & free them. The nice side effect is that we no longer
have to check for "fixed_state_dir" to call ga_install_service() with a
NULL state dir. The default values are set after parsing the command
line options.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqga: rename 'path' to 'channel_path'
Marc-André Lureau [Wed, 26 Aug 2015 23:34:51 +0000 (01:34 +0200)]
qga: rename 'path' to 'channel_path'

'path' is already a global function, rename the variable since it's
going to be in global scope in a later patch.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqga: make split_list() return allocated strings
Marc-André Lureau [Wed, 26 Aug 2015 23:34:50 +0000 (01:34 +0200)]
qga: make split_list() return allocated strings

In order to avoid any confusion, let's allocate new strings when
splitting.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqga: move string split in separate function
Marc-André Lureau [Wed, 26 Aug 2015 23:34:49 +0000 (01:34 +0200)]
qga: move string split in separate function

The function is going to be reused in a later patch.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqga: use exit() when parsing options
Marc-André Lureau [Wed, 26 Aug 2015 23:34:48 +0000 (01:34 +0200)]
qga: use exit() when parsing options

The option parsing is going to be moved to a separate function,
use exit() consistently.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqga: misc spelling
Marc-André Lureau [Wed, 26 Aug 2015 23:34:47 +0000 (01:34 +0200)]
qga: misc spelling

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoconfigure: qemu-ga: report MSI install support in summary
Michael Roth [Tue, 25 Aug 2015 20:46:18 +0000 (15:46 -0500)]
configure: qemu-ga: report MSI install support in summary

Currently we need to examine config-host.mak to determine whether
options/probes for MSI package generation had desired result. Report
this more prominently in ./configure summary as we do with other
guest agent configure options.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqemu-ga: Fixed paths issue with MSI build
Leonid Bloch [Wed, 26 Aug 2015 12:07:16 +0000 (15:07 +0300)]
qemu-ga: Fixed paths issue with MSI build

Previously, if building out-of-tree, the MSI build would fail since
it wasn't able to find the needed files.

Signed-off-by: Leonid Bloch <leonid@daynix.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* fixed up commit msg formating
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqemu-ga: Prevent QEMU-GA VSS provider from being unregistered on MSI reinstall
Leonid Bloch [Mon, 3 Aug 2015 17:54:24 +0000 (20:54 +0300)]
qemu-ga: Prevent QEMU-GA VSS provider from being unregistered on MSI reinstall

Previously, running the .msi would unregister the QEMU GA VSS service if QEMU GA was already installed on the machine, and then register it only if QEMU GA was NOT previously installed. This behavior caused the service to be registered only after the INITIAL installation, and any subsequent run of the .msi (to redo, repair, or upgrade the installation) ended in the service being unregistered.

Now, the VSS service is still unregistered if QEMU GA is already installed (so that a fix or an update could be performed) but then it is registered again (if the GA is not being uninstalled) thus finishing the repair/upgrade correctly. Additionally, downgrading is now prevented. If a user would like to downgrade a version, he/she must uninstall the newer version first.

Signed-off-by: Leonid Bloch <leonid@daynix.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqemu-ga: Created a separate component for each installed file in the MSI
Leonid Bloch [Mon, 3 Aug 2015 17:54:23 +0000 (20:54 +0300)]
qemu-ga: Created a separate component for each installed file in the MSI

This is done to follow the recommendations given here: https://msdn.microsoft.com/en-us/library/aa368269%28VS.85%29.aspx

Signed-off-by: Leonid Bloch <leonid@daynix.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqemu-ga: Minor cosmetic changes to the WXS file
Leonid Bloch [Mon, 3 Aug 2015 17:54:22 +0000 (20:54 +0300)]
qemu-ga: Minor cosmetic changes to the WXS file

Signed-off-by: Leonid Bloch <leonid@daynix.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqemu-ga: Fixed GUID capitalization
Leonid Bloch [Mon, 3 Aug 2015 17:54:21 +0000 (20:54 +0300)]
qemu-ga: Fixed GUID capitalization

For compatibility, all the letters in GUID should be capital.

Signed-off-by: Leonid Bloch <leonid@daynix.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqemu-ga: Two MSI related cosmetic changes
Leonid Bloch [Wed, 29 Jul 2015 17:10:51 +0000 (20:10 +0300)]
qemu-ga: Two MSI related cosmetic changes

Signed-off-by: Leonid Bloch <leonid@daynix.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqemu-ga: Add .msi files to .gitignore
Leonid Bloch [Wed, 29 Jul 2015 17:10:50 +0000 (20:10 +0300)]
qemu-ga: Add .msi files to .gitignore

Signed-off-by: Leonid Bloch <leonid@daynix.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agos390: fix softmmu compilation
Laurent Vivier [Fri, 28 Aug 2015 10:23:41 +0000 (12:23 +0200)]
s390: fix softmmu compilation

guest_base must be used only in linux-user mode.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Message-id: 1440757421-9674-1-git-send-email-laurent@vivier.eu
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>