[virt-tools-list] [libosinfo 2/2] Add Udev support

Daniel P. Berrange berrange at redhat.com
Thu Sep 1 11:15:38 UTC 2011


On Thu, Sep 01, 2011 at 02:09:17PM +0300, Zeeshan Ali (Khattak) wrote:
> On Thu, Sep 1, 2011 at 1:38 PM, Daniel P. Berrange <berrange at redhat.com> wrote:
> > On Tue, Aug 30, 2011 at 09:30:16PM +0300, Zeeshan Ali (Khattak) wrote:
> >> From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>
> >>
> >> If enabled, provide a udev rule to listen to insertion/removal of
> >> ISO9660 media and sets some helpful (to apps) properties on the device
> >> if media is bootable.
> >> ---
> >>  configure.ac            |    5 +++++
> >>  data/95-osinfo.rules.in |   21 +++++++++++++++++++++
> >>  data/Makefile.am        |   11 ++++++++++-
> >>  libosinfo.spec.in       |    1 +
> >>  4 files changed, 37 insertions(+), 1 deletions(-)
> >>  create mode 100644 data/95-osinfo.rules.in
> >>
> >> diff --git a/configure.ac b/configure.ac
> >> index 324c0a1..390e053 100644
> >> --- a/configure.ac
> >> +++ b/configure.ac
> >> @@ -93,6 +93,11 @@ if test "x$enable_introspection" != "xno" ; then
> >>  fi
> >>  AM_CONDITIONAL([WITH_GOBJECT_INTROSPECTION], [test "x$enable_introspection" = "xyes"])
> >>
> >> +AC_ARG_ENABLE([udev],
> >> +        AS_HELP_STRING([--enable-udev], [enable Udev support]),
> >> +        [], [enable_udev=no])
> >> +AM_CONDITIONAL([WITH_UDEV], [test "x$enable_udev" = "xyes"])
> >> +
> >>  AC_ARG_ENABLE([coverage],
> >>          AS_HELP_STRING([--enable-coverage], [enable GCC code coverage]),
> >>          [], [enable_coverage=no])
> >> diff --git a/data/95-osinfo.rules.in b/data/95-osinfo.rules.in
> >> new file mode 100644
> >> index 0000000..0d5e5dd
> >> --- /dev/null
> >> +++ b/data/95-osinfo.rules.in
> >> @@ -0,0 +1,21 @@
> >> +# USB flash drives
> >> +ACTION=="add|remove", \
> >> + SUBSYSTEM=="block", \
> >> + ENV{ID_FS_TYPE}=="iso9660", \
> >> + IMPORT{program}="@bindir@/osinfo-detect -f env $tempnode"
> >> +
> >> +# CDROMs
> >> +
> >> +# Disk inserted
> >> +ACTION=="change", \
> >> + SUBSYSTEM=="block", \
> >> + ENV{ID_FS_TYPE}=="iso9660", \
> >> + IMPORT{program}="@bindir@/osinfo-detect -f env $tempnode"
> >> +
> >> +# Disk ejected
> >> +ACTION=="change", \
> >> + SUBSYSTEM=="block", \
> >> + ENV{ID_FS_TYPE}!="iso9660", \
> >> + OSINFO_BOOTABLE="", \
> >> + OSINFO_INSTALLER=""
> >> +
> >> diff --git a/data/Makefile.am b/data/Makefile.am
> >> index 657916a..566c611 100644
> >> --- a/data/Makefile.am
> >> +++ b/data/Makefile.am
> >> @@ -1,11 +1,20 @@
> >>
> >>  SUBDIRS = devices oses hypervisors
> >>
> >> -EXTRA_DIST = usb.ids pci.ids
> >> +EXTRA_DIST = usb.ids pci.ids 95-osinfo.rules.in
> >>
> >>  databasedir = $(pkgdatadir)/data/
> >>  database_DATA = usb.ids pci.ids
> >>
> >> +if WITH_UDEV
> >> +udevdir = /lib/udev/rules.d/
> >> +udev_DATA = 95-osinfo.rules
> >> +BUILT_SOURCES = 95-osinfo.rules
> >> +
> >> +95-osinfo.rules: 95-osinfo.rules.in
> >> +     sed 's,\@bindir\@,$(exec_prefix)/bin,' 95-osinfo.rules.in > 95-osinfo.rules
> >> +endif
> >
> > Can be simplified to
> >
> >     sed 's,\@bindir\@,$(exec_prefix)/bin,' $< > $@
> >
> >> diff --git a/libosinfo.spec.in b/libosinfo.spec.in
> >> index 5d215ce..c91e897 100644
> >> --- a/libosinfo.spec.in
> >> +++ b/libosinfo.spec.in
> >> @@ -28,6 +28,7 @@ BuildRequires: gobject-introspection-devel
> >>  BuildRequires: gir-repository-devel
> >>  %endif
> >>  %endif
> >> +Requires: udev
> >
> > We need to have a BuildRequires:  too, otherwise there's a (small)
> > chance it won't be present when ./configure runs
> 
>   But there is no need for udev to be present at that (or any phase
> during the build) phase. Even at runtime, the worse that will happen
> is udev rule won't run on device insertion and we are not exactly
> depending on that to happen.

I was thinking that the configure.ac script had code which would
automatically enable the UDEV feature, if it saw udev on the host.


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 :|




More information about the virt-tools-list mailing list