Commit Graph

55547 Commits

Author SHA1 Message Date
Markus Armbruster 788b305c91 qapi: Convert indirect uses of FOO_lookup[...] to qapi_enum_lookup()
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-15-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-09-04 13:09:13 +02:00
Markus Armbruster 977c736f80 qapi: Mechanically convert FOO_lookup[...] to FOO_str(...)
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-14-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-09-04 13:09:13 +02:00
Markus Armbruster 5b5f825d44 qapi: Generate FOO_str() macro for QAPI enum FOO
The next commit will put it to use.  May look pointless now, but we're
going to change the FOO_lookup's type, and then it'll help.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-13-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-09-04 13:09:13 +02:00
Markus Armbruster 1c236ba531 qapi: Avoid unnecessary use of enum lookup table's sentinel
Currently, the FOO_lookup[] generated for QAPI enum types are
terminated by a NULL sentinel.

A future patch will generate enums with "holes".  NULL-termination
will cease to work then.

To prepare for that, replace "have we reached the sentinel?"
predicates by "have we reached the FOO__MAX value?" predicates.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-12-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-09-04 13:09:13 +02:00
Markus Armbruster 113e47ae6d qapi: Use qapi_enum_parse() in input_type_enum()
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-11-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-09-04 13:09:13 +02:00
Markus Armbruster 9ae33079c2 crypto: Use qapi_enum_parse() in qcrypto_block_luks_name_lookup()
Cc: "Daniel P. Berrange" <berrange@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-10-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Daniel P. Berrange <berrange@redhat.com>
2017-09-04 13:09:13 +02:00
Marc-André Lureau 8d5fb199fb quorum: Use qapi_enum_parse() in quorum_open()
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170822132255.23945-12-marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Rebased, qemu_opt_get() factored out, commit message tweaked]
Cc: Alberto Garcia <berto@igalia.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-9-git-send-email-armbru@redhat.com>
2017-09-04 13:09:13 +02:00
Marc-André Lureau f9509d1517 block: Use qemu_enum_parse() in blkdebug_debug_breakpoint()
The error message on invalid blkdebug events changes from

    qemu-system-x86_64: LOCATION: Invalid event name "VALUE"

to

    qemu-system-x86_64: LOCATION: invalid parameter value: VALUE

Slight degradation, but the message is sub-par even before the patch.
When complaining about a parameter value, both parameter name and
value should be mentioned, as the value may well not be unique.  Left
for another day.

Also left is the error message's unhelpful location: it points to the
config=FILENAME rather than into that file.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170822132255.23945-11-marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Rebased, commit message rewritten]
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Max Reitz <mreitz@redhat.com>
Cc: qemu-block@nongnu.org
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-8-git-send-email-armbru@redhat.com>
2017-09-04 13:09:13 +02:00
Marc-André Lureau 262517b7e0 hmp: Use qapi_enum_parse() in hmp_migrate_set_parameter()
The error message on invalid parameter name changes from

    Invalid parameter "NAME"

to

    invalid parameter value: NAME

Slight degratation, perhaps.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170822132255.23945-10-marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Rebased, assertion added, commit message rewritten]
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-7-git-send-email-armbru@redhat.com>
2017-09-04 13:09:13 +02:00
Marc-André Lureau 8e615e34f9 hmp: Use qapi_enum_parse() in hmp_migrate_set_capability()
The error message on invalid capability name changes from

    Invalid parameter "NAME"

to

    invalid parameter value: NAME

No worse than before.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170822132255.23945-9-marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Rebased, commit message rewritten]
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-6-git-send-email-armbru@redhat.com>
2017-09-04 13:09:13 +02:00
Markus Armbruster 00bbf50a50 tpm: Clean up model registration & lookup
We have a strict separation between enum TpmModel and tpm_models[]:

* TpmModel may have any number of members.  It just happens to have one.

* tpm_register_model() uses the first empty slot in tpm_models[].

  If you register more than tpm_models[] has space,
  tpn_register_model() fails.  Its caller silently ignores the
  failure.

  Register the same TpmModel more than once has no effect other than
  wasting tpm_models[] slots: tpm_model_is_registered() is happy with
  the first one it finds.

Since we only ever register one model, and tpm_models[] has space for
just that one, this contraption even works.

Turn tpm_models[] into a straight map from enum TpmType to bool.  Much
simpler.

Cc: Stefan Berger <stefanb@us.ibm.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-5-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
[Commit message typo fixed]
2017-09-04 13:09:13 +02:00
Marc-André Lureau a9a72aeefb tpm: Clean up driver registration & lookup
We have a strict separation between enum TpmType and be_drivers[]:

* TpmType may have any number of members.  It just happens to have one.

* tpm_register_driver() uses the first empty slot in be_drivers[].

  If you register more than tpm_models[] has space,
  tpm_register_driver() fails.  Its caller silently ignores the
  failure.

  If you register more than one with a given TpmType,
  tpm_display_backend_drivers() will shows all of them, but
  tpm_driver_find_by_type() and tpm_get_backend_driver() will find
  only the one one that registered first.

Since we only ever register one driver, and be_drivers[] has space for
just that one, this contraption even works.

Turn be_drivers[] into a straight map from enum TpmType to driver.
Much simpler, and has a decent chance to actually work should we ever
acquire additional drivers.

While there, use qapi_enum_parse() in tpm_get_backend_driver().

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170822132255.23945-8-marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Rebased, superfluous initializer dropped, commit message rewritten]
Cc: Stefan Berger <stefanb@us.ibm.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-4-git-send-email-armbru@redhat.com>
2017-09-04 13:09:13 +02:00
Markus Armbruster 06c60b6c46 qapi: Drop superfluous qapi_enum_parse() parameter max
The lookup tables have a sentinel, no need to make callers pass their
size.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-3-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[Rebased, commit message corrected]
2017-09-04 13:09:13 +02:00
Markus Armbruster 64355088e0 qapi: Update qapi-code-gen.txt examples to match current code
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-2-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-09-04 13:09:13 +02:00
Markus Armbruster f5cf31c575 qapi-schema: Improve section headings
The generated QEMU QMP reference is now structured as follows:

    1.1 Introduction
    1.2 Stability Considerations
    1.3 Common data types
    1.4 Socket data types
    1.5 VM run state
    1.6 Cryptography
    1.7 Block devices
    1.7.1 Block core (VM unrelated)
    1.7.2 QAPI block definitions (vm unrelated)
    1.8 Character devices
    1.9 Net devices
    1.10 Rocker switch device
    1.11 TPM (trusted platform module) devices
    1.12 Remote desktop
    1.12.1 Spice
    1.12.2 VNC
    1.13 Input
    1.14 Migration
    1.15 Transactions
    1.16 Tracing
    1.17 QMP introspection
    1.18 Miscellanea

Section "1.18 Miscellanea" is still too big: it documents 134 symbols.
Section "1.7.1 Block core (VM unrelated)" is also rather big: 128
symbols.  All the others are of reasonable size.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-17-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-09-04 13:09:12 +02:00
Markus Armbruster 496490a604 qapi-schema: Move queries from common.json to qapi-schema.json
query-version and query-commands are in common.json for no good
reason.  Several similar queries are in qapi-schema.json.  Move them
there.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-16-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-09-04 13:09:12 +02:00
Markus Armbruster 2031c133ed qapi-schema: Make block-core.json self-contained
Except for block-core.json, the sub-schemas are self-contained: if
they use a symbol defined in another sub-schema, they include that
sub-schema.  To check, feed the sub-schema to qapi2texi (or any other
QAPI generator) along with the pragma from qapi-schema.json.

Fix up things to make block-core.json self-contained, too.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-15-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-09-04 13:09:12 +02:00
Markus Armbruster c09656f1d3 qapi-schema: Fold event.json back into qapi-schema.json
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-14-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-09-04 13:09:12 +02:00
Markus Armbruster fd87a6bd3b qapi-schema: Move block events from event.json to block.json
Cc: Alberto Garcia <berto@igalia.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-13-git-send-email-armbru@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-09-04 13:09:12 +02:00
Markus Armbruster 3859b6cf67 qapi-schema: Collect TPM stuff in qapi/tpm.json
Sadly, we don't have a TPM maintainer, not even a MAINTAINERS entry.
Create one, and mark it orphaned.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-12-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-09-04 13:09:12 +02:00
Markus Armbruster fa988e39bf qapi-schema: Collect transaction stuff in qapi/transaction.json
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-11-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-09-04 13:09:12 +02:00
Markus Armbruster 48685a8e2c qapi-schema: Collect migration stuff in qapi/migration.json
Cc: Juan Quintela <quintela@redhat.com>
Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-10-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2017-09-04 13:09:12 +02:00
Markus Armbruster 608cfed66a qapi-schema: Collect UI stuff in qapi/ui.json
UI stuff is remote desktop stuff (Spice, VNC) and input stuff (mouse,
keyboard).

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-9-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
2017-09-04 13:09:12 +02:00
Markus Armbruster 3c0bd37dac qapi-schema: Collect net device stuff in qapi/net.json
Cc: Jason Wang <jasowang@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-8-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-09-04 13:09:12 +02:00
Markus Armbruster dbeee39233 qapi-schema: Collect char device stuff in qapi/char.json
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-7-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-09-04 13:09:12 +02:00
Markus Armbruster 0e201d3402 qapi-schema: Collect run state stuff in qapi/run-state.json
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-6-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-09-04 13:09:12 +02:00
Markus Armbruster a2ff5a48c4 qapi-schema: Collect sockets stuff in qapi/sockets.json
Cc: "Daniel P. Berrange" <berrange@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-5-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-09-04 13:09:12 +02:00
Markus Armbruster c7a4e0c40d qapi-schema: Rocker doc section contains unrelated stuff, fix
Bug: section "Rocker switch device" starts with the rocker stuff, but
then has unrelated stuff, like ReplayMode, xen-load-devices-state, ...

Cause: rocker.json is included in the middle of section "QMP commands".

Fix: include it in a sane place, namely next to the other sub-schemas.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <1503602048-12268-4-git-send-email-armbru@redhat.com>
2017-09-04 13:09:12 +02:00
Markus Armbruster a885cd3915 qapi-schema: Introspection doc is in the wrong section, fix
Bug: introspection documentation is in section "Tracing commands".

Cause: sub-schema qapi/introspect.json lacks a section header, and
therefore goes into whatever section precedes its include.

Fix: add a section header.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <1503602048-12268-3-git-send-email-armbru@redhat.com>
2017-09-04 13:09:12 +02:00
Markus Armbruster 211e5063be qapi-schema: Document how generated documentation is ordered
Documentation generated with qapi2texi.py is in source order, with
included sub-schemas inserted at the first include directive
(subsequent include directives have no effect).  To get a sane and
stable order, it's best to include each sub-schema just once, or
include it first in qapi-schema.json.  Document that.

While there, drop a few redundant comments.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <1503602048-12268-2-git-send-email-armbru@redhat.com>
2017-09-04 13:09:12 +02:00
Marc-André Lureau cbb6540526 qlit: Tighten QLit list vs QList comparison
We check that all members of the QLit list are also in the QList.  We
neglect to check the other direction.  Fix that.

While there, use QLIST_FOREACH_ENTRY() to simplify the code and break
the loop on the first mismatch.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170825105913.4060-13-marcandre.lureau@redhat.com>
[Commit message improved]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2017-09-04 13:09:12 +02:00
Marc-André Lureau 6da8a7a3b4 qlit: Tighten QLit dict vs QDict comparison
We check that all members of the QLit dictionary are also in the
QDict.  We neglect to check the other direction.

Comparing the number of members suffices, because QDict can't
contain duplicate members, and putting duplicates in a QLit is a
programming error.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170825105913.4060-12-marcandre.lureau@redhat.com>
[Commit message improved]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2017-09-04 13:09:12 +02:00
Marc-André Lureau 382176b4d7 tests/check-qlit: New, covering qobject/qlit.c
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170825105913.4060-11-marcandre.lureau@redhat.com>
[Copyright notice correction squashed in, commit message tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2017-09-04 13:09:12 +02:00
Marc-André Lureau 5f4bd80936 qlit: Replace open-coded qnum_get_int() by call
Bonus: rids us of a side effect in an assertion.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170825105913.4060-10-marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2017-09-04 13:09:11 +02:00
Marc-André Lureau 6c6084c1b0 qlit: add QLIT_QNULL and QLIT_BOOL
As they are going to be used in the following patches.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170825105913.4060-9-marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2017-09-04 13:09:11 +02:00
Marc-André Lureau e2346a1952 qlit: make qlit_equal_qobject() take const arguments
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170825105913.4060-8-marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2017-09-04 13:09:11 +02:00
Marc-André Lureau d9eba57a6a qlit: make qlit_equal_qobject return a bool
Make it more obvious about the expected return values.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170825105913.4060-7-marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2017-09-04 13:09:11 +02:00
Marc-André Lureau 60cc2eb7af qlit: rename compare_litqobj_to_qobj() to qlit_equal_qobject()
compare_litqobj_to_qobj() lacks a qlit_ prefix.  Moreover, "compare"
suggests -1, 0, +1 for less than, equal and greater than.  The
function actually returns non-zero for equal, zero for unequal.
Rename to qlit_equal_qobject().

Its return type will be cleaned up in the next patch.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170825105913.4060-6-marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2017-09-04 13:09:11 +02:00
Marc-André Lureau d5cd8fbf13 qlit: Change compound literals to initializers
The QLIT_QFOO() macros expand into compound literals.  Sadly, gcc
doesn't recognizes these as constant expressions (clang does), which
makes the macros useless for initializing objects with static storage
duration.

There is a gcc bug about it:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71713

Change the macros to expand into initializers.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170825105913.4060-5-marcandre.lureau@redhat.com>
[Commit message improved]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2017-09-04 13:09:11 +02:00
Marc-André Lureau 082696e767 qlit: use QLit prefix consistently
Rename from LiteralQ to QLit.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170825105913.4060-4-marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2017-09-04 13:09:11 +02:00
Marc-André Lureau 28035bcdf4 qlit: move qlit from check-qjson to qobject/
Fix code style issues while at it, to please checkpatch.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170825105913.4060-3-marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2017-09-04 13:09:11 +02:00
Marc-André Lureau 0f9afc2a8b qdict: Add qdict_put_null() helper, and put it to use
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170825105913.4060-2-marcandre.lureau@redhat.com>
[Update to qobject.cocci squashed in, commit message tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2017-09-04 13:09:11 +02:00
Markus Armbruster f90cb2846a qobject: Explain how QNum works, and why
Suggested-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503384739-17207-1-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
[Comment typos fixed]
2017-09-04 13:09:11 +02:00
Markus Armbruster e4a426e75e tests/qmp-test: Add generic, basic test of query commands
A command is a query if it has no side effect and yields a result.
Such commands are typically named query-FOO, but there are exceptions.

The basic idea is to find candidates with query-qmp-schema, filter out
the ones that aren't queries with an explicit blacklist, and test the
remaining ones against a QEMU with no special arguments.

The current blacklist is just add-fd.

The test can't do queries with arguments, because it knows nothing
about the arguments.  No coverage for query-cpu-model-baseline,
query-cpu-model-comparison, query-cpu-model-expansion, query-rocker,
query-rocker-ports, query-rocker-of-dpa-flows, and
query-rocker-of-dpa-groups.

Most tested commands are expected to succeed.  The test does not check
the return value then.

query-balloon and query-vm-generation-id are expected to fail because
they need a virtio-balloon / vmgenid device to succeed, and this test
is too dumb to set one up.  Could be addressed later.

query-acpi-ospm-status and query-hotpluggable-cpus are expected to
fail because they require features provided only by special machine
types, and this test is too dumb to set that up.  Could also be
addressed later.

Several commands may either be functional or stubs that always fail,
depending on build configuration.  Ideally, the stubs shouldn't be in
query-qmp-schema, but that requires QAPI schema compile-time
configuration, which we don't have, yet.  Until we do, we need to
figure out whether a command is a stub.  When we have a suitable
CONFIG_FOO preprocessor symbol is available, use that.  Else,
simply blacklist the command for now.

We get basic test coverage for the following commands, except as
noted:

    qom-list-types
    query-acpi-ospm-status      (expected to fail)
    query-balloon               (expected to fail)
    query-block
    query-block-jobs
    query-blockstats
    query-chardev
    query-chardev-backends
    query-command-line-options
    query-commands
    query-cpu-definitions       (blacklisted for now)
    query-cpus
    query-dump
    query-dump-guest-memory-capability
    query-events
    query-fdsets
    query-gic-capabilities      (blacklisted for now)
    query-hotpluggable-cpus     (expected to fail)
    query-iothreads
    query-kvm
    query-machines
    query-memdev
    query-memory-devices
    query-mice
    query-migrate
    query-migrate-cache-size
    query-migrate-capabilities
    query-migrate-parameters
    query-name
    query-named-block-nodes
    query-pci                   (blacklisted for now)
    query-qmp-schema
    query-rx-filter
    query-spice
    query-status
    query-target
    query-tpm
    query-tpm-models
    query-tpm-types
    query-uuid
    query-version
    query-vm-generation-id      (expected to fail)
    query-vnc
    query-vnc-servers
    query-xen-replication-status

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1502461148-10154-1-git-send-email-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[Typos in code under #ifndef and in the commit message fixed]
2017-09-04 13:09:03 +02:00
Eduardo Habkost fda72ab451 qapi: Fix error handling code on alternate conflict
The conflict check added by commit c0644771 ("qapi: Reject
alternates that can't work with keyval_parse()") doesn't work
with the following declaration:

  { 'alternate': 'Alt',
    'data': { 'one': 'bool',
              'two': 'str' } }

It crashes with:

  Traceback (most recent call last):
    File "./scripts/qapi-types.py", line 295, in <module>
      schema = QAPISchema(input_file)
    File "/home/ehabkost/rh/proj/virt/qemu/scripts/qapi.py", line 1468, in __init__
      self.exprs = check_exprs(parser.exprs)
    File "/home/ehabkost/rh/proj/virt/qemu/scripts/qapi.py", line 958, in check_exprs
      check_alternate(expr, info)
    File "/home/ehabkost/rh/proj/virt/qemu/scripts/qapi.py", line 830, in check_alternate
      % (name, key, types_seen[qtype]))
  KeyError: 'QTYPE_QSTRING'

This happens because the previously-seen conflicting member
('one') can't be found at types_seen[qtype], but at
types_seen['QTYPE_BOOL'].

Fix the bug by moving the error check to the same loop that adds
new items to types_seen, raising an exception if types_seen[qt]
is already set.

Add two additional test cases that can detect the bug.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <20170717180926.14924-1-ehabkost@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2017-09-01 12:51:04 +02:00
Peter Maydell 223cd0e13f -----BEGIN PGP SIGNATURE-----
iQIcBAABAgAGBQJZp+UNAAoJENro4Ql1lpzlL3AP/3gyYuAt4vR9FzeDx64XfPzB
 x31p50TadRXRIrb5mmN69dXZbg0pmnk68m0HEeSXBl0wh+gQVVPL2xfaMow2UhIw
 jd0v9IxkR8PH9ruEso3fJH1RbNGy9aRUlgCYQdGo3Y4W3IZhOsSOKwdmrU46rohy
 Bq+RzEL0sWH5I6v+ylFJXktNrVY6n1P1epWY5BnldDm58+l727z/H1rnHPA3t6sL
 FHoCmDypimXE4bOEXUQ9y30z1KGYlSmVE9Jm9ABGakcnK3LK0nZl758/DEJDZg02
 Ma+TJT3lnwqbLWPIanikeAiP6pf2NkYVhaJN42rqrYhFbOsl6ge2yzHxK83dzju+
 3b+Rk9yO932nQLwPTFGA1VGupAUqBtdDIMfZy8RpVD1anA83xgphBP2xPJh0Jsnj
 SAFinRdl1XFFVERoTLpMUqJWujp2mBsR14Ljw9dnF0HEfvr2jLkEyTwb6LwHyInx
 pAT06s9grsv0wlvaH+fZK5P1KviHr8TjX56qQM0YuGYr8LzvWAbd3mPor7c0EtR6
 pr2GhbKQIhCq/foRD9nWMDlmUCWmJBjaCk++XUnmwFr61eegLku0jpRiClwFwPI3
 I9dNfiJWrQFdtLFi2xi6A/ibtmCE9JS4lAZYw3ZVGnW8ulx0C2qev5HrgkcDtgq+
 vmNfitmbOSG5ZvBn+3eC
 =jCiK
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/elmarco/tags/tidy-pull-request' into staging

# gpg: Signature made Thu 31 Aug 2017 11:29:33 BST
# gpg:                using RSA key 0xDAE8E10975969CE5
# gpg: Good signature from "Marc-André Lureau <marcandre.lureau@redhat.com>"
# gpg:                 aka "Marc-André Lureau <marcandre.lureau@gmail.com>"
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 87A9 BD93 3F87 C606 D276  F62D DAE8 E109 7596 9CE5

* remotes/elmarco/tags/tidy-pull-request: (29 commits)
  eepro100: replace g_malloc()+memcpy() with g_memdup()
  test-iov: replace g_malloc()+memcpy() with g_memdup()
  i386: replace g_malloc()+memcpy() with g_memdup()
  i386: introduce ELF_NOTE_SIZE macro
  decnumber: use DIV_ROUND_UP
  kvm: use DIV_ROUND_UP
  i386/dump: use DIV_ROUND_UP
  ppc: use DIV_ROUND_UP
  msix: use DIV_ROUND_UP
  usb-hub: use DIV_ROUND_UP
  q35: use DIV_ROUND_UP
  piix: use DIV_ROUND_UP
  virtio-serial: use DIV_ROUND_UP
  console: use DIV_ROUND_UP
  monitor: use DIV_ROUND_UP
  virtio-gpu: use DIV_ROUND_UP
  vga: use DIV_ROUND_UP
  ui: use DIV_ROUND_UP
  vnc: use DIV_ROUND_UP
  vvfat: use DIV_ROUND_UP
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2017-08-31 15:52:43 +01:00
Peter Maydell 1d2a8e0690 -----BEGIN PGP SIGNATURE-----
iQEcBAABAgAGBQJZp8cdAAoJEJykq7OBq3PIyeQIALXlHMTJM+I2dfUZfkIYFrEk
 Euf0z1URMJ9k5hKy1kIhAVlmGWs2fB1snTCm9tZjCtPqMjH5EDWb8z+zrqmorpcQ
 LyIccYdT/XrFeU1x+n4PlhaubQKXiAfZbUbgZpbkZwGgX0k51gx3V9z1smHme6AX
 CIODhgotqbJ0Hy2kuAP8TM2OPgx1tcyel34GuT5e3Rrb8nL0QfHfG4nxcpWBB0q8
 iipoJfBvKWpRV0azSg+s51x1FFcB3iDKr81uBVABOyLtVW13nF6EMRIP76rqy5qp
 relNDo6kdmh0W19motNPjOa4BhnPQakEfF+bdARBOJPbXsFzd5X193yQBKW+nq4=
 =5ltA
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging

# gpg: Signature made Thu 31 Aug 2017 09:21:49 BST
# gpg:                using RSA key 0x9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* remotes/stefanha/tags/block-pull-request:
  qcow2: allocate cluster_cache/cluster_data on demand
  qemu-doc: Add UUID support in initiator name
  tests: migration/guestperf Python 2.6 argparse compatibility
  docker.py: Python 2.6 argparse compatibility
  scripts: add argparse module for Python 2.6 compatibility
  misc: Remove unused Error variables
  oslib-posix: Print errors before aborting on qemu_alloc_stack()
  throttle: Test the valid range of config values
  throttle: Make burst_length 64bit and add range checks
  throttle: Make LeakyBucket.avg and LeakyBucket.max integer types
  throttle: Remove throttle_fix_bucket() / throttle_unfix_bucket()
  throttle: Make throttle_is_valid() a bit less verbose
  throttle: Update the throttle_fix_bucket() documentation
  throttle: Fix wrong variable name in the header documentation
  nvme: Fix get/set number of queues feature, again

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2017-08-31 14:33:54 +01:00
Peter Maydell 2e75021eb6 nbd patches for 2017-08-30
- Kashyap Chamarthy: qemu-iotests: Extend non-shared storage migration test (194)
 - Stefan Hajnaczi: 0/3 nbd-client: enter read_reply_co during init to avoid crash
 - Vladimir Sementsov-Ogievskiy: portions of 0/17 nbd client refactoring and fixing
 -----BEGIN PGP SIGNATURE-----
 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg
 
 iQEcBAABCAAGBQJZpv4CAAoJEKeha0olJ0NqpLYH/3jX5h8r4kc4AcJYeS4FXHri
 pHWJIvbcVfw59eLM6RmGdRxAGfVk9cQHyo1O90Rym8/KWNo4BRz15AlVG/F6gqO2
 9BgQZ7I/J0HViV2RrKWDR6btkcnAFabmHt8oeUKQHc60jBWL+8xtlcfdlnwvABVs
 V7MPv27vZJKVPgku2i1jTDpYu65vKAPxGw8hly3qAkMXQuYnP0K0WkN6ihHgmx1F
 CEZ99GUfeNExk+71tN6ULV77rtR1E0iQnsrK2mBuYhgIhveJ8wYiqb4flDnlqHfm
 G7hvpyCAScDhIfEbMAV5K38VCRTJU/XK3x2FNljSAcZa0X1UTX+qprl0zhY9ENk=
 =XaJp
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2017-08-30' into staging

nbd patches for 2017-08-30

- Kashyap Chamarthy: qemu-iotests: Extend non-shared storage migration test (194)
- Stefan Hajnaczi: 0/3 nbd-client: enter read_reply_co during init to avoid crash
- Vladimir Sementsov-Ogievskiy: portions of 0/17 nbd client refactoring and fixing

# gpg: Signature made Wed 30 Aug 2017 19:03:46 BST
# gpg:                using RSA key 0xA7A16B4A2527436A
# gpg: Good signature from "Eric Blake <eblake@redhat.com>"
# gpg:                 aka "Eric Blake (Free Software Programmer) <ebb9@byu.net>"
# gpg:                 aka "[jpeg image of size 6874]"
# Primary key fingerprint: 71C2 CC22 B1C4 6029 27D2  F3AA A7A1 6B4A 2527 436A

* remotes/ericb/tags/pull-nbd-2017-08-30:
  block/nbd-client: refactor request send/receive
  block/nbd-client: rename nbd_recv_coroutines_enter_all
  block/nbd-client: get rid of ssize_t
  nbd/client: fix nbd_send_request to return int
  nbd/client: refactor nbd_receive_reply
  nbd/client: refactor nbd_read_eof
  nbd/client: fix nbd_opt_go
  qemu-iotests: test NBD over UNIX domain sockets in 083
  qemu-iotests: improve nbd-fault-injector.py startup protocol
  nbd-client: avoid read_reply_co entry if send failed
  qemu-iotests: Extend non-shared storage migration test (194)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2017-08-31 13:51:42 +01:00
Peter Maydell 1415e8ea1f First batch of s390x patches:
- 2.11 compat machine
 - support the new --s390-pgste linker option, making it possible to
   avoid enabling the global vm.allocate_pgste systl if all pieces
   are in place
 - correctly identify some devices as not hotpluggable
 - clean up some tests and enable them for s390x
 - wire up the diag288 watchdog in tcg
 - clean up dependencies on CONFIG_PCI, making it possible to disable
   it by hand
 - lots of cleanup in target/s390x/
 - fix alignment of the ccw1 structure in the s390-ccw bios
 - and some more bugfixes
 -----BEGIN PGP SIGNATURE-----
 
 iQIcBAABAgAGBQJZpuqCAAoJEN7Pa5PG8C+vGCUP/39T8NxUtnz+ZU28F7t2ON+b
 L8ASoxit4mQ5DkB8aKqm5UofwF3KGfAOeLWOxGNOsXtRUD0F6hmv7ep3brIIv8nf
 HJ7JlbZxrqL6ExVJrRcNcshu5LqJ/AWCdmRnIG5OP0DGBQ12HXTcvZ7tktNimqpg
 kJ6hfwxQaj3j79i2DsopsuEi800NXdyp9QKSj5jGNcVB23zEkpp6jLb3Jzbts9Wv
 SZwCQeJSI1tGN6nOcMmDHEQtYdGvz3gdf86AVuR3Vlhv0bElRcBeqKau4Jky2Xow
 wcy5B2wVuNqpa2SvE1MFI6zmDRIH2x1NcJ+n4AmbpnxmDT2LhfFIeR2Ieqfy5qHC
 uiKVaLUVKaAC02APyRUGApiPetPv6jm2U7BKZvpmqlPqLjEExAiZmLpK1cp8dkY+
 oU9Z0ce7u+NWTdziEFzRdmrJMO0DNd9dhKHWOZOU+ksL374dgMLOPzmRWKkopKuE
 nrtEf1IxmH6WirMsCUsrWrlwQb7SHJfWYQR5IyVhCfQ5zWzY3o0JtyqP/BDCBU8R
 Yv2bmR1krqfc7B1YqT3nGIeq6IGw80OTtgoxerqxcyvwAp+NVE4vb1mtqh/J7Kq3
 3aM6tq5Pju32lYdFL443AtsRXlEtPDyGuU1VrnuMmmy11gk6Mq7B8/yWCLrPai1n
 lFQyvYfrMoW6vGN/juiL
 =WxdK
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20170830' into staging

First batch of s390x patches:
- 2.11 compat machine
- support the new --s390-pgste linker option, making it possible to
  avoid enabling the global vm.allocate_pgste systl if all pieces
  are in place
- correctly identify some devices as not hotpluggable
- clean up some tests and enable them for s390x
- wire up the diag288 watchdog in tcg
- clean up dependencies on CONFIG_PCI, making it possible to disable
  it by hand
- lots of cleanup in target/s390x/
- fix alignment of the ccw1 structure in the s390-ccw bios
- and some more bugfixes

# gpg: Signature made Wed 30 Aug 2017 17:40:34 BST
# gpg:                using RSA key 0xDECF6B93C6F02FAF
# gpg: Good signature from "Cornelia Huck <conny@cornelia-huck.de>"
# gpg:                 aka "Cornelia Huck <huckc@linux.vnet.ibm.com>"
# gpg:                 aka "Cornelia Huck <cornelia.huck@de.ibm.com>"
# gpg:                 aka "Cornelia Huck <cohuck@kernel.org>"
# gpg:                 aka "Cornelia Huck <cohuck@redhat.com>"
# Primary key fingerprint: C3D0 D66D C362 4FF6 A8C0  18CE DECF 6B93 C6F0 2FAF

* remotes/cohuck/tags/s390x-20170830: (44 commits)
  s390x/pci: fixup trap_msix()
  pc-bios/s390-ccw.img: update image
  s390-ccw: Fix alignment for CCW1
  s390x/s390-stattrib: Mark the storage attribute as not user_creatable
  target/s390x: cleanup cpu.h
  s390x/kvm: move KVM declarations and stubs to separate files
  s390x: avoid calling kvm_ functions outside of target/s390x/
  target/s390x: move a couple of functions to cpu.c
  target/s390x: introduce internal.h
  target/s390x: move get_per_in_range() to misc_helper.c
  target/s390x: move s390_do_cpu_reset() to diag.c
  target/s390x: move psw_key_valid() to mem_helper.c
  target/s390x: move cpu_mmu_idx_to_asc() to excp_helper.c
  target/s390x: move cc_name() to helper.c
  target/s390x: move gtod_*() declarations to s390-virtio.h
  s390x: drop inclusion of sysemu/kvm.h from some files
  s390x/cpumodel: factor out determination of default model name
  target/s390x: no need to pass kvm_state to savevm_gtod handlers
  target/s390x: simplify gs_allowed()
  target/s390x: simplify ri_allowed()
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2017-08-31 11:29:41 +01:00
Marc-André Lureau e4d67e4f2e eepro100: replace g_malloc()+memcpy() with g_memdup()
I found these pattern via grepping the source tree. I don't have a
coccinelle script for it!

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
2017-08-31 12:29:07 +02:00