Jump to content

QEMU: Difference between revisions

From postmarketOS Wiki
Minecrell (talk | contribs)
m weird
m Reverted edits by Minecrell (talk) to last revision by IdanHoro
Tag: Rollback
Line 1: Line 1:
QEMU allows running postmarketOS in virtual machines. The following architectures are available:
=== Building and starting a QEMU image ===


* [[QEMU_amd64_(qemu-amd64)|QEMU for x86_64]]
<syntaxhighlight lang="shell-session">
* [[QEMU_aarch64_(qemu-aarch64)|QEMU for aarch64]]
$ pmbootstrap init  # Choose a qemu-* device (x86_64: amd64, arm: vexpress-soc)
 
$ pmbootstrap install
Note that running a virtual machine for a foreign architecture (e.g. aarch64 on x86_64) requires CPU emulation which is rather slow. Prefer the native architecture when possible.
$ pmbootstrap qemu --image-size=2G
 
</syntaxhighlight>
=== Phosh ===
By default, Phosh has the resolution hard-coded to 720x1440 (like the Librem 5), so the display is cut off on usual 1920x1080 (Full HD) monitors.
 
You can change the resolution by editing <code>/usr/share/phosh/phoc.ini</code>. By default it contains:
 
[output:Virtual-1]
# For the x86 VM using QXL to get a phone like geometry
modeline = 87.25  720 776 848 976  1440 1443 1453 1493 -hsync +vsync
mode = 720x1440
scale = 2


To add a new resolution, you need to add a new <code>modeline</code>, then change the <code>mode</code> (and eventually the <code>scale</code>). You can generate the modelines using the <code>cvt</code> tool.
''Note: The <code>amd64</code> version is recommended if you don't know which one to choose. See the device specific pages (links below) for the differences.''


For example, to set the resolution to qHD (540x960):
The <code>--image-size=2G</code> parameter will increase the image size to 2GB, so you don't instantly run out of space (by default the image size is as small as possible). Check out <code>pmbootstrap qemu --help</code> for more options, such as performance tweaks.


$ cvt -v 540 960
=== QEMU on Debian stretch ===
Warning: Aspect Ratio is not CVT standard.
{{note|This is only needed if you want to use <code>--host-qemu</code>, otherwise Alpine's QEMU will be used.}}
# 544x960 59.96 Hz (CVT) hsync: 59.72 kHz; pclk: 43.00 MHz
{{note|This also applies to '''Ubuntu''' Artful and below, Bionic likely will not have it enabled either - [https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1553999 Launchpad bug.]}}
Modeline "544x960_60.00"  43.00  544 576 632 720  960 963 973 996 -hsync +vsync


Note how it changed the horizontal resolution to <code>544</code> to match the CVT standard. Weird. Then add the new <code>modeline</code> and change <code>mode</code>:
QEMU on Debian does not include SDL-support by default. To use pmbootstrap on Debian you have to do the following:
 
# Ensure that /etc/apt/sources.list contains a deb-src line for Debian buster or later.
[output:Virtual-1]
# <code>sudo apt-get build-dep libvirglrenderer-dev/buster</code> (install build dependencies for libvirglrenderer)
# For the x86 VM using QXL to get a phone like geometry
# <code>fakeroot apt-get -b source libvirglrenderer-dev/buster</code> (download and build libvirglrenderer)
modeline = 87.25  720 776 848 976  1440 1443 1453 1493 -hsync +vsync
# <code>sudo dpkg -i libvirglrenderer0_0.6.0-2_amd64.deb libvirglrenderer-dev_0.6.0-2_amd64.deb</code> (install it)
modeline = 43.00  544 576 632 720  960 963 973 996 -hsync +vsync
# <code>sudo apt-get build-dep qemu/buster</code>
mode = 544x960
# <code>fakeroot apt-get -b source qemu/buster</code>
# Maybe it's a bit too large with scale 2 on this resolution? Or maybe not, just test it out :)
# Install the appropriate qemu Debian packages which have been created in the current directory.
scale = 1
 
Restart QEMU or <code>rc-service lightdm restart</code>, then Phosh should show up with the new resolution. Note that the <code>modeline</code> is necessary to support custom resolutions, you cannot just set the <code>mode</code>.


=== See also ===
=== See also ===
* [[QEMU_amd64_(qemu-amd64)|QEMU for x86_64]]
* [[QEMU_ARM_(qemu-vexpress)|QEMU for arm]]
* [[QEMU_aarch64_(qemu-aarch64)|QEMU for aarch64]]
* [[Troubleshooting:QEMU]]
* [[Troubleshooting:QEMU]]
* {{MR|1612}} Use Alpine's QEMU rather than host system QEMU
* {{MR|1612}} Use Alpine's QEMU rather than host system QEMU


[[Category:Technical Reference]]
[[Category:Technical Reference]]

Revision as of 15:47, 13 November 2022

Building and starting a QEMU image

$ pmbootstrap init  # Choose a qemu-* device (x86_64: amd64, arm: vexpress-soc)
$ pmbootstrap install
$ pmbootstrap qemu --image-size=2G

Note: The amd64 version is recommended if you don't know which one to choose. See the device specific pages (links below) for the differences.

The --image-size=2G parameter will increase the image size to 2GB, so you don't instantly run out of space (by default the image size is as small as possible). Check out pmbootstrap qemu --help for more options, such as performance tweaks.

QEMU on Debian stretch

Note This is only needed if you want to use --host-qemu, otherwise Alpine's QEMU will be used.
Note This also applies to Ubuntu Artful and below, Bionic likely will not have it enabled either - Launchpad bug.

QEMU on Debian does not include SDL-support by default. To use pmbootstrap on Debian you have to do the following:

  1. Ensure that /etc/apt/sources.list contains a deb-src line for Debian buster or later.
  2. sudo apt-get build-dep libvirglrenderer-dev/buster (install build dependencies for libvirglrenderer)
  3. fakeroot apt-get -b source libvirglrenderer-dev/buster (download and build libvirglrenderer)
  4. sudo dpkg -i libvirglrenderer0_0.6.0-2_amd64.deb libvirglrenderer-dev_0.6.0-2_amd64.deb (install it)
  5. sudo apt-get build-dep qemu/buster
  6. fakeroot apt-get -b source qemu/buster
  7. Install the appropriate qemu Debian packages which have been created in the current directory.

See also