Skip to content

Commit

Permalink
qemu: Support for arm64/aarch64
Browse files Browse the repository at this point in the history
This pull request defines aarch64 (arm64) machine. Currently it doesn't
support any buses except the 'virtio-bus', thus more intrusive changes
were necessarily.

1) machine_type=virt, cpu_model=host, vga=none, usbs=none
2) instead of "virtio-*-pci" devices, "virtio-*-device" are used
   without the possibility of setting address.
3) AAVMF EFI bios is copied from installed location (/usr/share/AAVMF)
4) When provided install CD doesn't contain 'isolinux' directory,
   non-bootable CD is created. This works fine with UEFI boot.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
  • Loading branch information
ldoktor committed Feb 28, 2015
1 parent 510f495 commit 65ca64c
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 20 deletions.
12 changes: 12 additions & 0 deletions shared/cfg/guest-hw.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ variants:
# Device selection for the NDISTest server machine
dp_regex_servermsgdev = VirtIO Ethernet Adapter$
dp_regex_serversupportdev = VirtIO Ethernet Adapter #2$
arm64:
# Currently arm only supports virtio-net-device
nic_model = virtio-net-device
# Currently arm does not support msix vectors
enable_msix_vectors = no
- xennet:
# placeholder
- spapr-vlan:
Expand Down Expand Up @@ -62,6 +67,13 @@ variants:
# Add -drive ...boot=yes unless qemu-kvm is 0.12.1.2 or newer
# then kvm_vm will ignore this option.
image_boot=yes
arm64:
# Direct usage of virtio-blk-device (using mmio transports) is used
# on arm64.
drive_format=virtio-blk-device
image_boot=yes
cd_format = scsi-cd
scsi_hba = virtio-scsi-device
- virtio_scsi:
no WinXP
# supported formats are: scsi-hd, scsi-cd, scsi-disk, scsi-block,
Expand Down
12 changes: 12 additions & 0 deletions shared/cfg/machines.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,15 @@ variants:
usb_type = pci-ohci
usb_type_usb1 = pci-ohci
usb_controller_tablet1 = ohci
- @arm64:
only aarch64
auto_cpu_model = "no"
cpu_model = host
machine_type = virt
# No support for VGA yet
vga = none
inactivity_watcher = none
take_regular_screendumps = no
# Currently no USB support
usbs =
usb_devices =
14 changes: 14 additions & 0 deletions virttest/qemu_devices/qbuses.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,20 @@ def _update_device_props(self, device, addr):
self._set_device_props(device, addr)


class QNoAddrCustomBus(QSparseBus):

"""
This is the opposite of QStrictCustomBus. Even when addr is set it's not
updated in the device's params.
"""

def _set_device_props(self, device, addr):
pass

def _update_device_props(self, device, addr):
pass


class QUSBBus(QSparseBus):

"""
Expand Down
68 changes: 57 additions & 11 deletions virttest/qemu_devices/qcontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import os
import qbuses
import qdevices
import shutil


#
Expand Down Expand Up @@ -817,6 +818,42 @@ def machine_i440FX(cmd=False):
)
return devices

def machine_aarch64(cmd=False):
"""
aarch64 (arm64) doesn't support PCI bus, only MMIO transports.
Also it requires pflash for EFI boot.
:param cmd: If set uses "-M $cmd" to force this machine type
:return: List of added devices (including default buses)
"""
logging.warn('Support for aarch64 is highly experimental!')
devices = []
devices.append(qdevices.QStringDevice('machine', cmdline=cmd))
# EFI pflash
aavmf_code = ("-drive file=/usr/share/AAVMF/AAVMF_CODE.fd,"
"if=pflash,format=raw,unit=0,readonly=on")
devices.append(qdevices.QStringDevice('AAVMF_CODE',
cmdline=aavmf_code))
aavmf_vars = os.path.join(data_dir.DATA_DIR, 'images',
'%s_AAVMF_VARS.fd' % self.vmname)
if not os.path.exists(aavmf_vars):
shutil.copy2('/usr/share/AAVMF/AAVMF_VARS.fd', aavmf_vars)
aavmf_vars = ("-drive file=%s,if=pflash,format=raw,unit=1"
% aavmf_vars)
devices.append(qdevices.QStringDevice('AAVMF_VARS',
cmdline=aavmf_vars))
# Add virtio-bus
# TODO: Currently this uses QNoAddrCustomBus and does not
# set the device's properties. This means that the qemu qtree
# and autotest's representations are completelly different and
# can't be used.
bus = qbuses.QNoAddrCustomBus('bus', [['addr'], [32]],
'virtio-mmio-bus', 'virtio-bus',
'virtio-mmio-bus')
devices.append(qdevices.QStringDevice('machine', cmdline=cmd,
child_bus=bus,
aobject="virtio-mmio-bus"))
return devices

def machine_other(cmd=False):
"""
isapc or unknown machine type. This type doesn't add any default
Expand All @@ -843,6 +880,8 @@ def machine_other(cmd=False):
cmd = ""
if 'q35' in machine_type: # Q35 + ICH9
devices = machine_q35(cmd)
elif arch.ARCH == 'aarch64':
devices = machine_aarch64(cmd)
elif 'isapc' not in machine_type: # i440FX
devices = machine_i440FX(cmd)
else: # isapc (or other)
Expand Down Expand Up @@ -1050,8 +1089,8 @@ def images_define_by_variables(self, name, filename, index=None, fmt=None,
:param num_queues: performace option for virtio-scsi-pci
:param bus_extra_params: options want to add to virtio-scsi-pci bus
"""
def define_hbas(qtype, atype, bus, unit, port, qbus, addr_spec=None,
pci_bus='pci.0', num_queues=None,
def define_hbas(qtype, atype, bus, unit, port, qbus, pci_bus,
addr_spec=None, num_queues=None,
bus_extra_params=None):
"""
Helper for creating HBAs of certain type.
Expand Down Expand Up @@ -1082,14 +1121,14 @@ def define_hbas(qtype, atype, bus, unit, port, qbus, addr_spec=None,
bus_params[key] = value
if addr_spec:
dev = qdevices.QDevice(params=bus_params,
parent_bus={'aobject': pci_bus},
parent_bus=pci_bus,
child_bus=qbus(busid=bus_name,
bus_type=qtype,
addr_spec=addr_spec,
atype=atype))
else:
dev = qdevices.QDevice(params=bus_params,
parent_bus={'aobject': pci_bus},
parent_bus=pci_bus,
child_bus=qbus(busid=bus_name))
devices.append(dev)
bus = _hba % bus
Expand Down Expand Up @@ -1152,6 +1191,8 @@ def define_hbas(qtype, atype, bus, unit, port, qbus, addr_spec=None,
"(disk %s)", name)
bus = none_or_int(pci_addr)

pci_bus = {'aobject': pci_bus}

#
# HBA
# fmt: ide, scsi, virtio, scsi-hd, ahci, usb1,2,3 + hba
Expand All @@ -1169,10 +1210,10 @@ def define_hbas(qtype, atype, bus, unit, port, qbus, addr_spec=None,
# In case we hotplug, lsi wasn't added during the startup hook
if arch.ARCH == 'ppc64':
_ = define_hbas('SCSI', 'spapr-vscsi', None, None, None,
qbuses.QSCSIBus, [8, 16384])
qbuses.QSCSIBus, pci_bus, [8, 16384])
else:
_ = define_hbas('SCSI', 'lsi53c895a', None, None, None,
qbuses.QSCSIBus, [8, 16384])
qbuses.QSCSIBus, pci_bus, [8, 16384])
devices.extend(_[0])
elif fmt == "ide":
if bus:
Expand All @@ -1182,7 +1223,7 @@ def define_hbas(qtype, atype, bus, unit, port, qbus, addr_spec=None,
dev_parent = {'type': 'IDE', 'atype': 'ide'}
elif fmt == "ahci":
devs, bus, dev_parent = define_hbas('IDE', 'ahci', bus, unit, port,
qbuses.QAHCIBus)
qbuses.QAHCIBus, pci_bus)
devices.extend(devs)
elif fmt.startswith('scsi-'):
if not scsi_hba:
Expand All @@ -1194,9 +1235,12 @@ def define_hbas(qtype, atype, bus, unit, port, qbus, addr_spec=None,
addr_spec = [8, 16384]
elif scsi_hba == 'virtio-scsi-pci':
addr_spec = [256, 16384]
elif scsi_hba == 'virtio-scsi-device':
addr_spec = [256, 16384]
pci_bus = {'type': 'virtio-bus'}
_, bus, dev_parent = define_hbas('SCSI', scsi_hba, bus, unit, port,
qbuses.QSCSIBus, addr_spec,
num_queues=num_queues,
qbuses.QSCSIBus, pci_bus,
addr_spec, num_queues=num_queues,
bus_extra_params=bus_extra_params)
devices.extend(_)
elif fmt in ('usb1', 'usb2', 'usb3'):
Expand All @@ -1211,7 +1255,9 @@ def define_hbas(qtype, atype, bus, unit, port, qbus, addr_spec=None,
elif fmt == 'usb3':
dev_parent = {'type': 'xhci'}
elif fmt == 'virtio':
dev_parent = {'aobject': pci_bus}
dev_parent = pci_bus
elif fmt == 'virtio-blk-device':
dev_parent = {'type': 'virtio-bus'}
else:
dev_parent = {'type': fmt}

Expand Down Expand Up @@ -1274,7 +1320,7 @@ def define_hbas(qtype, atype, bus, unit, port, qbus, addr_spec=None,
devices[-1].parent_bus = ({'type': fmt},)
elif fmt == 'virtio':
devices[-1].set_param('addr', pci_addr)
devices[-1].parent_bus = ({'aobject': pci_bus},)
devices[-1].parent_bus = (pci_bus,)
if not media == 'cdrom':
logging.warn("Using -drive fmt=xxx for %s is unsupported "
"method, false errors might occur.", name)
Expand Down
7 changes: 5 additions & 2 deletions virttest/qemu_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@ def add_qmp_monitor(devices, monitor_name, filename):
return cmd

def add_serial(devices, name, filename):
if arch.ARCH == 'ppc64' or not devices.has_option("chardev"):
if (arch.ARCH in ('ppc64', 'aarch64') or
not devices.has_option("chardev")):
return " -serial unix:'%s',server,nowait" % filename

serial_id = "serial_id_%s" % name
Expand Down Expand Up @@ -540,7 +541,9 @@ def add_nic(devices, vlan, model=None, mac=None, device_id=None,
# libvirt gains the pci_slot, free_pci_addr here,
# value by parsing the xml file, i.e. counting all the
# pci devices and store the number.
if model != 'spapr-vlan':
if model == 'virtio-net-device':
dev.parent_bus = {'type': 'virtio-bus'}
elif model != 'spapr-vlan':
dev.parent_bus = pci_bus
dev.set_param('addr', pci_addr)
if nic_extra_params:
Expand Down
21 changes: 14 additions & 7 deletions virttest/utils_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,20 @@ def get_answer_file_path(self, filename):
@error.context_aware
def close(self):
error.context("Creating unattended install CD image %s" % self.path)
f = open(os.path.join(self.mount, 'isolinux', 'isolinux.cfg'), 'w')
f.write('default /isolinux/vmlinuz append initrd=/isolinux/initrd.img '
'%s\n' % self.extra_params)
f.close()
m_cmd = ('mkisofs -o %s -b isolinux/isolinux.bin -c isolinux/boot.cat '
'-no-emul-boot -boot-load-size 4 -boot-info-table -f -R -J '
'-V -T %s' % (self.path, self.mount))
if os.path.exists(os.path.join(self.mount, 'isolinux')):
# bootable cdrom
f = open(os.path.join(self.mount, 'isolinux', 'isolinux.cfg'), 'w')
f.write('default /isolinux/vmlinuz append initrd=/isolinux/'
'initrd.img %s\n' % self.extra_params)
f.close()
boot = '-b isolinux/isolinux.bin'
else:
# Not a bootable CDROM, using -kernel instead (eg.: arm64)
boot = ''

m_cmd = ('mkisofs -o %s %s -c isolinux/boot.cat -no-emul-boot '
'-boot-load-size 4 -boot-info-table -f -R -J -V -T %s'
% (self.path, boot, self.mount))
utils.run(m_cmd)
os.chmod(self.path, 0755)
cleanup(self.mount)
Expand Down

0 comments on commit 65ca64c

Please sign in to comment.