[virt-tools-list] [PATCH v2 virt-manager 1/4] virtinst: add support for panic notifier device

Chen Hanxiao chenhanxiao at cn.fujitsu.com
Fri Jan 10 09:37:54 UTC 2014


From: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>

Signed-off-by: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
---
 virtinst/__init__.py    |  1 +
 virtinst/device.py      |  4 +++-
 virtinst/devicepanic.py | 44 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 virtinst/devicepanic.py

diff --git a/virtinst/__init__.py b/virtinst/__init__.py
index 71651fe..925af4c 100644
--- a/virtinst/__init__.py
+++ b/virtinst/__init__.py
@@ -56,6 +56,7 @@ from virtinst.deviceredirdev import VirtualRedirDevice
 from virtinst.devicememballoon import VirtualMemballoon
 from virtinst.devicetpm import VirtualTPMDevice
 from virtinst.devicerng import VirtualRNGDevice
+from virtinst.devicepanic import VirtualPanicDevice
 
 from virtinst.installer import (ContainerInstaller, ImportInstaller,
                                 LiveCDInstaller, PXEInstaller, Installer)
diff --git a/virtinst/device.py b/virtinst/device.py
index 43408d6..4ded87e 100644
--- a/virtinst/device.py
+++ b/virtinst/device.py
@@ -104,6 +104,7 @@ class VirtualDevice(XMLBuilder):
     VIRTUAL_DEV_MEMBALLOON      = "memballoon"
     VIRTUAL_DEV_TPM             = "tpm"
     VIRTUAL_DEV_RNG             = "rng"
+    VIRTUAL_DEV_PANIC           = "panic"
 
     # Ordering in this list is important: it will be the order the
     # Guest class outputs XML. So changing this may upset the test suite
@@ -125,7 +126,8 @@ class VirtualDevice(XMLBuilder):
                             VIRTUAL_DEV_REDIRDEV,
                             VIRTUAL_DEV_MEMBALLOON,
                             VIRTUAL_DEV_TPM,
-                            VIRTUAL_DEV_RNG]
+                            VIRTUAL_DEV_RNG,
+                            VIRTUAL_DEV_PANIC]
 
     virtual_device_classes = {}
 
diff --git a/virtinst/devicepanic.py b/virtinst/devicepanic.py
new file mode 100644
index 0000000..5f7cbd8
--- /dev/null
+++ b/virtinst/devicepanic.py
@@ -0,0 +1,44 @@
+# coding=utf-8
+#
+# Copyright 2013 Fujitsu Limited.
+# Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
+#
+# 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 General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA.
+
+from virtinst import VirtualDevice
+from virtinst.xmlbuilder import XMLProperty
+
+
+class VirtualPanicDevice(VirtualDevice):
+
+    virtual_device_type = VirtualDevice.VIRTUAL_DEV_PANIC
+    ADDRESS_TYPE_ISA = "isa"
+    TYPES = [ADDRESS_TYPE_ISA]
+    IOBASE_DEFAULT = "0x505"
+
+    @staticmethod
+    def get_pretty_type(panic_type):
+        if panic_type == VirtualPanicDevice.ADDRESS_TYPE_ISA:
+            return _("ISA")
+        return panic_type
+
+
+    type = XMLProperty("./address/@type",
+                       default_cb=lambda s: s.ADDRESS_TYPE_ISA)
+    iobase = XMLProperty("./address/@iobase",
+                       default_cb=lambda s: s.IOBASE_DEFAULT)
+
+VirtualPanicDevice.register_type()
-- 
1.8.2.1




More information about the virt-tools-list mailing list