Custom display resolutions in QEMU

04.05.2013 19:19

QEMU emulates a VESA-compliant VGA card that supports a static set of standard and a-bit-less-standard display resolutions. However, this set is far from universal and for example doesn't include the wide-screen 1600x900 resolution on my laptop. This means that running a virtualized OS full-screen would always stretch the display somewhat and give a blurry image.

Here's how I fixed that. Following instructions should pretty much work for adding an arbitrary resolution to QEMU's virtualized graphics card (but only when using -vga std). They are based on this patch.

Fetch QEMU source (I used 1.4.0) and edit roms/vgabios/vbetables-gen.c. For instance, to add 1600x900 I applied this patch:

--- qemu-1.4.0.orig/roms/vgabios/vbetables-gen.c	2013-02-16 00:09:22.000000000 +0100
+++ qemu-1.4.0/roms/vgabios/vbetables-gen.c	2013-05-04 11:46:55.000000000 +0200
@@ -76,6 +76,9 @@
 { 2560, 1600, 16                     , 0x18a},
 { 2560, 1600, 24                     , 0x18b},
 { 2560, 1600, 32                     , 0x18c},
+{ 1600,  900, 16                     , 0x18d},
+{ 1600,  900, 24                     , 0x18e},
+{ 1600,  900, 32                     , 0x18f},
 { 0, },
 };

Now re-build the VGA BIOS binary image (apt-get install bcc first):

$ cd roms/vgabios
$ make stdvga-bios

QEMU's make install will not install the image you just built. Instead, it will use an already built binary they ship with the source. Therefore you have to install it manually:

$ cp VGABIOS-lgpl-latest.stdvga.bin $PREFIX/share/qemu/vgabios-stdvga.bin

Of course, replace $PREFIX with the prefix you used when installing QEMU (/usr/local by default). Now when you start a virtualized OS you should see the resolution you added to vbetables-gen.c (for example as reported by xrandr or under Screen resolution in Windows).

Posted by Tomaž | Categories: Code

Comments

This was very useful, thx.

Posted by core

Thx for sharing first !

Strange I can not find this file:
./roms/vgabios/vbetables-gen.c

- this folder is siply empty:

$ l roms/vgabios/
total 8
drwxr-xr-x 2 root root 4096 Sep 19 13:52 ./
drwxr-xr-x 9 root root 4096 Sep 19 13:52 ../

I use git :
git clone git://git.qemu-project.org/qemu.git

now the branch is 1.5.xxx but checking out 1.4.0 doesnt help either.
The .bin are allready in pc-bios folder:

$ l pc-bios/vgabios*
-rw-r--r-- 1 root root 40448 Sep 19 13:52 pc-bios/vgabios.bin
-rw-r--r-- 1 root root 35840 Sep 19 13:52 pc-bios/vgabios-cirrus.bin
-rw-r--r-- 1 root root 40448 Sep 19 13:52 pc-bios/vgabios-qxl.bin
-rw-r--r-- 1 root root 40448 Sep 19 13:52 pc-bios/vgabios-stdvga.bin
-rw-r--r-- 1 root root 40448 Sep 19 13:52 pc-bios/vgabios-vmware.bin

any ideas how could this be ?

Thanks in advance !
Your UncleVan.

Posted by UncleVan

UncleVan, most likely vgabios code is stored in a different git repository. Check if they are using git submodules or something like that.

I was using the stable qemu-1.4.0.tar.bz2 release.

Posted by Tomaž

Add a new comment


(No HTML tags allowed. Separate paragraphs with a blank line.)