[PATCH v1 1/5] tests/qtest: Add a helper to query the QEMU version

Fabiano Rosas posted 5 patches 11 months, 3 weeks ago
Maintainers: "Alex Bennée" <alex.bennee@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Thomas Huth <thuth@redhat.com>, Wainer dos Santos Moschetta <wainersm@redhat.com>, Beraldo Leal <bleal@redhat.com>, Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Juan Quintela <quintela@redhat.com>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Leonardo Bras <leobras@redhat.com>
There is a newer version of this series
[PATCH v1 1/5] tests/qtest: Add a helper to query the QEMU version
Posted by Fabiano Rosas 11 months, 3 weeks ago
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
 tests/qtest/libqtest.c | 24 ++++++++++++++++++++++++
 tests/qtest/libqtest.h | 10 ++++++++++
 2 files changed, 34 insertions(+)

diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index f33a210861..7cee68a834 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -337,6 +337,30 @@ void qtest_remove_abrt_handler(void *data)
     }
 }
 
+void qtest_query_version(QTestState *who, int *major, int *minor, int *micro)
+{
+    QDict *rsp, *version;
+
+    rsp = qtest_qmp_assert_success_ref(who, "{ 'execute': 'query-version' }");
+    g_assert(rsp);
+
+    version = qdict_get_qdict(rsp, "qemu");
+
+    if (major) {
+        *major = qdict_get_int(version, "major");
+    }
+
+    if (minor) {
+        *minor = qdict_get_int(version, "minor");
+    }
+
+    if (micro) {
+        *micro = qdict_get_int(version, "micro");
+    }
+
+    qobject_unref(rsp);
+}
+
 static const char *qtest_qemu_binary(const char *var)
 {
     const char *qemu_bin;
diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h
index 6e3d3525bf..db7a780d26 100644
--- a/tests/qtest/libqtest.h
+++ b/tests/qtest/libqtest.h
@@ -1085,4 +1085,14 @@ bool have_qemu_img(void);
  */
 bool mkimg(const char *file, const char *fmt, unsigned size_mb);
 
+/**
+ * qtest_query_version:
+ * @who: QTestState instance to operate on
+ * @major: Pointer to where to store the major version number
+ * @minor: Pointer to where to store the minor version number
+ * @micro: Pointer to where to store the micro version number
+ *
+ */
+void qtest_query_version(QTestState *who, int *major, int *minor, int *micro);
+
 #endif
-- 
2.35.3
Re: [PATCH v1 1/5] tests/qtest: Add a helper to query the QEMU version
Posted by Thomas Huth 11 months, 1 week ago
On 07/12/2023 16.58, Fabiano Rosas wrote:
> Signed-off-by: Fabiano Rosas <farosas@suse.de>
> ---
>   tests/qtest/libqtest.c | 24 ++++++++++++++++++++++++
>   tests/qtest/libqtest.h | 10 ++++++++++
>   2 files changed, 34 insertions(+)
> 
> diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
> index f33a210861..7cee68a834 100644
> --- a/tests/qtest/libqtest.c
> +++ b/tests/qtest/libqtest.c
> @@ -337,6 +337,30 @@ void qtest_remove_abrt_handler(void *data)
>       }
>   }
>   
> +void qtest_query_version(QTestState *who, int *major, int *minor, int *micro)

I'd prefer "qts" instead of "who" ... but that's bikeshedding, so:

Reviewed-by: Thomas Huth <thuth@redhat.com>
Re: [PATCH v1 1/5] tests/qtest: Add a helper to query the QEMU version
Posted by Fabiano Rosas 11 months, 1 week ago
Thomas Huth <thuth@redhat.com> writes:

> On 07/12/2023 16.58, Fabiano Rosas wrote:
>> Signed-off-by: Fabiano Rosas <farosas@suse.de>
>> ---
>>   tests/qtest/libqtest.c | 24 ++++++++++++++++++++++++
>>   tests/qtest/libqtest.h | 10 ++++++++++
>>   2 files changed, 34 insertions(+)
>> 
>> diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
>> index f33a210861..7cee68a834 100644
>> --- a/tests/qtest/libqtest.c
>> +++ b/tests/qtest/libqtest.c
>> @@ -337,6 +337,30 @@ void qtest_remove_abrt_handler(void *data)
>>       }
>>   }
>>   
>> +void qtest_query_version(QTestState *who, int *major, int *minor, int *micro)
>
> I'd prefer "qts" instead of "who" ... but that's bikeshedding, so:

I'll change it. I need to send another version of this series anyway.