If you have a monitor with a non-standard resolution like 1600x900 or 2560x1440, then you can’t easily use this resolution in the guest operating system. If you run the guest in full screen mode, you either need to scale or you can’t use the full screen. But it is possible to add the native resolutions of your monitors to the bios QEMU is using so that you can select it in the guest os.

The bios, that QEMU is using, is called seabios. Debian provides a package already and I’ll use that to add the additional resolutions.

Howto

First step is to install any necessary build dependencies:

sudo apt-get install dpkg-dev devscripts quilt
sudo apt-get build-dep seabios

Also you’ll need to setup quilt, as it is described in https://www.debian.org/doc/manuals/maint-guide/modify.en.html.

After that, let’s create a new directory and do everything within it:

mkdir seabios-patch
cd seabios-patch

Get the sources for the seabios package so that we can patch it and rebuild it:

apt-get source seabios
cd seabios-1.8.2

apt-get source automatically extracts the archive and we are now in the subdirectory seabios-1.8.2. You’ll see a subdirectory debian which contains the debian package specs.

The following command creates a new entry in the changelog file and generates a new local version. Provide a description for the change such as “Adding new custom resolutions 1600x900 and 2560x1440”.

EMAIL=your.email@example.com dch --local custom

The generated version will be 1.8.2-1custom1.

Now let’s start modifying the bios. We’ll create a new patch called custom-resolutions.patch and use dquilt to track it. The file we’ll need to change is vgasrc/bochsvga.c.

mkdir debian/patches
dquilt new custom-resolutions.patch
dquilt add vgasrc/bochsvga.c

Use your favorite editor to modify the file. I’ve chosen gedit vgasrc/bochsvga.c. Add the following lines at the appropriate position, just after the last resolution definition:

/* custom resolutions */
{ 0x193, { MM_DIRECT, 1600,  900, 16, 8, 16, SEG_GRAPH } },
{ 0x194, { MM_DIRECT, 1600,  900, 24, 8, 16, SEG_GRAPH } },
{ 0x195, { MM_DIRECT, 1600,  900, 32, 8, 16, SEG_GRAPH } },
{ 0x196, { MM_DIRECT, 2560, 1440, 16, 8, 16, SEG_GRAPH } },
{ 0x197, { MM_DIRECT, 2560, 1440, 24, 8, 16, SEG_GRAPH } },
{ 0x198, { MM_DIRECT, 2560, 1440, 32, 8, 16, SEG_GRAPH } },

Then save the file end exit the editor. The following commands will record the patch in the file and save a description alongside the patch.

dquilt refresh
dquilt header -e # and add a description, like "adding custom resolutions 1600x900 and 2560x1440"

Last step is to actually rebuild the package and create a new deb, ready to be installed:

dpkg-buildpackage -us -uc

The generated package is availabe in the parent directory and can be installed as follows:

sudo dpkg -i ../seabios_1.8.2-1custom1_all.deb

References