Close #226: Launch postmarketOS in a qemu virtual machine (#350)

Thanks to Pablo Castellano and Martijn Braam!
In postmarketOS we are now able to generate system images with the
correct configuration so that they can boot already using qemu

This commit brings the `pmbootstrap qemu` action.
This command is very handy because you don't have to set all the
qemu parameters, pmbootstrap does it for you.

* device-qemu-vexpress: Added kernel command line according to wiki
* qemu: Added workaround for image writing permissions
* qemu: Added support to launch postmarketOS in a QEMU virtual machine

- Support for emulating these architectures in QEMU: arm, aarch64, x86_84
- Generate QEMU command correctly depending no guest architecture (arm/x86)
- Run QEMU in the same architecture as the host by default
- Refactoring in pmb.parse.arch and pmb.qemu.run
- Raise exception if DTB file or system image are not present
- Display more useful information when something fails (e.g. image not found)
- Run qemu version depending on arch (host or argument), not device configured

* device-qemu-amd64: set deviceinfo_kernel_cmdline to "PMOS_NO_OUTPUT_REDIRECT"
* qemu: added --memory argument to specific guest RAM
* device-qemu-amd64: adjusted deviceinfo_kernel_cmdline (console=tty1)
* Added /etc/network/interfaces for qemu-amd64
* qemu: Added KVM support if /dev/kvm if present
* Specify separate machines for architecture
* qemu: Check if QEMU is installed instead of crashing
* Added graphics driver to qemu-aarch64

- Use arm (as used in qemu) instead of armhf (used in Alpine)
- qemu argument is -dtb
- Follow same style to build the command + arguments

* qemu: Added SSH port redirection: ./pmbootstrap.py qemu -p 2222
This commit is contained in:
Pablo Castellano 2017-08-09 22:26:40 +02:00 committed by Oliver Smith
parent 96cb52847d
commit 49b35ad32d
16 changed files with 6202 additions and 11 deletions

View file

@ -120,3 +120,41 @@ def cpu_emulation_required(args, arch):
# No match: then it's required
return True
def uname_to_qemu(arch):
"""
Convert the most common architectures returned by 'uname' to those
used by the QEMU binary
"""
mapping = {
"aarch64": "aarch64",
"arm": "arm",
"armeb": "arm",
"armel": "arm",
"armhf": "arm",
"x86_64": "x86_64",
"amd64": "x86_64",
}
if arch in mapping:
return mapping[arch]
raise ValueError("Can not map host architecture '" + arch + "'"
" to the right QEMU value")
def qemu_to_pmos_device(arch):
"""
Convert the architecture used in the QEMU binary to the aport name in
postmarketOS defining the device
"""
mapping = {
"arm": "qemu-vexpress",
"aarch64": "qemu-aarch64",
"x86_64": "qemu-amd64",
}
if arch in mapping:
return mapping[arch]
raise ValueError("Can not map QEMU value '" + arch + "'"
" to the right postmarketOS device")