mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
libxl: Add a test suite for libxl_domain_config generator
The libxl library allows a libxl_domain_config object to be serialized from/to a JSON string. Use this to allow testing of the XML to libxl_domain_config conversion process. Test XML is converted to libxl_domain_config, which is then serialized to json. A json template corresponding to the test XML is converted to a libxl_domain_config object using libxl_domain_config_from_json(), and then serialized back to json using libxl_domain_config_to_json(). The two json docs are then compared. Using libxl to convert the json template to a libxl_domain_config object and then back to json provides a simple way to account for any changes or additions to the json representation across Xen releases. Signed-off-by: Jim Fehlig <jfehlig@suse.com> [update to v3.5.0-rc1, improve error reporting, use /bin/true emulator] Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
This commit is contained in:
89
tests/libxlxml2domconfigdata/basic-hvm.json
Normal file
89
tests/libxlxml2domconfigdata/basic-hvm.json
Normal file
@@ -0,0 +1,89 @@
|
||||
{
|
||||
"c_info": {
|
||||
"type": "hvm",
|
||||
"name": "test-hvm",
|
||||
"uuid": "2147d599-9cc6-c0dc-92ab-4064b5446e9b"
|
||||
},
|
||||
"b_info": {
|
||||
"max_vcpus": 4,
|
||||
"avail_vcpus": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3
|
||||
],
|
||||
"max_memkb": 1048576,
|
||||
"target_memkb": 1048576,
|
||||
"video_memkb": 8192,
|
||||
"shadow_memkb": 12288,
|
||||
"device_model_version": "qemu_xen",
|
||||
"device_model": "/bin/true",
|
||||
"sched_params": {
|
||||
"weight": 1000
|
||||
},
|
||||
"type.hvm": {
|
||||
"pae": "True",
|
||||
"apic": "True",
|
||||
"acpi": "True",
|
||||
"vga": {
|
||||
"kind": "cirrus"
|
||||
},
|
||||
"vnc": {
|
||||
"enable": "True",
|
||||
"listen": "0.0.0.0",
|
||||
"findunused": "False"
|
||||
},
|
||||
"sdl": {
|
||||
"enable": "False"
|
||||
},
|
||||
"spice": {
|
||||
|
||||
},
|
||||
"boot": "c",
|
||||
"rdm": {
|
||||
|
||||
}
|
||||
},
|
||||
"arch_arm": {
|
||||
|
||||
}
|
||||
},
|
||||
"disks": [
|
||||
{
|
||||
"pdev_path": "/var/lib/xen/images/test-hvm.img",
|
||||
"vdev": "hda",
|
||||
"backend": "qdisk",
|
||||
"format": "raw",
|
||||
"removable": 1,
|
||||
"readwrite": 1
|
||||
}
|
||||
],
|
||||
"nics": [
|
||||
{
|
||||
"devid": 0,
|
||||
"mac": "00:16:3e:66:12:b4",
|
||||
"bridge": "br0",
|
||||
"script": "/etc/xen/scripts/vif-bridge",
|
||||
"nictype": "vif_ioemu"
|
||||
}
|
||||
],
|
||||
"vfbs": [
|
||||
{
|
||||
"devid": -1,
|
||||
"vnc": {
|
||||
"enable": "True",
|
||||
"listen": "0.0.0.0",
|
||||
"findunused": "False"
|
||||
},
|
||||
"sdl": {
|
||||
"enable": "False"
|
||||
}
|
||||
}
|
||||
],
|
||||
"vkbs": [
|
||||
{
|
||||
"devid": -1
|
||||
}
|
||||
],
|
||||
"on_reboot": "restart"
|
||||
}
|
||||
36
tests/libxlxml2domconfigdata/basic-hvm.xml
Normal file
36
tests/libxlxml2domconfigdata/basic-hvm.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<domain type='xen'>
|
||||
<name>test-hvm</name>
|
||||
<description>None</description>
|
||||
<uuid>2147d599-9cc6-c0dc-92ab-4064b5446e9b</uuid>
|
||||
<memory>1048576</memory>
|
||||
<currentMemory>1048576</currentMemory>
|
||||
<vcpu>4</vcpu>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<clock sync='utc'/>
|
||||
<os>
|
||||
<type>hvm</type>
|
||||
<loader>/usr/lib/xen/boot/hvmloader</loader>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<features>
|
||||
<apic/>
|
||||
<acpi/>
|
||||
<pae/>
|
||||
</features>
|
||||
<devices>
|
||||
<emulator>/bin/true</emulator>
|
||||
<disk type='file' device='disk'>
|
||||
<driver name='qemu'/>
|
||||
<source file='/var/lib/xen/images/test-hvm.img'/>
|
||||
<target dev='hda'/>
|
||||
</disk>
|
||||
<interface type='bridge'>
|
||||
<source bridge='br0'/>
|
||||
<mac address='00:16:3e:66:12:b4'/>
|
||||
<script path='/etc/xen/scripts/vif-bridge'/>
|
||||
</interface>
|
||||
<graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'/>
|
||||
</devices>
|
||||
</domain>
|
||||
65
tests/libxlxml2domconfigdata/basic-pv.json
Normal file
65
tests/libxlxml2domconfigdata/basic-pv.json
Normal file
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"c_info": {
|
||||
"type": "pv",
|
||||
"name": "test-pv",
|
||||
"uuid": "039e9ee6-4a84-3055-4c81-8ba426ae2656"
|
||||
},
|
||||
"b_info": {
|
||||
"max_vcpus": 4,
|
||||
"avail_vcpus": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3
|
||||
],
|
||||
"max_memkb": 524288,
|
||||
"target_memkb": 524288,
|
||||
"sched_params": {
|
||||
"weight": 1000
|
||||
},
|
||||
"type.pv": {
|
||||
"bootloader": "pygrub"
|
||||
},
|
||||
"arch_arm": {
|
||||
|
||||
}
|
||||
},
|
||||
"disks": [
|
||||
{
|
||||
"pdev_path": "/var/lib/xen/images/test-pv.img",
|
||||
"vdev": "xvda",
|
||||
"backend": "qdisk",
|
||||
"format": "raw",
|
||||
"removable": 1,
|
||||
"readwrite": 1
|
||||
}
|
||||
],
|
||||
"nics": [
|
||||
{
|
||||
"devid": 0,
|
||||
"mac": "00:16:3e:3e:86:60",
|
||||
"bridge": "br0",
|
||||
"script": "/etc/xen/scripts/vif-bridge",
|
||||
"nictype": "vif"
|
||||
}
|
||||
],
|
||||
"vfbs": [
|
||||
{
|
||||
"devid": -1,
|
||||
"vnc": {
|
||||
"enable": "True",
|
||||
"listen": "0.0.0.0",
|
||||
"findunused": "False"
|
||||
},
|
||||
"sdl": {
|
||||
"enable": "False"
|
||||
}
|
||||
}
|
||||
],
|
||||
"vkbs": [
|
||||
{
|
||||
"devid": -1
|
||||
}
|
||||
],
|
||||
"on_reboot": "restart"
|
||||
}
|
||||
28
tests/libxlxml2domconfigdata/basic-pv.xml
Normal file
28
tests/libxlxml2domconfigdata/basic-pv.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<domain type='xen'>
|
||||
<name>test-pv</name>
|
||||
<uuid>039e9ee6-4a84-3055-4c81-8ba426ae2656</uuid>
|
||||
<memory>524288</memory>
|
||||
<currentMemory>524288</currentMemory>
|
||||
<vcpu>4</vcpu>
|
||||
<bootloader>pygrub</bootloader>
|
||||
<os>
|
||||
<type arch='x86_64' machine='xenpv'>linux</type>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<disk type='file' device='disk'>
|
||||
<driver name='qemu'/>
|
||||
<source file='/var/lib/xen/images/test-pv.img'/>
|
||||
<target dev='xvda'/>
|
||||
</disk>
|
||||
<interface type='bridge'>
|
||||
<source bridge='br0'/>
|
||||
<mac address='00:16:3e:3e:86:60'/>
|
||||
<script path='/etc/xen/scripts/vif-bridge'/>
|
||||
</interface>
|
||||
<graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'/>
|
||||
</devices>
|
||||
</domain>
|
||||
111
tests/libxlxml2domconfigdata/moredevs-hvm.json
Normal file
111
tests/libxlxml2domconfigdata/moredevs-hvm.json
Normal file
@@ -0,0 +1,111 @@
|
||||
{
|
||||
"c_info": {
|
||||
"type": "hvm",
|
||||
"hap": "True",
|
||||
"name": "test-hvm",
|
||||
"uuid": "2147d599-9cc6-c0dc-92ab-4064b5446e9b"
|
||||
},
|
||||
"b_info": {
|
||||
"max_vcpus": 4,
|
||||
"avail_vcpus": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3
|
||||
],
|
||||
"tsc_mode": "native",
|
||||
"max_memkb": 1048576,
|
||||
"target_memkb": 1048576,
|
||||
"video_memkb": 8192,
|
||||
"shadow_memkb": 12288,
|
||||
"device_model_version": "qemu_xen",
|
||||
"device_model": "/bin/true",
|
||||
"sched_params": {
|
||||
"weight": 1000
|
||||
},
|
||||
"type.hvm": {
|
||||
"pae": "True",
|
||||
"apic": "True",
|
||||
"acpi": "True",
|
||||
"hpet": "True",
|
||||
"vga": {
|
||||
"kind": "cirrus"
|
||||
},
|
||||
"vnc": {
|
||||
"enable": "True",
|
||||
"findunused": "False"
|
||||
},
|
||||
"sdl": {
|
||||
"enable": "False"
|
||||
},
|
||||
"spice": {
|
||||
|
||||
},
|
||||
"serial": "pty",
|
||||
"boot": "c",
|
||||
"usbdevice_list": [
|
||||
"mouse",
|
||||
"tablet"
|
||||
],
|
||||
"rdm": {
|
||||
|
||||
}
|
||||
},
|
||||
"arch_arm": {
|
||||
|
||||
}
|
||||
},
|
||||
"disks": [
|
||||
{
|
||||
"pdev_path": "/var/lib/xen/images/test-hvm.img",
|
||||
"vdev": "hda",
|
||||
"backend": "qdisk",
|
||||
"format": "raw",
|
||||
"removable": 1,
|
||||
"readwrite": 1
|
||||
},
|
||||
{
|
||||
"pdev_path": "/root/boot.iso",
|
||||
"vdev": "hdb",
|
||||
"backend": "qdisk",
|
||||
"format": "raw",
|
||||
"removable": 1,
|
||||
"is_cdrom": 1
|
||||
}
|
||||
],
|
||||
"nics": [
|
||||
{
|
||||
"devid": 0,
|
||||
"model": "netfront",
|
||||
"mac": "00:16:3e:7a:35:ce",
|
||||
"bridge": "br0",
|
||||
"script": "/etc/xen/scripts/vif-bridge",
|
||||
"nictype": "vif"
|
||||
}
|
||||
],
|
||||
"pcidevs": [
|
||||
{
|
||||
"dev": 16,
|
||||
"bus": 10,
|
||||
"rdm_policy": "invalid"
|
||||
}
|
||||
],
|
||||
"vfbs": [
|
||||
{
|
||||
"devid": -1,
|
||||
"vnc": {
|
||||
"enable": "True",
|
||||
"findunused": "False"
|
||||
},
|
||||
"sdl": {
|
||||
"enable": "False"
|
||||
}
|
||||
}
|
||||
],
|
||||
"vkbs": [
|
||||
{
|
||||
"devid": -1
|
||||
}
|
||||
],
|
||||
"on_reboot": "restart"
|
||||
}
|
||||
63
tests/libxlxml2domconfigdata/moredevs-hvm.xml
Normal file
63
tests/libxlxml2domconfigdata/moredevs-hvm.xml
Normal file
@@ -0,0 +1,63 @@
|
||||
<domain type='xen'>
|
||||
<name>test-hvm</name>
|
||||
<description>None</description>
|
||||
<uuid>2147d599-9cc6-c0dc-92ab-4064b5446e9b</uuid>
|
||||
<memory>1048576</memory>
|
||||
<currentMemory>1048576</currentMemory>
|
||||
<vcpu>4</vcpu>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<clock offset='variable' adjustment='0' basis='utc'>
|
||||
<timer name='tsc' present='yes' mode='native'/>
|
||||
<timer name='hpet' present='yes'/>
|
||||
</clock>
|
||||
<os>
|
||||
<type>hvm</type>
|
||||
<loader>/usr/lib/xen/boot/hvmloader</loader>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<features>
|
||||
<apic/>
|
||||
<acpi/>
|
||||
<pae/>
|
||||
<hap/>
|
||||
</features>
|
||||
<devices>
|
||||
<emulator>/bin/true</emulator>
|
||||
<disk type='file' device='disk'>
|
||||
<driver name='qemu' type='raw' cache='default'/>
|
||||
<source file='/var/lib/xen/images/test-hvm.img'/>
|
||||
<target dev='hda'/>
|
||||
</disk>
|
||||
<disk type='file' device='cdrom'>
|
||||
<driver name='qemu' type='raw' cache='default'/>
|
||||
<source file='/root/boot.iso'/>
|
||||
<target dev='hdb'/>
|
||||
</disk>
|
||||
<interface type='bridge'>
|
||||
<source bridge='br0'/>
|
||||
<mac address='00:16:3e:7a:35:ce'/>
|
||||
<script path='/etc/xen/scripts/vif-bridge'/>
|
||||
<model type='netfront'/>
|
||||
</interface>
|
||||
<interface type='hostdev' managed='yes'>
|
||||
<mac address='00:16:3e:2e:e7:fc'/>
|
||||
<driver name='xen'/>
|
||||
<source>
|
||||
<address type='pci' domain='0x0000' bus='0x0a' slot='0x10' function='0x0'/>
|
||||
</source>
|
||||
</interface>
|
||||
<graphics type='vnc'/>
|
||||
<video>
|
||||
<model type='cirrus' vram='8192' heads='1' primary='yes'/>
|
||||
</video>
|
||||
<console type='pty'>
|
||||
<target port='0'/>
|
||||
</console>
|
||||
<input type='mouse' bus='usb'/>
|
||||
<input type='tablet' bus='usb'/>
|
||||
<input type='mouse' bus='ps2'/>
|
||||
<input type='keyboard' bus='ps2'/>
|
||||
</devices>
|
||||
</domain>
|
||||
Reference in New Issue
Block a user