Blame SOURCES/0657-rules-add-udev-rule-that-automatically-offline-HW-at.patch

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