[virt-tools-list] [PATCH v2 virt-manager 3/4] virt-manager: add support for adding panic notifier device
Chen Hanxiao
chenhanxiao at cn.fujitsu.com
Fri Jan 10 09:37:56 UTC 2014
From: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
Signed-off-by: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
---
ui/addhardware.ui | 80 ++++++++++++++++++++++++++++++++++++++++++++--
virtManager/addhardware.py | 42 +++++++++++++++++++++++-
2 files changed, 119 insertions(+), 3 deletions(-)
diff --git a/ui/addhardware.ui b/ui/addhardware.ui
index eee0128..f6f1ba5 100644
--- a/ui/addhardware.ui
+++ b/ui/addhardware.ui
@@ -714,8 +714,6 @@
<object class="GtkAlignment" id="alignment5">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="hexpand">False</property>
- <property name="vexpand">False</property>
<child>
<placeholder/>
</child>
@@ -2203,6 +2201,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
+ <property name="width_chars">12</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -2543,6 +2542,83 @@
<property name="tab_fill">False</property>
</packing>
</child>
+ <child>
+ <object class="GtkGrid" id="grid2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label14">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Address _Type:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="panic-type">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label16">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_IO Base:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="panic-iobase">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">15</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="panic">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">panic</property>
+ </object>
+ <packing>
+ <property name="position">15</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
</object>
</child>
</object>
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index fc2f0f8..58e64d8 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -31,7 +31,8 @@ from virtinst import (VirtualChannelDevice, VirtualParallelDevice,
VirtualSerialDevice, VirtualConsoleDevice,
VirtualVideoDevice, VirtualWatchdog,
VirtualFilesystem, VirtualSmartCardDevice,
- VirtualRedirDevice, VirtualTPMDevice)
+ VirtualRedirDevice, VirtualTPMDevice,
+ VirtualPanicDevice)
from virtinst import VirtualController
from virtManager import uihelpers
@@ -54,6 +55,7 @@ PAGE_SMARTCARD = 11
PAGE_USBREDIR = 12
PAGE_TPM = 13
PAGE_RNG = 14
+PAGE_PANIC = 15
class vmmAddHardware(vmmGObjectUI):
@@ -329,6 +331,10 @@ class vmmAddHardware(vmmGObjectUI):
combo = self.widget("rng-backend-mode")
self.build_rng_backend_mode_combo(combo)
+ # Panic widgets
+ combo = self.widget("panic-type")
+ self.build_panic_address_type(combo)
+
# Available HW options
is_local = not self.conn.is_remote()
is_storage_capable = self.conn.is_storage_capable()
@@ -397,6 +403,7 @@ class vmmAddHardware(vmmGObjectUI):
add_hw_option("TPM", "device_cpu", PAGE_TPM,
True, None)
add_hw_option("RNG", "system-run", PAGE_RNG, True, None)
+ add_hw_option("Panic Notifier", "system-run", PAGE_PANIC, True, None)
def reset_state(self):
# Storage init
@@ -505,6 +512,9 @@ class vmmAddHardware(vmmGObjectUI):
for i in ["rng-bind-service", "rng-connect-service"]:
self.widget(i).set_text("708")
+ # Panic device params
+ self.widget("panic-iobase").set_text("0x505")
+
self.set_hw_selection(0)
#########################
@@ -650,6 +660,14 @@ class vmmAddHardware(vmmGObjectUI):
self.build_combo_with_values(combo, types, default)
+ def build_panic_address_type(self, combo):
+ types = []
+ for t in virtinst.VirtualPanicDevice.TYPES:
+ types.append([t, virtinst.VirtualPanicDevice.get_pretty_type(t)])
+
+ self.build_combo_with_values(combo, types,
+ virtinst.VirtualPanicDevice.ADDRESS_TYPE_ISA)
+
def get_config_hardware_type(self):
row = self.get_hw_selection()
if not row:
@@ -1099,6 +1117,8 @@ class vmmAddHardware(vmmGObjectUI):
return _("TPM")
if page == PAGE_RNG:
return _("Random Number Generator")
+ if page == PAGE_PANIC:
+ return _("Panic Notifier")
if page == PAGE_CHAR:
char_class = self.get_char_type()
@@ -1405,6 +1425,8 @@ class vmmAddHardware(vmmGObjectUI):
return self.validate_page_tpm()
elif page_num == PAGE_RNG:
return self.validate_page_rng()
+ elif page_num == PAGE_PANIC:
+ return self.validate_page_panic()
def validate(self, page_num):
ret = self._validate(page_num)
@@ -1765,6 +1787,24 @@ class vmmAddHardware(vmmGObjectUI):
except Exception, e:
return self.err.val_err(_("TPM device parameter error"), e)
+ def validate_page_panic(self):
+ conn = self.conn.get_backend()
+
+ iobase = self.widget("panic-iobase").get_text()
+
+ value_mappings = {
+ "iobase" : iobase,
+ }
+
+ try:
+ self._dev = VirtualPanicDevice(conn)
+ if not iobase:
+ iobase = self._dev.IOBASE_DEFAULT
+ for param_name, val in value_mappings.items():
+ setattr(self._dev, param_name, val)
+ except Exception, e:
+ return self.err.val_err(_("Panic device parameter error"), e)
+
def validate_page_rng(self):
conn = virtinst.VirtualRNGDevice.BACKEND_MODE_CONNECT in \
self.get_config_rng_backend_mode()
--
1.8.2.1
More information about the virt-tools-list
mailing list