[libvirt] [PATCH] check device-mapper when building without storage mpath

When I build libvirt without libvirtd, I receive the following errors: GEN virsh.1 CCLD virsh ../src/.libs/libvirt.so: undefined reference to `dm_is_dm_major' collect2: ld returned 1 exit status make[3]: *** [virsh] Error 1 My build step: # ./autogen.sh --without-libvirtd # make dist # rpmbuild --nodeps --define "_sourcedir `pwd`" --define "_without_libvirtd 1" -ba libvirt.spec This bug was caused by commit df1011ca. Signed-off-by: Wen Congyang <wency@cn.fujitsu.com> --- configure.ac | 35 ++++++++++++++++------------------- 1 files changed, 16 insertions(+), 19 deletions(-) diff --git a/configure.ac b/configure.ac index 2bb6918..0f81484 100644 --- a/configure.ac +++ b/configure.ac @@ -1697,25 +1697,22 @@ if test "$with_storage_mpath" = "check" && test "$with_linux" = "yes"; then fi AM_CONDITIONAL([WITH_STORAGE_MPATH], [test "$with_storage_mpath" = "yes"]) -if test "$with_storage_mpath" = "yes"; then - DEVMAPPER_CFLAGS= - DEVMAPPER_LIBS= - PKG_CHECK_MODULES([DEVMAPPER], [devmapper >= $DEVMAPPER_REQUIRED], [], [DEVMAPPER_FOUND=no]) - if test "$DEVMAPPER_FOUND" = "no"; then - # devmapper is missing pkg-config files in ubuntu, suse, etc - save_LIBS="$LIBS" - save_CFLAGS="$CFLAGS" - DEVMAPPER_FOUND=yes - AC_CHECK_HEADER([libdevmapper.h],,[DEVMAPPER_FOUND=no]) - AC_CHECK_LIB([devmapper], [dm_task_run],,[DEVMAPPER_FOUND=no]) - DEVMAPPER_LIBS="-ldevmapper" - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" - fi - if test "$DEVMAPPER_FOUND" = "no" ; then - AC_MSG_ERROR([You must install device-mapper-devel/libdevmapper >= $DEVMAPPER_REQUIRED to compile libvirt]) - fi - +DEVMAPPER_CFLAGS= +DEVMAPPER_LIBS= +PKG_CHECK_MODULES([DEVMAPPER], [devmapper >= $DEVMAPPER_REQUIRED], [], [DEVMAPPER_FOUND=no]) +if test "$DEVMAPPER_FOUND" = "no"; then + # devmapper is missing pkg-config files in ubuntu, suse, etc + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + DEVMAPPER_FOUND=yes + AC_CHECK_HEADER([libdevmapper.h],,[DEVMAPPER_FOUND=no]) + AC_CHECK_LIB([devmapper], [dm_task_run],,[DEVMAPPER_FOUND=no]) + DEVMAPPER_LIBS="-ldevmapper" + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" +fi +if test "$DEVMAPPER_FOUND" = "no" ; then + AC_MSG_ERROR([You must install device-mapper-devel/libdevmapper >= $DEVMAPPER_REQUIRED to compile libvirt]) fi AC_SUBST([DEVMAPPER_CFLAGS]) AC_SUBST([DEVMAPPER_LIBS]) -- 1.7.1

于 2011年02月18日 11:00, Wen Congyang 写道:
When I build libvirt without libvirtd, I receive the following errors: GEN virsh.1 CCLD virsh ../src/.libs/libvirt.so: undefined reference to `dm_is_dm_major' collect2: ld returned 1 exit status make[3]: *** [virsh] Error 1
My build step: # ./autogen.sh --without-libvirtd # make dist # rpmbuild --nodeps --define "_sourcedir `pwd`" --define "_without_libvirtd 1" -ba libvirt.spec
This bug was caused by commit df1011ca.
Signed-off-by: Wen Congyang<wency@cn.fujitsu.com>
--- configure.ac | 35 ++++++++++++++++------------------- 1 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/configure.ac b/configure.ac index 2bb6918..0f81484 100644 --- a/configure.ac +++ b/configure.ac @@ -1697,25 +1697,22 @@ if test "$with_storage_mpath" = "check"&& test "$with_linux" = "yes"; then fi AM_CONDITIONAL([WITH_STORAGE_MPATH], [test "$with_storage_mpath" = "yes"])
-if test "$with_storage_mpath" = "yes"; then - DEVMAPPER_CFLAGS= - DEVMAPPER_LIBS= - PKG_CHECK_MODULES([DEVMAPPER], [devmapper>= $DEVMAPPER_REQUIRED], [], [DEVMAPPER_FOUND=no]) - if test "$DEVMAPPER_FOUND" = "no"; then - # devmapper is missing pkg-config files in ubuntu, suse, etc - save_LIBS="$LIBS" - save_CFLAGS="$CFLAGS" - DEVMAPPER_FOUND=yes - AC_CHECK_HEADER([libdevmapper.h],,[DEVMAPPER_FOUND=no]) - AC_CHECK_LIB([devmapper], [dm_task_run],,[DEVMAPPER_FOUND=no]) - DEVMAPPER_LIBS="-ldevmapper" - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" - fi - if test "$DEVMAPPER_FOUND" = "no" ; then - AC_MSG_ERROR([You must install device-mapper-devel/libdevmapper>= $DEVMAPPER_REQUIRED to compile libvirt]) - fi - +DEVMAPPER_CFLAGS= +DEVMAPPER_LIBS= +PKG_CHECK_MODULES([DEVMAPPER], [devmapper>= $DEVMAPPER_REQUIRED], [], [DEVMAPPER_FOUND=no]) +if test "$DEVMAPPER_FOUND" = "no"; then + # devmapper is missing pkg-config files in ubuntu, suse, etc + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + DEVMAPPER_FOUND=yes + AC_CHECK_HEADER([libdevmapper.h],,[DEVMAPPER_FOUND=no]) + AC_CHECK_LIB([devmapper], [dm_task_run],,[DEVMAPPER_FOUND=no]) + DEVMAPPER_LIBS="-ldevmapper" + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" +fi +if test "$DEVMAPPER_FOUND" = "no" ; then + AC_MSG_ERROR([You must install device-mapper-devel/libdevmapper>= $DEVMAPPER_REQUIRED to compile libvirt]) fi AC_SUBST([DEVMAPPER_CFLAGS]) AC_SUBST([DEVMAPPER_LIBS])
Thanks for the fix, actually It can be reproduced simply by: % ./autogen.sh --with-storage-mpath=no % make As src/util/util.c invokes "dm_is_dm_major". ACK. Regards, Osier

On Fri, Feb 18, 2011 at 16:21:20 +0800, Osier Yang wrote:
于 2011年02月18日 11:00, Wen Congyang 写道:
+DEVMAPPER_CFLAGS= +DEVMAPPER_LIBS= +PKG_CHECK_MODULES([DEVMAPPER], [devmapper>= $DEVMAPPER_REQUIRED], [], [DEVMAPPER_FOUND=no]) +if test "$DEVMAPPER_FOUND" = "no"; then + # devmapper is missing pkg-config files in ubuntu, suse, etc + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + DEVMAPPER_FOUND=yes + AC_CHECK_HEADER([libdevmapper.h],,[DEVMAPPER_FOUND=no]) + AC_CHECK_LIB([devmapper], [dm_task_run],,[DEVMAPPER_FOUND=no]) + DEVMAPPER_LIBS="-ldevmapper" + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" +fi +if test "$DEVMAPPER_FOUND" = "no" ; then + AC_MSG_ERROR([You must install device-mapper-devel/libdevmapper>= $DEVMAPPER_REQUIRED to compile libvirt]) fi AC_SUBST([DEVMAPPER_CFLAGS]) AC_SUBST([DEVMAPPER_LIBS])
Thanks for the fix, actually It can be reproduced simply by: % ./autogen.sh --with-storage-mpath=no % make
As src/util/util.c invokes "dm_is_dm_major".
Yes it does, but I'm not convinced this is the right approach to fix it. Why should libvirt always require device-mapper libraries? It only needs it for disk and mpath storage drivers so if neither of them is built, we shouldn't check for the library and we shouldn't call dm_is_dm_major. NACK to the current patch. Jirka

On 18/02/2011, at 7:46 PM, Jiri Denemark wrote: <snip>
Thanks for the fix, actually It can be reproduced simply by: % ./autogen.sh --with-storage-mpath=no % make
As src/util/util.c invokes "dm_is_dm_major".
Yes it does, but I'm not convinced this is the right approach to fix it. Why should libvirt always require device-mapper libraries?
As a data point, device-mapper isn't available on non-Linux platforms. If Osier was meaning to make it "required", I can see a problem about there. ;)

At 02/18/2011 05:00 PM, Justin Clift Write:
On 18/02/2011, at 7:46 PM, Jiri Denemark wrote: <snip>
Thanks for the fix, actually It can be reproduced simply by: % ./autogen.sh --with-storage-mpath=no % make
As src/util/util.c invokes "dm_is_dm_major".
Yes it does, but I'm not convinced this is the right approach to fix it. Why should libvirt always require device-mapper libraries?
As a data point, device-mapper isn't available on non-Linux platforms. If Osier was meaning to make it "required", I can see a problem about there. ;)
Do we build storage mpath on such platforms?
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On 18/02/2011, at 8:07 PM, Wen Congyang wrote:
At 02/18/2011 05:00 PM, Justin Clift Write:
On 18/02/2011, at 7:46 PM, Jiri Denemark wrote: <snip>
Thanks for the fix, actually It can be reproduced simply by: % ./autogen.sh --with-storage-mpath=no % make
As src/util/util.c invokes "dm_is_dm_major".
Yes it does, but I'm not convinced this is the right approach to fix it. Why should libvirt always require device-mapper libraries?
As a data point, device-mapper isn't available on non-Linux platforms. If Osier was meaning to make it "required", I can see a problem about there. ;)
Do we build storage mpath on such platforms?
No. This is the ./configure output on OSX using libvirt 0.8.8, with most of the stuff enabled that can be made to compile: ********************************************* configure: Configuration summary configure: ===================== configure: configure: Drivers configure: configure: Xen: no configure: QEMU: no configure: UML: no configure: OpenVZ: yes configure: VMware: yes configure: VBox: yes configure: XenAPI: no configure: LXC: no configure: PHYP: no configure: ONE: no configure: ESX: yes configure: Test: yes configure: Remote: yes configure: Network: no configure: Libvirtd: yes configure: netcf: no configure: macvtap: no configure: virtport: no configure: configure: Storage Drivers configure: configure: Dir: yes configure: FS: no configure: NetFS: no configure: LVM: no configure: iSCSI: no configure: SCSI: yes configure: mpath: no configure: Disk: no configure: configure: Security Drivers configure: configure: SELinux: no configure: AppArmor: no configure: configure: Driver Loadable Modules configure: configure: dlopen: no configure: configure: Libraries configure: configure: libxml: -I/opt/local/include/libxml2 -L/opt/local/lib -lxml2 configure: libcurl: -DCURL_DISABLE_TYPECHECK -I/opt/local/include -L/opt/local/lib -lcurl configure: libssh2: configure: gnutls: -I/opt/local/include -L/opt/local/lib -lgnutls -lgcrypt configure: sasl: -lsasl2 configure: yajl: -lyajl configure: avahi: no configure: polkit: no configure: audit: no configure: selinux: no configure: apparmor: no configure: numactl: no configure: capng: no configure: xen: no configure: xenapi: no configure: hal: no configure: udev: no configure: netcf: no configure: xmlrpc: no configure: pcap: no configure: nl: no configure: mscom: no configure: xdr: configure: configure: Test suite configure: configure: Coverage: no configure: Alloc OOM: no configure: configure: Miscellaneous configure: configure: Debug: yes configure: Warnings: maximum configure: Readline: yes configure: Python: yes configure: DTrace: no configure: XML Catalog: /opt/local/etc/xml/catalog configure: configure: Privileges configure: configure: QEMU: root:root ********************************************* With some persistence, it's also possible to get: + libssh2 support compiled in, although that can tricky as there doesn't seem to be a way to pass non "/usr/local" include directories to configure for it it + Avahi support can also be made to compile, but has a huge dependency chain on OSX so I don't bother. That pulls in compiling of all X windows, no idea why. + libpcap. I've seen it compile in before, but haven't really looked at what this gives. Hope that's useful info. :) Regards and best wishes, Justin Clift

At 02/18/2011 05:35 PM, Justin Clift Write:
On 18/02/2011, at 8:07 PM, Wen Congyang wrote:
At 02/18/2011 05:00 PM, Justin Clift Write:
On 18/02/2011, at 7:46 PM, Jiri Denemark wrote: <snip>
Thanks for the fix, actually It can be reproduced simply by: % ./autogen.sh --with-storage-mpath=no % make
As src/util/util.c invokes "dm_is_dm_major".
Yes it does, but I'm not convinced this is the right approach to fix it. Why should libvirt always require device-mapper libraries?
As a data point, device-mapper isn't available on non-Linux platforms. If Osier was meaning to make it "required", I can see a problem about there. ;)
Do we build storage mpath on such platforms?
No. This is the ./configure output on OSX using libvirt 0.8.8, with most of the stuff enabled that can be made to compile:
<snip>
Hope that's useful info. :)
Thank you for providing such useful info.
Regards and best wishes,
Justin Clift

于 2011年02月18日 17:00, Justin Clift 写道:
On 18/02/2011, at 7:46 PM, Jiri Denemark wrote: <snip>
Thanks for the fix, actually It can be reproduced simply by: % ./autogen.sh --with-storage-mpath=no % make
As src/util/util.c invokes "dm_is_dm_major".
Yes it does, but I'm not convinced this is the right approach to fix it. Why should libvirt always require device-mapper libraries?
As a data point, device-mapper isn't available on non-Linux platforms. If Osier was meaning to make it "required", I can see a problem about there. ;)
That's a problem indeed, but we already required it to use "parted" to create storage volume. Perhaps we need a better solution, but currently I have no better idea. :-) Regards Osier

On Fri, Feb 18, 2011 at 08:00:34PM +1100, Justin Clift wrote:
On 18/02/2011, at 7:46 PM, Jiri Denemark wrote: <snip>
Thanks for the fix, actually It can be reproduced simply by: % ./autogen.sh --with-storage-mpath=no % make
As src/util/util.c invokes "dm_is_dm_major".
Yes it does, but I'm not convinced this is the right approach to fix it. Why should libvirt always require device-mapper libraries?
As a data point, device-mapper isn't available on non-Linux platforms. If Osier was meaning to make it "required", I can see a problem about there. ;)
Since device-mapper is Linux specific, then by definition virIsDevMapperDevice() will always return false on those platforms. So there is no requirement for any device-mapper libs on non-Linux, you just trivially make it do: #if HAVE_DEVICE_MAPPER bool virIsDevMapperDevice(const char *devname) { struct stat buf; if (!stat(devname, &buf) && S_ISBLK(buf.st_mode) && dm_is_dm_major(major(buf.st_rdev))) return true; return false; } #else bool virIsDevMapperDevice(const char *devname ATTRIBUTE_UNUSED) { return false; } #endif Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

At 02/18/2011 04:46 PM, Jiri Denemark Write:
On Fri, Feb 18, 2011 at 16:21:20 +0800, Osier Yang wrote:
于 2011年02月18日 11:00, Wen Congyang 写道:
+DEVMAPPER_CFLAGS= +DEVMAPPER_LIBS= +PKG_CHECK_MODULES([DEVMAPPER], [devmapper>= $DEVMAPPER_REQUIRED], [], [DEVMAPPER_FOUND=no]) +if test "$DEVMAPPER_FOUND" = "no"; then + # devmapper is missing pkg-config files in ubuntu, suse, etc + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + DEVMAPPER_FOUND=yes + AC_CHECK_HEADER([libdevmapper.h],,[DEVMAPPER_FOUND=no]) + AC_CHECK_LIB([devmapper], [dm_task_run],,[DEVMAPPER_FOUND=no]) + DEVMAPPER_LIBS="-ldevmapper" + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" +fi +if test "$DEVMAPPER_FOUND" = "no" ; then + AC_MSG_ERROR([You must install device-mapper-devel/libdevmapper>= $DEVMAPPER_REQUIRED to compile libvirt]) fi AC_SUBST([DEVMAPPER_CFLAGS]) AC_SUBST([DEVMAPPER_LIBS])
Thanks for the fix, actually It can be reproduced simply by: % ./autogen.sh --with-storage-mpath=no % make
As src/util/util.c invokes "dm_is_dm_major".
Yes it does, but I'm not convinced this is the right approach to fix it. Why should libvirt always require device-mapper libraries? It only needs it for disk and mpath storage drivers so if neither of them is built, we shouldn't check for the library and we shouldn't call dm_is_dm_major.
Yes, you are right. I will update this patch next week.
NACK to the current patch.
Jirka

于 2011年02月18日 16:46, Jiri Denemark 写道:
On Fri, Feb 18, 2011 at 16:21:20 +0800, Osier Yang wrote:
于 2011年02月18日 11:00, Wen Congyang 写道:
+DEVMAPPER_CFLAGS= +DEVMAPPER_LIBS= +PKG_CHECK_MODULES([DEVMAPPER], [devmapper>= $DEVMAPPER_REQUIRED], [], [DEVMAPPER_FOUND=no]) +if test "$DEVMAPPER_FOUND" = "no"; then + # devmapper is missing pkg-config files in ubuntu, suse, etc + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + DEVMAPPER_FOUND=yes + AC_CHECK_HEADER([libdevmapper.h],,[DEVMAPPER_FOUND=no]) + AC_CHECK_LIB([devmapper], [dm_task_run],,[DEVMAPPER_FOUND=no]) + DEVMAPPER_LIBS="-ldevmapper" + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" +fi +if test "$DEVMAPPER_FOUND" = "no" ; then + AC_MSG_ERROR([You must install device-mapper-devel/libdevmapper>= $DEVMAPPER_REQUIRED to compile libvirt]) fi AC_SUBST([DEVMAPPER_CFLAGS]) AC_SUBST([DEVMAPPER_LIBS])
Thanks for the fix, actually It can be reproduced simply by: % ./autogen.sh --with-storage-mpath=no % make
As src/util/util.c invokes "dm_is_dm_major".
Yes it does, but I'm not convinced this is the right approach to fix it. Why should libvirt always require device-mapper libraries? It only needs it for disk and mpath storage drivers so if neither of them is built, we shouldn't check for the library and we shouldn't call dm_is_dm_major.
Yes, it's better.
NACK to the current patch.
Jirka

On 02/18/2011 01:21 AM, Osier Yang wrote:
于 2011年02月18日 11:00, Wen Congyang 写道:
When I build libvirt without libvirtd, I receive the following errors: GEN virsh.1 CCLD virsh ../src/.libs/libvirt.so: undefined reference to `dm_is_dm_major' collect2: ld returned 1 exit status make[3]: *** [virsh] Error 1 Thanks for the fix, actually It can be reproduced simply by:
% ./autogen.sh --with-storage-mpath=no % make
As src/util/util.c invokes "dm_is_dm_major".
It's also reproducible with a mingw build: CC libvirt_util_la-util.lo ../../src/util/util.c:48:26: fatal error: libdevmapper.h: No such file or directory compilation terminated. I agree with danpb's approach that virIsDevMapperDevice should be a no-op for other platforms, so I'll be coming up with something along those lines soon. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (6)
-
Daniel P. Berrange
-
Eric Blake
-
Jiri Denemark
-
Justin Clift
-
Osier Yang
-
Wen Congyang