예제 #1
0
    def test_minimal_domain_xml(self, user_conf, domain_type):
        expected_xml = """
          <domain type="{domain_type}"
                  xmlns:ns0="http://ovirt.org/vm/tune/1.0"
                  xmlns:ns1="http://ovirt.org/vm/1.0">
              <name>testVm</name>
              <uuid>9ffe28b6-6134-4b1e-8804-1185f49c436f</uuid>
              <memory>1048576</memory>
              <currentMemory>1048576</currentMemory>
              <vcpu current="8">160</vcpu>
              <devices/>
              <metadata>
                <ns0:qos/>
                <ns1:vm/>
              </metadata>
              <clock adjustment="0" offset="variable">
                <timer name="rtc" tickpolicy="catchup" />
                <timer name="pit" tickpolicy="delay" />
                <timer name="hpet" present="no" />
              </clock>
              <features>
                <acpi />
              </features>
           </domain>""".format(domain_type=domain_type)

        conf = {}
        conf.update(self.conf)
        conf.update(user_conf)
        domxml = libvirtxml.make_minimal_domain(
            libvirtxml.Domain(conf, self.log, cpuarch.X86_64))
        self.assertXMLEqual(domxml.toxml(), expected_xml)
예제 #2
0
    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 six.iteritems(qemu2libvirtBoot):
            vmConfs.append({'boot': k})
            expectedXMLs.append(OSXML % v)

        for vmConf, osXML in zip(vmConfs, expectedXMLs):
            vmConf.update(self.conf)
            domxml = libvirtxml.Domain(vmConf, self.log, cpuarch.PPC64)
            domxml.appendOs()
            xml = find_xml_element(domxml.toxml(), './os')
            self.assertXMLEqual(xml, osXML)
예제 #3
0
 def testFeaturesXML(self):
     featuresXML = """
         <features>
               <acpi/>
         </features>"""
     domxml = libvirtxml.Domain(self.conf, self.log, cpuarch.X86_64)
     domxml.appendFeatures()
     xml = find_xml_element(domxml.toxml(), './features')
     self.assertXMLEqual(xml, featuresXML)
예제 #4
0
    def testMemoryBackingXML(self):
        memorybacking_xml = """
          <memoryBacking>
            <hugepages>
              <page size="1048576" />
            </hugepages>
          </memoryBacking>"""

        domxml = libvirtxml.Domain(self.conf, self.log, cpuarch.X86_64)
        domxml.appendMemoryBacking(1048576)
        xml = find_xml_element(domxml.toxml(), './memoryBacking')
        self.assertXMLEqual(xml, memorybacking_xml)
예제 #5
0
 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 = libvirtxml.Domain(self.conf, self.log, cpuarch.X86_64)
     domxml.appendClock()
     xml = find_xml_element(domxml.toxml(), './clock')
     self.assertXMLEqual(xml, clockXML)
예제 #6
0
 def testNumaTuneXMLMultiNode(self):
     domxml = libvirtxml.Domain(self.conf, self.log, cpuarch.X86_64)
     devices = [
         hostdevice.HostDevice(self.log, **{
             'type': 'hostdev',
             'device': device
         }) for device in [_SRIOV_PF, _SRIOV_VF, 'pci_0000_00_02_0']
     ]
     domxml.appendHostdevNumaTune(devices)
     xml = vmxml.format_xml(domxml.dom)
     self.assertRaises(AssertionError,
                       lambda: find_xml_element(xml, './numatune'))
예제 #7
0
    def testMemoryBackingXMLDefaultPPC(self):
        memorybacking_xml = """
          <memoryBacking>
            <hugepages>
              <page size="16384" />
            </hugepages>
          </memoryBacking>"""

        domxml = libvirtxml.Domain(self.conf, self.log, cpuarch.PPC64LE)
        domxml.appendMemoryBacking(
            hugepages.DEFAULT_HUGEPAGESIZE[cpuarch.real()])
        xml = find_xml_element(domxml.toxml(), './memoryBacking')
        self.assertXMLEqual(xml, memorybacking_xml)
예제 #8
0
    def testInputXMLPPC64(self):
        expectedXMLs = [
            """<input bus="usb" type="mouse"/>""",
            """<input bus="usb" type="tablet"/>"""
        ]

        vmConfs = [{}, {'tabletEnable': 'true'}]
        for vmConf, inputXML in zip(vmConfs, expectedXMLs):
            vmConf.update(self.conf)
            domxml = libvirtxml.Domain(vmConf, self.log, cpuarch.PPC64)
            domxml.appendInput()
            xml = find_xml_element(domxml.toxml(), './devices/input')
            self.assertXMLEqual(xml, inputXML)
예제 #9
0
 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 = libvirtxml.Domain(self.conf, self.log, cpuarch.X86_64)
     domxml._appendAgentDevice(path, name)
     xml = find_xml_element(domxml.toxml(), './devices/channel')
     self.assertXMLEqual(xml, channelXML)
예제 #10
0
 def testHyperVClockXML(self):
     clockXML = """
         <clock adjustment="-3600" offset="variable">
             <timer name="hypervclock" present="yes"/>
             <timer name="rtc" tickpolicy="catchup"/>
             <timer name="pit" tickpolicy="delay"/>
             <timer name="hpet" present="no"/>
         </clock>"""
     conf = {'timeOffset': '-3600', 'hypervEnable': 'true'}
     conf.update(self.conf)
     domxml = libvirtxml.Domain(conf, self.log, cpuarch.X86_64)
     domxml.appendClock()
     xml = find_xml_element(domxml.toxml(), './clock')
     self.assertXMLEqual(xml, clockXML)
예제 #11
0
 def testFeaturesHyperVXML(self):
     featuresXML = """
         <features>
               <acpi/>
               <hyperv>
                      <relaxed state="on"/>
                      <vapic state="on"/>
                      <spinlocks retries="8191" state="on"/>
               </hyperv>
         </features>"""
     conf = {'hypervEnable': 'true'}
     conf.update(self.conf)
     domxml = libvirtxml.Domain(conf, self.log, cpuarch.X86_64)
     domxml.appendFeatures()
     xml = find_xml_element(domxml.toxml(), './features')
     self.assertXMLEqual(xml, featuresXML)
예제 #12
0
파일: hostdev_test.py 프로젝트: jxyzn/vdsm
    def testNumaTuneXMLSingleNode(self, devices, numa_node):
        numatuneXML = """
          <numatune>
              <memory mode="preferred" nodeset="{}" />
          </numatune> """.format(numa_node)

        domxml = libvirtxml.Domain(self.conf, self.log, cpuarch.X86_64)
        devices = [
            hostdevice.HostDevice(self.log, **{
                'type': 'hostdev',
                'device': device
            }) for device in devices
        ]
        domxml.appendHostdevNumaTune(devices)
        xml = xmlutils.tostring(domxml.dom)
        self.assertXMLEqual(find_xml_element(xml, './numatune'), numatuneXML)
예제 #13
0
    def testSharedGuestNumaNodes(self):
        numaXML = """
              <numa>
                  <cell cpus="0-1" memory="5242880" memAccess="shared"/>
              </numa>
              """

        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',
                'memnodes': [{
                    'vmNodeIndex': '0',
                    'nodeset': '1'
                }, {
                    'vmNodeIndex': '1',
                    'nodeset': '0'
                }]
            },
            'guestNumaNodes': [
                {
                    'cpus': '0-1',
                    'memory': '5120',
                    'nodeIndex': 0
                },
            ]
        }

        vmConf.update(self.conf)
        domxml = libvirtxml.Domain(vmConf, self.log, cpuarch.X86_64)
        domxml.appendCpu(hugepages_shared=True)
        xml = domxml.toxml()
        self.assertXMLEqual(find_xml_element(xml, "./cpu/numa"), numaXML)
예제 #14
0
 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 = libvirtxml.Domain(self.conf, self.log, cpuarch.X86_64)
     domxml.appendSysinfo(product, version, serial)
     xml = find_xml_element(domxml.toxml(), './sysinfo')
     self.assertXMLEqual(xml, sysinfoXML)
예제 #15
0
    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="5242880"/>
                  <cell cpus="2,3" memory="5242880"/>
              </numa>
          </cpu> """
        cputuneXML = """
          <cputune>
              <vcpupin cpuset="0-1" vcpu="0"/>
              <vcpupin cpuset="2-3" vcpu="1"/>
          </cputune> """

        numatuneXML = """
          <numatune>
              <memory mode="strict" nodeset="0-1"/>
              <memnode cellid="0" mode="strict" nodeset="1"/>
              <memnode cellid="1" mode="strict" nodeset="0"/>
          </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',
                'memnodes': [{
                    'vmNodeIndex': '0',
                    'nodeset': '1'
                }, {
                    'vmNodeIndex': '1',
                    'nodeset': '0'
                }]
            },
            'guestNumaNodes': [{
                'cpus': '0-1',
                'memory': '5120',
                'nodeIndex': 0
            }, {
                'cpus': '2,3',
                'memory': '5120',
                'nodeIndex': 1
            }]
        }
        vmConf.update(self.conf)
        domxml = libvirtxml.Domain(vmConf, self.log, cpuarch.X86_64)
        domxml.appendCpu()
        domxml.appendNumaTune()
        xml = domxml.toxml()
        self.assertXMLEqual(find_xml_element(xml, "./cpu"), cpuXML)
        self.assertXMLEqual(find_xml_element(xml, "./cputune"), cputuneXML)
        self.assertXMLEqual(find_xml_element(xml, './numatune'), numatuneXML)
예제 #16
0
 def testOSXMLBootMenu(self):
     vmConfs = (
         # trivial cases first
         {},
         {
             'bootMenuEnable': 'true'
         },
         {
             'bootMenuEnable': 'false'
         },
         {
             'bootMenuEnable': True
         },
         {
             'bootMenuEnable': False
         },
         # next with more fields
         {
             'bootMenuEnable': True,
             'kernelArgs': 'console=ttyS0 1'
         },
         {
             'bootMenuEnable': False,
             'kernelArgs': 'console=ttyS0 1'
         })
     expectedXMLs = ("""
         <os>
              <type arch="x86_64" machine="pc">hvm</type>
              <smbios mode="sysinfo"/>
         </os>""", """
         <os>
              <type arch="x86_64" machine="pc">hvm</type>
              <smbios mode="sysinfo"/>
              <bootmenu enable="yes" timeout="10000"/>
         </os>""", """
         <os>
              <type arch="x86_64" machine="pc">hvm</type>
              <smbios mode="sysinfo"/>
         </os>""", """
         <os>
              <type arch="x86_64" machine="pc">hvm</type>
              <smbios mode="sysinfo"/>
              <bootmenu enable="yes" timeout="10000"/>
         </os>""", """
         <os>
              <type arch="x86_64" machine="pc">hvm</type>
              <smbios mode="sysinfo"/>
         </os>""", """
         <os>
              <type arch="x86_64" machine="pc">hvm</type>
              <cmdline>console=ttyS0 1</cmdline>
              <smbios mode="sysinfo"/>
              <bootmenu enable="yes" timeout="10000"/>
         </os>""", """
         <os>
              <type arch="x86_64" machine="pc">hvm</type>
              <cmdline>console=ttyS0 1</cmdline>
              <smbios mode="sysinfo"/>
         </os>""")
     for conf, osXML in zip(vmConfs, expectedXMLs):
         conf.update(self.conf)
         domxml = libvirtxml.Domain(conf, self.log, cpuarch.X86_64)
         domxml.appendOs()
         xml = find_xml_element(domxml.toxml(), './os')
         self.assertXMLEqual(xml, osXML)