[virt-tools-list] [virt-manager PATCH 5/5] devicepanic: add all models supported by libvirt

Pavel Hrdina phrdina at redhat.com
Tue Sep 5 07:59:19 UTC 2017


Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---
 .../compare/virt-install-panic-pseries-default.xml | 18 ++++++++++++++
 .../compare/virt-install-panic-s390x-default.xml   | 20 ++++++++++++++++
 tests/clitest.py                                   |  6 +++++
 virtManager/addhardware.py                         |  5 ++--
 virtinst/devicepanic.py                            | 28 +++++++++++++++++++++-
 virtinst/guest.py                                  |  7 ++++++
 6 files changed, 81 insertions(+), 3 deletions(-)
 create mode 100644 tests/cli-test-xml/compare/virt-install-panic-pseries-default.xml
 create mode 100644 tests/cli-test-xml/compare/virt-install-panic-s390x-default.xml

diff --git a/tests/cli-test-xml/compare/virt-install-panic-pseries-default.xml b/tests/cli-test-xml/compare/virt-install-panic-pseries-default.xml
new file mode 100644
index 00000000..9d647e82
--- /dev/null
+++ b/tests/cli-test-xml/compare/virt-install-panic-pseries-default.xml
@@ -0,0 +1,18 @@
+<domain type="kvm">
+  <name>foobar</name>
+  <uuid>00000000-1111-2222-3333-444444444444</uuid>
+  <memory>65536</memory>
+  <currentMemory>65536</currentMemory>
+  <vcpu>1</vcpu>
+  <os>
+    <type arch="ppc64le" machine="pseries">hvm</type>
+    <boot dev="hd"/>
+  </os>
+  <clock offset="utc"/>
+  <devices>
+    <emulator>/usr/libexec/qemu-kvm</emulator>
+    <controller type="usb" index="0" model="none"/>
+    <console type="pty"/>
+    <panic model="pseries"/>
+  </devices>
+</domain>
diff --git a/tests/cli-test-xml/compare/virt-install-panic-s390x-default.xml b/tests/cli-test-xml/compare/virt-install-panic-s390x-default.xml
new file mode 100644
index 00000000..f2a4621f
--- /dev/null
+++ b/tests/cli-test-xml/compare/virt-install-panic-s390x-default.xml
@@ -0,0 +1,20 @@
+<domain type="kvm">
+  <name>foobar</name>
+  <uuid>00000000-1111-2222-3333-444444444444</uuid>
+  <memory>65536</memory>
+  <currentMemory>65536</currentMemory>
+  <vcpu>1</vcpu>
+  <os>
+    <type arch="s390x" machine="s390-ccw-virtio">hvm</type>
+    <boot dev="hd"/>
+  </os>
+  <clock offset="utc"/>
+  <devices>
+    <emulator>/usr/bin/qemu-system-s390x</emulator>
+    <controller type="usb" index="0" model="none"/>
+    <console type="pty">
+      <target type="sclp"/>
+    </console>
+    <panic model="s390"/>
+  </devices>
+</domain>
diff --git a/tests/clitest.py b/tests/clitest.py
index 147c615c..8ced1208 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -654,6 +654,12 @@ c.add_compare("--panic default", "panic-default")
 c.add_compare("--panic isa", "panic-isa")
 c.add_compare("--panic isa,iobase=0x505", "panic-isa-iobase")
 
+c = vinst.add_category("panic", "--connect %(URI-KVM-PPC64LE)s --noautoconsole --import --disk none --graphics none --controller usb,model=none --network none")
+c.add_compare("--panic default", "panic-pseries-default")
+
+c = vinst.add_category("panic", "--connect %(URI-KVM-S390X)s --noautoconsole --import --disk none --graphics none --controller usb,model=none --network none")
+c.add_compare("--panic default", "panic-s390x-default")
+
 
 ################################################
 # Invalid devices that hit virtinst code paths #
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index e14e6bdf..b2d29f37 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -978,11 +978,12 @@ class vmmAddHardware(vmmGObjectUI):
 
     def _build_panic_models(self, combo):
         models = []
-        for m in virtinst.VirtualPanicDevice.MODELS:
+        for m in virtinst.VirtualPanicDevice.get_models(self.vm.get_xmlobj().os):
             models.append([m, virtinst.VirtualPanicDevice.get_pretty_model(m)])
 
         self._build_combo_with_values(combo, models,
-                virtinst.VirtualPanicDevice.MODEL_ISA)
+                virtinst.VirtualPanicDevice.get_default_model(
+                        self.vm.get_xmlobj().os))
 
 
     #########################
diff --git a/virtinst/devicepanic.py b/virtinst/devicepanic.py
index 2463b011..63a88f71 100644
--- a/virtinst/devicepanic.py
+++ b/virtinst/devicepanic.py
@@ -27,7 +27,10 @@ class VirtualPanicDevice(VirtualDevice):
 
     MODEL_DEFAULT = "default"
     MODEL_ISA = "isa"
-    MODELS = [MODEL_ISA]
+    MODEL_PSERIES = "pseries"
+    MODEL_HYPERV = "hyperv"
+    MODEL_S390 = "s390"
+    MODELS = [MODEL_ISA, MODEL_PSERIES, MODEL_HYPERV, MODEL_S390]
 
     ISA_ADDRESS_TYPE = "isa"
 
@@ -35,8 +38,31 @@ class VirtualPanicDevice(VirtualDevice):
     def get_pretty_model(panic_model):
         if panic_model == VirtualPanicDevice.MODEL_ISA:
             return _("ISA")
+        elif panic_model == VirtualPanicDevice.MODEL_PSERIES:
+            return _("pSeries")
+        elif panic_model == VirtualPanicDevice.MODEL_HYPERV:
+            return _("Hyper-V")
+        elif panic_model == VirtualPanicDevice.MODEL_S390:
+            return _("s390")
         return panic_model
 
+    @staticmethod
+    def get_models(os):
+        if os.is_x86():
+            return [VirtualPanicDevice.MODEL_ISA, VirtualPanicDevice.MODEL_HYPERV]
+        elif os.is_pseries():
+            return [VirtualPanicDevice.MODEL_PSERIES]
+        elif os.is_s390x():
+            return [VirtualPanicDevice.MODEL_S390]
+        return None
+
+    @staticmethod
+    def get_default_model(os):
+        models = VirtualPanicDevice.get_models(os)
+        if models:
+            return models[0]
+        return None
+
     def _get_default_address_type(self):
         if self.iobase:
             return VirtualPanicDevice.ISA_ADDRESS_TYPE
diff --git a/virtinst/guest.py b/virtinst/guest.py
index 529286f4..143a36f2 100644
--- a/virtinst/guest.py
+++ b/virtinst/guest.py
@@ -38,6 +38,7 @@ from .devicecontroller import VirtualController
 from .devicedisk import VirtualDisk
 from .devicegraphics import VirtualGraphics
 from .deviceinput import VirtualInputDevice
+from .devicepanic import VirtualPanicDevice
 from .deviceredirdev import VirtualRedirDevice
 from .devicerng import VirtualRNGDevice
 from .devicevideo import VirtualVideoDevice
@@ -796,6 +797,7 @@ class Guest(XMLBuilder):
         self._set_net_defaults()
         self._set_video_defaults()
         self._set_sound_defaults()
+        self._set_panic_defaults()
 
     def _is_full_os_container(self):
         if not self.os.is_container():
@@ -1246,3 +1248,8 @@ class Guest(XMLBuilder):
                 video.model = video_model
                 if video.model == 'virtio' and self.has_gl():
                     video.accel3d = True
+
+    def _set_panic_defaults(self):
+        for panic in self.get_devices("panic"):
+            if panic.model == VirtualPanicDevice.MODEL_DEFAULT:
+                panic.model = VirtualPanicDevice.get_default_model(self.os)
-- 
2.13.5




More information about the virt-tools-list mailing list