[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 34/40] qapi: Drop inline nested struct in query-versi
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PULL 34/40] qapi: Drop inline nested struct in query-version |
Date: |
Tue, 5 May 2015 18:47:20 +0200 |
From: Eric Blake <address@hidden>
A future patch will be using a 'name':{dictionary} entry in the
QAPI schema to specify a default value for an optional argument
(see previous commit message for more details why); but existing
use of inline nested structs conflicts with that goal. This patch
fixes one of only two commands relying on nested types, by
breaking the nesting into an explicit type; it means that the
type is now boxed instead of unboxed in C code, but the QMP wire
format is unaffected by this change.
Prefer the safer g_new0() while making the conversion.
Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Markus Armbruster <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
---
hmp.c | 2 +-
qapi/common.json | 26 +++++++++++++++++++-------
qmp.c | 9 +++++----
3 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/hmp.c b/hmp.c
index d85d913..97d9c2c 100644
--- a/hmp.c
+++ b/hmp.c
@@ -60,7 +60,7 @@ void hmp_info_version(Monitor *mon, const QDict *qdict)
info = qmp_query_version(NULL);
monitor_printf(mon, "%" PRId64 ".%" PRId64 ".%" PRId64 "%s\n",
- info->qemu.major, info->qemu.minor, info->qemu.micro,
+ info->qemu->major, info->qemu->minor, info->qemu->micro,
info->package);
qapi_free_VersionInfo(info);
diff --git a/qapi/common.json b/qapi/common.json
index 12431c6..bad56bf 100644
--- a/qapi/common.json
+++ b/qapi/common.json
@@ -29,15 +29,28 @@
'DeviceNotActive', 'DeviceNotFound', 'KVMMissingCap' ] }
##
+# @VersionTriple
+#
+# A three-part version number.
+#
+# @qemu.major: The major version number.
+#
+# @qemu.minor: The minor version number.
+#
+# @qemu.micro: The micro version number.
+#
+# Since: 2.4
+##
+{ 'struct': 'VersionTriple',
+ 'data': {'major': 'int', 'minor': 'int', 'micro': 'int'} }
+
+
+##
# @VersionInfo:
#
# A description of QEMU's version.
#
-# @qemu.major: The major version of QEMU
-#
-# @qemu.minor: The minor version of QEMU
-#
-# @qemu.micro: The micro version of QEMU. By current convention, a micro
+# @qemu: The version of QEMU. By current convention, a micro
# version of 50 signifies a development branch. A micro version
# greater than or equal to 90 signifies a release candidate for
# the next minor version. A micro version of less than 50
@@ -51,8 +64,7 @@
# Since: 0.14.0
##
{ 'struct': 'VersionInfo',
- 'data': {'qemu': {'major': 'int', 'minor': 'int', 'micro': 'int'},
- 'package': 'str'} }
+ 'data': {'qemu': 'VersionTriple', 'package': 'str'} }
##
# @query-version:
diff --git a/qmp.c b/qmp.c
index e6c7050..3f5dfe3 100644
--- a/qmp.c
+++ b/qmp.c
@@ -45,15 +45,16 @@ NameInfo *qmp_query_name(Error **errp)
VersionInfo *qmp_query_version(Error **errp)
{
- VersionInfo *info = g_malloc0(sizeof(*info));
+ VersionInfo *info = g_new0(VersionInfo, 1);
const char *version = QEMU_VERSION;
char *tmp;
- info->qemu.major = strtol(version, &tmp, 10);
+ info->qemu = g_new0(VersionTriple, 1);
+ info->qemu->major = strtol(version, &tmp, 10);
tmp++;
- info->qemu.minor = strtol(tmp, &tmp, 10);
+ info->qemu->minor = strtol(tmp, &tmp, 10);
tmp++;
- info->qemu.micro = strtol(tmp, &tmp, 10);
+ info->qemu->micro = strtol(tmp, &tmp, 10);
info->package = g_strdup(QEMU_PKGVERSION);
return info;
--
1.9.3
- [Qemu-devel] [PULL 24/40] qapi: More rigourous checking of types, (continued)
- [Qemu-devel] [PULL 24/40] qapi: More rigourous checking of types, Markus Armbruster, 2015/05/05
- [Qemu-devel] [PULL 29/40] qapi: Document 'struct' metatype, Markus Armbruster, 2015/05/05
- [Qemu-devel] [PULL 40/40] qapi: Check for member name conflicts with a base class, Markus Armbruster, 2015/05/05
- [Qemu-devel] [PULL 33/40] qapi: Drop tests for inline nested structs, Markus Armbruster, 2015/05/05
- [Qemu-devel] [PULL 35/40] qapi: Drop inline nested structs in query-pci, Markus Armbruster, 2015/05/05
- [Qemu-devel] [PULL 23/40] qapi: Add some type check tests, Markus Armbruster, 2015/05/05
- [Qemu-devel] [PULL 39/40] qapi: Support (subset of) \u escapes in strings, Markus Armbruster, 2015/05/05
- [Qemu-devel] [PULL 38/40] qapi: Tweak doc references to QMP when QGA is also meant, Markus Armbruster, 2015/05/05
- [Qemu-devel] [PULL 36/40] qapi: Drop support for inline nested types, Markus Armbruster, 2015/05/05
- [Qemu-devel] [PULL 28/40] qapi: Prefer 'struct' over 'type' in generator, Markus Armbruster, 2015/05/05
- [Qemu-devel] [PULL 34/40] qapi: Drop inline nested struct in query-version,
Markus Armbruster <=
- [Qemu-devel] [PULL 32/40] qapi: Merge UserDefTwo and UserDefNested in tests, Markus Armbruster, 2015/05/05
- [Qemu-devel] [PULL 37/40] qapi: Drop dead visitor code related to nested structs, Markus Armbruster, 2015/05/05
- [Qemu-devel] [PULL 30/40] qapi: Use 'struct' instead of 'type' in schema, Markus Armbruster, 2015/05/05
- Re: [Qemu-devel] [PULL 00/40] drop qapi nested structs, Peter Maydell, 2015/05/06