From 0de378dafc132d928d84c90a67a093305dfe446e Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Tue, 5 Jul 2011 22:10:09 +0200 Subject: [PATCH] dom0: automatically bind PCI devices to pciback at VM start (#252) --- dom0/aux-tools/unbind_pci_device.sh | 5 +++++ dom0/init.d/qubes_netvm | 1 - dom0/qvm-core/qubes.py | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/dom0/aux-tools/unbind_pci_device.sh b/dom0/aux-tools/unbind_pci_device.sh index c54ee2f2..3995ec06 100755 --- a/dom0/aux-tools/unbind_pci_device.sh +++ b/dom0/aux-tools/unbind_pci_device.sh @@ -27,6 +27,11 @@ if [ x$BDF = x ] ; then fi BDF=0000:$BDF #echo -n "Binding device $BDF to xen-pciback..." +if [ -e /sys/bus/pci/drivers/pciback/$BDF ]; then + # Already bound to pciback + exit 0 +fi + if [ -e /sys/bus/pci/devices/$BDF/driver/unbind ] ; then echo -n $BDF > /sys/bus/pci/devices/$BDF/driver/unbind || exit 1 fi diff --git a/dom0/init.d/qubes_netvm b/dom0/init.d/qubes_netvm index 3a14411e..13f68a32 100755 --- a/dom0/init.d/qubes_netvm +++ b/dom0/init.d/qubes_netvm @@ -41,7 +41,6 @@ start() else echo -n $"Starting default NetVM:" - /usr/lib/qubes/unbind_all_network_devices || exit 1 qvm-start -q --no-guid $NETVM || exit 1 fi diff --git a/dom0/qvm-core/qubes.py b/dom0/qvm-core/qubes.py index 0b30288d..000c7daa 100755 --- a/dom0/qvm-core/qubes.py +++ b/dom0/qvm-core/qubes.py @@ -88,6 +88,7 @@ dom0_vm = None qubes_appmenu_create_cmd = "/usr/lib/qubes/create_apps_for_appvm.sh" qubes_appmenu_remove_cmd = "/usr/lib/qubes/remove_appvm_appmenus.sh" +qubes_pciback_cmd = '/usr/lib/qubes/unbind_pci_device.sh' class QubesException (Exception) : pass @@ -926,6 +927,10 @@ class QubesVm(object): qmemman_client.close() raise MemoryError ("ERROR: insufficient memory to start this VM") + # Bind pci devices to pciback driver + for pci in self.pcidevs: + subprocess.check_call('sudo', qubes_pciback_cmd, pci) + xl_cmdline = ['sudo', '/usr/sbin/xl', 'create', self.conf_file, '-p'] try: