dom0/core: detect if PCI device not already attached to some other VM (#522)
This commit is contained in:
parent
c22296fe38
commit
abaea52da0
@ -29,6 +29,14 @@ BDF=0000:$BDF
|
|||||||
#echo -n "Binding device $BDF to xen-pciback..."
|
#echo -n "Binding device $BDF to xen-pciback..."
|
||||||
if [ -e /sys/bus/pci/drivers/pciback/$BDF ]; then
|
if [ -e /sys/bus/pci/drivers/pciback/$BDF ]; then
|
||||||
# Already bound to pciback
|
# Already bound to pciback
|
||||||
|
# Check if device not assigned to any RUNNING VM
|
||||||
|
XS_PATH=/local/domain/0/backend/pci
|
||||||
|
GREP_RE="^$XS_PATH/[0-9]*/[0-9]*/dev-[0-9]* = \"$BDF\""
|
||||||
|
if xenstore-ls -f $XS_PATH | grep -q "$GREP_RE"; then
|
||||||
|
DOMID=`xenstore-ls -f $XS_PATH | grep "$GREP_RE"|cut -d/ -f7`
|
||||||
|
echo "ERROR: Device already attached to the running VM '`xl domname $DOMID`'" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1352,7 +1352,10 @@ class QubesVm(object):
|
|||||||
|
|
||||||
# Bind pci devices to pciback driver
|
# Bind pci devices to pciback driver
|
||||||
for pci in self.pcidevs:
|
for pci in self.pcidevs:
|
||||||
subprocess.check_call(['sudo', qubes_pciback_cmd, pci])
|
try:
|
||||||
|
subprocess.check_call(['sudo', qubes_pciback_cmd, pci])
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
raise QubesException("Failed to prepare PCI device %s" % pci)
|
||||||
|
|
||||||
xl_cmdline = ['sudo', '/usr/sbin/xl', 'create', self.conf_file, '-q', '-p']
|
xl_cmdline = ['sudo', '/usr/sbin/xl', 'create', self.conf_file, '-q', '-p']
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user