Hi Alex, On 08/31/2012 03:13 PM, Alex Jia wrote:
If you want to verify if libvirt's XML configration is valid, you may use 'virt-xml-validate' tool to do this: virt-xml-validate XML-FILE [SCHEMA-NAME] - validate libvirt XML files against a schema
Thanks for telling me this. :) Here, I don't want to verify if the xml is valid. I just want to check if the xml configuration is the same as I thought. But this tool is very useful, and I will try to reuse it in the future.
If you want to generate libvirt's XML configration, we have ever done this in internal auto project, the basic idea is to create a XML construction function for each XML element block such as '<devices> .... </devices>', '<emulator> ... </emulator>', '<interface xxxxx> ... </interface>', '<disk xxxxx> ... </disk>', etc. it's very flexible and easy to reuse, you may use different XML construction function to generate different libvirt's XML configuration, and also call them to generate a guest XML configuration.
Thanks for this. I believe this will be very useful in attach-device command tests. Thanks. :)
def emulator_xml(xxxx): # check emulator based on currently hypervisor then construct <emulator> ... </emulator> def iface_xml(xxxx): # to construct <interface> ... </interface> def disk_xml(xxxx): # ..... def devices_xml(xxxx): ...... emu_xml = emulator_xml(xxxx) iface_xml = iface_xml(xxxx) disk_xml = disk_xml(xxxx) # if you want attach 2 disk then you may call disk_xml() 2 times with different parameters. # of course, you may use virsh attach-disk or attach-device to do this later. ...... def guest_xml(xxxx): ...... devices_xml = devices_xml(xxxx) ...... Regards, Alex
_______________________________________________ Autotest-kernel mailing list [email protected] https://www.redhat.com/mailman/listinfo/autotest-kernel
