Recently I had to setup a virtual machine on a Citrix XenServer host that could use 32bpp. This turned out harder than I thought because the default video adapter in a Xen virtual machine is a Cirrus with 4MB, and that video card is not capable of 32bpp.

To be honest when I read Cirrus I had a flash-back to the times I bought my first computer; a 386SX 33Mhz with 2MB RAM and a Cirrus VGA card (on a ISA interface if I’m not mistaking).

 

Adding video memory

I thought hoped it would be easy to just add some video memory with xe vm-param-set but couldn’t find a parameter to configure. In fact, there isn’t (yet).

There is method described but this will affect all virtual machines on the same XenServer host, it is described below (qemu-dm-wrapper). Knowing it is possible to ‘swap’ the videocard in a virtual machine and adding video memory by adding parameters to the QEMU (open source machine emulator and virtualizer) process.

A Xen virtual machine consist of two processes and can be found with ps aux | grep qemu

65556    13951  7.7  1.3  31380  9720 ?        SLsl 12:52   0:01 qemu-dm-21 -d 21 -m 4096 -boot dc -serial pty -vcpus 1 -vncunused -k en-us -usb -usbdevice tablet -net nic,vlan=0,macaddr=66:18:15:10:62:0a,model=rtl8139 -net tap,vlan=0,bridge=xenbr0,ifname=tap21.0 -acpi -videoram 4 -M xenfv -monitor pty -vnc 127.0.0.1:1
root     13956  0.0  0.4  26464  3552 ?        S    12:52   0:00 qemu-dm-21 -d 21 -m 4096 -boot dc -serial pty -vcpus 1 -vncunused -k en-us -usb -usbdevice tablet -net nic,vlan=0,macaddr=66:18:15:10:62:0a,model=rtl8139 -net tap,vlan=0,bridge=xenbr0,ifname=tap21.0 -acpi -videoram 4 -M xenfv -monitor pty -vnc 127.0.0.1:1

When the video adapter is ‘swapped’ the result of the ps command is:

65565    18611  0.0  0.6  26456  4568 ?        SLsl 13:56   0:00 qemu-dm-30 -d 30 -m 4096 -boot dc -serial pty -vcpus 1 -vncunused -k en-us -usb -usbdevice tablet -net nic,vlan=0,macaddr=66:18:15:10:62:0a,model=rtl8139 -net tap,vlan=0,bridge=xenbr0,ifname=tap30.0 -acpi -videoram 4 -M xenfv -monitor pty -vnc 127.0.0.1:1 -std-vga -videoram 4
root     18616  0.0  0.4  26456  3540 ?        S    13:56   0:00 qemu-dm-30 -d 30 -m 4096 -boot dc -serial pty -vcpus 1 -vncunused -k en-us -usb -usbdevice tablet -net nic,vlan=0,macaddr=66:18:15:10:62:0a,model=rtl8139 -net tap,vlan=0,bridge=xenbr0,ifname=tap30.0 -acpi -videoram 4 -M xenfv -monitor pty -vnc 127.0.0.1:1 -std-vga -videoram 4

As you can see two parameters are added:

  • -std-vga  (use ‘standard’ video card, instead of the cirrus)
  • -videoram 4 (set 4MB of video ram)

Since there is no configurable parameter per VM (xe vm-param-set) I looked for a solution to inject the parameter via another parameter. In github.com I found the xenops.ml file that launched the qemu-dm-wrapper script. Here I found three possible candidates:

  • static_max_kib;
  • boot;
  • vcpus.

Since both static_max_kib and vcpus are integer values there was no way I could add the parameter (-std-vga –videoram 4), but boot… let’s give it a shot!

Don’t try this at home/office/wherever, it doesn’t work (spoiler alert)

I added the parameters to the boot priority (default=dc: 1) cd-rom [d] and then 2) hdd ([c]) parameter of the virtual machine…

xe vm-param-set uuid= HVM-boot-params:order="dc -acpi -vga std"

…and started the virtual machine. Nothing happened, the VM could not be started. The /var/log/messsage logfile should me why.

Jun 21 14:00:47 xenserver-orulmhui kernel: device vif31.0 entered promiscuous mode
Jun 21 14:00:47 xenserver-orulmhui fe: qemu-dm-31[19173]: domid: 31
Jun 21 14:00:47 xenserver-orulmhui fe: qemu-dm-31[19173]: Invalid boot device ' '
Jun 21 14:00:47 xenserver-orulmhui fe: 19173 (/opt/xensource/libexec/qemu-dm-wrapper 31 -d 31 -m 4096 -boot dc -std-vga -se...) exitted with code 1
Jun 21 14:00:52 xenserver-orulmhui xapi: [error|xenserver-orulmhui|8220|Async.VM.start R:8311b4a1f5f7|xenops] watch: timeout while watching xenstore after 5.000000 seconds

There is a check builtin the vl.c that verifies each boot option, a space is not allowed as a boot option.

I’ve run some more test but it all came to a death end…

…until I found a pull request from David Scott (XenServer System Architect at Citrix Systems) with the name ‘Add platform options for HVM display adapter and videoram’.  So there will be a configurable parameter per VM that enable you to specify which video adapter to use and how many video ram it has. It has even been merged in the Xen code! On my XenServer 6.0.12 the parameters didn’t work so I assume they’re not included the XenServer code (yet).

I’ve sent David an e-mail to ask him if and when it will be included in Citrix XenServer. To be continued!?!

 

qemu-dm-wrapper

You can add the parameters to the QEMU process by altering the qemu-dm-wrapper file, which can be found in the /opt/xensource/libexec directory of the XenServer host.

Keep in mind this will change the behaviour of ALL virtual machines running on this (and only on this ) XenServer host .

  1. Locate the line def main(argv):
  2. Below you will find a line that lookes like qemu_args = [‘qemu-dm-%d’%domid] + argv[3:] (this is different for XenServer 5 / 6 / etc.)
  3. Immediately after that line add the following lines:
    • qemu_args.append(‘-std-vga’)
    • qemu_args.append(‘-videoram’)
    • qemu_args.append(‘4’) << you can increase the video memory if you want

    Now each virtual machine that gets started will receive a ‘standard’ VGA adapter instead of a Cirrus. Most importantly (for me), 32bpp is available.

Eén reactie

  1. At Citrix Blogs a post was added which described how to change the videocard (and memory) in a much easier way:
    http://blogs.citrix.com/2014/05/12/from-my-virtual-desktop-using-standard-vga-instead-of-cirrus/

    “1. Halt your VM

    2. From the command line, find the UUID of your VM:
    xe vm-list name-label=”Name of your VM”

    3. Taking the UUID value, run the following two commands:
    xe vm-param-set uuid= platform:vga=std
    xe vm-param-set uuid=
    platform:videoram=4

    Restart your VM and presto. You should now be able to achieve 32bpp. AND as for the videoram, the max value is 16MiB (just because the max is 16MiB doesn’t mean you need to use it).”

Geef een reactie

Het e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *

Deze site gebruikt Akismet om spam te verminderen. Bekijk hoe je reactie-gegevens worden verwerkt.

nl_NLNederlands