virtinst: add support for panic notifier device

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
This commit is contained in:
Chen Hanxiao
2014-01-10 17:37:54 +08:00
committed by Cole Robinson
parent 2427254ffe
commit 8419835b1d
9 changed files with 195 additions and 1 deletions

View File

@@ -344,6 +344,11 @@
<source mode='connect' host='1.2.3.4' service='1234'/> <source mode='connect' host='1.2.3.4' service='1234'/>
</backend> </backend>
</rng> </rng>
<!-- panic notifier devices -->
<panic>
<address type='isa' iobase='0x505'/>
</panic>
</devices> </devices>
</domain> </domain>

View File

@@ -101,6 +101,9 @@
<source host="foobar.com" service="1234"/> <source host="foobar.com" service="1234"/>
</redirdev> </redirdev>
<memballoon model="virtio"/> <memballoon model="virtio"/>
<panic>
<address type="isa" iobase="0x505"/>
</panic>
</devices> </devices>
<seclabel type="static" model="selinux"> <seclabel type="static" model="selinux">
<label>foolabel</label> <label>foolabel</label>

View File

@@ -30,6 +30,7 @@ from virtinst import VirtualVideoDevice
from virtinst import VirtualController from virtinst import VirtualController
from virtinst import VirtualWatchdog from virtinst import VirtualWatchdog
from virtinst import VirtualMemballoon from virtinst import VirtualMemballoon
from virtinst import VirtualPanicDevice
from tests import utils from tests import utils
@@ -875,6 +876,10 @@ class TestXMLConfig(unittest.TestCase):
g.add_device(redir1) g.add_device(redir1)
g.add_device(redir2) g.add_device(redir2)
#Panic Notifier device
pdev = VirtualPanicDevice(g.conn)
g.add_device(pdev)
self._compare(g, "boot-many-devices", False) self._compare(g, "boot-many-devices", False)
def testCpuset(self): def testCpuset(self):

View 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>

View 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>

View File

@@ -781,6 +781,16 @@ class XMLParseTest(unittest.TestCase):
self._alter_compare(guest.get_xml_config(), outfile) 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): def testAddRemoveDevices(self):
guest, outfile = self._get_test_content("add-devices") guest, outfile = self._get_test_content("add-devices")

View File

@@ -56,6 +56,7 @@ from virtinst.deviceredirdev import VirtualRedirDevice
from virtinst.devicememballoon import VirtualMemballoon from virtinst.devicememballoon import VirtualMemballoon
from virtinst.devicetpm import VirtualTPMDevice from virtinst.devicetpm import VirtualTPMDevice
from virtinst.devicerng import VirtualRNGDevice from virtinst.devicerng import VirtualRNGDevice
from virtinst.devicepanic import VirtualPanicDevice
from virtinst.installer import (ContainerInstaller, ImportInstaller, from virtinst.installer import (ContainerInstaller, ImportInstaller,
LiveCDInstaller, PXEInstaller, Installer) LiveCDInstaller, PXEInstaller, Installer)

View File

@@ -104,6 +104,7 @@ class VirtualDevice(XMLBuilder):
VIRTUAL_DEV_MEMBALLOON = "memballoon" VIRTUAL_DEV_MEMBALLOON = "memballoon"
VIRTUAL_DEV_TPM = "tpm" VIRTUAL_DEV_TPM = "tpm"
VIRTUAL_DEV_RNG = "rng" VIRTUAL_DEV_RNG = "rng"
VIRTUAL_DEV_PANIC = "panic"
# Ordering in this list is important: it will be the order the # Ordering in this list is important: it will be the order the
# Guest class outputs XML. So changing this may upset the test suite # Guest class outputs XML. So changing this may upset the test suite
@@ -125,7 +126,8 @@ class VirtualDevice(XMLBuilder):
VIRTUAL_DEV_REDIRDEV, VIRTUAL_DEV_REDIRDEV,
VIRTUAL_DEV_MEMBALLOON, VIRTUAL_DEV_MEMBALLOON,
VIRTUAL_DEV_TPM, VIRTUAL_DEV_TPM,
VIRTUAL_DEV_RNG] VIRTUAL_DEV_RNG,
VIRTUAL_DEV_PANIC]
virtual_device_classes = {} virtual_device_classes = {}

44
virtinst/devicepanic.py Normal file
View 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()