* [Qemu-devel] [PATCH 0/2] Use glib's checks for use of too-new functions
@ 2015-05-29 15:01 Dr. David Alan Gilbert (git)
2015-05-29 15:01 ` [Qemu-devel] [PATCH 1/2] Fix glib_subprocess test Dr. David Alan Gilbert (git)
2015-05-29 15:01 ` [Qemu-devel] [PATCH 2/2] Compile time checks for newer glib Dr. David Alan Gilbert (git)
0 siblings, 2 replies; 8+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2015-05-29 15:01 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, armbru, mst
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Glib 2.32 adds a checking mechanism to warn of use of functions that
are available in glib versions newer than a particular version.
This series enables that check (via a -D added during configure);
with it you get warnings like:
/home/dgilbert/git/qemu-world3/vl.c: In function 'main':
/home/dgilbert/git/qemu-world3/vl.c:4385:5: warning: 'g_source_get_ready_time' is deprecated: Not available before 2.36 [-Wdeprecated-declarations]
printf("Foo! %lld\n", (long long) g_source_get_ready_time(NULL));
Notes:
a) The other patch in the set fixes a configure error that caused a test
never to be run even if there was a new enough glib
b) Peter said he would prefer something #included rather than added as a -D
but then we'd have to change a whole bunch of files to make sure they
do that before glib.h is included, and it wouldn't protect you from new
code that forgot to do that.
c) Glib's older than 2.32 don't have the mechanism and thus don't complain
d) The earliest version marker that glib lets you check against is 2.26,
which is what I've set it to. Since we allow 2.22 but 2.22 doesn't have
this new check, it doesn't cause any warnings.
e) Build and make check'd on fedora 22 (glib 2.44), rhel6 (glib 2.26), and
rhel5 with glib 2.22 built on it.
Dave
Dr. David Alan Gilbert (2):
Fix glib_subprocess test
Compile time checks for newer glib
configure | 7 ++++++-
include/glib-compat.h | 6 ++++++
tests/test-qdev-global-props.c | 2 +-
tests/vhost-user-test.c | 2 ++
4 files changed, 15 insertions(+), 2 deletions(-)
--
2.4.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH 1/2] Fix glib_subprocess test
2015-05-29 15:01 [Qemu-devel] [PATCH 0/2] Use glib's checks for use of too-new functions Dr. David Alan Gilbert (git)
@ 2015-05-29 15:01 ` Dr. David Alan Gilbert (git)
2015-05-29 15:01 ` [Qemu-devel] [PATCH 2/2] Compile time checks for newer glib Dr. David Alan Gilbert (git)
1 sibling, 0 replies; 8+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2015-05-29 15:01 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, armbru, mst
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
A typo means that the tests dependent on glib with subprocess
support are never run.
Fixes: 9d41401b90fa10b335d2e739149d36437cfbf622
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
configure | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configure b/configure
index 9852aef..24ee0a4 100755
--- a/configure
+++ b/configure
@@ -4776,7 +4776,7 @@ if test "$bluez" = "yes" ; then
echo "CONFIG_BLUEZ=y" >> $config_host_mak
echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
fi
-if test "glib_subprocess" = "yes" ; then
+if test "$glib_subprocess" = "yes" ; then
echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
fi
echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
--
2.4.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH 2/2] Compile time checks for newer glib
2015-05-29 15:01 [Qemu-devel] [PATCH 0/2] Use glib's checks for use of too-new functions Dr. David Alan Gilbert (git)
2015-05-29 15:01 ` [Qemu-devel] [PATCH 1/2] Fix glib_subprocess test Dr. David Alan Gilbert (git)
@ 2015-05-29 15:01 ` Dr. David Alan Gilbert (git)
2015-05-29 15:37 ` Paolo Bonzini
2015-05-29 15:53 ` Peter Maydell
1 sibling, 2 replies; 8+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2015-05-29 15:01 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, armbru, mst
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Newer glib has support for checking that applications aren't
using newer glib calls than they should be.
The support for the check only went into glib 2.32 and it only
has macros for version 2.26 upwards; although we only insist
on 2.22 at the moment, I set the glib checks to the earliest of 2.26,
it wont cause problems on anything <2.32 since the checks aren't
there.
While mainly we're interested in the check from GLIB_VERSION_MAX_ALLOWED
which checks we're not using anything too recent, the glib macros
require that if we set that then we must also define
GLIB_VERSION_MIN_REQUIRED which checks we're not using anything
deprecated too long ago.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
configure | 5 +++++
include/glib-compat.h | 6 ++++++
tests/test-qdev-global-props.c | 2 +-
tests/vhost-user-test.c | 2 ++
4 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index 24ee0a4..5c6230a 100755
--- a/configure
+++ b/configure
@@ -2781,6 +2781,11 @@ fi
glib_req_ver=2.22
glib_modules=gthread-2.0
+# Force warnings over use of newer glib features; 2.26 is the earliest
+# version macro that is defined; eventually we should match
+# glib_req_ver above
+QEMU_CFLAGS="-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26 $QEMU_CFLAGS"
+QEMU_CFLAGS="-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_26 $QEMU_CFLAGS"
if test "$modules" = yes; then
glib_modules="$glib_modules gmodule-2.0"
fi
diff --git a/include/glib-compat.h b/include/glib-compat.h
index 318e000..cbd660c 100644
--- a/include/glib-compat.h
+++ b/include/glib-compat.h
@@ -16,6 +16,12 @@
#ifndef QEMU_GLIB_COMPAT_H
#define QEMU_GLIB_COMPAT_H
+/*
+ * The source file including this compat header knows it's using newer glib
+ * functions than we generally allow, so don't warn about it.
+ */
+#undef GLIB_VERSION_MIN_REQUIRED
+#undef GLIB_VERSION_MAX_ALLOWED
#include <glib.h>
/* GLIB version compatibility flags */
diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
index 0be9835..896e6bf 100644
--- a/tests/test-qdev-global-props.c
+++ b/tests/test-qdev-global-props.c
@@ -22,7 +22,7 @@
* THE SOFTWARE.
*/
-#include <glib.h>
+#include "glib-compat.h"
#include <stdint.h>
#include "hw/qdev.h"
diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 75fedf0..7aeb927 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -8,6 +8,8 @@
*
*/
+#undef GLIB_VERSION_MIN_REQUIRED
+#undef GLIB_VERSION_MAX_ALLOWED
#define QEMU_GLIB_COMPAT_H
#include <glib.h>
--
2.4.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] Compile time checks for newer glib
2015-05-29 15:01 ` [Qemu-devel] [PATCH 2/2] Compile time checks for newer glib Dr. David Alan Gilbert (git)
@ 2015-05-29 15:37 ` Paolo Bonzini
2015-05-29 15:49 ` Dr. David Alan Gilbert
2015-05-29 15:53 ` Peter Maydell
1 sibling, 1 reply; 8+ messages in thread
From: Paolo Bonzini @ 2015-05-29 15:37 UTC (permalink / raw)
To: Dr. David Alan Gilbert (git), qemu-devel; +Cc: peter.maydell, armbru, mst
On 29/05/2015 17:01, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>
> Newer glib has support for checking that applications aren't
> using newer glib calls than they should be.
>
> The support for the check only went into glib 2.32 and it only
> has macros for version 2.26 upwards; although we only insist
> on 2.22 at the moment, I set the glib checks to the earliest of 2.26,
> it wont cause problems on anything <2.32 since the checks aren't
> there.
I think we need 2.32 minimum, because we use the 2.32 mutex/condvar
functions if available.
Paolo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] Compile time checks for newer glib
2015-05-29 15:37 ` Paolo Bonzini
@ 2015-05-29 15:49 ` Dr. David Alan Gilbert
0 siblings, 0 replies; 8+ messages in thread
From: Dr. David Alan Gilbert @ 2015-05-29 15:49 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: peter.maydell, mst, qemu-devel, armbru
* Paolo Bonzini (pbonzini@redhat.com) wrote:
>
>
> On 29/05/2015 17:01, Dr. David Alan Gilbert (git) wrote:
> > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> >
> > Newer glib has support for checking that applications aren't
> > using newer glib calls than they should be.
> >
> > The support for the check only went into glib 2.32 and it only
> > has macros for version 2.26 upwards; although we only insist
> > on 2.22 at the moment, I set the glib checks to the earliest of 2.26,
> > it wont cause problems on anything <2.32 since the checks aren't
> > there.
>
> I think we need 2.32 minimum, because we use the 2.32 mutex/condvar
> functions if available.
Are all those done via glib-compat.h ?
Note that in the patch I turn off the version checks at the top of glib-compat.h
on the assumption that anything trying to use it knows what it is doing.
Dave
>
> Paolo
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] Compile time checks for newer glib
2015-05-29 15:01 ` [Qemu-devel] [PATCH 2/2] Compile time checks for newer glib Dr. David Alan Gilbert (git)
2015-05-29 15:37 ` Paolo Bonzini
@ 2015-05-29 15:53 ` Peter Maydell
2015-05-29 16:01 ` Dr. David Alan Gilbert
1 sibling, 1 reply; 8+ messages in thread
From: Peter Maydell @ 2015-05-29 15:53 UTC (permalink / raw)
To: Dr. David Alan Gilbert (git)
Cc: Markus Armbruster, QEMU Developers, Michael S. Tsirkin
On 29 May 2015 at 16:01, Dr. David Alan Gilbert (git)
<dgilbert@redhat.com> wrote:
> --- a/include/glib-compat.h
> +++ b/include/glib-compat.h
> @@ -16,6 +16,12 @@
> #ifndef QEMU_GLIB_COMPAT_H
> #define QEMU_GLIB_COMPAT_H
>
> +/*
> + * The source file including this compat header knows it's using newer glib
> + * functions than we generally allow, so don't warn about it.
> + */
> +#undef GLIB_VERSION_MIN_REQUIRED
> +#undef GLIB_VERSION_MAX_ALLOWED
> #include <glib.h>
...but glib-compat.h is included by qemu-common.h and in general
the point is that code anywhere in QEMU can assume the compat
versions exist, so it feels like this will defeat the point.
-- PMM
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] Compile time checks for newer glib
2015-05-29 15:53 ` Peter Maydell
@ 2015-05-29 16:01 ` Dr. David Alan Gilbert
2015-06-01 18:01 ` John Snow
0 siblings, 1 reply; 8+ messages in thread
From: Dr. David Alan Gilbert @ 2015-05-29 16:01 UTC (permalink / raw)
To: Peter Maydell
Cc: pbonzini, QEMU Developers, Markus Armbruster, Michael S. Tsirkin
* Peter Maydell (peter.maydell@linaro.org) wrote:
> On 29 May 2015 at 16:01, Dr. David Alan Gilbert (git)
> <dgilbert@redhat.com> wrote:
> > --- a/include/glib-compat.h
> > +++ b/include/glib-compat.h
> > @@ -16,6 +16,12 @@
> > #ifndef QEMU_GLIB_COMPAT_H
> > #define QEMU_GLIB_COMPAT_H
> >
> > +/*
> > + * The source file including this compat header knows it's using newer glib
> > + * functions than we generally allow, so don't warn about it.
> > + */
> > +#undef GLIB_VERSION_MIN_REQUIRED
> > +#undef GLIB_VERSION_MAX_ALLOWED
> > #include <glib.h>
>
> ...but glib-compat.h is included by qemu-common.h and in general
> the point is that code anywhere in QEMU can assume the compat
> versions exist, so it feels like this will defeat the point.
Hmm, a lot of files seem to include glib.h directly. But OK,
so then Paolo is suggesting setting the minimum to 2.32
which I can do, but then that wouldn't stop something that's
in 2.22-2.32 but not in glib-compat.h
Dave
>
> -- PMM
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] Compile time checks for newer glib
2015-05-29 16:01 ` Dr. David Alan Gilbert
@ 2015-06-01 18:01 ` John Snow
0 siblings, 0 replies; 8+ messages in thread
From: John Snow @ 2015-06-01 18:01 UTC (permalink / raw)
To: Dr. David Alan Gilbert, Peter Maydell
Cc: pbonzini, Michael S. Tsirkin, QEMU Developers, Markus Armbruster
On 05/29/2015 12:01 PM, Dr. David Alan Gilbert wrote:
> * Peter Maydell (peter.maydell@linaro.org) wrote:
>> On 29 May 2015 at 16:01, Dr. David Alan Gilbert (git)
>> <dgilbert@redhat.com> wrote:
>>> --- a/include/glib-compat.h
>>> +++ b/include/glib-compat.h
>>> @@ -16,6 +16,12 @@
>>> #ifndef QEMU_GLIB_COMPAT_H
>>> #define QEMU_GLIB_COMPAT_H
>>>
>>> +/*
>>> + * The source file including this compat header knows it's using newer glib
>>> + * functions than we generally allow, so don't warn about it.
>>> + */
>>> +#undef GLIB_VERSION_MIN_REQUIRED
>>> +#undef GLIB_VERSION_MAX_ALLOWED
>>> #include <glib.h>
>>
>> ...but glib-compat.h is included by qemu-common.h and in general
>> the point is that code anywhere in QEMU can assume the compat
>> versions exist, so it feels like this will defeat the point.
>
> Hmm, a lot of files seem to include glib.h directly. But OK,
> so then Paolo is suggesting setting the minimum to 2.32
> which I can do, but then that wouldn't stop something that's
> in 2.22-2.32 but not in glib-compat.h
>
> Dave
>
>>
>> -- PMM
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
>
When I bumped glib to 2.22, I played with using these macros and forcing
all files to include glib-compat and prohibiting direct includes of glib.
The problem is without a minimum version set to 2.3x, as you've stated,
the deprecated warnings will trigger for functions we added explicit
compat wrappers for, and I could think of no sane way to "forgive" these
usages as a one-time exception.
Perhaps -- /perhaps/ -- you could have a qemu-internal glib.h that sets
the version warnings and leave glib-compat alone without those includes,
but this seems like a setup that is inviting frustration for future devs.
--js
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-06-01 18:01 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-29 15:01 [Qemu-devel] [PATCH 0/2] Use glib's checks for use of too-new functions Dr. David Alan Gilbert (git)
2015-05-29 15:01 ` [Qemu-devel] [PATCH 1/2] Fix glib_subprocess test Dr. David Alan Gilbert (git)
2015-05-29 15:01 ` [Qemu-devel] [PATCH 2/2] Compile time checks for newer glib Dr. David Alan Gilbert (git)
2015-05-29 15:37 ` Paolo Bonzini
2015-05-29 15:49 ` Dr. David Alan Gilbert
2015-05-29 15:53 ` Peter Maydell
2015-05-29 16:01 ` Dr. David Alan Gilbert
2015-06-01 18:01 ` John Snow
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).