qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 5/6] tests/libqtest: Move global_test wrapper


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v2 5/6] tests/libqtest: Move global_test wrapper function into a separate header
Date: Wed, 4 Sep 2019 09:23:22 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0

On 9/4/19 8:00 AM, Thomas Huth wrote:
> We want libqtest.h to become completely independen from global_qtest

independent

> (so that the wrapper functions are not used by accident anymore). As
> a first step, move the wrapper functions into a separate header file.
> 
> Signed-off-by: Thomas Huth <address@hidden>
> ---
>  MAINTAINERS             |   2 +-
>  tests/libqtest-single.h | 311 ++++++++++++++++++++++++++++++++++++++++
>  tests/libqtest.c        |  11 --
>  tests/libqtest.h        | 287 +-----------------------------------
>  4 files changed, 313 insertions(+), 298 deletions(-)
>  create mode 100644 tests/libqtest-single.h
> 

> +/**
> + * qmp:
> + * @fmt...: QMP message to send to qemu, formatted like
> + * qobject_from_jsonf_nofail().  See parse_escape() for what's
> + * supported after '%'.
> + *
> + * Sends a QMP message to QEMU and returns the response.
> + */
> +GCC_FMT_ATTR(1, 2)
> +static inline QDict *qmp(const char *fmt, ...)
> +{

I'm a bit surprised gcc doesn't complain about inlining a va_arg
function, but since it works, I'm fine with the approach.

> +++ b/tests/libqtest.c
> @@ -1106,17 +1106,6 @@ void qtest_memset(QTestState *s, uint64_t addr, 
> uint8_t pattern, size_t size)
>      qtest_rsp(s, 0);
>  }
>  
> -QDict *qmp(const char *fmt, ...)
> -{
> -    va_list ap;
> -    QDict *response;
> -
> -    va_start(ap, fmt);
> -    response = qtest_vqmp(global_qtest, fmt, ap);
> -    va_end(ap);
> -    return response;
> -}
> -

Nice - we've reduced the use of global_qtest to just a single optional
header!

> +++ b/tests/libqtest.h

> -/**
> - * clock_step:
> - * @step: Number of nanoseconds to advance the clock by.
> - *
> - * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
> - *
> - * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
> - */
> -static inline int64_t clock_step(int64_t step)
> -{
> -    return qtest_clock_step(global_qtest, step);
> -}
> +#include "libqtest-single.h"

Well, almost.  I guess this commit is the code motion, and the next one
actually fixes clients to track the rename, so this #include is
temporary (I hope).  It's just churn to put a TODO comment in this
commit that would get removed in the next.  So,

Reviewed-by: Eric Blake <address@hidden>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]