Beispiel #1
0
    def test_config_host(self):
        obj = config.LibvirtConfigGuestCPU()
        obj.mode = "host-model"
        obj.match = "exact"

        xml = obj.to_xml()
        self.assertXmlEqual(xml, """
            <cpu mode="host-model" match="exact"/>
        """)
Beispiel #2
0
    def test_config_simple(self):
        obj = config.LibvirtConfigGuestCPU()
        obj.model = "Penryn"

        xml = obj.to_xml()
        self.assertXmlEqual(xml, """
            <cpu match="exact">
              <model>Penryn</model>
            </cpu>
        """)
Beispiel #3
0
 def _vcpu_model_to_cpu_config(self, vcpu_model):
     cpu_config = vconfig.LibvirtConfigGuestCPU()
     cpu_config.arch = vcpu_model.arch
     cpu_config.model = vcpu_model.model
     cpu_config.mode = vcpu_model.mode
     cpu_config.match = vcpu_model.match
     cpu_config.vendor = vcpu_model.vendor
     if vcpu_model.topology:
         cpu_config.sockets = vcpu_model.topology.sockets
         cpu_config.cores = vcpu_model.topology.cores
         cpu_config.threads = vcpu_model.topology.threads
     if vcpu_model.features:
         for f in vcpu_model.features:
             xf = vconfig.LibvirtConfigGuestCPUFeature()
             xf.name = f.name
             xf.policy = f.policy
             cpu_config.features.add(xf)
     return cpu_config
Beispiel #4
0
    def test_config_complex(self):
        obj = config.LibvirtConfigGuestCPU()
        obj.model = "Penryn"
        obj.vendor = "Intel"
        obj.arch = "x86_64"
        obj.mode = "custom"

        obj.add_feature(config.LibvirtConfigGuestCPUFeature("mtrr"))
        obj.add_feature(config.LibvirtConfigGuestCPUFeature("apic"))

        xml = obj.to_xml()
        self.assertXmlEqual(xml, """
            <cpu mode="custom" match="exact">
              <arch>x86_64</arch>
              <model>Penryn</model>
              <vendor>Intel</vendor>
              <feature name="mtrr" policy="require"/>
              <feature name="apic" policy="require"/>
            </cpu>
        """)