diff mbox

[2/2] configure: use pkg-config for obtaining xen version

Message ID 20170316141953.16161-3-jgross@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jürgen Groß March 16, 2017, 2:19 p.m. UTC
Instead of trying to guess the Xen version to use by compiling various
test programs first just ask the system via pkg-config. Only if it
can't return the version fall back to the test program scheme.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 configure | 31 +++++++++++--------------------
 1 file changed, 11 insertions(+), 20 deletions(-)

Comments

Stefano Stabellini March 16, 2017, 8:20 p.m. UTC | #1
On Thu, 16 Mar 2017, Juergen Gross wrote:
> Instead of trying to guess the Xen version to use by compiling various
> test programs first just ask the system via pkg-config. Only if it
> can't return the version fall back to the test program scheme.

That's OK, but why did you remove the Xen unstable test?


> Signed-off-by: Juergen Gross <jgross@suse.com>
> ---
>  configure | 31 +++++++++++--------------------
>  1 file changed, 11 insertions(+), 20 deletions(-)
> 
> diff --git a/configure b/configure
> index aabf098..b43fbd5 100755
> --- a/configure
> +++ b/configure
> @@ -1983,26 +1983,12 @@ EOF
>      fi
>      xen=no
>  
> -  # Xen unstable
> -  elif
> -      cat > $TMPC <<EOF &&
> -#undef XC_WANT_COMPAT_DEVICEMODEL_API
> -#define __XEN_TOOLS__
> -#include <xendevicemodel.h>
> -int main(void) {
> -  xendevicemodel_handle *xd;
> -
> -  xd = xendevicemodel_open(0, 0);
> -  xendevicemodel_close(xd);
> -
> -  return 0;
> -}
> -EOF
> -      compile_prog "" "$xen_libs $xen_stable_libs -lxendevicemodel"
> -    then
> -    xen_stable_libs="$xen_stable_libs -lxendevicemodel"
> -    xen_ctrl_version=40900
> +  # Xen version via pkg-config (Xen 4.9.0 and newer)
> +  elif $pkg_config --exists xencontrol ; then
> +    xen_ctrl_version="$(printf '%d%02d%02d' \
> +      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
>      xen=yes
> +
>    elif
>        cat > $TMPC <<EOF &&
>  /*
> @@ -2214,7 +2200,12 @@ EOF
>    fi
>  
>    if test "$xen" = yes; then
> -    if test $xen_ctrl_version -ge 40701  ; then
> +    if test $xen_ctrl_version -ge 40900 ; then
> +      xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab xenevtchn"
> +      xen_pc="$xen_pc xendevicemodel"
> +      xen_libs="$($pkg_config --libs $xen_pc)"
> +      QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
> +    elif test $xen_ctrl_version -ge 40701 ; then
>        libs_softmmu="$xen_stable_libs $libs_softmmu"
>      fi
>      libs_softmmu="$xen_libs $libs_softmmu"
Jürgen Groß March 17, 2017, 4:49 a.m. UTC | #2
On 16/03/17 21:20, Stefano Stabellini wrote:
> On Thu, 16 Mar 2017, Juergen Gross wrote:
>> Instead of trying to guess the Xen version to use by compiling various
>> test programs first just ask the system via pkg-config. Only if it
>> can't return the version fall back to the test program scheme.
> 
> That's OK, but why did you remove the Xen unstable test?

From Xen 4.9 on pkg-config will return the needed information. There is
no longer a need for a test program to determine the Xen version. After
all this was the main objective of my series adding the pkg-config
files to Xen.


Juergen
Stefano Stabellini March 17, 2017, 6:33 p.m. UTC | #3
On Fri, 17 Mar 2017, Juergen Gross wrote:
> On 16/03/17 21:20, Stefano Stabellini wrote:
> > On Thu, 16 Mar 2017, Juergen Gross wrote:
> >> Instead of trying to guess the Xen version to use by compiling various
> >> test programs first just ask the system via pkg-config. Only if it
> >> can't return the version fall back to the test program scheme.
> > 
> > That's OK, but why did you remove the Xen unstable test?
> 
> >From Xen 4.9 on pkg-config will return the needed information. There is
> no longer a need for a test program to determine the Xen version. After
> all this was the main objective of my series adding the pkg-config
> files to Xen.

I was going to say something like "yeah, but is pkg-config always
available?" In reality, QEMU already has pkg-config as build
dependency, so I guess there is no problem with that.

Please add a note about this to the commit message.
Jürgen Groß March 21, 2017, 5:34 a.m. UTC | #4
On 17/03/17 19:33, Stefano Stabellini wrote:
> On Fri, 17 Mar 2017, Juergen Gross wrote:
>> On 16/03/17 21:20, Stefano Stabellini wrote:
>>> On Thu, 16 Mar 2017, Juergen Gross wrote:
>>>> Instead of trying to guess the Xen version to use by compiling various
>>>> test programs first just ask the system via pkg-config. Only if it
>>>> can't return the version fall back to the test program scheme.
>>>
>>> That's OK, but why did you remove the Xen unstable test?
>>
>> >From Xen 4.9 on pkg-config will return the needed information. There is
>> no longer a need for a test program to determine the Xen version. After
>> all this was the main objective of my series adding the pkg-config
>> files to Xen.
> 
> I was going to say something like "yeah, but is pkg-config always
> available?" In reality, QEMU already has pkg-config as build
> dependency, so I guess there is no problem with that.
> 
> Please add a note about this to the commit message.
> 

Okay.


Juergen
Stefano Stabellini March 21, 2017, 6:54 p.m. UTC | #5
On Tue, 21 Mar 2017, Juergen Gross wrote:
> On 17/03/17 19:33, Stefano Stabellini wrote:
> > On Fri, 17 Mar 2017, Juergen Gross wrote:
> >> On 16/03/17 21:20, Stefano Stabellini wrote:
> >>> On Thu, 16 Mar 2017, Juergen Gross wrote:
> >>>> Instead of trying to guess the Xen version to use by compiling various
> >>>> test programs first just ask the system via pkg-config. Only if it
> >>>> can't return the version fall back to the test program scheme.
> >>>
> >>> That's OK, but why did you remove the Xen unstable test?
> >>
> >> >From Xen 4.9 on pkg-config will return the needed information. There is
> >> no longer a need for a test program to determine the Xen version. After
> >> all this was the main objective of my series adding the pkg-config
> >> files to Xen.
> > 
> > I was going to say something like "yeah, but is pkg-config always
> > available?" In reality, QEMU already has pkg-config as build
> > dependency, so I guess there is no problem with that.
> > 
> > Please add a note about this to the commit message.
> > 
> 
> Okay.

Sorry to point this out only now, and I realize that it might be
unimportant for production builds, but it is important to me, and
developers in general, to be able to test a single QEMU tree against a
number of Xen trees (all releases from 4.3 onward).

With this change (specifically dropping the 4.9 build test), out of tree
builds don't work anymore. I would like to be able to do:

./configure --enable-xen --target-list=i386-softmmu \
                --extra-cflags="-I$DIR/tools/include \
                -I$DIR/tools/libs/toollog/include \
                -I$DIR/tools/libs/evtchn/include \
                -I$DIR/tools/libs/gnttab/include \
                -I$DIR/tools/libs/foreignmemory/include \
                -I$DIR/tools/libs/devicemodel/include \
                -I$DIR/tools/libxc/include \
                -I$DIR/tools/xenstore/include \
                -I$DIR/tools/xenstore/compat/include" \
                --extra-ldflags="-L$DIR/tools/libxc \
                -L$DIR/tools/xenstore \
                -L$DIR/tools/libs/evtchn \
                -L$DIR/tools/libs/gnttab \
                -L$DIR/tools/libs/foreignmemory \
                -L$DIR/tools/libs/devicemodel \
                -Wl,-rpath-link=$DIR/tools/libs/toollog \
                -Wl,-rpath-link=$DIR/tools/libs/evtchn \
                -Wl,-rpath-link=$DIR/tools/libs/gnttab \
                -Wl,-rpath-link=$DIR/tools/libs/call \
                -Wl,-rpath-link=$DIR/tools/libs/foreignmemory \
                -Wl,-rpath-link=$DIR/tools/libs/devicemodel" \
            --disable-kvm 
make

And the make should succeed. Is there a way to do that with pkg-config?
If not, I think we should keep the existing tests (and only add
pkg-config tests in addition to them, not in alternative).
Jürgen Groß March 22, 2017, 5:02 a.m. UTC | #6
On 21/03/17 19:54, Stefano Stabellini wrote:
> On Tue, 21 Mar 2017, Juergen Gross wrote:
>> On 17/03/17 19:33, Stefano Stabellini wrote:
>>> On Fri, 17 Mar 2017, Juergen Gross wrote:
>>>> On 16/03/17 21:20, Stefano Stabellini wrote:
>>>>> On Thu, 16 Mar 2017, Juergen Gross wrote:
>>>>>> Instead of trying to guess the Xen version to use by compiling various
>>>>>> test programs first just ask the system via pkg-config. Only if it
>>>>>> can't return the version fall back to the test program scheme.
>>>>>
>>>>> That's OK, but why did you remove the Xen unstable test?
>>>>
>>>> >From Xen 4.9 on pkg-config will return the needed information. There is
>>>> no longer a need for a test program to determine the Xen version. After
>>>> all this was the main objective of my series adding the pkg-config
>>>> files to Xen.
>>>
>>> I was going to say something like "yeah, but is pkg-config always
>>> available?" In reality, QEMU already has pkg-config as build
>>> dependency, so I guess there is no problem with that.
>>>
>>> Please add a note about this to the commit message.
>>>
>>
>> Okay.
> 
> Sorry to point this out only now, and I realize that it might be
> unimportant for production builds, but it is important to me, and
> developers in general, to be able to test a single QEMU tree against a
> number of Xen trees (all releases from 4.3 onward).
> 
> With this change (specifically dropping the 4.9 build test), out of tree
> builds don't work anymore. I would like to be able to do:
> 
> ./configure --enable-xen --target-list=i386-softmmu \
>                 --extra-cflags="-I$DIR/tools/include \
>                 -I$DIR/tools/libs/toollog/include \
>                 -I$DIR/tools/libs/evtchn/include \
>                 -I$DIR/tools/libs/gnttab/include \
>                 -I$DIR/tools/libs/foreignmemory/include \
>                 -I$DIR/tools/libs/devicemodel/include \
>                 -I$DIR/tools/libxc/include \
>                 -I$DIR/tools/xenstore/include \
>                 -I$DIR/tools/xenstore/compat/include" \
>                 --extra-ldflags="-L$DIR/tools/libxc \
>                 -L$DIR/tools/xenstore \
>                 -L$DIR/tools/libs/evtchn \
>                 -L$DIR/tools/libs/gnttab \
>                 -L$DIR/tools/libs/foreignmemory \
>                 -L$DIR/tools/libs/devicemodel \
>                 -Wl,-rpath-link=$DIR/tools/libs/toollog \
>                 -Wl,-rpath-link=$DIR/tools/libs/evtchn \
>                 -Wl,-rpath-link=$DIR/tools/libs/gnttab \
>                 -Wl,-rpath-link=$DIR/tools/libs/call \
>                 -Wl,-rpath-link=$DIR/tools/libs/foreignmemory \
>                 -Wl,-rpath-link=$DIR/tools/libs/devicemodel" \
>             --disable-kvm 
> make
> 
> And the make should succeed. Is there a way to do that with pkg-config?

Sure, for Xen 4.9 just do:

PKG_CONFIG_PATH=$(DIR)/tools/pkg-config ./configure \
		--enable-xen --target-list=i386-softmmu \
		--disable-kvm
make


Juergen
Stefano Stabellini March 22, 2017, 6:21 p.m. UTC | #7
On Wed, 22 Mar 2017, Juergen Gross wrote:
> On 21/03/17 19:54, Stefano Stabellini wrote:
> > On Tue, 21 Mar 2017, Juergen Gross wrote:
> >> On 17/03/17 19:33, Stefano Stabellini wrote:
> >>> On Fri, 17 Mar 2017, Juergen Gross wrote:
> >>>> On 16/03/17 21:20, Stefano Stabellini wrote:
> >>>>> On Thu, 16 Mar 2017, Juergen Gross wrote:
> >>>>>> Instead of trying to guess the Xen version to use by compiling various
> >>>>>> test programs first just ask the system via pkg-config. Only if it
> >>>>>> can't return the version fall back to the test program scheme.
> >>>>>
> >>>>> That's OK, but why did you remove the Xen unstable test?
> >>>>
> >>>> >From Xen 4.9 on pkg-config will return the needed information. There is
> >>>> no longer a need for a test program to determine the Xen version. After
> >>>> all this was the main objective of my series adding the pkg-config
> >>>> files to Xen.
> >>>
> >>> I was going to say something like "yeah, but is pkg-config always
> >>> available?" In reality, QEMU already has pkg-config as build
> >>> dependency, so I guess there is no problem with that.
> >>>
> >>> Please add a note about this to the commit message.
> >>>
> >>
> >> Okay.
> > 
> > Sorry to point this out only now, and I realize that it might be
> > unimportant for production builds, but it is important to me, and
> > developers in general, to be able to test a single QEMU tree against a
> > number of Xen trees (all releases from 4.3 onward).
> > 
> > With this change (specifically dropping the 4.9 build test), out of tree
> > builds don't work anymore. I would like to be able to do:
> > 
> > ./configure --enable-xen --target-list=i386-softmmu \
> >                 --extra-cflags="-I$DIR/tools/include \
> >                 -I$DIR/tools/libs/toollog/include \
> >                 -I$DIR/tools/libs/evtchn/include \
> >                 -I$DIR/tools/libs/gnttab/include \
> >                 -I$DIR/tools/libs/foreignmemory/include \
> >                 -I$DIR/tools/libs/devicemodel/include \
> >                 -I$DIR/tools/libxc/include \
> >                 -I$DIR/tools/xenstore/include \
> >                 -I$DIR/tools/xenstore/compat/include" \
> >                 --extra-ldflags="-L$DIR/tools/libxc \
> >                 -L$DIR/tools/xenstore \
> >                 -L$DIR/tools/libs/evtchn \
> >                 -L$DIR/tools/libs/gnttab \
> >                 -L$DIR/tools/libs/foreignmemory \
> >                 -L$DIR/tools/libs/devicemodel \
> >                 -Wl,-rpath-link=$DIR/tools/libs/toollog \
> >                 -Wl,-rpath-link=$DIR/tools/libs/evtchn \
> >                 -Wl,-rpath-link=$DIR/tools/libs/gnttab \
> >                 -Wl,-rpath-link=$DIR/tools/libs/call \
> >                 -Wl,-rpath-link=$DIR/tools/libs/foreignmemory \
> >                 -Wl,-rpath-link=$DIR/tools/libs/devicemodel" \
> >             --disable-kvm 
> > make
> > 
> > And the make should succeed. Is there a way to do that with pkg-config?
> 
> Sure, for Xen 4.9 just do:
> 
> PKG_CONFIG_PATH=$(DIR)/tools/pkg-config ./configure \
> 		--enable-xen --target-list=i386-softmmu \
> 		--disable-kvm
> make

Yes, that works, thanks! I committed it to my next branch adding
"pkg-config, which is already a build dependency of QEMU, will be used
exclusively to determine the Xen version from Xen 4.9 onward." to the
commit message.
Paul Durrant March 24, 2017, 3:12 p.m. UTC | #8
> -----Original Message-----
> From: Stefano Stabellini [mailto:sstabellini@kernel.org]
> Sent: 22 March 2017 18:22
> To: Juergen Gross <jgross@suse.com>
> Cc: Stefano Stabellini <sstabellini@kernel.org>; qemu-devel@nongnu.org;
> xen-devel@lists.xenproject.org; Anthony Perard
> <anthony.perard@citrix.com>; kraxel@redhat.com; Paul Durrant
> <Paul.Durrant@citrix.com>
> Subject: Re: [PATCH 2/2] configure: use pkg-config for obtaining xen version
> 
> On Wed, 22 Mar 2017, Juergen Gross wrote:
> > On 21/03/17 19:54, Stefano Stabellini wrote:
> > > On Tue, 21 Mar 2017, Juergen Gross wrote:
> > >> On 17/03/17 19:33, Stefano Stabellini wrote:
> > >>> On Fri, 17 Mar 2017, Juergen Gross wrote:
> > >>>> On 16/03/17 21:20, Stefano Stabellini wrote:
> > >>>>> On Thu, 16 Mar 2017, Juergen Gross wrote:
> > >>>>>> Instead of trying to guess the Xen version to use by compiling
> various
> > >>>>>> test programs first just ask the system via pkg-config. Only if it
> > >>>>>> can't return the version fall back to the test program scheme.
> > >>>>>
> > >>>>> That's OK, but why did you remove the Xen unstable test?
> > >>>>
> > >>>> >From Xen 4.9 on pkg-config will return the needed information.
> There is
> > >>>> no longer a need for a test program to determine the Xen version.
> After
> > >>>> all this was the main objective of my series adding the pkg-config
> > >>>> files to Xen.
> > >>>
> > >>> I was going to say something like "yeah, but is pkg-config always
> > >>> available?" In reality, QEMU already has pkg-config as build
> > >>> dependency, so I guess there is no problem with that.
> > >>>
> > >>> Please add a note about this to the commit message.
> > >>>
> > >>
> > >> Okay.
> > >
> > > Sorry to point this out only now, and I realize that it might be
> > > unimportant for production builds, but it is important to me, and
> > > developers in general, to be able to test a single QEMU tree against a
> > > number of Xen trees (all releases from 4.3 onward).
> > >
> > > With this change (specifically dropping the 4.9 build test), out of tree
> > > builds don't work anymore. I would like to be able to do:
> > >
> > > ./configure --enable-xen --target-list=i386-softmmu \
> > >                 --extra-cflags="-I$DIR/tools/include \
> > >                 -I$DIR/tools/libs/toollog/include \
> > >                 -I$DIR/tools/libs/evtchn/include \
> > >                 -I$DIR/tools/libs/gnttab/include \
> > >                 -I$DIR/tools/libs/foreignmemory/include \
> > >                 -I$DIR/tools/libs/devicemodel/include \
> > >                 -I$DIR/tools/libxc/include \
> > >                 -I$DIR/tools/xenstore/include \
> > >                 -I$DIR/tools/xenstore/compat/include" \
> > >                 --extra-ldflags="-L$DIR/tools/libxc \
> > >                 -L$DIR/tools/xenstore \
> > >                 -L$DIR/tools/libs/evtchn \
> > >                 -L$DIR/tools/libs/gnttab \
> > >                 -L$DIR/tools/libs/foreignmemory \
> > >                 -L$DIR/tools/libs/devicemodel \
> > >                 -Wl,-rpath-link=$DIR/tools/libs/toollog \
> > >                 -Wl,-rpath-link=$DIR/tools/libs/evtchn \
> > >                 -Wl,-rpath-link=$DIR/tools/libs/gnttab \
> > >                 -Wl,-rpath-link=$DIR/tools/libs/call \
> > >                 -Wl,-rpath-link=$DIR/tools/libs/foreignmemory \
> > >                 -Wl,-rpath-link=$DIR/tools/libs/devicemodel" \
> > >             --disable-kvm
> > > make
> > >
> > > And the make should succeed. Is there a way to do that with pkg-config?
> >
> > Sure, for Xen 4.9 just do:
> >
> > PKG_CONFIG_PATH=$(DIR)/tools/pkg-config ./configure \
> > 		--enable-xen --target-list=i386-softmmu \
> > 		--disable-kvm
> > make
> 
> Yes, that works, thanks! I committed it to my next branch adding
> "pkg-config, which is already a build dependency of QEMU, will be used
> exclusively to determine the Xen version from Xen 4.9 onward." to the
> commit message.

A further question...

I have a xen tree which I've been using to build and install master against my own checked out QEMU repo. No problem with that. I've now reverted my tree to 4.7.0 and cannot build tools (even after a make distclean) because QEMU's configure is still getting up a xen_ctrl_version of 40900. This is because pkg-config is still finding a 4.9.0 xencontrol package? Where is it getting this from?

  Paul
Paul Durrant March 24, 2017, 3:24 p.m. UTC | #9
> -----Original Message-----
> From: Paul Durrant
> Sent: 24 March 2017 15:13
> To: 'Stefano Stabellini' <sstabellini@kernel.org>; Juergen Gross
> <jgross@suse.com>
> Cc: qemu-devel@nongnu.org; xen-devel@lists.xenproject.org; Anthony
> Perard <anthony.perard@citrix.com>; kraxel@redhat.com
> Subject: RE: [PATCH 2/2] configure: use pkg-config for obtaining xen version
> 
> > -----Original Message-----
> > From: Stefano Stabellini [mailto:sstabellini@kernel.org]
> > Sent: 22 March 2017 18:22
> > To: Juergen Gross <jgross@suse.com>
> > Cc: Stefano Stabellini <sstabellini@kernel.org>; qemu-devel@nongnu.org;
> > xen-devel@lists.xenproject.org; Anthony Perard
> > <anthony.perard@citrix.com>; kraxel@redhat.com; Paul Durrant
> > <Paul.Durrant@citrix.com>
> > Subject: Re: [PATCH 2/2] configure: use pkg-config for obtaining xen
> version
> >
> > On Wed, 22 Mar 2017, Juergen Gross wrote:
> > > On 21/03/17 19:54, Stefano Stabellini wrote:
> > > > On Tue, 21 Mar 2017, Juergen Gross wrote:
> > > >> On 17/03/17 19:33, Stefano Stabellini wrote:
> > > >>> On Fri, 17 Mar 2017, Juergen Gross wrote:
> > > >>>> On 16/03/17 21:20, Stefano Stabellini wrote:
> > > >>>>> On Thu, 16 Mar 2017, Juergen Gross wrote:
> > > >>>>>> Instead of trying to guess the Xen version to use by compiling
> > various
> > > >>>>>> test programs first just ask the system via pkg-config. Only if it
> > > >>>>>> can't return the version fall back to the test program scheme.
> > > >>>>>
> > > >>>>> That's OK, but why did you remove the Xen unstable test?
> > > >>>>
> > > >>>> >From Xen 4.9 on pkg-config will return the needed information.
> > There is
> > > >>>> no longer a need for a test program to determine the Xen version.
> > After
> > > >>>> all this was the main objective of my series adding the pkg-config
> > > >>>> files to Xen.
> > > >>>
> > > >>> I was going to say something like "yeah, but is pkg-config always
> > > >>> available?" In reality, QEMU already has pkg-config as build
> > > >>> dependency, so I guess there is no problem with that.
> > > >>>
> > > >>> Please add a note about this to the commit message.
> > > >>>
> > > >>
> > > >> Okay.
> > > >
> > > > Sorry to point this out only now, and I realize that it might be
> > > > unimportant for production builds, but it is important to me, and
> > > > developers in general, to be able to test a single QEMU tree against a
> > > > number of Xen trees (all releases from 4.3 onward).
> > > >
> > > > With this change (specifically dropping the 4.9 build test), out of tree
> > > > builds don't work anymore. I would like to be able to do:
> > > >
> > > > ./configure --enable-xen --target-list=i386-softmmu \
> > > >                 --extra-cflags="-I$DIR/tools/include \
> > > >                 -I$DIR/tools/libs/toollog/include \
> > > >                 -I$DIR/tools/libs/evtchn/include \
> > > >                 -I$DIR/tools/libs/gnttab/include \
> > > >                 -I$DIR/tools/libs/foreignmemory/include \
> > > >                 -I$DIR/tools/libs/devicemodel/include \
> > > >                 -I$DIR/tools/libxc/include \
> > > >                 -I$DIR/tools/xenstore/include \
> > > >                 -I$DIR/tools/xenstore/compat/include" \
> > > >                 --extra-ldflags="-L$DIR/tools/libxc \
> > > >                 -L$DIR/tools/xenstore \
> > > >                 -L$DIR/tools/libs/evtchn \
> > > >                 -L$DIR/tools/libs/gnttab \
> > > >                 -L$DIR/tools/libs/foreignmemory \
> > > >                 -L$DIR/tools/libs/devicemodel \
> > > >                 -Wl,-rpath-link=$DIR/tools/libs/toollog \
> > > >                 -Wl,-rpath-link=$DIR/tools/libs/evtchn \
> > > >                 -Wl,-rpath-link=$DIR/tools/libs/gnttab \
> > > >                 -Wl,-rpath-link=$DIR/tools/libs/call \
> > > >                 -Wl,-rpath-link=$DIR/tools/libs/foreignmemory \
> > > >                 -Wl,-rpath-link=$DIR/tools/libs/devicemodel" \
> > > >             --disable-kvm
> > > > make
> > > >
> > > > And the make should succeed. Is there a way to do that with pkg-
> config?
> > >
> > > Sure, for Xen 4.9 just do:
> > >
> > > PKG_CONFIG_PATH=$(DIR)/tools/pkg-config ./configure \
> > > 		--enable-xen --target-list=i386-softmmu \
> > > 		--disable-kvm
> > > make
> >
> > Yes, that works, thanks! I committed it to my next branch adding
> > "pkg-config, which is already a build dependency of QEMU, will be used
> > exclusively to determine the Xen version from Xen 4.9 onward." to the
> > commit message.
> 
> A further question...
> 
> I have a xen tree which I've been using to build and install master against my
> own checked out QEMU repo. No problem with that. I've now reverted my
> tree to 4.7.0 and cannot build tools (even after a make distclean) because
> QEMU's configure is still getting up a xen_ctrl_version of 40900. This is
> because pkg-config is still finding a 4.9.0 xencontrol package? Where is it
> getting this from?
> 

Even in a completely fresh checkout of xen.git RELEASE-4.7.2 tag I'm *still* getting a xen_ctrl_version of 40900, which presumably means it is coming from the version of xenctrl I have *installed* rather than the one I've built. This is quite a change in behaviour and one that is going to cause problems.

  Paul

>   Paul
Jürgen Groß March 24, 2017, 3:34 p.m. UTC | #10
On 24/03/17 16:12, Paul Durrant wrote:
>> -----Original Message-----
>> From: Stefano Stabellini [mailto:sstabellini@kernel.org]
>> Sent: 22 March 2017 18:22
>> To: Juergen Gross <jgross@suse.com>
>> Cc: Stefano Stabellini <sstabellini@kernel.org>; qemu-devel@nongnu.org;
>> xen-devel@lists.xenproject.org; Anthony Perard
>> <anthony.perard@citrix.com>; kraxel@redhat.com; Paul Durrant
>> <Paul.Durrant@citrix.com>
>> Subject: Re: [PATCH 2/2] configure: use pkg-config for obtaining xen version
>>
>> On Wed, 22 Mar 2017, Juergen Gross wrote:
>>> On 21/03/17 19:54, Stefano Stabellini wrote:
>>>> On Tue, 21 Mar 2017, Juergen Gross wrote:
>>>>> On 17/03/17 19:33, Stefano Stabellini wrote:
>>>>>> On Fri, 17 Mar 2017, Juergen Gross wrote:
>>>>>>> On 16/03/17 21:20, Stefano Stabellini wrote:
>>>>>>>> On Thu, 16 Mar 2017, Juergen Gross wrote:
>>>>>>>>> Instead of trying to guess the Xen version to use by compiling
>> various
>>>>>>>>> test programs first just ask the system via pkg-config. Only if it
>>>>>>>>> can't return the version fall back to the test program scheme.
>>>>>>>>
>>>>>>>> That's OK, but why did you remove the Xen unstable test?
>>>>>>>
>>>>>>> >From Xen 4.9 on pkg-config will return the needed information.
>> There is
>>>>>>> no longer a need for a test program to determine the Xen version.
>> After
>>>>>>> all this was the main objective of my series adding the pkg-config
>>>>>>> files to Xen.
>>>>>>
>>>>>> I was going to say something like "yeah, but is pkg-config always
>>>>>> available?" In reality, QEMU already has pkg-config as build
>>>>>> dependency, so I guess there is no problem with that.
>>>>>>
>>>>>> Please add a note about this to the commit message.
>>>>>>
>>>>>
>>>>> Okay.
>>>>
>>>> Sorry to point this out only now, and I realize that it might be
>>>> unimportant for production builds, but it is important to me, and
>>>> developers in general, to be able to test a single QEMU tree against a
>>>> number of Xen trees (all releases from 4.3 onward).
>>>>
>>>> With this change (specifically dropping the 4.9 build test), out of tree
>>>> builds don't work anymore. I would like to be able to do:
>>>>
>>>> ./configure --enable-xen --target-list=i386-softmmu \
>>>>                 --extra-cflags="-I$DIR/tools/include \
>>>>                 -I$DIR/tools/libs/toollog/include \
>>>>                 -I$DIR/tools/libs/evtchn/include \
>>>>                 -I$DIR/tools/libs/gnttab/include \
>>>>                 -I$DIR/tools/libs/foreignmemory/include \
>>>>                 -I$DIR/tools/libs/devicemodel/include \
>>>>                 -I$DIR/tools/libxc/include \
>>>>                 -I$DIR/tools/xenstore/include \
>>>>                 -I$DIR/tools/xenstore/compat/include" \
>>>>                 --extra-ldflags="-L$DIR/tools/libxc \
>>>>                 -L$DIR/tools/xenstore \
>>>>                 -L$DIR/tools/libs/evtchn \
>>>>                 -L$DIR/tools/libs/gnttab \
>>>>                 -L$DIR/tools/libs/foreignmemory \
>>>>                 -L$DIR/tools/libs/devicemodel \
>>>>                 -Wl,-rpath-link=$DIR/tools/libs/toollog \
>>>>                 -Wl,-rpath-link=$DIR/tools/libs/evtchn \
>>>>                 -Wl,-rpath-link=$DIR/tools/libs/gnttab \
>>>>                 -Wl,-rpath-link=$DIR/tools/libs/call \
>>>>                 -Wl,-rpath-link=$DIR/tools/libs/foreignmemory \
>>>>                 -Wl,-rpath-link=$DIR/tools/libs/devicemodel" \
>>>>             --disable-kvm
>>>> make
>>>>
>>>> And the make should succeed. Is there a way to do that with pkg-config?
>>>
>>> Sure, for Xen 4.9 just do:
>>>
>>> PKG_CONFIG_PATH=$(DIR)/tools/pkg-config ./configure \
>>> 		--enable-xen --target-list=i386-softmmu \
>>> 		--disable-kvm
>>> make
>>
>> Yes, that works, thanks! I committed it to my next branch adding
>> "pkg-config, which is already a build dependency of QEMU, will be used
>> exclusively to determine the Xen version from Xen 4.9 onward." to the
>> commit message.
> 
> A further question...
> 
> I have a xen tree which I've been using to build and install master against my own checked out QEMU repo. No problem with that. I've now reverted my tree to 4.7.0 and cannot build tools (even after a make distclean) because QEMU's configure is still getting up a xen_ctrl_version of 40900. This is because pkg-config is still finding a 4.9.0 xencontrol package? Where is it getting this from?

Hmm, could it be you have Xen unstable installed on your machine?

Didn't think of this problem. I can think of 3 solutions:

a) delete the xencontrol.pc file (on my system under
   /usr/share/pkgconfig/ )

b) we add a patch to qemu to test an environment variable whether
   pkg-config should be ignored for Xen version detection

c) set the environment variable PKG_CONFIG_LIBDIR to a local directory
   and copy all but the xen*.pc files from /usr/share/pkgconfig/ (or
   your correct directory) to it (or link them to avoid missing updates)

OTOH this is something you have to be aware of for other packages as
well: mixing the build environment and the target environment can lead
to bad results. Now Xen has been added to the list.


Juergen
Paul Durrant March 24, 2017, 3:44 p.m. UTC | #11
> -----Original Message-----

> From: Juergen Gross [mailto:jgross@suse.com]

> Sent: 24 March 2017 15:35

> To: Paul Durrant <Paul.Durrant@citrix.com>; 'Stefano Stabellini'

> <sstabellini@kernel.org>

> Cc: Anthony Perard <anthony.perard@citrix.com>; xen-

> devel@lists.xenproject.org; qemu-devel@nongnu.org; kraxel@redhat.com

> Subject: Re: [Xen-devel] [PATCH 2/2] configure: use pkg-config for obtaining

> xen version

> 

> On 24/03/17 16:12, Paul Durrant wrote:

> >> -----Original Message-----

> >> From: Stefano Stabellini [mailto:sstabellini@kernel.org]

> >> Sent: 22 March 2017 18:22

> >> To: Juergen Gross <jgross@suse.com>

> >> Cc: Stefano Stabellini <sstabellini@kernel.org>; qemu-

> devel@nongnu.org;

> >> xen-devel@lists.xenproject.org; Anthony Perard

> >> <anthony.perard@citrix.com>; kraxel@redhat.com; Paul Durrant

> >> <Paul.Durrant@citrix.com>

> >> Subject: Re: [PATCH 2/2] configure: use pkg-config for obtaining xen

> version

> >>

> >> On Wed, 22 Mar 2017, Juergen Gross wrote:

> >>> On 21/03/17 19:54, Stefano Stabellini wrote:

> >>>> On Tue, 21 Mar 2017, Juergen Gross wrote:

> >>>>> On 17/03/17 19:33, Stefano Stabellini wrote:

> >>>>>> On Fri, 17 Mar 2017, Juergen Gross wrote:

> >>>>>>> On 16/03/17 21:20, Stefano Stabellini wrote:

> >>>>>>>> On Thu, 16 Mar 2017, Juergen Gross wrote:

> >>>>>>>>> Instead of trying to guess the Xen version to use by compiling

> >> various

> >>>>>>>>> test programs first just ask the system via pkg-config. Only if it

> >>>>>>>>> can't return the version fall back to the test program scheme.

> >>>>>>>>

> >>>>>>>> That's OK, but why did you remove the Xen unstable test?

> >>>>>>>

> >>>>>>> >From Xen 4.9 on pkg-config will return the needed information.

> >> There is

> >>>>>>> no longer a need for a test program to determine the Xen version.

> >> After

> >>>>>>> all this was the main objective of my series adding the pkg-config

> >>>>>>> files to Xen.

> >>>>>>

> >>>>>> I was going to say something like "yeah, but is pkg-config always

> >>>>>> available?" In reality, QEMU already has pkg-config as build

> >>>>>> dependency, so I guess there is no problem with that.

> >>>>>>

> >>>>>> Please add a note about this to the commit message.

> >>>>>>

> >>>>>

> >>>>> Okay.

> >>>>

> >>>> Sorry to point this out only now, and I realize that it might be

> >>>> unimportant for production builds, but it is important to me, and

> >>>> developers in general, to be able to test a single QEMU tree against a

> >>>> number of Xen trees (all releases from 4.3 onward).

> >>>>

> >>>> With this change (specifically dropping the 4.9 build test), out of tree

> >>>> builds don't work anymore. I would like to be able to do:

> >>>>

> >>>> ./configure --enable-xen --target-list=i386-softmmu \

> >>>>                 --extra-cflags="-I$DIR/tools/include \

> >>>>                 -I$DIR/tools/libs/toollog/include \

> >>>>                 -I$DIR/tools/libs/evtchn/include \

> >>>>                 -I$DIR/tools/libs/gnttab/include \

> >>>>                 -I$DIR/tools/libs/foreignmemory/include \

> >>>>                 -I$DIR/tools/libs/devicemodel/include \

> >>>>                 -I$DIR/tools/libxc/include \

> >>>>                 -I$DIR/tools/xenstore/include \

> >>>>                 -I$DIR/tools/xenstore/compat/include" \

> >>>>                 --extra-ldflags="-L$DIR/tools/libxc \

> >>>>                 -L$DIR/tools/xenstore \

> >>>>                 -L$DIR/tools/libs/evtchn \

> >>>>                 -L$DIR/tools/libs/gnttab \

> >>>>                 -L$DIR/tools/libs/foreignmemory \

> >>>>                 -L$DIR/tools/libs/devicemodel \

> >>>>                 -Wl,-rpath-link=$DIR/tools/libs/toollog \

> >>>>                 -Wl,-rpath-link=$DIR/tools/libs/evtchn \

> >>>>                 -Wl,-rpath-link=$DIR/tools/libs/gnttab \

> >>>>                 -Wl,-rpath-link=$DIR/tools/libs/call \

> >>>>                 -Wl,-rpath-link=$DIR/tools/libs/foreignmemory \

> >>>>                 -Wl,-rpath-link=$DIR/tools/libs/devicemodel" \

> >>>>             --disable-kvm

> >>>> make

> >>>>

> >>>> And the make should succeed. Is there a way to do that with pkg-

> config?

> >>>

> >>> Sure, for Xen 4.9 just do:

> >>>

> >>> PKG_CONFIG_PATH=$(DIR)/tools/pkg-config ./configure \

> >>> 		--enable-xen --target-list=i386-softmmu \

> >>> 		--disable-kvm

> >>> make

> >>

> >> Yes, that works, thanks! I committed it to my next branch adding

> >> "pkg-config, which is already a build dependency of QEMU, will be used

> >> exclusively to determine the Xen version from Xen 4.9 onward." to the

> >> commit message.

> >

> > A further question...

> >

> > I have a xen tree which I've been using to build and install master against

> my own checked out QEMU repo. No problem with that. I've now reverted

> my tree to 4.7.0 and cannot build tools (even after a make distclean) because

> QEMU's configure is still getting up a xen_ctrl_version of 40900. This is

> because pkg-config is still finding a 4.9.0 xencontrol package? Where is it

> getting this from?

> 

> Hmm, could it be you have Xen unstable installed on your machine?


I do indeed. I build on my test machine.

> 

> Didn't think of this problem. I can think of 3 solutions:

> 

> a) delete the xencontrol.pc file (on my system under

>    /usr/share/pkgconfig/ )

> 


I just found mine using pkg-config --debug... /usr/local/share/pkgconfig for me

> b) we add a patch to qemu to test an environment variable whether

>    pkg-config should be ignored for Xen version detection

> 

> c) set the environment variable PKG_CONFIG_LIBDIR to a local directory

>    and copy all but the xen*.pc files from /usr/share/pkgconfig/ (or

>    your correct directory) to it (or link them to avoid missing updates)

> 

> OTOH this is something you have to be aware of for other packages as

> well: mixing the build environment and the target environment can lead

> to bad results. Now Xen has been added to the list.

> 


That's a change in behaviour that I, and probably others, have long been used to. What we really want, presumably, is to have pkg-config just look under tools/pkgconfig when querying for the version of xencontrol. Could that not be done by simply setting PKG_CONFIG_LIBDIR in QEMU's configure script, or would it still mean picking up installed libraries before ones just built?

  Paul

> 

> Juergen
Jürgen Groß March 24, 2017, 3:51 p.m. UTC | #12
On 24/03/17 16:44, Paul Durrant wrote:
>> -----Original Message-----
>> From: Juergen Gross [mailto:jgross@suse.com]
>> Sent: 24 March 2017 15:35
>> To: Paul Durrant <Paul.Durrant@citrix.com>; 'Stefano Stabellini'
>> <sstabellini@kernel.org>
>> Cc: Anthony Perard <anthony.perard@citrix.com>; xen-
>> devel@lists.xenproject.org; qemu-devel@nongnu.org; kraxel@redhat.com
>> Subject: Re: [Xen-devel] [PATCH 2/2] configure: use pkg-config for obtaining
>> xen version
>>
>> On 24/03/17 16:12, Paul Durrant wrote:
>>>> -----Original Message-----
>>>> From: Stefano Stabellini [mailto:sstabellini@kernel.org]
>>>> Sent: 22 March 2017 18:22
>>>> To: Juergen Gross <jgross@suse.com>
>>>> Cc: Stefano Stabellini <sstabellini@kernel.org>; qemu-
>> devel@nongnu.org;
>>>> xen-devel@lists.xenproject.org; Anthony Perard
>>>> <anthony.perard@citrix.com>; kraxel@redhat.com; Paul Durrant
>>>> <Paul.Durrant@citrix.com>
>>>> Subject: Re: [PATCH 2/2] configure: use pkg-config for obtaining xen
>> version
>>>>
>>>> On Wed, 22 Mar 2017, Juergen Gross wrote:
>>>>> On 21/03/17 19:54, Stefano Stabellini wrote:
>>>>>> On Tue, 21 Mar 2017, Juergen Gross wrote:
>>>>>>> On 17/03/17 19:33, Stefano Stabellini wrote:
>>>>>>>> On Fri, 17 Mar 2017, Juergen Gross wrote:
>>>>>>>>> On 16/03/17 21:20, Stefano Stabellini wrote:
>>>>>>>>>> On Thu, 16 Mar 2017, Juergen Gross wrote:
>>>>>>>>>>> Instead of trying to guess the Xen version to use by compiling
>>>> various
>>>>>>>>>>> test programs first just ask the system via pkg-config. Only if it
>>>>>>>>>>> can't return the version fall back to the test program scheme.
>>>>>>>>>>
>>>>>>>>>> That's OK, but why did you remove the Xen unstable test?
>>>>>>>>>
>>>>>>>>> >From Xen 4.9 on pkg-config will return the needed information.
>>>> There is
>>>>>>>>> no longer a need for a test program to determine the Xen version.
>>>> After
>>>>>>>>> all this was the main objective of my series adding the pkg-config
>>>>>>>>> files to Xen.
>>>>>>>>
>>>>>>>> I was going to say something like "yeah, but is pkg-config always
>>>>>>>> available?" In reality, QEMU already has pkg-config as build
>>>>>>>> dependency, so I guess there is no problem with that.
>>>>>>>>
>>>>>>>> Please add a note about this to the commit message.
>>>>>>>>
>>>>>>>
>>>>>>> Okay.
>>>>>>
>>>>>> Sorry to point this out only now, and I realize that it might be
>>>>>> unimportant for production builds, but it is important to me, and
>>>>>> developers in general, to be able to test a single QEMU tree against a
>>>>>> number of Xen trees (all releases from 4.3 onward).
>>>>>>
>>>>>> With this change (specifically dropping the 4.9 build test), out of tree
>>>>>> builds don't work anymore. I would like to be able to do:
>>>>>>
>>>>>> ./configure --enable-xen --target-list=i386-softmmu \
>>>>>>                 --extra-cflags="-I$DIR/tools/include \
>>>>>>                 -I$DIR/tools/libs/toollog/include \
>>>>>>                 -I$DIR/tools/libs/evtchn/include \
>>>>>>                 -I$DIR/tools/libs/gnttab/include \
>>>>>>                 -I$DIR/tools/libs/foreignmemory/include \
>>>>>>                 -I$DIR/tools/libs/devicemodel/include \
>>>>>>                 -I$DIR/tools/libxc/include \
>>>>>>                 -I$DIR/tools/xenstore/include \
>>>>>>                 -I$DIR/tools/xenstore/compat/include" \
>>>>>>                 --extra-ldflags="-L$DIR/tools/libxc \
>>>>>>                 -L$DIR/tools/xenstore \
>>>>>>                 -L$DIR/tools/libs/evtchn \
>>>>>>                 -L$DIR/tools/libs/gnttab \
>>>>>>                 -L$DIR/tools/libs/foreignmemory \
>>>>>>                 -L$DIR/tools/libs/devicemodel \
>>>>>>                 -Wl,-rpath-link=$DIR/tools/libs/toollog \
>>>>>>                 -Wl,-rpath-link=$DIR/tools/libs/evtchn \
>>>>>>                 -Wl,-rpath-link=$DIR/tools/libs/gnttab \
>>>>>>                 -Wl,-rpath-link=$DIR/tools/libs/call \
>>>>>>                 -Wl,-rpath-link=$DIR/tools/libs/foreignmemory \
>>>>>>                 -Wl,-rpath-link=$DIR/tools/libs/devicemodel" \
>>>>>>             --disable-kvm
>>>>>> make
>>>>>>
>>>>>> And the make should succeed. Is there a way to do that with pkg-
>> config?
>>>>>
>>>>> Sure, for Xen 4.9 just do:
>>>>>
>>>>> PKG_CONFIG_PATH=$(DIR)/tools/pkg-config ./configure \
>>>>> 		--enable-xen --target-list=i386-softmmu \
>>>>> 		--disable-kvm
>>>>> make
>>>>
>>>> Yes, that works, thanks! I committed it to my next branch adding
>>>> "pkg-config, which is already a build dependency of QEMU, will be used
>>>> exclusively to determine the Xen version from Xen 4.9 onward." to the
>>>> commit message.
>>>
>>> A further question...
>>>
>>> I have a xen tree which I've been using to build and install master against
>> my own checked out QEMU repo. No problem with that. I've now reverted
>> my tree to 4.7.0 and cannot build tools (even after a make distclean) because
>> QEMU's configure is still getting up a xen_ctrl_version of 40900. This is
>> because pkg-config is still finding a 4.9.0 xencontrol package? Where is it
>> getting this from?
>>
>> Hmm, could it be you have Xen unstable installed on your machine?
> 
> I do indeed. I build on my test machine.
> 
>>
>> Didn't think of this problem. I can think of 3 solutions:
>>
>> a) delete the xencontrol.pc file (on my system under
>>    /usr/share/pkgconfig/ )
>>
> 
> I just found mine using pkg-config --debug... /usr/local/share/pkgconfig for me
> 
>> b) we add a patch to qemu to test an environment variable whether
>>    pkg-config should be ignored for Xen version detection
>>
>> c) set the environment variable PKG_CONFIG_LIBDIR to a local directory
>>    and copy all but the xen*.pc files from /usr/share/pkgconfig/ (or
>>    your correct directory) to it (or link them to avoid missing updates)
>>
>> OTOH this is something you have to be aware of for other packages as
>> well: mixing the build environment and the target environment can lead
>> to bad results. Now Xen has been added to the list.
>>
> 
> That's a change in behaviour that I, and probably others, have long been used to. What we really want, presumably, is to have pkg-config just look under tools/pkgconfig when querying for the version of xencontrol. Could that not be done by simply setting PKG_CONFIG_LIBDIR in QEMU's configure script, or would it still mean picking up installed libraries before ones just built?

I guess this would break qemu's configure badly as it wouldn't find all
the other library informations it is looking for via pkg-config.


Juergen
Jürgen Groß March 24, 2017, 3:54 p.m. UTC | #13
On 24/03/17 16:51, Juergen Gross wrote:
> On 24/03/17 16:44, Paul Durrant wrote:
>>> -----Original Message-----
>>> From: Juergen Gross [mailto:jgross@suse.com]
>>> Sent: 24 March 2017 15:35
>>> To: Paul Durrant <Paul.Durrant@citrix.com>; 'Stefano Stabellini'
>>> <sstabellini@kernel.org>
>>> Cc: Anthony Perard <anthony.perard@citrix.com>; xen-
>>> devel@lists.xenproject.org; qemu-devel@nongnu.org; kraxel@redhat.com
>>> Subject: Re: [Xen-devel] [PATCH 2/2] configure: use pkg-config for obtaining
>>> xen version
>>>
>>> On 24/03/17 16:12, Paul Durrant wrote:
>>>>> -----Original Message-----
>>>>> From: Stefano Stabellini [mailto:sstabellini@kernel.org]
>>>>> Sent: 22 March 2017 18:22
>>>>> To: Juergen Gross <jgross@suse.com>
>>>>> Cc: Stefano Stabellini <sstabellini@kernel.org>; qemu-
>>> devel@nongnu.org;
>>>>> xen-devel@lists.xenproject.org; Anthony Perard
>>>>> <anthony.perard@citrix.com>; kraxel@redhat.com; Paul Durrant
>>>>> <Paul.Durrant@citrix.com>
>>>>> Subject: Re: [PATCH 2/2] configure: use pkg-config for obtaining xen
>>> version
>>>>>
>>>>> On Wed, 22 Mar 2017, Juergen Gross wrote:
>>>>>> On 21/03/17 19:54, Stefano Stabellini wrote:
>>>>>>> On Tue, 21 Mar 2017, Juergen Gross wrote:
>>>>>>>> On 17/03/17 19:33, Stefano Stabellini wrote:
>>>>>>>>> On Fri, 17 Mar 2017, Juergen Gross wrote:
>>>>>>>>>> On 16/03/17 21:20, Stefano Stabellini wrote:
>>>>>>>>>>> On Thu, 16 Mar 2017, Juergen Gross wrote:
>>>>>>>>>>>> Instead of trying to guess the Xen version to use by compiling
>>>>> various
>>>>>>>>>>>> test programs first just ask the system via pkg-config. Only if it
>>>>>>>>>>>> can't return the version fall back to the test program scheme.
>>>>>>>>>>>
>>>>>>>>>>> That's OK, but why did you remove the Xen unstable test?
>>>>>>>>>>
>>>>>>>>>> >From Xen 4.9 on pkg-config will return the needed information.
>>>>> There is
>>>>>>>>>> no longer a need for a test program to determine the Xen version.
>>>>> After
>>>>>>>>>> all this was the main objective of my series adding the pkg-config
>>>>>>>>>> files to Xen.
>>>>>>>>>
>>>>>>>>> I was going to say something like "yeah, but is pkg-config always
>>>>>>>>> available?" In reality, QEMU already has pkg-config as build
>>>>>>>>> dependency, so I guess there is no problem with that.
>>>>>>>>>
>>>>>>>>> Please add a note about this to the commit message.
>>>>>>>>>
>>>>>>>>
>>>>>>>> Okay.
>>>>>>>
>>>>>>> Sorry to point this out only now, and I realize that it might be
>>>>>>> unimportant for production builds, but it is important to me, and
>>>>>>> developers in general, to be able to test a single QEMU tree against a
>>>>>>> number of Xen trees (all releases from 4.3 onward).
>>>>>>>
>>>>>>> With this change (specifically dropping the 4.9 build test), out of tree
>>>>>>> builds don't work anymore. I would like to be able to do:
>>>>>>>
>>>>>>> ./configure --enable-xen --target-list=i386-softmmu \
>>>>>>>                 --extra-cflags="-I$DIR/tools/include \
>>>>>>>                 -I$DIR/tools/libs/toollog/include \
>>>>>>>                 -I$DIR/tools/libs/evtchn/include \
>>>>>>>                 -I$DIR/tools/libs/gnttab/include \
>>>>>>>                 -I$DIR/tools/libs/foreignmemory/include \
>>>>>>>                 -I$DIR/tools/libs/devicemodel/include \
>>>>>>>                 -I$DIR/tools/libxc/include \
>>>>>>>                 -I$DIR/tools/xenstore/include \
>>>>>>>                 -I$DIR/tools/xenstore/compat/include" \
>>>>>>>                 --extra-ldflags="-L$DIR/tools/libxc \
>>>>>>>                 -L$DIR/tools/xenstore \
>>>>>>>                 -L$DIR/tools/libs/evtchn \
>>>>>>>                 -L$DIR/tools/libs/gnttab \
>>>>>>>                 -L$DIR/tools/libs/foreignmemory \
>>>>>>>                 -L$DIR/tools/libs/devicemodel \
>>>>>>>                 -Wl,-rpath-link=$DIR/tools/libs/toollog \
>>>>>>>                 -Wl,-rpath-link=$DIR/tools/libs/evtchn \
>>>>>>>                 -Wl,-rpath-link=$DIR/tools/libs/gnttab \
>>>>>>>                 -Wl,-rpath-link=$DIR/tools/libs/call \
>>>>>>>                 -Wl,-rpath-link=$DIR/tools/libs/foreignmemory \
>>>>>>>                 -Wl,-rpath-link=$DIR/tools/libs/devicemodel" \
>>>>>>>             --disable-kvm
>>>>>>> make
>>>>>>>
>>>>>>> And the make should succeed. Is there a way to do that with pkg-
>>> config?
>>>>>>
>>>>>> Sure, for Xen 4.9 just do:
>>>>>>
>>>>>> PKG_CONFIG_PATH=$(DIR)/tools/pkg-config ./configure \
>>>>>> 		--enable-xen --target-list=i386-softmmu \
>>>>>> 		--disable-kvm
>>>>>> make
>>>>>
>>>>> Yes, that works, thanks! I committed it to my next branch adding
>>>>> "pkg-config, which is already a build dependency of QEMU, will be used
>>>>> exclusively to determine the Xen version from Xen 4.9 onward." to the
>>>>> commit message.
>>>>
>>>> A further question...
>>>>
>>>> I have a xen tree which I've been using to build and install master against
>>> my own checked out QEMU repo. No problem with that. I've now reverted
>>> my tree to 4.7.0 and cannot build tools (even after a make distclean) because
>>> QEMU's configure is still getting up a xen_ctrl_version of 40900. This is
>>> because pkg-config is still finding a 4.9.0 xencontrol package? Where is it
>>> getting this from?
>>>
>>> Hmm, could it be you have Xen unstable installed on your machine?
>>
>> I do indeed. I build on my test machine.
>>
>>>
>>> Didn't think of this problem. I can think of 3 solutions:
>>>
>>> a) delete the xencontrol.pc file (on my system under
>>>    /usr/share/pkgconfig/ )
>>>
>>
>> I just found mine using pkg-config --debug... /usr/local/share/pkgconfig for me
>>
>>> b) we add a patch to qemu to test an environment variable whether
>>>    pkg-config should be ignored for Xen version detection
>>>
>>> c) set the environment variable PKG_CONFIG_LIBDIR to a local directory
>>>    and copy all but the xen*.pc files from /usr/share/pkgconfig/ (or
>>>    your correct directory) to it (or link them to avoid missing updates)
>>>
>>> OTOH this is something you have to be aware of for other packages as
>>> well: mixing the build environment and the target environment can lead
>>> to bad results. Now Xen has been added to the list.
>>>
>>
>> That's a change in behaviour that I, and probably others, have long been used to. What we really want, presumably, is to have pkg-config just look under tools/pkgconfig when querying for the version of xencontrol. Could that not be done by simply setting PKG_CONFIG_LIBDIR in QEMU's configure script, or would it still mean picking up installed libraries before ones just built?
> 
> I guess this would break qemu's configure badly as it wouldn't find all
> the other library informations it is looking for via pkg-config.

Aah, wait, you mean just for the Xen query?

This might complicate things for my qemu stubdom plans...


Juergen
Paul Durrant March 24, 2017, 3:56 p.m. UTC | #14
> -----Original Message-----

> From: Juergen Gross [mailto:jgross@suse.com]

> Sent: 24 March 2017 15:55

> To: Paul Durrant <Paul.Durrant@citrix.com>; 'Stefano Stabellini'

> <sstabellini@kernel.org>

> Cc: Anthony Perard <anthony.perard@citrix.com>; xen-

> devel@lists.xenproject.org; qemu-devel@nongnu.org; kraxel@redhat.com

> Subject: Re: [Xen-devel] [PATCH 2/2] configure: use pkg-config for obtaining

> xen version

> 

> On 24/03/17 16:51, Juergen Gross wrote:

> > On 24/03/17 16:44, Paul Durrant wrote:

> >>> -----Original Message-----

> >>> From: Juergen Gross [mailto:jgross@suse.com]

> >>> Sent: 24 March 2017 15:35

> >>> To: Paul Durrant <Paul.Durrant@citrix.com>; 'Stefano Stabellini'

> >>> <sstabellini@kernel.org>

> >>> Cc: Anthony Perard <anthony.perard@citrix.com>; xen-

> >>> devel@lists.xenproject.org; qemu-devel@nongnu.org;

> kraxel@redhat.com

> >>> Subject: Re: [Xen-devel] [PATCH 2/2] configure: use pkg-config for

> obtaining

> >>> xen version

> >>>

> >>> On 24/03/17 16:12, Paul Durrant wrote:

> >>>>> -----Original Message-----

> >>>>> From: Stefano Stabellini [mailto:sstabellini@kernel.org]

> >>>>> Sent: 22 March 2017 18:22

> >>>>> To: Juergen Gross <jgross@suse.com>

> >>>>> Cc: Stefano Stabellini <sstabellini@kernel.org>; qemu-

> >>> devel@nongnu.org;

> >>>>> xen-devel@lists.xenproject.org; Anthony Perard

> >>>>> <anthony.perard@citrix.com>; kraxel@redhat.com; Paul Durrant

> >>>>> <Paul.Durrant@citrix.com>

> >>>>> Subject: Re: [PATCH 2/2] configure: use pkg-config for obtaining xen

> >>> version

> >>>>>

> >>>>> On Wed, 22 Mar 2017, Juergen Gross wrote:

> >>>>>> On 21/03/17 19:54, Stefano Stabellini wrote:

> >>>>>>> On Tue, 21 Mar 2017, Juergen Gross wrote:

> >>>>>>>> On 17/03/17 19:33, Stefano Stabellini wrote:

> >>>>>>>>> On Fri, 17 Mar 2017, Juergen Gross wrote:

> >>>>>>>>>> On 16/03/17 21:20, Stefano Stabellini wrote:

> >>>>>>>>>>> On Thu, 16 Mar 2017, Juergen Gross wrote:

> >>>>>>>>>>>> Instead of trying to guess the Xen version to use by

> compiling

> >>>>> various

> >>>>>>>>>>>> test programs first just ask the system via pkg-config. Only if

> it

> >>>>>>>>>>>> can't return the version fall back to the test program

> scheme.

> >>>>>>>>>>>

> >>>>>>>>>>> That's OK, but why did you remove the Xen unstable test?

> >>>>>>>>>>

> >>>>>>>>>> >From Xen 4.9 on pkg-config will return the needed

> information.

> >>>>> There is

> >>>>>>>>>> no longer a need for a test program to determine the Xen

> version.

> >>>>> After

> >>>>>>>>>> all this was the main objective of my series adding the pkg-

> config

> >>>>>>>>>> files to Xen.

> >>>>>>>>>

> >>>>>>>>> I was going to say something like "yeah, but is pkg-config always

> >>>>>>>>> available?" In reality, QEMU already has pkg-config as build

> >>>>>>>>> dependency, so I guess there is no problem with that.

> >>>>>>>>>

> >>>>>>>>> Please add a note about this to the commit message.

> >>>>>>>>>

> >>>>>>>>

> >>>>>>>> Okay.

> >>>>>>>

> >>>>>>> Sorry to point this out only now, and I realize that it might be

> >>>>>>> unimportant for production builds, but it is important to me, and

> >>>>>>> developers in general, to be able to test a single QEMU tree against

> a

> >>>>>>> number of Xen trees (all releases from 4.3 onward).

> >>>>>>>

> >>>>>>> With this change (specifically dropping the 4.9 build test), out of

> tree

> >>>>>>> builds don't work anymore. I would like to be able to do:

> >>>>>>>

> >>>>>>> ./configure --enable-xen --target-list=i386-softmmu \

> >>>>>>>                 --extra-cflags="-I$DIR/tools/include \

> >>>>>>>                 -I$DIR/tools/libs/toollog/include \

> >>>>>>>                 -I$DIR/tools/libs/evtchn/include \

> >>>>>>>                 -I$DIR/tools/libs/gnttab/include \

> >>>>>>>                 -I$DIR/tools/libs/foreignmemory/include \

> >>>>>>>                 -I$DIR/tools/libs/devicemodel/include \

> >>>>>>>                 -I$DIR/tools/libxc/include \

> >>>>>>>                 -I$DIR/tools/xenstore/include \

> >>>>>>>                 -I$DIR/tools/xenstore/compat/include" \

> >>>>>>>                 --extra-ldflags="-L$DIR/tools/libxc \

> >>>>>>>                 -L$DIR/tools/xenstore \

> >>>>>>>                 -L$DIR/tools/libs/evtchn \

> >>>>>>>                 -L$DIR/tools/libs/gnttab \

> >>>>>>>                 -L$DIR/tools/libs/foreignmemory \

> >>>>>>>                 -L$DIR/tools/libs/devicemodel \

> >>>>>>>                 -Wl,-rpath-link=$DIR/tools/libs/toollog \

> >>>>>>>                 -Wl,-rpath-link=$DIR/tools/libs/evtchn \

> >>>>>>>                 -Wl,-rpath-link=$DIR/tools/libs/gnttab \

> >>>>>>>                 -Wl,-rpath-link=$DIR/tools/libs/call \

> >>>>>>>                 -Wl,-rpath-link=$DIR/tools/libs/foreignmemory \

> >>>>>>>                 -Wl,-rpath-link=$DIR/tools/libs/devicemodel" \

> >>>>>>>             --disable-kvm

> >>>>>>> make

> >>>>>>>

> >>>>>>> And the make should succeed. Is there a way to do that with pkg-

> >>> config?

> >>>>>>

> >>>>>> Sure, for Xen 4.9 just do:

> >>>>>>

> >>>>>> PKG_CONFIG_PATH=$(DIR)/tools/pkg-config ./configure \

> >>>>>> 		--enable-xen --target-list=i386-softmmu \

> >>>>>> 		--disable-kvm

> >>>>>> make

> >>>>>

> >>>>> Yes, that works, thanks! I committed it to my next branch adding

> >>>>> "pkg-config, which is already a build dependency of QEMU, will be

> used

> >>>>> exclusively to determine the Xen version from Xen 4.9 onward." to

> the

> >>>>> commit message.

> >>>>

> >>>> A further question...

> >>>>

> >>>> I have a xen tree which I've been using to build and install master

> against

> >>> my own checked out QEMU repo. No problem with that. I've now

> reverted

> >>> my tree to 4.7.0 and cannot build tools (even after a make distclean)

> because

> >>> QEMU's configure is still getting up a xen_ctrl_version of 40900. This is

> >>> because pkg-config is still finding a 4.9.0 xencontrol package? Where is it

> >>> getting this from?

> >>>

> >>> Hmm, could it be you have Xen unstable installed on your machine?

> >>

> >> I do indeed. I build on my test machine.

> >>

> >>>

> >>> Didn't think of this problem. I can think of 3 solutions:

> >>>

> >>> a) delete the xencontrol.pc file (on my system under

> >>>    /usr/share/pkgconfig/ )

> >>>

> >>

> >> I just found mine using pkg-config --debug... /usr/local/share/pkgconfig

> for me

> >>

> >>> b) we add a patch to qemu to test an environment variable whether

> >>>    pkg-config should be ignored for Xen version detection

> >>>

> >>> c) set the environment variable PKG_CONFIG_LIBDIR to a local directory

> >>>    and copy all but the xen*.pc files from /usr/share/pkgconfig/ (or

> >>>    your correct directory) to it (or link them to avoid missing updates)

> >>>

> >>> OTOH this is something you have to be aware of for other packages as

> >>> well: mixing the build environment and the target environment can lead

> >>> to bad results. Now Xen has been added to the list.

> >>>

> >>

> >> That's a change in behaviour that I, and probably others, have long been

> used to. What we really want, presumably, is to have pkg-config just look

> under tools/pkgconfig when querying for the version of xencontrol. Could

> that not be done by simply setting PKG_CONFIG_LIBDIR in QEMU's configure

> script, or would it still mean picking up installed libraries before ones just

> built?

> >

> > I guess this would break qemu's configure badly as it wouldn't find all

> > the other library informations it is looking for via pkg-config.

> 

> Aah, wait, you mean just for the Xen query?

> 


Yes, we want QEMU to pick up xen libs from the build env and not any that have been previously installed the default search path needs to be squashed.

> This might complicate things for my qemu stubdom plans...

> 


Maybe that can be worked around in the stubdom build?

  Paul

> 

> Juergen
diff mbox

Patch

diff --git a/configure b/configure
index aabf098..b43fbd5 100755
--- a/configure
+++ b/configure
@@ -1983,26 +1983,12 @@  EOF
     fi
     xen=no
 
-  # Xen unstable
-  elif
-      cat > $TMPC <<EOF &&
-#undef XC_WANT_COMPAT_DEVICEMODEL_API
-#define __XEN_TOOLS__
-#include <xendevicemodel.h>
-int main(void) {
-  xendevicemodel_handle *xd;
-
-  xd = xendevicemodel_open(0, 0);
-  xendevicemodel_close(xd);
-
-  return 0;
-}
-EOF
-      compile_prog "" "$xen_libs $xen_stable_libs -lxendevicemodel"
-    then
-    xen_stable_libs="$xen_stable_libs -lxendevicemodel"
-    xen_ctrl_version=40900
+  # Xen version via pkg-config (Xen 4.9.0 and newer)
+  elif $pkg_config --exists xencontrol ; then
+    xen_ctrl_version="$(printf '%d%02d%02d' \
+      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
     xen=yes
+
   elif
       cat > $TMPC <<EOF &&
 /*
@@ -2214,7 +2200,12 @@  EOF
   fi
 
   if test "$xen" = yes; then
-    if test $xen_ctrl_version -ge 40701  ; then
+    if test $xen_ctrl_version -ge 40900 ; then
+      xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab xenevtchn"
+      xen_pc="$xen_pc xendevicemodel"
+      xen_libs="$($pkg_config --libs $xen_pc)"
+      QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
+    elif test $xen_ctrl_version -ge 40701 ; then
       libs_softmmu="$xen_stable_libs $libs_softmmu"
     fi
     libs_softmmu="$xen_libs $libs_softmmu"