mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-22 13:34:07 +03:00
cpu: Have host-copy use domcaps if qemu is new enough (bz 1637767)
capabilities is known problematic. Use domcaps if libvirt+qemu reports working host-model https://bugzilla.redhat.com/show_bug.cgi?id=1637767
This commit is contained in:
parent
535e34481d
commit
b051b6c95d
@ -0,0 +1,161 @@
|
||||
<domain type="kvm">
|
||||
<name>foobar</name>
|
||||
<uuid>00000000-1111-2222-3333-444444444444</uuid>
|
||||
<memory>65536</memory>
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="network"/>
|
||||
</os>
|
||||
<features>
|
||||
<acpi/>
|
||||
<apic/>
|
||||
<vmport state="off"/>
|
||||
</features>
|
||||
<cpu mode="custom" match="exact">
|
||||
<model>Opteron_G4</model>
|
||||
<vendor>AMD</vendor>
|
||||
<feature name="invtsc"/>
|
||||
<feature name="perfctr_nb"/>
|
||||
<feature name="perfctr_core"/>
|
||||
<feature name="topoext"/>
|
||||
<feature name="nodeid_msr"/>
|
||||
<feature name="lwp"/>
|
||||
<feature name="wdt"/>
|
||||
<feature name="skinit"/>
|
||||
<feature name="ibs"/>
|
||||
<feature name="osvw"/>
|
||||
<feature name="cr8legacy"/>
|
||||
<feature name="extapic"/>
|
||||
<feature name="cmp_legacy"/>
|
||||
<feature name="fxsr_opt"/>
|
||||
<feature name="mmxext"/>
|
||||
<feature name="osxsave"/>
|
||||
<feature name="monitor"/>
|
||||
<feature name="ht"/>
|
||||
<feature name="vme"/>
|
||||
</cpu>
|
||||
<clock offset="utc">
|
||||
<timer name="rtc" tickpolicy="catchup"/>
|
||||
<timer name="pit" tickpolicy="delay"/>
|
||||
<timer name="hpet" present="no"/>
|
||||
</clock>
|
||||
<on_reboot>destroy</on_reboot>
|
||||
<pm>
|
||||
<suspend-to-mem enabled="no"/>
|
||||
<suspend-to-disk enabled="no"/>
|
||||
</pm>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-kvm</emulator>
|
||||
<controller type="usb" index="0" model="ich9-ehci1"/>
|
||||
<controller type="usb" index="0" model="ich9-uhci1">
|
||||
<master startport="0"/>
|
||||
</controller>
|
||||
<controller type="usb" index="0" model="ich9-uhci2">
|
||||
<master startport="2"/>
|
||||
</controller>
|
||||
<controller type="usb" index="0" model="ich9-uhci3">
|
||||
<master startport="4"/>
|
||||
</controller>
|
||||
<interface type="bridge">
|
||||
<source bridge="eth0"/>
|
||||
<mac address="00:11:22:33:44:55"/>
|
||||
<model type="e1000"/>
|
||||
</interface>
|
||||
<console type="pty"/>
|
||||
<channel type="spicevmc">
|
||||
<target type="virtio" name="com.redhat.spice.0"/>
|
||||
</channel>
|
||||
<input type="tablet" bus="usb"/>
|
||||
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
|
||||
<image compression="off"/>
|
||||
</graphics>
|
||||
<sound model="ich6"/>
|
||||
<video>
|
||||
<model type="qxl"/>
|
||||
</video>
|
||||
<redirdev bus="usb" type="spicevmc"/>
|
||||
<redirdev bus="usb" type="spicevmc"/>
|
||||
</devices>
|
||||
</domain>
|
||||
<domain type="kvm">
|
||||
<name>foobar</name>
|
||||
<uuid>00000000-1111-2222-3333-444444444444</uuid>
|
||||
<memory>65536</memory>
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="network"/>
|
||||
</os>
|
||||
<features>
|
||||
<acpi/>
|
||||
<apic/>
|
||||
<vmport state="off"/>
|
||||
</features>
|
||||
<cpu mode="custom" match="exact">
|
||||
<model>Opteron_G4</model>
|
||||
<vendor>AMD</vendor>
|
||||
<feature name="invtsc"/>
|
||||
<feature name="perfctr_nb"/>
|
||||
<feature name="perfctr_core"/>
|
||||
<feature name="topoext"/>
|
||||
<feature name="nodeid_msr"/>
|
||||
<feature name="lwp"/>
|
||||
<feature name="wdt"/>
|
||||
<feature name="skinit"/>
|
||||
<feature name="ibs"/>
|
||||
<feature name="osvw"/>
|
||||
<feature name="cr8legacy"/>
|
||||
<feature name="extapic"/>
|
||||
<feature name="cmp_legacy"/>
|
||||
<feature name="fxsr_opt"/>
|
||||
<feature name="mmxext"/>
|
||||
<feature name="osxsave"/>
|
||||
<feature name="monitor"/>
|
||||
<feature name="ht"/>
|
||||
<feature name="vme"/>
|
||||
</cpu>
|
||||
<clock offset="utc">
|
||||
<timer name="rtc" tickpolicy="catchup"/>
|
||||
<timer name="pit" tickpolicy="delay"/>
|
||||
<timer name="hpet" present="no"/>
|
||||
</clock>
|
||||
<pm>
|
||||
<suspend-to-mem enabled="no"/>
|
||||
<suspend-to-disk enabled="no"/>
|
||||
</pm>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-kvm</emulator>
|
||||
<controller type="usb" index="0" model="ich9-ehci1"/>
|
||||
<controller type="usb" index="0" model="ich9-uhci1">
|
||||
<master startport="0"/>
|
||||
</controller>
|
||||
<controller type="usb" index="0" model="ich9-uhci2">
|
||||
<master startport="2"/>
|
||||
</controller>
|
||||
<controller type="usb" index="0" model="ich9-uhci3">
|
||||
<master startport="4"/>
|
||||
</controller>
|
||||
<interface type="bridge">
|
||||
<source bridge="eth0"/>
|
||||
<mac address="00:11:22:33:44:55"/>
|
||||
<model type="e1000"/>
|
||||
</interface>
|
||||
<console type="pty"/>
|
||||
<channel type="spicevmc">
|
||||
<target type="virtio" name="com.redhat.spice.0"/>
|
||||
</channel>
|
||||
<input type="tablet" bus="usb"/>
|
||||
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
|
||||
<image compression="off"/>
|
||||
</graphics>
|
||||
<sound model="ich6"/>
|
||||
<video>
|
||||
<model type="qxl"/>
|
||||
</video>
|
||||
<redirdev bus="usb" type="spicevmc"/>
|
||||
<redirdev bus="usb" type="spicevmc"/>
|
||||
</devices>
|
||||
</domain>
|
@ -29,7 +29,21 @@
|
||||
<acpi/>
|
||||
<vmport state="off"/>
|
||||
</features>
|
||||
<cpu mode="host-model"/>
|
||||
<cpu mode="custom" match="exact">
|
||||
<model fallback="forbid">Broadwell</model>
|
||||
<vendor>Intel</vendor>
|
||||
<feature policy="require" name="vme"/>
|
||||
<feature policy="require" name="ss"/>
|
||||
<feature policy="require" name="f16c"/>
|
||||
<feature policy="require" name="rdrand"/>
|
||||
<feature policy="require" name="hypervisor"/>
|
||||
<feature policy="require" name="arat"/>
|
||||
<feature policy="require" name="tsc_adjust"/>
|
||||
<feature policy="require" name="xsaveopt"/>
|
||||
<feature policy="require" name="pdpe1gb"/>
|
||||
<feature policy="require" name="abm"/>
|
||||
<feature policy="require" name="invtsc"/>
|
||||
</cpu>
|
||||
<clock offset="localtime">
|
||||
<timer name="rtc" tickpolicy="catchup"/>
|
||||
<timer name="pit" tickpolicy="delay"/>
|
||||
|
@ -357,7 +357,7 @@ c = vinst.add_category("xml-comparsion", "--connect %(URI-KVM)s --noautoconsole
|
||||
c.add_compare(""" \
|
||||
--memory 1024 \
|
||||
--vcpus 4 --cpuset=1,3-5 \
|
||||
--cpu host \
|
||||
--cpu host-copy \
|
||||
--description \"foobar & baz\" \
|
||||
--boot uefi,smbios_mode=emulate \
|
||||
--security type=dynamic \
|
||||
@ -732,6 +732,8 @@ c.add_compare("--disk %(EXISTIMG1)s --pxe --os-variant rhel5.4", "kvm-rhel5") #
|
||||
c.add_compare("--disk %(EXISTIMG1)s --pxe --os-variant rhel6.4", "kvm-rhel6") # RHEL6 defaults
|
||||
c.add_compare("--disk %(EXISTIMG1)s --pxe --os-variant rhel7.0", "kvm-rhel7", skip_check=OLD_OSINFO) # RHEL7 defaults
|
||||
c.add_compare("--connect " + utils.URIs.kvm_nodomcaps + " --disk %(EXISTIMG1)s --pxe --os-variant rhel7.0", "kvm-cpu-default-fallback", skip_check=OLD_OSINFO) # No domcaps, so mode=host-model isn't safe, so we fallback to host-model-only
|
||||
c.add_compare("--connect " + utils.URIs.kvm_nodomcaps + " --cpu host-copy --disk none --pxe", "kvm-hostcopy-fallback") # No domcaps so need to use capabilities for CPU host-copy
|
||||
c.add_compare("--disk %(EXISTIMG1)s --pxe --os-variant centos7.0", "kvm-centos7", skip_check=OLD_OSINFO) # Centos 7 defaults
|
||||
c.add_compare("--disk %(EXISTIMG1)s --pxe --os-variant centos7.0", "kvm-centos7", skip_check=OLD_OSINFO) # Centos 7 defaults
|
||||
c.add_compare("--disk %(EXISTIMG1)s --cdrom %(EXISTIMG2)s --os-variant win10", "kvm-win10", skip_check=OLD_OSINFO) # win10 defaults
|
||||
c.add_compare("--os-variant win7 --cdrom %(EXISTIMG2)s --boot loader_type=pflash,loader=CODE.fd,nvram_template=VARS.fd --disk %(EXISTIMG1)s", "win7-uefi", skip_check=OLD_OSINFO) # no HYPER-V with UEFI
|
||||
|
@ -1426,7 +1426,7 @@ class XMLParseTest(unittest.TestCase):
|
||||
outfile = "tests/xmlparse-xml/%s-out.xml" % basename
|
||||
guest = virtinst.Guest(self.kvmconn, parsexml=open(infile).read())
|
||||
|
||||
guest.cpu.copy_host_cpu()
|
||||
guest.cpu.copy_host_cpu(guest)
|
||||
guest.cpu.clear()
|
||||
utils.diff_compare(guest.get_xml(), outfile)
|
||||
|
||||
|
@ -96,7 +96,7 @@ class DomainCpu(XMLBuilder):
|
||||
self.remove_child(f)
|
||||
self.mode = val
|
||||
elif val == self.SPECIAL_MODE_HOST_COPY:
|
||||
self.copy_host_cpu()
|
||||
self.copy_host_cpu(guest)
|
||||
elif (val == self.SPECIAL_MODE_HV_DEFAULT or
|
||||
val == self.SPECIAL_MODE_CLEAR):
|
||||
self.clear()
|
||||
@ -119,24 +119,36 @@ class DomainCpu(XMLBuilder):
|
||||
cells = XMLChildProperty(_CPUCell, relative_xpath="./numa")
|
||||
cache = XMLChildProperty(_CPUCache)
|
||||
|
||||
def copy_host_cpu(self):
|
||||
def copy_host_cpu(self, guest):
|
||||
"""
|
||||
Enact the equivalent of qemu -cpu host, pulling all info
|
||||
from capabilities about the host CPU
|
||||
Try to manually mimic host-model, copying all the info
|
||||
preferably out of domcapabilities, but capabilities as fallback.
|
||||
"""
|
||||
cpu = self.conn.caps.host.cpu
|
||||
if not cpu.model:
|
||||
raise ValueError(_("No host CPU reported in capabilities"))
|
||||
domcaps = guest.lookup_domcaps()
|
||||
if domcaps.supports_safe_host_model():
|
||||
logging.debug("Using domcaps for host-copy")
|
||||
cpu = domcaps.cpu.get_mode("host-model")
|
||||
model = cpu.models[0].model
|
||||
fallback = cpu.models[0].fallback
|
||||
else:
|
||||
cpu = self.conn.caps.host.cpu
|
||||
model = cpu.model
|
||||
fallback = None
|
||||
if not model:
|
||||
raise ValueError(_("No host CPU reported in capabilities"))
|
||||
|
||||
self.mode = "custom"
|
||||
self.match = "exact"
|
||||
self.model = cpu.model
|
||||
self.model = model
|
||||
if fallback:
|
||||
self.model_fallback = fallback
|
||||
self.vendor = cpu.vendor
|
||||
|
||||
for feature in self.features:
|
||||
self.remove_child(feature)
|
||||
for feature in cpu.features:
|
||||
self.add_feature(feature.name)
|
||||
policy = getattr(feature, "policy", "require")
|
||||
self.add_feature(feature.name, policy)
|
||||
|
||||
def vcpus_from_topology(self):
|
||||
"""
|
||||
|
@ -95,19 +95,29 @@ class _CPUModel(XMLBuilder):
|
||||
XML_NAME = "model"
|
||||
model = XMLProperty(".")
|
||||
usable = XMLProperty("./@usable", is_yesno=True)
|
||||
fallback = XMLProperty("./@fallback")
|
||||
|
||||
|
||||
class _CPUFeature(XMLBuilder):
|
||||
XML_NAME = "feature"
|
||||
name = XMLProperty("./@name")
|
||||
policy = XMLProperty("./@policy")
|
||||
|
||||
|
||||
class _CPUMode(XMLBuilder):
|
||||
XML_NAME = "mode"
|
||||
name = XMLProperty("./@name")
|
||||
supported = XMLProperty("./@supported", is_yesno=True)
|
||||
models = XMLChildProperty(_CPUModel)
|
||||
vendor = XMLProperty("./vendor")
|
||||
|
||||
models = XMLChildProperty(_CPUModel)
|
||||
def get_model(self, name):
|
||||
for model in self.models:
|
||||
if model.model == name:
|
||||
return model
|
||||
|
||||
features = XMLChildProperty(_CPUFeature)
|
||||
|
||||
|
||||
class _CPU(XMLBuilder):
|
||||
XML_NAME = "cpu"
|
||||
|
Loading…
Reference in New Issue
Block a user