Skip to contentSkip to conversation

support udev or hotplug based on the system [2/3]

PATCH In review Jeremy Katz 1 participant 2 messages Oct 6, 2005 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 support udev or hotplug based on the system [2/3]

Add udev rules that map similar to the hotplug agent. Based off of what Chris Bainbridge posted the end of last week but doing things as directly as possible.

Jeremy

unchanged:

Makefile +14 -5
@@ -36,16 +36,25 @@
 	$(MAKE) -C tools build
 	$(MAKE) -C docs build
 
-# build and install everything into local dist directory
-dist: DESTDIR=$(DISTDIR)/install
-dist: dist-xen dist-kernels dist-tools dist-docs
+# build and install everything into local dist directory.  
+dist:
+	@make XEN_BUILD_DIST=1 realdist
+dist-%:
+	@make XEN_BUILD_DIST=1 realdist-`echo -n $@ | sed -e 's/dist-//'`
+
+# these are the real targets, but we need to set a variable so that
+# everything will be installed to the distdir (making the tarball complete 
+# for any distribution)
+realdist: DESTDIR=$(DISTDIR)/install 
+realdist: dist-xen dist-kernels dist-tools dist-docs
 	$(INSTALL_DIR) $(DISTDIR)/check
 	$(INSTALL_DATA) ./COPYING $(DISTDIR)
 	$(INSTALL_DATA) ./README $(DISTDIR)
 	$(INSTALL_PROG) ./install.sh $(DISTDIR)
 	$(INSTALL_PROG) tools/check/chk tools/check/check_* $(DISTDIR)/check
-dist-%: DESTDIR=$(DISTDIR)/install
-dist-%: install-%
+realdist-%: DESTDIR=$(DISTDIR)/install
+realdist-%: install-%
+	export XEN_BUILD_DIST=1
 	@: # do nothing
 
 # Legacy dist targets
install.sh +7 -1
diff -u b/install.sh b/install.sh
@@ -24,8 +24,14 @@
 
 echo "Installing Xen from '$src' to '$dst'..."
-(cd $src; tar -cf - --exclude etc/init.d * ) | tar -C $dst -xf -
+(cd $src; tar -cf - --exclude etc/init.d --exclude etc/hotplug --exclude etc/udev * ) | tar -C $dst -xf -
 cp -fdRL $src/etc/init.d/* $dst/etc/init.d/
 echo "All done."
 
+if [ -x /sbin/udev ] && [ `/sbin/udev -V` -ge 059 ]; then
+    cp -f $src/etc/udev/rules.d/xen-backend.rules $dst/etc/udev/rules.d/xen-backend.rules
+else
+    cp -f $src/etc/hotplug/xen-backend.agent $dst/etc/hotplug/xen-backend.agent
+fi
+
 echo "Checking to see whether prerequisite tools are installed..."
 cd $src/../check

unchanged:

tools/check/check_hotplug +3 -0
@@ -7,4 +7,7 @@
    exit 1
 }
 
+if [ -x /sbin/udev ] && [ `udev -V` -ge 059 ]; then
+  exit 0
+fi
 which hotplug 1>/dev/null 2>&1 || error
tools/examples/Makefile +23 -1
diff -u b/tools/examples/Makefile b/tools/examples/Makefile
@@ -28,10 +28,23 @@
 XEN_HOTPLUG_DIR = /etc/hotplug
 XEN_HOTPLUG_SCRIPTS = xen-backend.agent
 
+UDEV_RULES_DIR = /etc/udev/rules.d
+UDEV_RULES = xen-backend.rules
+
+ifeq (1, $(XEN_BUILD_DIST))
+HOTPLUGS=install-hotplug install-udev
+else
+ifeq (1,$(shell if [ -x /sbin/udev ] && [ `/sbin/udev -V` -ge 059 ]; then echo 1; fi))
+HOTPLUGS=install-udev
+else
+HOTPLUGS=install-hotplug
+endif
+endif
+
 all:
 build:
 
-install: all install-initd install-configs install-scripts install-hotplug
+install: all install-initd install-configs install-scripts $(HOTPLUGS)
 
 install-initd:
 	[ -d $(DESTDIR)/etc/init.d ] || $(INSTALL_DIR) $(DESTDIR)/etc/init.d
@@ -66,2 +79,11 @@
 
+install-udev:
+	[ -d $(DESTDIR)$(UDEV_RULES_DIR) ] || \
+		$(INSTALL_DIR) $(DESTDIR)$(UDEV_RULES_DIR)
+	for i in $(UDEV_RULES); \
+	    do \
+	    $(INSTALL_PROG) $$i $(DESTDIR)$(UDEV_RULES_DIR); \
+	done
+
+
 clean:

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 5 lines · Jeremy Katz

Add udev rules that map similar to the hotplug agent. Based off of what Chris Bainbridge posted the end of last week but doing things as directly as possible.

Wrong patch was attached (3/3 was attached to this mail)

Jeremy

# HG changeset patch
# User [email protected]
# Node ID d62a9e2969e3bcb9e32b65cbb14f3fafcaf68f00
# Parent b955507c41895ace00ef82f074e9366fd17eae97
add udev rules file which does the same thing as the hotplug agent

tools/examples/xen-backend.rules new file +4 -0
diff -r b955507c4189 -r d62a9e2969e3 tools/examples/xen-backend.rules
@@ -0,0 +1,4 @@
+SUBSYSTEM=="xen-backend", KERNEL=="vbd*", ACTION=="add", RUN+="/etc/xen/scripts/block bind"
+SUBSYSTEM=="xen-backend", KERNEL=="vbd*", ACTION=="remove", RUN+="/etc/xen/scripts/block unbind"
+SUBSYSTEM=="xen-backend", KERNEL=="vif*", ENV{PHYSDEVDRIVER}=="vif", ACTION=="online", RUN+="$env{script} up"
+SUBSYSTEM=="xen-backend", ACTION=="remove", RUN+="/usr/bin/xenstore-rm $env{XENBUS_PATH}"

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel