Fix qemu-vexpress and qemu-aarch64 (#1029)

* Don't ask for the mesa driver when the Qemu arch is not the
  native arch and always use swrast in that case
* qemu-vexpress: use LTS kernel
* qemu-aarch64: use drm-backend for weston
This commit is contained in:
Oliver Smith 2018-01-08 15:18:37 +00:00 committed by GitHub
parent fd67263c27
commit 12340fe5f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 66 additions and 32 deletions

View file

@ -1,14 +1,15 @@
pkgname=device-qemu-aarch64 pkgname=device-qemu-aarch64
pkgver=1 pkgver=1
pkgrel=8 pkgrel=9
pkgdesc="Simulated device in qemu with vexpress soc" pkgdesc="Simulated device in qemu with vexpress soc"
url="https://github.com/postmarketOS" url="https://github.com/postmarketOS"
arch="noarch" arch="noarch"
license="MIT" license="MIT"
depends="linux-postmarketos-stable mesa-dri-swrast" # NOTE: 'pmbootstrap init' allows you to choose the mesa-dri-* package
depends="linux-postmarketos-stable"
makedepends="" makedepends=""
subpackages="" subpackages="$pkgname-weston"
source="deviceinfo interfaces" source="deviceinfo interfaces weston.ini"
options="!check" options="!check"
package() { package() {
@ -18,5 +19,13 @@ package() {
"$pkgdir"/etc/network/interfaces "$pkgdir"/etc/network/interfaces
} }
weston() {
install_if="$pkgname weston"
install -Dm644 "$srcdir"/weston.ini \
"$subpkgdir"/etc/xdg/weston/weston.ini
}
sha512sums="8802ad301bffd10d79db938adecf4bbdf8293c8caefe5fce753c56f228a7212330318a0be9853a83442e8971bbc235269796fe66077c501d35a935df1d2ed90c deviceinfo sha512sums="8802ad301bffd10d79db938adecf4bbdf8293c8caefe5fce753c56f228a7212330318a0be9853a83442e8971bbc235269796fe66077c501d35a935df1d2ed90c deviceinfo
d510ca304066840aa5e6c4fc71ded1b7e83012c93837fa39e37bdb873b3636230030d56f7aa50c93fc688f563cb4cb96c02ad333bbc45a400c1ebee1792a9dd4 interfaces" d510ca304066840aa5e6c4fc71ded1b7e83012c93837fa39e37bdb873b3636230030d56f7aa50c93fc688f563cb4cb96c02ad333bbc45a400c1ebee1792a9dd4 interfaces
df0fe900693e5f176076c59f5379e56aaa96c3df16a4120448f15b71f530170730b43e5fe32733c40c118a00ca3581043231a062a8a1eb0a930bfbfbb6c52a47 weston.ini"

View file

@ -0,0 +1,3 @@
[core]
xwayland=true
backend=drm-backend.so

View file

@ -1,11 +1,12 @@
pkgname=device-qemu-vexpress pkgname=device-qemu-vexpress
pkgver=1 pkgver=1
pkgrel=15 pkgrel=16
pkgdesc="Simulated device in qemu with vexpress soc" pkgdesc="Simulated device in qemu with vexpress soc"
url="https://github.com/postmarketOS" url="https://github.com/postmarketOS"
arch="noarch" arch="noarch"
license="MIT" license="MIT"
depends="linux-postmarketos-stable mesa-dri-swrast" # NOTE: 'pmbootstrap init' allows you to choose the mesa-dri-* package
depends="linux-postmarketos-lts"
makedepends="" makedepends=""
subpackages="" subpackages=""
source="deviceinfo interfaces" source="deviceinfo interfaces"

View file

@ -46,7 +46,7 @@ work_version = "1"
# Only save keys to the config file, which we ask for in 'pmbootstrap init'. # Only save keys to the config file, which we ask for in 'pmbootstrap init'.
config_keys = ["ccache_size", "device", "extra_packages", "jobs", "keymap", config_keys = ["ccache_size", "device", "extra_packages", "jobs", "keymap",
"qemu_mesa_driver", "timestamp_based_rebuild", "timezone", "qemu_native_mesa_driver", "timestamp_based_rebuild", "timezone",
"ui", "user", "work"] "ui", "user", "work"]
# Config file/commandline default values # Config file/commandline default values
@ -72,7 +72,7 @@ defaults = {
"mirror_alpine": "http://dl-cdn.alpinelinux.org/alpine/", "mirror_alpine": "http://dl-cdn.alpinelinux.org/alpine/",
"mirror_postmarketos": "http://postmarketos.brixit.nl", "mirror_postmarketos": "http://postmarketos.brixit.nl",
"port_distccd": "33632", "port_distccd": "33632",
"qemu_mesa_driver": "dri-virtio", "qemu_native_mesa_driver": "dri-virtio",
"timestamp_based_rebuild": True, "timestamp_based_rebuild": True,
"timezone": "GMT", "timezone": "GMT",
"ui": "weston", "ui": "weston",
@ -383,4 +383,4 @@ aportgen = {
# #
# QEMU # QEMU
# #
qemu_mesa_drivers = ["dri-swrast", "dri-virtio"] qemu_native_mesa_drivers = ["dri-swrast", "dri-virtio"]

View file

@ -81,7 +81,7 @@ def ask_for_ui(args):
def ask_for_keymaps(args, device): def ask_for_keymaps(args, device):
info = pmb.parse.deviceinfo(args, device=device) info = pmb.parse.deviceinfo(args, device)
if "keymaps" not in info or info["keymaps"].strip() == "": if "keymaps" not in info or info["keymaps"].strip() == "":
return "" return ""
options = info["keymaps"].split(' ') options = info["keymaps"].split(' ')
@ -147,18 +147,23 @@ def ask_for_device(args):
return (device, device_exists) return (device, device_exists)
def ask_for_qemu_mesa_driver(args): def ask_for_qemu_native_mesa_driver(args, device, arch_native):
drivers = pmb.config.qemu_mesa_drivers # Native Qemu device selected? (e.g. qemu-amd64 on x86_64)
logging.info("Which mesa driver do you prefer for your Qemu device? Only" if not pmb.parse.arch.qemu_check_device(device, arch_native):
" select something other than the default if you are having" return None
" graphical problems (such as glitches).")
drivers = pmb.config.qemu_native_mesa_drivers
logging.info("Which mesa driver do you prefer for your native Qemu device?"
" Only select something other than the default if you are"
" having graphical problems (such as glitches).")
while True: while True:
ret = pmb.helpers.cli.ask(args, "Mesa driver", drivers, ret = pmb.helpers.cli.ask(args, "Mesa driver", drivers,
args.qemu_mesa_driver) args.qemu_native_mesa_driver)
if ret in drivers: if ret in drivers:
return ret return ret
logging.fatal("ERROR: Please specify a driver from the list. To change" logging.fatal("ERROR: Please specify a driver from the list. To change"
" it, see qemu_mesa_drivers in pmb/config/__init__.py.") " it, see qemu_native_mesa_drivers in"
" pmb/config/__init__.py.")
def ask_for_build_options(args, cfg): def ask_for_build_options(args, cfg):
@ -205,16 +210,18 @@ def frontend(args):
cfg["pmbootstrap"]["work"] = args.work = ask_for_work_path(args) cfg["pmbootstrap"]["work"] = args.work = ask_for_work_path(args)
# Device # Device
cfg["pmbootstrap"]["device"], device_exists = ask_for_device(args) device, device_exists = ask_for_device(args)
cfg["pmbootstrap"]["device"] = device
# Qemu mesa driver # Qemu mesa driver
if cfg["pmbootstrap"]["device"].startswith("qemu-"): if cfg["pmbootstrap"]["device"].startswith("qemu-"):
cfg["pmbootstrap"]["qemu_mesa_driver"] = ask_for_qemu_mesa_driver(args) driver = ask_for_qemu_native_mesa_driver(args, device, args.arch_native)
if driver:
cfg["pmbootstrap"]["qemu_native_mesa_driver"] = driver
# Device keymap # Device keymap
if device_exists: if device_exists:
cfg["pmbootstrap"]["keymap"] = ask_for_keymaps( cfg["pmbootstrap"]["keymap"] = ask_for_keymaps(args, device)
args, device=cfg["pmbootstrap"]["device"])
# Username # Username
cfg["pmbootstrap"]["user"] = pmb.helpers.cli.ask(args, "Username", None, cfg["pmbootstrap"]["user"] = pmb.helpers.cli.ask(args, "Username", None,
@ -243,8 +250,8 @@ def frontend(args):
if (device_exists and if (device_exists and
len(glob.glob(args.work + "/chroot_*")) and len(glob.glob(args.work + "/chroot_*")) and
pmb.helpers.cli.confirm(args, "Zap existing chroots to apply configuration?", default=True)): pmb.helpers.cli.confirm(args, "Zap existing chroots to apply configuration?", default=True)):
setattr(args, "deviceinfo", pmb.parse.deviceinfo( setattr(args, "deviceinfo", pmb.parse.deviceinfo(args, device=device))
args, device=cfg["pmbootstrap"]["device"]))
# Do not zap any existing packages or cache_http directories # Do not zap any existing packages or cache_http directories
pmb.chroot.zap(args, confirm=False) pmb.chroot.zap(args, confirm=False)

View file

@ -308,7 +308,7 @@ def install(args):
if args.add: if args.add:
install_packages += args.add.split(",") install_packages += args.add.split(",")
if args.device.startswith("qemu-"): if args.device.startswith("qemu-"):
install_packages += ["mesa-" + args.qemu_mesa_driver] install_packages += ["mesa-" + args.qemu_native_mesa_driver]
for pkgname in install_packages: for pkgname in install_packages:
pmb.build.package(args, pkgname, args.deviceinfo["arch"]) pmb.build.package(args, pkgname, args.deviceinfo["arch"])

View file

@ -159,3 +159,16 @@ def qemu_to_pmos_device(arch):
raise ValueError("Can not map QEMU value '" + arch + "'" raise ValueError("Can not map QEMU value '" + arch + "'"
" to the right postmarketOS device") " to the right postmarketOS device")
def qemu_check_device(device, arch):
"""
Check whether a device has a specific architecture.
Examples:
qemu_check_device("qemu-amd64", "x86_64") is True
qemu_check_device("qemu-vexpress", "armel") is True
qemu_check_device("qemu-vexpress", "aarch64") is False
"""
arch_qemu = uname_to_qemu(arch)
return device == qemu_to_pmos_device(arch_qemu)

View file

@ -157,12 +157,12 @@ def command_qemu(args, arch, device, img_path, spice_enabled):
raise RuntimeError("Architecture {} not supported by this command yet.".format(arch)) raise RuntimeError("Architecture {} not supported by this command yet.".format(arch))
# Kernel Virtual Machine (KVM) support # Kernel Virtual Machine (KVM) support
enable_kvm = True native = True
if args.arch: if args.arch:
arch1 = pmb.parse.arch.uname_to_qemu(args.arch_native) arch1 = pmb.parse.arch.uname_to_qemu(args.arch_native)
arch2 = pmb.parse.arch.uname_to_qemu(args.arch) arch2 = pmb.parse.arch.uname_to_qemu(args.arch)
enable_kvm = (arch1 == arch2) native = (arch1 == arch2)
if enable_kvm and os.path.exists("/dev/kvm"): if native and os.path.exists("/dev/kvm"):
command += ["-enable-kvm"] command += ["-enable-kvm"]
else: else:
logging.info("WARNING: Qemu is not using KVM and will run slower!") logging.info("WARNING: Qemu is not using KVM and will run slower!")
@ -174,7 +174,7 @@ def command_qemu(args, arch, device, img_path, spice_enabled):
"port=" + args.spice_port + ",addr=127.0.0.1" + "port=" + args.spice_port + ",addr=127.0.0.1" +
",disable-ticketing"] ",disable-ticketing"]
else: else:
if args.qemu_mesa_driver == "dri-virtio": if native and args.qemu_native_mesa_driver == "dri-virtio":
command += ["-vga", "virtio"] command += ["-vga", "virtio"]
command += ["-display", args.qemu_display] command += ["-display", args.qemu_display]

View file

@ -140,10 +140,11 @@ def test_questions(args, monkeypatch, tmpdir):
assert func(args, "nokia-rx51") == "us/rx51_us" assert func(args, "nokia-rx51") == "us/rx51_us"
assert func(args, "lg-mako") == "" assert func(args, "lg-mako") == ""
# Qemu mesa driver # Qemu native mesa driver
func = pmb.config.init.ask_for_qemu_mesa_driver func = pmb.config.init.ask_for_qemu_native_mesa_driver
answers = ["invalid_driver", "dri-swrast"] answers = ["invalid_driver", "dri-swrast"]
assert func(args) == "dri-swrast" assert func(args, "qemu-amd64", "x86_64") == "dri-swrast"
assert func(args, "qemu-aarch64", "x86_64") is None
# UI # UI
answers = ["invalid_UI", "weston"] answers = ["invalid_UI", "weston"]