All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] vhost-user-test: revert changes to make 'make check' happy
@ 2014-10-26  7:46 arei.gonglei
  2014-10-26  7:55 ` Paolo Bonzini
  2014-10-28 11:14 ` Gonglei
  0 siblings, 2 replies; 5+ messages in thread
From: arei.gonglei @ 2014-10-26  7:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, weidong.huang, peter.huangpeng, n.nikolaev,
	Gonglei, stefanha, imammedo

From: Gonglei <arei.gonglei@huawei.com>

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 <arei.gonglei@huawei.com>
---
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 <sys/vfs.h>
 #include <qemu/sockets.h>
 
+/* 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 */
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] vhost-user-test: revert changes to make 'make check' happy
  2014-10-26  7:46 [Qemu-devel] [PATCH] vhost-user-test: revert changes to make 'make check' happy arei.gonglei
@ 2014-10-26  7:55 ` Paolo Bonzini
  2014-10-26  8:04   ` Gonglei
  2014-10-28 11:14 ` Gonglei
  1 sibling, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2014-10-26  7:55 UTC (permalink / raw)
  To: arei.gonglei, qemu-devel
  Cc: peter.maydell, weidong.huang, peter.huangpeng, n.nikolaev,
	stefanha, imammedo



On 10/26/2014 08:46 AM, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
> 
> 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 <arei.gonglei@huawei.com>
> ---
> 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 <sys/vfs.h>
>  #include <qemu/sockets.h>
>  
> +/* 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] vhost-user-test: revert changes to make 'make check' happy
  2014-10-26  7:55 ` Paolo Bonzini
@ 2014-10-26  8:04   ` Gonglei
  0 siblings, 0 replies; 5+ messages in thread
From: Gonglei @ 2014-10-26  8:04 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: peter.maydell, Huangweidong (C),
	qemu-devel, n.nikolaev, Huangpeng (Peter),
	stefanha, imammedo

On 2014/10/26 15:55, Paolo Bonzini wrote:

> 
> 
> On 10/26/2014 08:46 AM, arei.gonglei@huawei.com wrote:
>> From: Gonglei <arei.gonglei@huawei.com>
>>
>> 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 <arei.gonglei@huawei.com>
>> ---
>> 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 <sys/vfs.h>
>>  #include <qemu/sockets.h>
>>  
>> +/* 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.
> 

Yes. First we should re-realize _cond_wait_until() in glib-compat.h, then
using CompatGMutex/CompatGCond instead of GMutex/GCond.

Best regards,
-Gonglei

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] vhost-user-test: revert changes to make 'make check' happy
  2014-10-26  7:46 [Qemu-devel] [PATCH] vhost-user-test: revert changes to make 'make check' happy arei.gonglei
  2014-10-26  7:55 ` Paolo Bonzini
@ 2014-10-28 11:14 ` Gonglei
  2014-11-02 10:33   ` Gonglei
  1 sibling, 1 reply; 5+ messages in thread
From: Gonglei @ 2014-10-28 11:14 UTC (permalink / raw)
  To: Gonglei (Arei)
  Cc: peter.maydell, Huangweidong (C),
	qemu-devel, n.nikolaev, Huangpeng (Peter),
	stefanha, imammedo

On 2014/10/26 15:46, Gonglei (Arei) wrote:

> From: Gonglei <arei.gonglei@huawei.com>
> 
> 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 <arei.gonglei@huawei.com>

Hi, Peter

This bug break 'make check' with glib < 2.26,
Please consider to apply it. Thanks!

Best regards,
-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 <sys/vfs.h>
>  #include <qemu/sockets.h>
>  
> +/* 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 */

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] vhost-user-test: revert changes to make 'make check' happy
  2014-10-28 11:14 ` Gonglei
@ 2014-11-02 10:33   ` Gonglei
  0 siblings, 0 replies; 5+ messages in thread
From: Gonglei @ 2014-11-02 10:33 UTC (permalink / raw)
  To: Gonglei (Arei)
  Cc: peter.maydell, Huangweidong (C),
	qemu-devel, n.nikolaev, Huangpeng (Peter),
	stefanha, imammedo

Ping...

Best regards,
-Gonglei

> On 2014/10/26 15:46, Gonglei (Arei) wrote:
> 
>> From: Gonglei <arei.gonglei@huawei.com>
>>
>> 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 <arei.gonglei@huawei.com>
> 
> Hi, Peter
> 
> This bug break 'make check' with glib < 2.26,
> Please consider to apply it. Thanks!
> 
> Best regards,
> -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 <sys/vfs.h>
>>  #include <qemu/sockets.h>
>>  
>> +/* 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 */
> 
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-11-02 10:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-26  7:46 [Qemu-devel] [PATCH] vhost-user-test: revert changes to make 'make check' happy arei.gonglei
2014-10-26  7:55 ` Paolo Bonzini
2014-10-26  8:04   ` Gonglei
2014-10-28 11:14 ` Gonglei
2014-11-02 10:33   ` Gonglei

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.