mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-08 15:13:11 -06:00
virtinst: add support for panic notifier device
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
This commit is contained in:
parent
2427254ffe
commit
8419835b1d
@ -344,6 +344,11 @@
|
||||
<source mode='connect' host='1.2.3.4' service='1234'/>
|
||||
</backend>
|
||||
</rng>
|
||||
|
||||
<!-- panic notifier devices -->
|
||||
<panic>
|
||||
<address type='isa' iobase='0x505'/>
|
||||
</panic>
|
||||
</devices>
|
||||
</domain>
|
||||
|
||||
|
@ -101,6 +101,9 @@
|
||||
<source host="foobar.com" service="1234"/>
|
||||
</redirdev>
|
||||
<memballoon model="virtio"/>
|
||||
<panic>
|
||||
<address type="isa" iobase="0x505"/>
|
||||
</panic>
|
||||
</devices>
|
||||
<seclabel type="static" model="selinux">
|
||||
<label>foolabel</label>
|
||||
|
@ -30,6 +30,7 @@ from virtinst import VirtualVideoDevice
|
||||
from virtinst import VirtualController
|
||||
from virtinst import VirtualWatchdog
|
||||
from virtinst import VirtualMemballoon
|
||||
from virtinst import VirtualPanicDevice
|
||||
|
||||
from tests import utils
|
||||
|
||||
@ -875,6 +876,10 @@ class TestXMLConfig(unittest.TestCase):
|
||||
g.add_device(redir1)
|
||||
g.add_device(redir2)
|
||||
|
||||
#Panic Notifier device
|
||||
pdev = VirtualPanicDevice(g.conn)
|
||||
g.add_device(pdev)
|
||||
|
||||
self._compare(g, "boot-many-devices", False)
|
||||
|
||||
def testCpuset(self):
|
||||
|
62
tests/xmlparse-xml/change-panic-device-in.xml
Normal file
62
tests/xmlparse-xml/change-panic-device-in.xml
Normal file
@ -0,0 +1,62 @@
|
||||
<domain type='kvm'>
|
||||
<name>Ftest</name>
|
||||
<uuid>9d544d2e-e001-a6b2-4aa7-7768796353ea</uuid>
|
||||
<memory unit='KiB'>1048576</memory>
|
||||
<currentMemory unit='KiB'>1048576</currentMemory>
|
||||
<vcpu placement='static'>1</vcpu>
|
||||
<os>
|
||||
<type arch='i686' machine='pc-i440fx-1.4'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<features>
|
||||
<acpi/>
|
||||
<apic/>
|
||||
<pae/>
|
||||
</features>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>restart</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/local/bin/qemu-system-x86_64</emulator>
|
||||
<disk type='file' device='disk'>
|
||||
<driver name='qemu' type='raw'/>
|
||||
<source file='/home/IMG/F19_test.img'/>
|
||||
<target dev='hda' bus='ide'/>
|
||||
</disk>
|
||||
<controller type='usb' index='0'>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
|
||||
</controller>
|
||||
<controller type='pci' index='0' model='pci-root'/>
|
||||
<controller type='ide' index='0'>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
|
||||
</controller>
|
||||
<controller type='virtio-serial' index='0'>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
|
||||
</controller>
|
||||
<interface type='network'>
|
||||
<mac address='52:54:00:93:45:ce'/>
|
||||
<source network='default'/>
|
||||
<model type='rtl8139'/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
|
||||
</interface>
|
||||
<serial type='pty'>
|
||||
<target port='0'/>
|
||||
</serial>
|
||||
<console type='pty'>
|
||||
<target type='serial' port='0'/>
|
||||
</console>
|
||||
<input type='mouse' bus='ps2'/>
|
||||
<graphics type='vnc' port='-1' autoport='yes'/>
|
||||
<video>
|
||||
<model type='vga' vram='9216' heads='1'/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
|
||||
</video>
|
||||
<memballoon model='virtio'>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
|
||||
</memballoon>
|
||||
<panic>
|
||||
<address type='isa' iobase='0x505'/>
|
||||
</panic>
|
||||
</devices>
|
||||
</domain>
|
62
tests/xmlparse-xml/change-panic-device-out.xml
Normal file
62
tests/xmlparse-xml/change-panic-device-out.xml
Normal file
@ -0,0 +1,62 @@
|
||||
<domain type="kvm">
|
||||
<name>Ftest</name>
|
||||
<uuid>9d544d2e-e001-a6b2-4aa7-7768796353ea</uuid>
|
||||
<memory unit="KiB">1048576</memory>
|
||||
<currentMemory unit="KiB">1048576</currentMemory>
|
||||
<vcpu placement="static">1</vcpu>
|
||||
<os>
|
||||
<type arch="i686" machine="pc-i440fx-1.4">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
<acpi/>
|
||||
<apic/>
|
||||
<pae/>
|
||||
</features>
|
||||
<clock offset="utc"/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>restart</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/local/bin/qemu-system-x86_64</emulator>
|
||||
<disk type="file" device="disk">
|
||||
<driver name="qemu" type="raw"/>
|
||||
<source file="/home/IMG/F19_test.img"/>
|
||||
<target dev="hda" bus="ide"/>
|
||||
</disk>
|
||||
<controller type="usb" index="0">
|
||||
<address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x2"/>
|
||||
</controller>
|
||||
<controller type="pci" index="0" model="pci-root"/>
|
||||
<controller type="ide" index="0">
|
||||
<address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x1"/>
|
||||
</controller>
|
||||
<controller type="virtio-serial" index="0">
|
||||
<address type="pci" domain="0x0000" bus="0x00" slot="0x04" function="0x0"/>
|
||||
</controller>
|
||||
<interface type="network">
|
||||
<mac address="52:54:00:93:45:ce"/>
|
||||
<source network="default"/>
|
||||
<model type="rtl8139"/>
|
||||
<address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x0"/>
|
||||
</interface>
|
||||
<serial type="pty">
|
||||
<target port="0"/>
|
||||
</serial>
|
||||
<console type="pty">
|
||||
<target type="serial" port="0"/>
|
||||
</console>
|
||||
<input type="mouse" bus="ps2"/>
|
||||
<graphics type="vnc" port="-1" autoport="yes"/>
|
||||
<video>
|
||||
<model type="vga" vram="9216" heads="1"/>
|
||||
<address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x0"/>
|
||||
</video>
|
||||
<memballoon model="virtio">
|
||||
<address type="pci" domain="0x0000" bus="0x00" slot="0x05" function="0x0"/>
|
||||
</memballoon>
|
||||
<panic>
|
||||
<address type="isa" iobase="0x506"/>
|
||||
</panic>
|
||||
</devices>
|
||||
</domain>
|
@ -781,6 +781,16 @@ class XMLParseTest(unittest.TestCase):
|
||||
|
||||
self._alter_compare(guest.get_xml_config(), outfile)
|
||||
|
||||
def testPanicDevice(self):
|
||||
guest, outfile = self._get_test_content("change-panic-device")
|
||||
|
||||
dev1 = guest.get_devices("panic")[0]
|
||||
|
||||
check = self._make_checker(dev1)
|
||||
check("type", "isa", "isa")
|
||||
check("iobase", "0x505", "0x506")
|
||||
self._alter_compare(guest.get_xml_config(), outfile)
|
||||
|
||||
def testAddRemoveDevices(self):
|
||||
guest, outfile = self._get_test_content("add-devices")
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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 = {}
|
||||
|
||||
|
44
virtinst/devicepanic.py
Normal file
44
virtinst/devicepanic.py
Normal file
@ -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()
|
Loading…
Reference in New Issue
Block a user