mirror of https://github.com/xemu-project/xemu.git
QAPI patches patches for 2022-04-21
-----BEGIN PGP SIGNATURE----- iQJGBAABCAAwFiEENUvIs9frKmtoZ05fOHC0AOuRhlMFAmJhZgISHGFybWJydUBy ZWRoYXQuY29tAAoJEDhwtADrkYZTuZQP/iesk/r4ytyk+q+ksNCQHTZl4B4uZcbI TgbA1dwbwkKOfNaqByKZzXvbymL9Y4RpZavZ0i1qa3hK5orKHThLK4omRaFD+SPp sH53TeTgkG/UNUQk00dim1BzuWJefqFo1rYSqvTzaXVPyx1Q9Gk9193q5zDTlMJs w6UKD+q+Yxne9aoi1IH2NzzEKElHz7MMFeBDsnxDbkedzBxY1Ka05IOI2ucXhJ7X mYTZxHsrjncW4qJNkf57u9y4faNDIBeT3vkFqBaIeTXSSqm+xO1rkLanGOLQKtIM zD6JDMcqsIkZttEy0QCOrjKvMueWaOTZsS0sbdCC+JpBAbyVeS83kmRyYwEhyGre FJzf81zcEH6FtnDYudWWUT7hKV6sHWbw+4ho5WTkCYnr/Cfqr3TyDbSW+f/eIxUK vaujP/8MTypS4p0mx4QfM2/eO05oZHwEaslOn0gkg7siAJWuC7KUkkWSwz6ZNZCp qj/+jtDRGhvB4bGFusciqwtbnLNtVPX2meUuVxK74lmKa00+zXraNFfvGIxfzzC0 pJ6weJj2jMLo5OEsZ2xWfNqhDigFQYxbGR8X3N2hg5GZTx1k5WXx7mRz3GlAwd8Q /4hcTBXKTFxDNxXqzL2eHBtaruKHjnHoVo2eAodyF+9FqErInjr/wisVm6I+R8NR Z94UBs8lvMIC =a3AD -----END PGP SIGNATURE----- Merge tag 'pull-qapi-2022-04-21' of git://repo.or.cz/qemu/armbru into staging QAPI patches patches for 2022-04-21 # -----BEGIN PGP SIGNATURE----- # # iQJGBAABCAAwFiEENUvIs9frKmtoZ05fOHC0AOuRhlMFAmJhZgISHGFybWJydUBy # ZWRoYXQuY29tAAoJEDhwtADrkYZTuZQP/iesk/r4ytyk+q+ksNCQHTZl4B4uZcbI # TgbA1dwbwkKOfNaqByKZzXvbymL9Y4RpZavZ0i1qa3hK5orKHThLK4omRaFD+SPp # sH53TeTgkG/UNUQk00dim1BzuWJefqFo1rYSqvTzaXVPyx1Q9Gk9193q5zDTlMJs # w6UKD+q+Yxne9aoi1IH2NzzEKElHz7MMFeBDsnxDbkedzBxY1Ka05IOI2ucXhJ7X # mYTZxHsrjncW4qJNkf57u9y4faNDIBeT3vkFqBaIeTXSSqm+xO1rkLanGOLQKtIM # zD6JDMcqsIkZttEy0QCOrjKvMueWaOTZsS0sbdCC+JpBAbyVeS83kmRyYwEhyGre # FJzf81zcEH6FtnDYudWWUT7hKV6sHWbw+4ho5WTkCYnr/Cfqr3TyDbSW+f/eIxUK # vaujP/8MTypS4p0mx4QfM2/eO05oZHwEaslOn0gkg7siAJWuC7KUkkWSwz6ZNZCp # qj/+jtDRGhvB4bGFusciqwtbnLNtVPX2meUuVxK74lmKa00+zXraNFfvGIxfzzC0 # pJ6weJj2jMLo5OEsZ2xWfNqhDigFQYxbGR8X3N2hg5GZTx1k5WXx7mRz3GlAwd8Q # /4hcTBXKTFxDNxXqzL2eHBtaruKHjnHoVo2eAodyF+9FqErInjr/wisVm6I+R8NR # Z94UBs8lvMIC # =a3AD # -----END PGP SIGNATURE----- # gpg: Signature made Thu 21 Apr 2022 07:11:14 AM PDT # gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653 # gpg: issuer "armbru@redhat.com" # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [undefined] # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [undefined] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * tag 'pull-qapi-2022-04-21' of git://repo.or.cz/qemu/armbru: qapi: Fix version of cpu0-id field qapi: Fix typo qapi: Fix documentation for query-xen-replication-status docs: qapi: Remove outdated reference to simple unions qapi-schema: test: add a unit test for parsing array alternates qapi-schema: test: add a qapi-schema-test for array alternates qapi-schema: support alternates with array type Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
commit
378f973a6c
|
@ -41,8 +41,8 @@ used internally.
|
|||
|
||||
There are several kinds of types: simple types (a number of built-in
|
||||
types, such as ``int`` and ``str``; as well as enumerations), arrays,
|
||||
complex types (structs and two flavors of unions), and alternate types
|
||||
(a choice between other types).
|
||||
complex types (structs and unions), and alternate types (a choice
|
||||
between other types).
|
||||
|
||||
|
||||
Schema syntax
|
||||
|
|
|
@ -1619,7 +1619,7 @@
|
|||
#
|
||||
# Query replication status while the vm is running.
|
||||
#
|
||||
# Returns: A @ReplicationResult object showing the status.
|
||||
# Returns: A @ReplicationStatus object showing the status.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
|
|
|
@ -144,7 +144,7 @@
|
|||
#
|
||||
# @cert-chain: PDH certificate chain (base64 encoded)
|
||||
#
|
||||
# @cpu0-id: Unique ID of CPU0 (base64 encoded) (since 7.0)
|
||||
# @cpu0-id: Unique ID of CPU0 (base64 encoded) (since 7.1)
|
||||
#
|
||||
# @cbitpos: C-bit location in page table entry
|
||||
#
|
||||
|
|
|
@ -149,7 +149,7 @@
|
|||
#
|
||||
# Note: This type is deprecated in favor of SocketAddress. The
|
||||
# difference between SocketAddressLegacy and SocketAddress is that the
|
||||
# latter is has fewer {} on the wire.
|
||||
# latter has fewer {} on the wire.
|
||||
#
|
||||
# Since: 1.3
|
||||
##
|
||||
|
|
|
@ -554,7 +554,7 @@ def check_alternate(expr: _JSONObject, info: QAPISourceInfo) -> None:
|
|||
check_name_lower(key, info, source)
|
||||
check_keys(value, info, source, ['type'], ['if'])
|
||||
check_if(value, info, source)
|
||||
check_type(value['type'], info, source)
|
||||
check_type(value['type'], info, source, allow_array=True)
|
||||
|
||||
|
||||
def check_command(expr: _JSONObject, info: QAPISourceInfo) -> None:
|
||||
|
|
|
@ -243,6 +243,7 @@ class QAPISchemaType(QAPISchemaEntity):
|
|||
'number': 'QTYPE_QNUM',
|
||||
'int': 'QTYPE_QNUM',
|
||||
'boolean': 'QTYPE_QBOOL',
|
||||
'array': 'QTYPE_QLIST',
|
||||
'object': 'QTYPE_QDICT'
|
||||
}
|
||||
return json2qtype.get(self.json_type())
|
||||
|
@ -1069,6 +1070,9 @@ class QAPISchema:
|
|||
None))
|
||||
|
||||
def _make_variant(self, case, typ, ifcond, info):
|
||||
if isinstance(typ, list):
|
||||
assert len(typ) == 1
|
||||
typ = self._make_array_type(typ[0], info)
|
||||
return QAPISchemaVariant(case, info, typ, ifcond)
|
||||
|
||||
def _def_union_type(self, expr, info, doc):
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
alternate-array.json: In alternate 'Alt':
|
||||
alternate-array.json:5: 'data' member 'two' cannot be an array
|
|
@ -1,5 +1,3 @@
|
|||
# we do not allow array branches in alternates
|
||||
# TODO: should we support this?
|
||||
{ 'struct': 'One',
|
||||
'data': { 'name': 'str' } }
|
||||
{ 'alternate': 'Alt',
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
module ./builtin
|
||||
object q_empty
|
||||
enum QType
|
||||
prefix QTYPE
|
||||
member none
|
||||
member qnull
|
||||
member qnum
|
||||
member qstring
|
||||
member qdict
|
||||
member qlist
|
||||
member qbool
|
||||
module alternate-array.json
|
||||
object One
|
||||
member name: str optional=False
|
||||
alternate Alt
|
||||
tag type
|
||||
case one: One
|
||||
case two: intList
|
|
@ -0,0 +1,2 @@
|
|||
alternate-conflict-lists.json: In alternate 'Alt':
|
||||
alternate-conflict-lists.json:4: branch 'two' can't be distinguished from 'one'
|
|
@ -0,0 +1,6 @@
|
|||
# Two lists conflict even if their inner types would be compatible
|
||||
{ 'struct': 'One',
|
||||
'data': { 'name': 'str' } }
|
||||
{ 'alternate': 'Alt',
|
||||
'data': { 'one': [ 'int' ],
|
||||
'two': [ 'str' ] } }
|
|
@ -11,6 +11,7 @@ schemas = [
|
|||
'alternate-conflict-dict.json',
|
||||
'alternate-conflict-enum-bool.json',
|
||||
'alternate-conflict-enum-int.json',
|
||||
'alternate-conflict-lists.json',
|
||||
'alternate-conflict-string.json',
|
||||
'alternate-conflict-bool-string.json',
|
||||
'alternate-conflict-num-string.json',
|
||||
|
|
|
@ -119,6 +119,7 @@
|
|||
{ 'alternate': 'AltEnumNum', 'data': { 'e': 'EnumOne', 'n': 'number' } }
|
||||
{ 'alternate': 'AltNumEnum', 'data': { 'n': 'number', 'e': 'EnumOne' } }
|
||||
{ 'alternate': 'AltEnumInt', 'data': { 'e': 'EnumOne', 'i': 'int' } }
|
||||
{ 'alternate': 'AltListInt', 'data': { 'l': ['int'], 'i': 'int' } }
|
||||
|
||||
# for testing use of 'str' within alternates
|
||||
{ 'alternate': 'AltStrObj', 'data': { 's': 'str', 'o': 'TestStruct' } }
|
||||
|
|
|
@ -121,6 +121,10 @@ alternate AltEnumInt
|
|||
tag type
|
||||
case e: EnumOne
|
||||
case i: int
|
||||
alternate AltListInt
|
||||
tag type
|
||||
case l: intList
|
||||
case i: int
|
||||
alternate AltStrObj
|
||||
tag type
|
||||
case s: str
|
||||
|
|
|
@ -775,6 +775,7 @@ static void test_visitor_in_alternate_number(TestInputVisitorData *data,
|
|||
AltEnumNum *aen;
|
||||
AltNumEnum *ans;
|
||||
AltEnumInt *asi;
|
||||
AltListInt *ali;
|
||||
|
||||
/* Parsing an int */
|
||||
|
||||
|
@ -801,6 +802,12 @@ static void test_visitor_in_alternate_number(TestInputVisitorData *data,
|
|||
g_assert_cmpint(asi->u.i, ==, 42);
|
||||
qapi_free_AltEnumInt(asi);
|
||||
|
||||
v = visitor_input_test_init(data, "42");
|
||||
visit_type_AltListInt(v, NULL, &ali, &error_abort);
|
||||
g_assert_cmpint(ali->type, ==, QTYPE_QNUM);
|
||||
g_assert_cmpint(ali->u.i, ==, 42);
|
||||
qapi_free_AltListInt(ali);
|
||||
|
||||
/* Parsing a double */
|
||||
|
||||
v = visitor_input_test_init(data, "42.5");
|
||||
|
@ -826,6 +833,37 @@ static void test_visitor_in_alternate_number(TestInputVisitorData *data,
|
|||
qapi_free_AltEnumInt(asi);
|
||||
}
|
||||
|
||||
static void test_visitor_in_alternate_list(TestInputVisitorData *data,
|
||||
const void *unused)
|
||||
{
|
||||
intList *item;
|
||||
Visitor *v;
|
||||
AltListInt *ali;
|
||||
int i;
|
||||
|
||||
v = visitor_input_test_init(data, "[ 42, 43, 44 ]");
|
||||
visit_type_AltListInt(v, NULL, &ali, &error_abort);
|
||||
g_assert(ali != NULL);
|
||||
|
||||
g_assert_cmpint(ali->type, ==, QTYPE_QLIST);
|
||||
for (i = 0, item = ali->u.l; item; item = item->next, i++) {
|
||||
g_assert_cmpint(item->value, ==, 42 + i);
|
||||
}
|
||||
|
||||
qapi_free_AltListInt(ali);
|
||||
ali = NULL;
|
||||
|
||||
/* An empty list is valid */
|
||||
v = visitor_input_test_init(data, "[]");
|
||||
visit_type_AltListInt(v, NULL, &ali, &error_abort);
|
||||
g_assert(ali != NULL);
|
||||
|
||||
g_assert_cmpint(ali->type, ==, QTYPE_QLIST);
|
||||
g_assert(!ali->u.l);
|
||||
qapi_free_AltListInt(ali);
|
||||
ali = NULL;
|
||||
}
|
||||
|
||||
static void input_visitor_test_add(const char *testpath,
|
||||
const void *user_data,
|
||||
void (*test_func)(TestInputVisitorData *data,
|
||||
|
@ -1187,6 +1225,8 @@ int main(int argc, char **argv)
|
|||
NULL, test_visitor_in_wrong_type);
|
||||
input_visitor_test_add("/visitor/input/alternate-number",
|
||||
NULL, test_visitor_in_alternate_number);
|
||||
input_visitor_test_add("/visitor/input/alternate-list",
|
||||
NULL, test_visitor_in_alternate_list);
|
||||
input_visitor_test_add("/visitor/input/fail/struct",
|
||||
NULL, test_visitor_in_fail_struct);
|
||||
input_visitor_test_add("/visitor/input/fail/struct-nested",
|
||||
|
|
Loading…
Reference in New Issue