From: Chen Hanxiao <chenhanxiao@xxxxxxxxxxxxxx> If we didn't set values for @type and @iobase in XML, libvirt will use the default value. Currently, virt-manager will display "-" if we don't set any values. This patch will use default values for display. And add a test case to cover this scenario. Signed-off-by: Chen Hanxiao <chenhanxiao@xxxxxxxxxxxxxx> --- .../change-panic-device-default-in.xml | 61 +++++++++++++++++++++ .../change-panic-device-default-out.xml | 62 ++++++++++++++++++++++ tests/xmlparse.py | 10 ++++ virtManager/details.py | 3 ++ virtinst/devicepanic.py | 1 + 5 files changed, 137 insertions(+) create mode 100644 tests/xmlparse-xml/change-panic-device-default-in.xml create mode 100644 tests/xmlparse-xml/change-panic-device-default-out.xml diff --git a/tests/xmlparse-xml/change-panic-device-default-in.xml b/tests/xmlparse-xml/change-panic-device-default-in.xml new file mode 100644 index 0000000..3094267 --- /dev/null +++ b/tests/xmlparse-xml/change-panic-device-default-in.xml @@ -0,0 +1,61 @@ +<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> + </panic> + </devices> +</domain> diff --git a/tests/xmlparse-xml/change-panic-device-default-out.xml b/tests/xmlparse-xml/change-panic-device-default-out.xml new file mode 100644 index 0000000..7aa732c --- /dev/null +++ b/tests/xmlparse-xml/change-panic-device-default-out.xml @@ -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> diff --git a/tests/xmlparse.py b/tests/xmlparse.py index 4567bb8..dfe196a 100644 --- a/tests/xmlparse.py +++ b/tests/xmlparse.py @@ -791,6 +791,16 @@ class XMLParseTest(unittest.TestCase): check("iobase", "0x505", "0x506") self._alter_compare(guest.get_xml_config(), outfile) + def testPanicDeviceDefault(self): + guest, outfile = self._get_test_content("change-panic-device-default") + + dev1 = guest.get_devices("panic")[0] + + check = self._make_checker(dev1) + check("type", None, "isa") + check("iobase", None, "0x506") + self._alter_compare(guest.get_xml_config(), outfile) + def testAddRemoveDevices(self): guest, outfile = self._get_test_content("add-devices") diff --git a/virtManager/details.py b/virtManager/details.py index 51573f6..d8481dd 100644 --- a/virtManager/details.py +++ b/virtManager/details.py @@ -3110,6 +3110,9 @@ class vmmDetails(vmmGObjectUI): widgetname = "panic-" + param.replace("_", "-") if not val: val = getattr(dev, param) + if not val: + propername = param.upper() + "_DEFAULT" + val = (eval("virtinst.VirtualPanicDevice." + propername)).upper() uihelpers.set_grid_row_visible(self.widget(widgetname), True) self.widget(widgetname).set_text(val or "-") diff --git a/virtinst/devicepanic.py b/virtinst/devicepanic.py index 5f7cbd8..a41af94 100644 --- a/virtinst/devicepanic.py +++ b/virtinst/devicepanic.py @@ -26,6 +26,7 @@ class VirtualPanicDevice(VirtualDevice): virtual_device_type = VirtualDevice.VIRTUAL_DEV_PANIC ADDRESS_TYPE_ISA = "isa" + TYPE_DEFAULT = ADDRESS_TYPE_ISA TYPES = [ADDRESS_TYPE_ISA] IOBASE_DEFAULT = "0x505" -- 1.8.2.1 _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list