|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen staging] libxl_qmp: Change qmp_qemu_check_version to compare version
commit 535dface491c4132d5b7e3af077058b25e1cd40c
Author: Anthony PERARD <anthony.perard@xxxxxxxxxx>
AuthorDate: Fri Nov 9 17:45:54 2018 +0000
Commit: Wei Liu <wei.liu2@xxxxxxxxxx>
CommitDate: Fri Jan 11 14:57:35 2019 +0000
libxl_qmp: Change qmp_qemu_check_version to compare version
This patch makes the function simpler to read. It also add the ability
for a caller to tell if QEMU is newer or have the exact version.
Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
tools/libxl/libxl_qmp.c | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c
index 45a2cc423b..73f2202b4f 100644
--- a/tools/libxl/libxl_qmp.c
+++ b/tools/libxl/libxl_qmp.c
@@ -392,13 +392,27 @@ static int qmp_handle_response(libxl__gc *gc,
libxl__qmp_handler *qmp,
return 0;
}
-static bool qmp_qemu_check_version(libxl__qmp_handler *qmp, int major,
- int minor, int micro)
+/*
+ * return values:
+ * < 0 if qemu's version < asked version
+ * = 0 if qemu's version == asked version
+ * > 0 if qemu's version > asked version
+ */
+static int qmp_qemu_compare_version(libxl__qmp_handler *qmp, int major,
+ int minor, int micro)
{
- return qmp->version.major > major ||
- (qmp->version.major == major &&
- (qmp->version.minor > minor ||
- (qmp->version.minor == minor && qmp->version.micro >= micro)));
+#define CHECK_VERSION(level) do { \
+ if (qmp->version.level > (level)) return +1; \
+ if (qmp->version.level < (level)) return -1; \
+} while (0)
+
+ CHECK_VERSION(major);
+ CHECK_VERSION(minor);
+ CHECK_VERSION(micro);
+
+#undef CHECK_VERSION
+
+ return 0;
}
/*
@@ -1012,7 +1026,7 @@ int libxl__qmp_save(libxl__gc *gc, int domid, const char
*filename, bool live)
/* live parameter was added to QEMU 2.11. It signal QEMU that the save
* operation is for a live migration rather that for taking a snapshot. */
- if (qmp_qemu_check_version(qmp, 2, 11, 0))
+ if (qmp_qemu_compare_version(qmp, 2, 11, 0) >= 0)
qmp_parameters_add_bool(gc, &args, "live", live);
rc = qmp_synchronous_send(qmp, "xen-save-devices-state", args,
--
generated by git-patchbot for /home/xen/git/xen.git#staging
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |