Bladeren bron

Adding a button to list PCI devices and enable no-strict-reset

Marta Marczykowska-Górecka 6 jaren geleden
bovenliggende
commit
f4fae54057
4 gewijzigde bestanden met toevoegingen van 87 en 2 verwijderingen
  1. 61 0
      qubesmanager/device_list.py
  2. 16 1
      qubesmanager/settings.py
  3. 2 0
      rpm_spec/qmgr.spec
  4. 8 1
      ui/settingsdlg.ui

+ 61 - 0
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 <http://www.gnu.org/licenses/>.
+#
+#
+
+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()

+ 16 - 1
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):

+ 2 - 0
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
 

+ 8 - 1
ui/settingsdlg.ui

@@ -29,7 +29,7 @@
         <locale language="English" country="UnitedStates"/>
        </property>
        <property name="currentIndex">
-        <number>2</number>
+        <number>3</number>
        </property>
        <widget class="QWidget" name="basic_tab">
         <property name="locale">
@@ -1089,6 +1089,13 @@ border-width: 1px;</string>
            </item>
           </layout>
          </item>
+         <item>
+          <widget class="QPushButton" name="no_strict_reset_button">
+           <property name="text">
+            <string>Configure strict reset for PCI devices</string>
+           </property>
+          </widget>
+         </item>
         </layout>
        </widget>
        <widget class="QWidget" name="apps_tab">