aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--initscripts.spec2
-rw-r--r--udev/rules.d/81-kvm-rhel.rules1
-rwxr-xr-xudev/udev-kvm-check49
3 files changed, 52 insertions, 0 deletions
diff --git a/initscripts.spec b/initscripts.spec
index d2778f95..02356f82 100644
--- a/initscripts.spec
+++ b/initscripts.spec
@@ -187,6 +187,7 @@ rm -rf $RPM_BUILD_ROOT
%attr(2755,root,root) /usr/sbin/netreport
/usr/lib/udev/rules.d/*
/usr/lib/udev/rename_device
+/usr/lib/udev/udev-kvm-check
/usr/sbin/service
/usr/sbin/ppp-watch
%{_mandir}/man*/*
@@ -207,6 +208,7 @@ rm -rf $RPM_BUILD_ROOT
%ghost %attr(0600,root,utmp) /var/log/btmp
%ghost %attr(0664,root,utmp) /var/log/wtmp
%ghost %attr(0664,root,utmp) /var/run/utmp
+%ghost %attr(0644,root,root) /etc/sysconfig/kvm
%ghost %verify(not md5 size mtime) %config(noreplace,missingok) /etc/crypttab
%dir /usr/lib/tmpfiles.d
/usr/lib/tmpfiles.d/initscripts.conf
diff --git a/udev/rules.d/81-kvm-rhel.rules b/udev/rules.d/81-kvm-rhel.rules
new file mode 100644
index 00000000..787cad62
--- /dev/null
+++ b/udev/rules.d/81-kvm-rhel.rules
@@ -0,0 +1 @@
+DEVPATH=="*/kvm", ACTION=="change", RUN+="/lib/udev/udev-kvm-check $env{COUNT} $env{EVENT}"
diff --git a/udev/udev-kvm-check b/udev/udev-kvm-check
new file mode 100755
index 00000000..f8a9921e
--- /dev/null
+++ b/udev/udev-kvm-check
@@ -0,0 +1,49 @@
+#! /bin/sh
+
+if test -f /etc/sysconfig/kvm; then
+ . /etc/sysconfig/kvm
+fi
+
+: ${THRESHOLD:=0}
+COUNT=$1
+EVENT=$2
+
+if [ "$THRESHOLD" -eq 0 ]; then
+ level=user.debug
+else
+ level=user.info
+fi
+
+subscr_msg="your Red Hat Enterprise Linux subscription limit is $THRESHOLD"
+subscr_msg="$subscr_msg guests. Please review your Red Hat Enterprise Linux"
+subscr_msg="$subscr_msg subscription agreement or contact your Red Hat"
+subscr_msg="$subscr_msg support representative for more information. You"
+subscr_msg="$subscr_msg may review the Red Hat Enterprise subscription"
+subscr_msg="$subscr_msg limits at http://www.redhat.com/rhel-virt-limits"
+
+case $COUNT in
+ 1) guests=guest ;;
+ *) guests=guests ;;
+esac
+
+case $EVENT in
+ create)
+ if [ "$THRESHOLD" -eq 0 ]; then
+ msg="$COUNT $guests now active"
+ elif [ $COUNT -gt "$THRESHOLD" ]; then
+ level=user.warning
+ msg="$COUNT $guests are currently active; $subscr_msg"
+ fi
+ ;;
+ terminate)
+ if [ $COUNT -ge "$THRESHOLD" ]; then
+ msg="$COUNT $guests now active"
+ fi
+ ;;
+esac
+
+if [ -n "$msg" ]; then
+ logger -p $level "KVM: $msg"
+fi
+exit 0
+