udev: fix deadlock on xenstore access during dom0 boot
During early dom0 boot, before xenstored is started any access to it through /proc/xen/xenbus (or /dev/xen/xenbus) will wait until xenstored is started. If that happens in script ordered to start before xenstored, we have a deadlock. Prevent this by using `xenstore-ls -s` in dom0, which will fail immediately when xenstored isn't running yet. This fail isn't a problem, because when xenstored isn't running yet, surely device isn't attached anywhere. QubesOS/qubes-issues#1081
This commit is contained in:
parent
b25bab4421
commit
cdbcb2eb55
@ -2,6 +2,7 @@
|
||||
|
||||
shopt -s nullglob
|
||||
|
||||
|
||||
export LC_CTYPE=en_US.UTF-8
|
||||
NAME=${DEVNAME#/dev/}
|
||||
DESC="`echo "${ID_MODEL} (${ID_FS_LABEL})" | iconv -f utf8 -t ascii//TRANSLIT`"
|
||||
@ -36,9 +37,18 @@ is_used() {
|
||||
return 1
|
||||
}
|
||||
|
||||
# communicate with xenstored through socket in dom0
|
||||
# trying to access xenstore before xenstored is started, hang forever (in
|
||||
# non-killable state), so better fail ('-s' in VM if /proc/xen isn't mounted
|
||||
# yet) than hang dom0 boot
|
||||
if [ ! -r /proc/xen/capabilities ] || grep -q control_d /proc/xen/capabilities; then
|
||||
XENSTORE_LS="xenstore-ls -s"
|
||||
else
|
||||
XENSTORE_LS="xenstore-ls"
|
||||
fi
|
||||
is_attached() {
|
||||
dev_hex=$(stat -c %t:%T /dev/$(basename $1))
|
||||
xenstore-ls backend/vbd | grep -q "physical-device = \"$dev_hex\""
|
||||
$XENSTORE_LS backend/vbd | grep -q "physical-device = \"$dev_hex\""
|
||||
}
|
||||
|
||||
# update info about parent devices, if any:
|
||||
|
Loading…
Reference in New Issue
Block a user