libxl: Assert qmp_ev's state in qmp_ev_qemu_compare_version
authorAnthony PERARD <anthony.perard@citrix.com>
Tue, 11 May 2021 09:28:07 +0000 (10:28 +0100)
committerJulien Grall <jgrall@amazon.com>
Tue, 15 Jun 2021 12:56:26 +0000 (13:56 +0100)
We are supposed to read the version information only when qmp_ev is in
state "Connected" (that correspond to state==qmp_state_connected),
assert it so that the function isn't used too early.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
tools/libs/light/libxl_qmp.c

index 9b638e6f5442f21101bbb42ad9dac2a746d3bd0d..d0967c9f029f0d8ef5694a6b4477903d49f1320e 100644 (file)
@@ -292,6 +292,8 @@ static int qmp_handle_response(libxl__gc *gc, libxl__qmp_handler *qmp,
 static int qmp_ev_qemu_compare_version(libxl__ev_qmp *ev, int major,
                                        int minor, int micro)
 {
+    assert(ev->state == qmp_state_connected);
+
 #define CHECK_VERSION(level) do { \
     if (ev->qemu_version.level > (level)) return +1; \
     if (ev->qemu_version.level < (level)) return -1; \