daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
923a60
From 6bc676b1a1bfa7145106f737a6747526ce662b93 Mon Sep 17 00:00:00 2001
923a60
From: Michal Sekletar <msekleta@redhat.com>
923a60
Date: Mon, 23 Jul 2018 16:57:22 +0200
923a60
Subject: [PATCH] rules: add udev rule that automatically offline HW attached
923a60
 to ACPI container
923a60
923a60
Resolves: #1597958
923a60
---
923a60
 Makefile.am                     |  1 +
923a60
 rules/40-redhat-hotunplug.rules | 14 ++++++++++++++
923a60
 2 files changed, 15 insertions(+)
923a60
 create mode 100644 rules/40-redhat-hotunplug.rules
923a60
923a60
diff --git a/Makefile.am b/Makefile.am
923a60
index 40ebbe98ee..3995dcce89 100644
923a60
--- a/Makefile.am
923a60
+++ b/Makefile.am
923a60
@@ -3524,6 +3524,7 @@ dist_udevrules_DATA += \
923a60
 	rules/40-redhat.rules \
923a60
 	rules/40-redhat-disable-lenovo-ir-camera.rules \
923a60
 	rules/40-redhat-disable-dell-ir-camera.rules \
923a60
+	rules/40-redhat-hotunplug.rules \
923a60
 	rules/73-idrac.rules \
923a60
         rules/80-net-name-slot.rules
923a60
 
923a60
diff --git a/rules/40-redhat-hotunplug.rules b/rules/40-redhat-hotunplug.rules
923a60
new file mode 100644
923a60
index 0000000000..3befdaffc8
923a60
--- /dev/null
923a60
+++ b/rules/40-redhat-hotunplug.rules
923a60
@@ -0,0 +1,14 @@
923a60
+# ACPI0004 container offline for Huawei Kunlun
923a60
+# do not edit this file, it will be overwritten on update
923a60
+
923a60
+SUBSYSTEM=="container", ACTION=="change", DEVPATH=="*/ACPI0004:??", \
923a60
+RUN+="/bin/sh -c ' \
923a60
+if [ $(cat /sys/$env{DEVPATH}/online) -eq 1 ]; then \
923a60
+        find -L /sys/$env{DEVPATH}/firmware_node/*/physical_node* -maxdepth 1 -name online | \
923a60
+        while read line; do \
923a60
+                if [ $(cat $line) -eq 1 ]; then \
923a60
+                        /bin/echo 0 > $line; \
923a60
+                fi \
923a60
+        done; \
923a60
+        /bin/echo 0 > /sys/$env{DEVPATH}/online; \
923a60
+fi'"
923a60
\ No newline at end of file