diff --git a/qubesmanager/device_list.py b/qubesmanager/device_list.py new file mode 100644 index 0000000..4e0c7f9 --- /dev/null +++ b/qubesmanager/device_list.py @@ -0,0 +1,61 @@ +#!/usr/bin/python3 +# +# The Qubes OS Project, http://www.qubes-os.org +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License along +# with this program; if not, see . +# +# + +from . import ui_devicelist # pylint: disable=no-name-in-module +from PyQt4 import QtGui, QtCore # pylint: disable=import-error + + +class PCIDeviceListWindow(ui_devicelist.Ui_Dialog, QtGui.QDialog): + def __init__(self, vm, qapp, dev_list, parent=None): + super(PCIDeviceListWindow, self).__init__(parent) + + self.vm = vm + self.qapp = qapp + self.dev_list = dev_list + + self.setupUi(self) + + self.connect( + self.buttonBox, QtCore.SIGNAL("accepted()"), self.save_and_apply) + self.connect( + self.buttonBox, QtCore.SIGNAL("rejected()"), self.reject) + + self.fill_device_list() + + def fill_device_list(self): + self.device_list.clear() + + pci_devices = [ass.ident.replace('_', ':') + for ass in self.vm.devices['pci'].assignments()] + + for i in range(self.dev_list.selected_list.count()): + text = self.dev_list.selected_list.item(i).text() + ident = self.dev_list.selected_list.item(i).ident + if ident in pci_devices: + self.device_list.addItem(text) + + def reject(self): + self.done(0) + + def save_and_apply(self): + self.done(0) + + def show(self): + super(PCIDeviceListWindow, self).show() + self.fill_device_list() diff --git a/qubesmanager/settings.py b/qubesmanager/settings.py index c430fbb..9e2a085 100755 --- a/qubesmanager/settings.py +++ b/qubesmanager/settings.py @@ -37,6 +37,7 @@ import qubesadmin.exc from . import utils from . import multiselectwidget from . import thread_monitor +from . import device_list from .appmenu_select import AppmenuSelectManager from . import firewall @@ -123,6 +124,8 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): self.connect(self.dev_list, QtCore.SIGNAL("selected_changed()"), self.devices_selection_changed) + self.no_strict_reset_button.clicked.connect( + self.strict_reset_button_pressed) ####### services tab self.__init_services_tab__() @@ -668,6 +671,8 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): def __apply_devices_tab__(self): msg = [] + no_strict_reset = self.no_pci_strict_reset.isChecked() + try: old = [ass.ident.replace('_', ':') for ass in self.vm.devices['pci'].persistent()] @@ -676,10 +681,13 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): for i in range(self.dev_list.selected_list.count())] for ident in new: if ident not in old: + options = {} + if no_strict_reset: + options['no-strict-reset'] = True ass = devices.DeviceAssignment( self.vm.app.domains['dom0'], ident.replace(':', '_'), - persistent=True) + persistent=True, options=options) self.vm.devices['pci'].attach(ass) for ass in self.vm.devices['pci'].assignments(persistent=True): if ass.ident.replace('_', ':') not in new: @@ -717,6 +725,13 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): self.dmm_warning_adv.hide() self.dmm_warning_dev.hide() + def strict_reset_button_pressed(self): + device_list_window = device_list.PCIDeviceListWindow( + self.vm, self.qapp, self.dev_list, self) + device_list_window.show() + pass + + ######## applications tab def refresh_apps_in_vm(self, t_monitor): diff --git a/rpm_spec/qmgr.spec b/rpm_spec/qmgr.spec index 877caaa..4207419 100644 --- a/rpm_spec/qmgr.spec +++ b/rpm_spec/qmgr.spec @@ -91,6 +91,7 @@ rm -rf $RPM_BUILD_ROOT %{python3_sitelib}/qubesmanager/qube_manager.py %{python3_sitelib}/qubesmanager/utils.py %{python3_sitelib}/qubesmanager/bootfromdevice.py +%{python3_sitelib}/qubesmanager/device_list.py %{python3_sitelib}/qubesmanager/resources_rc.py @@ -107,6 +108,7 @@ rm -rf $RPM_BUILD_ROOT %{python3_sitelib}/qubesmanager/ui_releasenotes.py %{python3_sitelib}/qubesmanager/ui_informationnotes.py %{python3_sitelib}/qubesmanager/ui_qubemanager.py +%{python3_sitelib}/qubesmanager/ui_devicelist.py %{python3_sitelib}/qubesmanager/i18n/qubesmanager_*.qm %{python3_sitelib}/qubesmanager/i18n/qubesmanager_*.ts diff --git a/ui/settingsdlg.ui b/ui/settingsdlg.ui index f67c299..d259557 100644 --- a/ui/settingsdlg.ui +++ b/ui/settingsdlg.ui @@ -29,7 +29,7 @@ - 2 + 3 @@ -1089,6 +1089,13 @@ border-width: 1px; + + + + Configure strict reset for PCI devices + + +