def testOSXML(self): expectedXMLs = [ """ <os> <type arch="x86_64" machine="pc">hvm</type> <initrd>/tmp/initrd-2.6.18.img</initrd> <kernel>/tmp/vmlinuz-2.6.18</kernel> <cmdline>console=ttyS0 1</cmdline> <smbios mode="sysinfo"/> </os>""" ] vmConfs = [ {"kernel": "/tmp/vmlinuz-2.6.18", "initrd": "/tmp/initrd-2.6.18.img", "kernelArgs": "console=ttyS0 1"} ] OSXML = """ <os> <type arch="x86_64" machine="pc">hvm</type> <boot dev="%s"/> <smbios mode="sysinfo"/> </os>""" qemu2libvirtBoot = {"a": "fd", "c": "hd", "d": "cdrom", "n": "network"} for k, v in qemu2libvirtBoot.iteritems(): vmConfs.append({"boot": k}) expectedXMLs.append(OSXML % v) for vmConf, xml in zip(vmConfs, expectedXMLs): vmConf.update(self.conf) domxml = vm._DomXML(vmConf, self.log) domxml.appendOs() self.assertXML(domxml.dom, xml, "os")
def testOSPPCXML(self): expectedXMLs = [""" <os> <type arch="ppc64" machine="pseries">hvm</type> <initrd>/tmp/initrd-2.6.18.img</initrd> <kernel>/tmp/vmlinuz-2.6.18</kernel> <cmdline>console=ttyS0 1</cmdline> </os>"""] vmConfs = [{'kernel': '/tmp/vmlinuz-2.6.18', 'initrd': '/tmp/initrd-2.6.18.img', 'kernelArgs': 'console=ttyS0 1'}] OSXML = """ <os> <type arch="ppc64" machine="pseries">hvm</type> <boot dev="%s"/> </os>""" qemu2libvirtBoot = {'a': 'fd', 'c': 'hd', 'd': 'cdrom', 'n': 'network'} for k, v in qemu2libvirtBoot.iteritems(): vmConfs.append({'boot': k}) expectedXMLs.append(OSXML % v) for vmConf, xml in zip(vmConfs, expectedXMLs): vmConf.update(self.conf) domxml = vm._DomXML(vmConf, self.log, caps.Architecture.PPC64) domxml.appendOs() self.assertXML(domxml.dom, xml, 'os')
def testOSXML(self): expectedXMLs = [ """ <os> <type arch="x86_64" machine="pc">hvm</type> <initrd>/tmp/initrd-2.6.18.img</initrd> <kernel>/tmp/vmlinuz-2.6.18</kernel> <cmdline>console=ttyS0 1</cmdline> <smbios mode="sysinfo"/> </os>""" ] vmConfs = [{ 'kernel': '/tmp/vmlinuz-2.6.18', 'initrd': '/tmp/initrd-2.6.18.img', 'kernelArgs': 'console=ttyS0 1' }] OSXML = """ <os> <type arch="x86_64" machine="pc">hvm</type> <boot dev="%s"/> <smbios mode="sysinfo"/> </os>""" qemu2libvirtBoot = {'a': 'fd', 'c': 'hd', 'd': 'cdrom', 'n': 'network'} for k, v in qemu2libvirtBoot.iteritems(): vmConfs.append({'boot': k}) expectedXMLs.append(OSXML % v) for vmConf, xml in zip(vmConfs, expectedXMLs): vmConf.update(self.conf) domxml = vm._DomXML(vmConf, self.log) domxml.appendOs() self.assertXML(domxml.dom, xml, 'os')
def testCpuXML(self): cpuXML = """ <cpu match="exact"> <model>Opteron_G4</model> <feature name="sse4.1" policy="require"/> <feature name="sse4.2" policy="require"/> <feature name="svm" policy="disable"/> <topology cores="2" sockets="2" threads="2"/> </cpu> """ cputuneXML = """ <cputune> <vcpupin cpuset="2-3" vcpu="1"/> <vcpupin cpuset="0-1" vcpu="0"/> </cputune> """ vmConf = { "cpuType": "Opteron_G4,+sse4_1,+sse4_2,-svm", "smpCoresPerSocket": 2, "smpThreadsPerCore": 2, "cpuPinning": {"0": "0-1", "1": "2-3"}, } vmConf.update(self.conf) domxml = vm._DomXML(vmConf, self.log) domxml.appendCpu() self.assertXML(domxml.dom, cpuXML, "cpu") self.assertXML(domxml.dom, cputuneXML, "cputune")
def testCpuXML(self): cpuXML = """ <cpu match="exact"> <model>Opteron_G4</model> <feature name="sse4.1" policy="require"/> <feature name="sse4.2" policy="require"/> <feature name="svm" policy="disable"/> <topology cores="2" sockets="2" threads="2"/> </cpu> """ cputuneXML = """ <cputune> <vcpupin cpuset="2-3" vcpu="1"/> <vcpupin cpuset="0-1" vcpu="0"/> </cputune> """ vmConf = { 'cpuType': "Opteron_G4,+sse4_1,+sse4_2,-svm", 'smpCoresPerSocket': 2, 'smpThreadsPerCore': 2, 'cpuPinning': { '0': '0-1', '1': '2-3' } } vmConf.update(self.conf) domxml = vm._DomXML(vmConf, self.log) domxml.appendCpu() self.assertXML(domxml.dom, cpuXML, 'cpu') self.assertXML(domxml.dom, cputuneXML, 'cputune')
def testFeaturesXML(self): featuresXML = """ <features> <acpi/> </features>""" domxml = vm._DomXML(self.conf, self.log) domxml.appendFeatures() self.assertXML(domxml.dom, featuresXML, 'features')
def testInputXML(self): expectedXMLs = ["""<input bus="ps2" type="mouse"/>""", """<input bus="usb" type="tablet"/>"""] vmConfs = [{}, {"tabletEnable": "true"}] for vmConf, xml in zip(vmConfs, expectedXMLs): vmConf.update(self.conf) domxml = vm._DomXML(vmConf, self.log) domxml.appendInput() self.assertXML(domxml.dom, xml, "devices/input")
def testClockXML(self): clockXML = """ <clock adjustment="-3600" offset="variable"> <timer name="rtc" tickpolicy="catchup"/> </clock>""" self.conf['timeOffset'] = '-3600' domxml = vm._DomXML(self.conf, self.log) domxml.appendClock() self.assertXML(domxml.dom, clockXML, 'clock')
def testClockXML(self): clockXML = """ <clock adjustment="-3600" offset="variable"> <timer name="rtc" tickpolicy="catchup"/> <timer name="pit" tickpolicy="delay"/> <timer name="hpet" present="no"/> </clock>""" self.conf['timeOffset'] = '-3600' domxml = vm._DomXML(self.conf, self.log, caps.Architecture.X86_64) domxml.appendClock() self.assertXML(domxml.dom, clockXML, 'clock')
def testInputXMLPPC64(self): expectedXMLs = [ """<input bus="usb" type="mouse"/>""", """<input bus="usb" type="tablet"/>"""] vmConfs = [{}, {'tabletEnable': 'true'}] for vmConf, xml in zip(vmConfs, expectedXMLs): vmConf.update(self.conf) domxml = vm._DomXML(vmConf, self.log, caps.Architecture.PPC64) domxml.appendInput() self.assertXML(domxml.dom, xml, 'devices/input')
def testInputXML(self): expectedXMLs = [ """<input bus="ps2" type="mouse"/>""", """<input bus="usb" type="tablet"/>""" ] vmConfs = [{}, {'tabletEnable': 'true'}] for vmConf, xml in zip(vmConfs, expectedXMLs): vmConf.update(self.conf) domxml = vm._DomXML(vmConf, self.log) domxml.appendInput() self.assertXML(domxml.dom, xml, 'devices/input')
def testChannelXML(self): channelXML = """ <channel type="unix"> <target name="%s" type="virtio"/> <source mode="bind" path="%s"/> </channel>""" path = '/tmp/channel-socket' name = 'org.linux-kvm.port.0' channelXML = channelXML % (name, path) domxml = vm._DomXML(self.conf, self.log) domxml._appendAgentDevice(path, name) self.assertXML(domxml.dom, channelXML, 'devices/channel')
def testDomXML(self): expectedXML = """ <domain type="kvm"> <name>testVm</name> <uuid>9ffe28b6-6134-4b1e-8804-1185f49c436f</uuid> <memory>1048576</memory> <currentMemory>1048576</currentMemory> <vcpu>8</vcpu> <devices/> </domain>""" domxml = vm._DomXML(self.conf, self.log) self.assertXML(domxml.dom, expectedXML)
def testDomXML(self): expectedXML = """ <domain type="kvm"> <name>testVm</name> <uuid>9ffe28b6-6134-4b1e-8804-1185f49c436f</uuid> <memory>1048576</memory> <currentMemory>1048576</currentMemory> <vcpu>8</vcpu> <memtune> <min_guarantee>524288</min_guarantee> </memtune> <devices/> </domain>""" domxml = vm._DomXML(self.conf, self.log) self.assertXML(domxml.dom, expectedXML)
def testGraphicsXML(self): expectedXMLs = [ """ <graphics autoport="yes" keymap="en-us" passwd="*****" passwdValidTo="1970-01-01T00:00:01" port="-1" type="vnc"> <listen network="vdsm-vmDisplay" type="network"/> </graphics>""", """ <graphics autoport="yes" listen="0" passwd="*****" passwdValidTo="1970-01-01T00:00:01" port="-1" tlsPort="-1" type="spice"> <channel mode="secure" name="main"/> <channel mode="secure" name="inputs"/> <channel mode="secure" name="cursor"/> <channel mode="secure" name="playback"/> <channel mode="secure" name="record"/> <channel mode="secure" name="display"/> </graphics>""" ] spiceChannelXML = """ <channel type="spicevmc"> <target name="com.redhat.spice.0" type="virtio"/> </channel>""" vmConfs = [{ 'display': 'vnc', 'displayPort': '-1', 'displayNetwork': 'vmDisplay', 'keyboardLayout': 'en-us' }, { 'display': 'qxl', 'displayPort': '-1', 'displaySecurePort': '-1', 'spiceSecureChannels': "smain,sinputs,scursor,splayback,srecord,sdisplay" }] for vmConf, xml in zip(vmConfs, expectedXMLs): vmConf.update(self.conf) domxml = vm._DomXML(vmConf, self.log) domxml.appendGraphics() self.assertXML(domxml.dom, xml, 'devices/graphics') if vmConf['display'] == 'qxl': self.assertXML(domxml.dom, spiceChannelXML, 'devices/channel')
def testDomXML(self): expectedXML = """ <domain type="kvm"> <name>testVm</name> <uuid>9ffe28b6-6134-4b1e-8804-1185f49c436f</uuid> <memory>1048576</memory> <currentMemory>1048576</currentMemory> <vcpu current="8">160</vcpu> <memtune> <min_guarantee>524288</min_guarantee> </memtune> <devices/> </domain>""" domxml = vm._DomXML(self.conf, self.log, caps.Architecture.X86_64) self.assertXML(domxml.dom, expectedXML)
def testSysinfoXML(self): sysinfoXML = """ <sysinfo type="smbios"> <system> <entry name="manufacturer">%s</entry> <entry name="product">%s</entry> <entry name="version">%s</entry> <entry name="serial">%s</entry> <entry name="uuid">%s</entry> </system> </sysinfo>""" product = "oVirt Node" version = "17-1" serial = "A5955881-519B-11CB-8352-E78A528C28D8_00:21:cc:68:d7:38" sysinfoXML = sysinfoXML % (constants.SMBIOS_MANUFACTURER, product, version, serial, self.conf["vmId"]) domxml = vm._DomXML(self.conf, self.log) domxml.appendSysinfo(product, version, serial) self.assertXML(domxml.dom, sysinfoXML, "sysinfo")
def testSysinfoXML(self): sysinfoXML = """ <sysinfo type="smbios"> <system> <entry name="manufacturer">%s</entry> <entry name="product">%s</entry> <entry name="version">%s</entry> <entry name="serial">%s</entry> <entry name="uuid">%s</entry> </system> </sysinfo>""" product = 'oVirt Node' version = '17-1' serial = 'A5955881-519B-11CB-8352-E78A528C28D8_00:21:cc:68:d7:38' sysinfoXML = sysinfoXML % (constants.SMBIOS_MANUFACTURER, product, version, serial, self.conf['vmId']) domxml = vm._DomXML(self.conf, self.log) domxml.appendSysinfo(product, version, serial) self.assertXML(domxml.dom, sysinfoXML, 'sysinfo')
def testGraphicsXML(self): expectedXMLs = [ """ <graphics autoport="yes" keymap="en-us" passwd="*****" passwdValidTo="1970-01-01T00:00:01" port="-1" type="vnc"> <listen network="vdsm-vmDisplay" type="network"/> </graphics>""", """ <graphics autoport="yes" listen="0" passwd="*****" passwdValidTo="1970-01-01T00:00:01" port="-1" tlsPort="-1" type="spice"> <channel mode="secure" name="main"/> <channel mode="secure" name="inputs"/> <channel mode="secure" name="cursor"/> <channel mode="secure" name="playback"/> <channel mode="secure" name="record"/> <channel mode="secure" name="display"/> </graphics>""", ] spiceChannelXML = """ <channel type="spicevmc"> <target name="com.redhat.spice.0" type="virtio"/> </channel>""" vmConfs = [ {"display": "vnc", "displayPort": "-1", "displayNetwork": "vmDisplay", "keyboardLayout": "en-us"}, { "display": "qxl", "displayPort": "-1", "displaySecurePort": "-1", "spiceSecureChannels": "smain,sinputs,scursor,splayback,srecord,sdisplay", }, ] for vmConf, xml in zip(vmConfs, expectedXMLs): vmConf.update(self.conf) domxml = vm._DomXML(vmConf, self.log) domxml.appendGraphics() self.assertXML(domxml.dom, xml, "devices/graphics") if vmConf["display"] == "qxl": self.assertXML(domxml.dom, spiceChannelXML, "devices/channel")
def testSysinfoXML(self): sysinfoXML = """ <sysinfo type="smbios"> <system> <entry name="manufacturer">%s</entry> <entry name="product">%s</entry> <entry name="version">%s</entry> <entry name="serial">%s</entry> <entry name="uuid">%s</entry> </system> </sysinfo>""" product = 'oVirt Node' version = '17-1' serial = 'A5955881-519B-11CB-8352-E78A528C28D8_00:21:cc:68:d7:38' sysinfoXML = sysinfoXML % (constants.SMBIOS_MANUFACTURER, product, version, serial, self.conf['vmId']) domxml = vm._DomXML(self.conf, self.log, caps.Architecture.X86_64) domxml.appendSysinfo(product, version, serial) self.assertXML(domxml.dom, sysinfoXML, 'sysinfo')
def testGraphicsXML(self): expectedXMLs = [ """ <graphics autoport="yes" keymap="en-us" passwd="*****" passwdValidTo="1970-01-01T00:00:01" port="-1" type="vnc"> <listen network="vdsm-vmDisplay" type="network"/> </graphics>""", """ <graphics autoport="yes" listen="0" passwd="*****" passwdValidTo="1970-01-01T00:00:01" port="-1" tlsPort="-1" type="spice"> <channel mode="secure" name="main"/> <channel mode="secure" name="inputs"/> <channel mode="secure" name="cursor"/> <channel mode="secure" name="playback"/> <channel mode="secure" name="record"/> <channel mode="secure" name="display"/> </graphics>"""] spiceChannelXML = """ <channel type="spicevmc"> <target name="com.redhat.spice.0" type="virtio"/> </channel>""" vmConfs = [ {'display': 'vnc', 'displayPort': '-1', 'displayNetwork': 'vmDisplay', 'keyboardLayout': 'en-us'}, {'display': 'qxl', 'displayPort': '-1', 'displaySecurePort': '-1', 'spiceSecureChannels': "smain,sinputs,scursor,splayback,srecord,sdisplay"}] for vmConf, xml in zip(vmConfs, expectedXMLs): vmConf.update(self.conf) domxml = vm._DomXML(vmConf, self.log, caps.Architecture.X86_64) domxml.appendGraphics() self.assertXML(domxml.dom, xml, 'devices/graphics') if vmConf['display'] == 'qxl': self.assertXML(domxml.dom, spiceChannelXML, 'devices/channel')
def testCpuXML(self): cpuXML = """ <cpu match="exact"> <model>Opteron_G4</model> <feature name="sse4.1" policy="require"/> <feature name="sse4.2" policy="require"/> <feature name="svm" policy="disable"/> <topology cores="2" sockets="40" threads="2"/> <numa> <cell cpus="0-1" memory="512000"/> <cell cpus="2,3" memory="512000"/> </numa> </cpu> """ cputuneXML = """ <cputune> <vcpupin cpuset="2-3" vcpu="1"/> <vcpupin cpuset="0-1" vcpu="0"/> </cputune> """ numatuneXML = """ <numatune> <memory mode="strict" nodeset="0-1"/> </numatune> """ vmConf = {'cpuType': "Opteron_G4,+sse4_1,+sse4_2,-svm", 'smpCoresPerSocket': 2, 'smpThreadsPerCore': 2, 'cpuPinning': {'0': '0-1', '1': '2-3'}, 'numaTune': {'mode': 'strict', 'nodeset': '0-1'}, 'guestNumaNodes': [{'cpus': '0-1', 'memory': '512000'}, {'cpus': '2,3', 'memory': 512000}]} vmConf.update(self.conf) domxml = vm._DomXML(vmConf, self.log, caps.Architecture.X86_64) domxml.appendCpu() self.assertXML(domxml.dom, cpuXML, 'cpu') self.assertXML(domxml.dom, cputuneXML, 'cputune') domxml.appendNumaTune() self.assertXML(domxml.dom, numatuneXML, 'numatune')
def testCpuXML(self): cpuXML = """ <cpu match="exact"> <model>Opteron_G4</model> <feature name="sse4.1" policy="require"/> <feature name="sse4.2" policy="require"/> <feature name="svm" policy="disable"/> <topology cores="2" sockets="40" threads="2"/> </cpu> """ cputuneXML = """ <cputune> <vcpupin cpuset="2-3" vcpu="1"/> <vcpupin cpuset="0-1" vcpu="0"/> </cputune> """ vmConf = {'cpuType': "Opteron_G4,+sse4_1,+sse4_2,-svm", 'smpCoresPerSocket': 2, 'smpThreadsPerCore': 2, 'cpuPinning': {'0': '0-1', '1': '2-3'}} vmConf.update(self.conf) domxml = vm._DomXML(vmConf, self.log, caps.Architecture.X86_64) domxml.appendCpu() self.assertXML(domxml.dom, cpuXML, 'cpu') self.assertXML(domxml.dom, cputuneXML, 'cputune')