dcavalca / rpms / systemd

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