Use -M virt as default machine for arm/aarch64

Centralize the default machine logic in caps and use it consistently
This commit is contained in:
Cole Robinson 2014-09-23 16:05:48 -04:00
parent 0182ba3ead
commit c4162f6708
8 changed files with 81 additions and 14 deletions

View File

@ -5,7 +5,7 @@
<currentMemory>65536</currentMemory> <currentMemory>65536</currentMemory>
<vcpu>1</vcpu> <vcpu>1</vcpu>
<os> <os>
<type arch="aarch64">hvm</type> <type arch="aarch64" machine="virt">hvm</type>
<kernel>/f19-arm.kernel</kernel> <kernel>/f19-arm.kernel</kernel>
<initrd>/f19-arm.initrd</initrd> <initrd>/f19-arm.initrd</initrd>
<cmdline>console=ttyAMA0,1234 rw root=/dev/vda3</cmdline> <cmdline>console=ttyAMA0,1234 rw root=/dev/vda3</cmdline>
@ -24,11 +24,12 @@
<disk type="file" device="disk"> <disk type="file" device="disk">
<driver name="qemu" type="qcow2"/> <driver name="qemu" type="qcow2"/>
<source file="/dev/default-pool/testvol1.img"/> <source file="/dev/default-pool/testvol1.img"/>
<target dev="sda" bus="sd"/> <target dev="vda" bus="virtio"/>
</disk> </disk>
<interface type="bridge"> <interface type="bridge">
<source bridge="eth0"/> <source bridge="eth0"/>
<mac address="00:11:22:33:44:55"/> <mac address="00:11:22:33:44:55"/>
<model type="virtio"/>
</interface> </interface>
<console type="pty"/> <console type="pty"/>
</devices> </devices>

View File

@ -5,7 +5,7 @@
<currentMemory>65536</currentMemory> <currentMemory>65536</currentMemory>
<vcpu>1</vcpu> <vcpu>1</vcpu>
<os> <os>
<type arch="armv7l">hvm</type> <type arch="armv7l" machine="virt">hvm</type>
<kernel>/f19-arm.kernel</kernel> <kernel>/f19-arm.kernel</kernel>
<initrd>/f19-arm.initrd</initrd> <initrd>/f19-arm.initrd</initrd>
<cmdline>console=ttyAMA0,1234 rw root=/dev/vda3</cmdline> <cmdline>console=ttyAMA0,1234 rw root=/dev/vda3</cmdline>
@ -24,11 +24,12 @@
<disk type="file" device="disk"> <disk type="file" device="disk">
<driver name="qemu" type="qcow2"/> <driver name="qemu" type="qcow2"/>
<source file="/dev/default-pool/testvol1.img"/> <source file="/dev/default-pool/testvol1.img"/>
<target dev="sda" bus="sd"/> <target dev="vda" bus="virtio"/>
</disk> </disk>
<interface type="bridge"> <interface type="bridge">
<source bridge="eth0"/> <source bridge="eth0"/>
<mac address="00:11:22:33:44:55"/> <mac address="00:11:22:33:44:55"/>
<model type="virtio"/>
</interface> </interface>
<console type="pty"/> <console type="pty"/>
</devices> </devices>

View File

@ -0,0 +1,42 @@
<domain type="qemu">
<name>foobar</name>
<uuid>00000000-1111-2222-3333-444444444444</uuid>
<memory>65536</memory>
<currentMemory>65536</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch="ppc64" machine="pseries">hvm</type>
<boot dev="network"/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset="utc"/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-ppc64</emulator>
<disk type="file" device="disk">
<driver name="qemu" type="qcow2"/>
<source file="/dev/default-pool/testvol1.img"/>
<target dev="sda" bus="scsi"/>
</disk>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<console type="pty"/>
<channel type="unix">
<source mode="bind"/>
<target type="virtio" name="org.qemu.guest_agent.0"/>
</channel>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>
</channel>
<video>
<model type="vga"/>
</video>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
</devices>
</domain>

View File

@ -526,6 +526,7 @@ c.add_compare("--arch armv7l --boot kernel=/f19-arm.kernel,initrd=/f19-arm.initr
c.add_compare("--arch aarch64 --machine virt --boot kernel=/f19-arm.kernel,initrd=/f19-arm.initrd,kernel_args=\"console=ttyAMA0,1234 rw root=/dev/vda3\",extra_args=foo --disk %(EXISTIMG1)s", "aarch64-machvirt") c.add_compare("--arch aarch64 --machine virt --boot kernel=/f19-arm.kernel,initrd=/f19-arm.initrd,kernel_args=\"console=ttyAMA0,1234 rw root=/dev/vda3\",extra_args=foo --disk %(EXISTIMG1)s", "aarch64-machvirt")
c.add_compare("--arch aarch64 --boot kernel=/f19-arm.kernel,initrd=/f19-arm.initrd,kernel_args=\"console=ttyAMA0,1234 rw root=/dev/vda3\",extra_args=foo --disk %(EXISTIMG1)s", "aarch64-machdefault") c.add_compare("--arch aarch64 --boot kernel=/f19-arm.kernel,initrd=/f19-arm.initrd,kernel_args=\"console=ttyAMA0,1234 rw root=/dev/vda3\",extra_args=foo --disk %(EXISTIMG1)s", "aarch64-machdefault")
c.add_compare("--arch ppc64 --machine pseries --boot network --disk %(EXISTIMG1)s --os-variant fedora20 --network none", "ppc64-pseries-f20") c.add_compare("--arch ppc64 --machine pseries --boot network --disk %(EXISTIMG1)s --os-variant fedora20 --network none", "ppc64-pseries-f20")
c.add_compare("--arch ppc64 --boot network --disk %(EXISTIMG1)s --os-variant fedora20 --network none", "ppc64-machdefault-f20")
c.add_compare("--disk none --location /tmp/fake.iso --nonetworks", "location-iso") # Using --location iso mounting c.add_compare("--disk none --location /tmp/fake.iso --nonetworks", "location-iso") # Using --location iso mounting
c.add_compare("--disk %(EXISTIMG1)s --pxe --os-variant rhel6.4", "kvm-rhel6") # RHEL6 defaults 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") # RHEL7 defaults c.add_compare("--disk %(EXISTIMG1)s --pxe --os-variant rhel7.0", "kvm-rhel7") # RHEL7 defaults

View File

@ -360,7 +360,6 @@ def get_guest(conn, options):
typ=req_hv_type, typ=req_hv_type,
machine=options.machine) machine=options.machine)
guest = conn.caps.build_virtinst_guest(conn, capsguest, capsdomain) guest = conn.caps.build_virtinst_guest(conn, capsguest, capsdomain)
guest.os.machine = options.machine
except Exception, e: except Exception, e:
fail(e) fail(e)

View File

@ -717,12 +717,11 @@ class vmmCreate(vmmGObjectUI):
defmachine = None defmachine = None
prios = [] prios = []
if self.capsguest.arch == "armv7l": recommended_machine = self.capsdomain.get_recommended_machine(
defmachine = "vexpress-a9" self.conn.get_backend(), self.capsguest)
prios = ["vexpress-a9", "vexpress-a15", "highbank", "midway"] if recommended_machine:
elif self.capsguest.arch == "ppc64": defmachine = recommended_machine
defmachine = "pseries" prios = [defmachine]
prios = ["pseries"]
for p in prios[:]: for p in prios[:]:
if p not in machines: if p not in machines:

View File

@ -360,10 +360,15 @@ class Guest(object):
def bestDomainType(self, dtype=None, machine=None): def bestDomainType(self, dtype=None, machine=None):
domains = [] domains = []
for d in self.domains: for d in self.domains:
d.set_recommended_machine(None)
if dtype and d.hypervisor_type != dtype.lower(): if dtype and d.hypervisor_type != dtype.lower():
continue continue
if machine and machine not in d.machines: if machine and machine not in d.machines:
continue continue
if machine:
d.set_recommended_machine(machine)
domains.append(d) domains.append(d)
return self._favoredDomain(domains) return self._favoredDomain(domains)
@ -378,9 +383,30 @@ class Domain(object):
self.loader = loader self.loader = loader
self.machines = machines self.machines = machines
self._recommended_machine = None
if node is not None: if node is not None:
self.parseXML(node) self.parseXML(node)
def get_recommended_machine(self, conn, capsguest):
if self._recommended_machine:
return self._recommended_machine
if not conn.is_test() and not conn.is_qemu():
return None
if capsguest.arch == "ppc64" and "pseries" in self.machines:
return "pseries"
if capsguest.arch in ["armv7l", "aarch64"]:
if "virt" in self.machines:
return "virt"
if "vexpress-a15" in self.machines:
return "vexpress-a15"
return None
def set_recommended_machine(self, machine):
self._recommended_machine = machine
def parseXML(self, node): def parseXML(self, node):
child = node.children child = node.children
@ -695,5 +721,6 @@ class Capabilities(object):
gobj.os.arch = guest.arch gobj.os.arch = guest.arch
gobj.os.loader = domain.loader gobj.os.loader = domain.loader
gobj.emulator = domain.emulator gobj.emulator = domain.emulator
gobj.os.machine = domain.get_recommended_machine(conn, guest)
return gobj return gobj

View File

@ -686,9 +686,6 @@ class Guest(XMLBuilder):
if self.os.kernel or self.os.init: if self.os.kernel or self.os.init:
self.os.bootorder = [] self.os.bootorder = []
if (self.os.machine is None and self.os.is_ppc64()):
self.os.machine = "pseries"
def _set_clock_defaults(self): def _set_clock_defaults(self):
if not self.os.is_hvm(): if not self.os.is_hvm():
return return