anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

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

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