From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48089) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XiIgA-00016r-6L for qemu-devel@nongnu.org; Sun, 26 Oct 2014 03:56:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XiIg4-0006nH-Oq for qemu-devel@nongnu.org; Sun, 26 Oct 2014 03:55:58 -0400 Received: from mail-wg0-x22b.google.com ([2a00:1450:400c:c00::22b]:49106) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XiIg4-0006n8-Dk for qemu-devel@nongnu.org; Sun, 26 Oct 2014 03:55:52 -0400 Received: by mail-wg0-f43.google.com with SMTP id n12so3560549wgh.26 for ; Sun, 26 Oct 2014 00:55:50 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <544CA902.70302@redhat.com> Date: Sun, 26 Oct 2014 08:55:46 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1414309615-11848-1-git-send-email-arei.gonglei@huawei.com> In-Reply-To: <1414309615-11848-1-git-send-email-arei.gonglei@huawei.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] vhost-user-test: revert changes to make 'make check' happy List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: arei.gonglei@huawei.com, qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, weidong.huang@huawei.com, peter.huangpeng@huawei.com, n.nikolaev@virtualopensystems.com, stefanha@redhat.com, imammedo@redhat.com On 10/26/2014 08:46 AM, arei.gonglei@huawei.com wrote: > From: Gonglei > > After commit 89b516d8, some logics is turbid. > First, vhost-usr-test.c rely on glib-compat.h because > of using G_TIME_SPAN_SECOND [glib < 2.26] and g_get_monotonic_time(), > but vhost-usr-test.c defined QEMU_GLIB_COMPAT_H, which make > glib-compat.h will not be included. > Second, if we remove QEMU_GLIB_COMPAT_H definability in > vhost-usr-test.c, then we will get warning as below: > > tests/vhost-user-test.c: In function 'read_guest_mem': > tests/vhost-user-test.c:190: warning: passing argument 1 > of 'g_mutex_lock' from incompatible pointer type > tests/vhost-user-test.c:234: warning: passing argument 1 > of 'g_mutex_unlock' from incompatible pointer type > > That's because glib-compat.h redefine the g_mutex_lock/unlock > function. Those functions' arguments is CompatGMutex/CompatGCond, > but vhost-user-test.c is using GMutex/GCond, which cause the type > is not consistent. > > We can rerealize those functions of vhost-user-test.c, > which need a lots of patches. Let's simply address it, and > leave this file alone. > > Signed-off-by: Gonglei > --- > The errors and warnings I got: > > tests/vhost-user-test.c: In function '_cond_wait_until': > tests/vhost-user-test.c:154: error: 'G_TIME_SPAN_SECOND' undeclared (first use in this function) > tests/vhost-user-test.c:154: error: (Each undeclared identifier is reported only once > tests/vhost-user-test.c:154: error: for each function it appears in.) > tests/vhost-user-test.c: In function 'read_guest_mem': > tests/vhost-user-test.c:192: warning: implicit declaration of function 'g_get_monotonic_time' > tests/vhost-user-test.c:192: warning: nested extern declaration of 'g_get_monotonic_time' > tests/vhost-user-test.c:192: error: 'G_TIME_SPAN_SECOND' undeclared (first use in this function) > make: *** [tests/vhost-user-test.o] Error 1 > > After remove QEMU_GLIB_COMPAT_H definability in vhost-usr-test.c: > > tests/vhost-user-test.c: In function 'read_guest_mem': > tests/vhost-user-test.c:190: warning: passing argument 1 of 'g_mutex_lock' from incompatible pointer type > tests/vhost-user-test.c:234: warning: passing argument 1 of 'g_mutex_unlock' from incompatible pointer type > tests/vhost-user-test.c: In function 'chr_read': > tests/vhost-user-test.c:262: warning: passing argument 1 of 'g_mutex_lock' from incompatible pointer type > tests/vhost-user-test.c:295: warning: passing argument 1 of 'g_cond_signal' from incompatible pointer type > tests/vhost-user-test.c:312: warning: passing argument 1 of 'g_mutex_unlock' from incompatible pointer type > --- > tests/vhost-user-test.c | 23 ++++++++++++++++++++++- > 1 file changed, 22 insertions(+), 1 deletion(-) > > diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c > index fdf91e7..75fedf0 100644 > --- a/tests/vhost-user-test.c > +++ b/tests/vhost-user-test.c > @@ -21,6 +21,15 @@ > #include > #include > > +/* GLIB version compatibility flags */ > +#if !GLIB_CHECK_VERSION(2, 26, 0) > +#define G_TIME_SPAN_SECOND (G_GINT64_CONSTANT(1000000)) > +#endif > + > +#if GLIB_CHECK_VERSION(2, 28, 0) > +#define HAVE_MONOTONIC_TIME > +#endif > + > #if GLIB_CHECK_VERSION(2, 32, 0) > #define HAVE_MUTEX_INIT > #define HAVE_COND_INIT > @@ -107,6 +116,18 @@ static VhostUserMemory memory; > static GMutex *data_mutex; > static GCond *data_cond; > > +static gint64 _get_time(void) > +{ > +#ifdef HAVE_MONOTONIC_TIME > + return g_get_monotonic_time(); > +#else > + GTimeVal time; > + g_get_current_time(&time); > + > + return time.tv_sec * G_TIME_SPAN_SECOND + time.tv_usec; > +#endif > +} > + > static GMutex *_mutex_new(void) > { > GMutex *mutex; > @@ -189,7 +210,7 @@ static void read_guest_mem(void) > > g_mutex_lock(data_mutex); > > - end_time = g_get_monotonic_time() + 5 * G_TIME_SPAN_SECOND; > + end_time = _get_time() + 5 * G_TIME_SPAN_SECOND; > while (!fds_num) { > if (!_cond_wait_until(data_cond, data_mutex, end_time)) { > /* timeout has passed */ > Looks good; sooner or later we should convert vhost-user-test.c to use glib-compat.h. Paolo