mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-23 17:34:21 +03:00
guest: Always encode machine= in XML
Don't rely on libvirt's default. This makes any XML changes more explicit, and can help other parts of the code that may depend on a machine type being encoded
This commit is contained in:
parent
ec69ae44b6
commit
e903d374c2
@ -6,7 +6,7 @@
|
||||
<currentMemory>795648</currentMemory>
|
||||
<vcpu>3</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>524288</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="network"/>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
@ -76,7 +76,7 @@
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<kernel>/tmp/virtinst-vmlinuz.</kernel>
|
||||
<initrd>/tmp/virtinst-initrd.img.</initrd>
|
||||
<cmdline>console=ttyS0 method=tests/cli-test-xml/fakefedoratree</cmdline>
|
||||
@ -67,7 +67,7 @@
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="i686">hvm</type>
|
||||
<type arch="i686" machine="pc">hvm</type>
|
||||
<loader readonly="yes" type="pflash">/usr/share/edk2/ovmf-ia32/OVMF_CODE.fd</loader>
|
||||
<boot dev="network"/>
|
||||
</os>
|
||||
@ -63,7 +63,7 @@
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="i686">hvm</type>
|
||||
<type arch="i686" machine="pc">hvm</type>
|
||||
<loader readonly="yes" type="pflash">/usr/share/edk2/ovmf-ia32/OVMF_CODE.fd</loader>
|
||||
<boot dev="network"/>
|
||||
</os>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="network"/>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
@ -76,7 +76,7 @@
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="network"/>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
@ -76,7 +76,7 @@
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="cdrom"/>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
@ -84,7 +84,7 @@
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="cdrom"/>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
@ -74,7 +74,7 @@
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<kernel>/tmp/virtinst-vmlinuz.</kernel>
|
||||
<initrd>/tmp/virtinst-initrd.img.</initrd>
|
||||
</os>
|
||||
@ -67,7 +67,7 @@
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu placement="static">4</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
</os>
|
||||
<features>
|
||||
<acpi/>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="i686">hvm</type>
|
||||
<type arch="i686" machine="pc">hvm</type>
|
||||
<boot dev="network"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="cdrom"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<partition>/virtualmachines/production</partition>
|
||||
</resource>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<loader readonly="yes" type="pflash">/usr/share/OVMF/OVMF_CODE.fd</loader>
|
||||
<boot dev="hd"/>
|
||||
<smbios mode="emulate"/>
|
||||
|
@ -59,7 +59,7 @@
|
||||
</sysinfo>
|
||||
<bootloader>/new/bootld</bootloader>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<loader>/foo/bar</loader>
|
||||
<boot dev="network"/>
|
||||
<smbios mode="sysinfo"/>
|
||||
@ -237,7 +237,7 @@
|
||||
</sysinfo>
|
||||
<bootloader>/new/bootld</bootloader>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<loader>/foo/bar</loader>
|
||||
<boot dev="cdrom"/>
|
||||
<boot dev="fd"/>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>1048576</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<loader type="pflash">CODE.fd</loader>
|
||||
<nvram template="VARS.fd"/>
|
||||
<boot dev="cdrom"/>
|
||||
@ -79,7 +79,7 @@
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<loader type="pflash">CODE.fd</loader>
|
||||
<nvram template="VARS.fd"/>
|
||||
<boot dev="hd"/>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>524288</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<currentMemory>795648</currentMemory>
|
||||
<vcpu>3</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<currentMemory>795648</currentMemory>
|
||||
<vcpu>3</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<currentMemory>1048576</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>4194304</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>4194304</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>524288</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="cdrom"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>204800</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>524288</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>524288</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>524288</currentMemory>
|
||||
<vcpu>2</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64">hvm</type>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>204800</currentMemory>
|
||||
<vcpu>5</vcpu>
|
||||
<os>
|
||||
<type arch="i686">hvm</type>
|
||||
<type arch="i686" machine="pc">hvm</type>
|
||||
<boot dev="cdrom"/>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<currentMemory>204800</currentMemory>
|
||||
<vcpu>5</vcpu>
|
||||
<os>
|
||||
<type arch="i686">hvm</type>
|
||||
<type arch="i686" machine="pc">hvm</type>
|
||||
<boot dev="cdrom"/>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
|
@ -110,32 +110,27 @@ class Guest(XMLBuilder):
|
||||
@staticmethod
|
||||
def get_recommended_machine(capsinfo):
|
||||
"""
|
||||
Return the recommended machine type for the passed capsinfo
|
||||
Return the recommended machine type for the passed capsinfo.
|
||||
We only return this for arch cases where there's a very clear
|
||||
preference that's different from the default machine type
|
||||
"""
|
||||
# For any other HV just let libvirt get us the default, these
|
||||
# are the only ones we've tested.
|
||||
if (not capsinfo.conn.is_test() and
|
||||
not capsinfo.conn.is_qemu() and
|
||||
not capsinfo.conn.is_xen()):
|
||||
return None
|
||||
def _qemu_machine():
|
||||
if (capsinfo.arch in ["ppc64", "ppc64le"] and
|
||||
"pseries" in capsinfo.machines):
|
||||
return "pseries"
|
||||
|
||||
if capsinfo.conn.is_xen() and len(capsinfo.machines):
|
||||
return capsinfo.machines[0]
|
||||
if capsinfo.arch in ["armv7l", "aarch64"]:
|
||||
if "virt" in capsinfo.machines:
|
||||
return "virt"
|
||||
if "vexpress-a15" in capsinfo.machines:
|
||||
return "vexpress-a15"
|
||||
|
||||
if (capsinfo.arch in ["ppc64", "ppc64le"] and
|
||||
"pseries" in capsinfo.machines):
|
||||
return "pseries"
|
||||
|
||||
if capsinfo.arch in ["armv7l", "aarch64"]:
|
||||
if "virt" in capsinfo.machines:
|
||||
return "virt"
|
||||
if "vexpress-a15" in capsinfo.machines:
|
||||
return "vexpress-a15"
|
||||
|
||||
if capsinfo.arch in ["s390x"]:
|
||||
if "s390-ccw-virtio" in capsinfo.machines:
|
||||
return "s390-ccw-virtio"
|
||||
if capsinfo.arch in ["s390x"]:
|
||||
if "s390-ccw-virtio" in capsinfo.machines:
|
||||
return "s390-ccw-virtio"
|
||||
|
||||
if capsinfo.conn.is_qemu() or capsinfo.conn.is_test():
|
||||
return _qemu_machine()
|
||||
return None
|
||||
|
||||
|
||||
@ -451,7 +446,12 @@ class Guest(XMLBuilder):
|
||||
self.uuid = util.generate_uuid(self.conn)
|
||||
if not self.vcpus:
|
||||
self.vcpus = 1
|
||||
|
||||
self.set_capabilities_defaults()
|
||||
if not self.os.machine:
|
||||
capsinfo = self.lookup_capsinfo()
|
||||
default = capsinfo.machines and capsinfo.machines[0] or None
|
||||
self.os.machine = default
|
||||
|
||||
self._add_default_graphics()
|
||||
self._add_default_video_device()
|
||||
|
Loading…
Reference in New Issue
Block a user