Chuck Zmudzinski
2017-Feb-23 16:18 UTC
[Pkg-xen-devel] Bug#776742: Solved for jessie: Bug#776742: xen-utils-common: no support for VGA Passthrough
I have a solution to this bug for jessie that is essentially the upstream xen solution for VGA passthrough for version 4.4 of xen that is installed on jessie: use the traditional qemu device model (qemu-dm), which is only supported by upstream xen with the rombios bios. In Debian, qemu-xen-traditional was removed some time ago, as was the rombios bios. To use my solution on jessie, it is necessary to rebuild the xen source package for jessie with support for qemu-xen-traditional and rombios, which is easily accomplished by changing those two configure options for the build of the xen packages for jessie in the debian/rules.real file of the xen source package for jessie and then debugging the build process and testing it until it works. I have done this and it is not that difficult. I have three ways to package my fix for this bug on Debian jessie on either amd64 or i386 that work well for me and I am willing to share my solutions with Debian if Debian will consider them. Some detail about my three ways of packaging upstream's solution for providing VGA passthrough support on xen 4.4 in a way that integrates with the current xen packages for jessie follow below. 1. The first way modifies the xen source package, to which I assigned nmu version number 4.4.1-9+deb8u8.1, in such a way that the /usr/lib/xen-4.4/bin/qemu-dm binary and a modified version of the /usr/lib/xen-4.4/boot/hvmloader binary are added to the xen-utils-4.4 binary package on amd64 and i386. I restricted my modifications to amd64 and i386 because I doubt my fix will work on the arm architectures, and Ubuntu trusty, which also uses xen version 4.4, only supplies qemu-dm for amd64 and i386. This way of packaging my fix also rebuilds all the binaries in the xen source package although this is not really necessary because the fix only requires an upgraded version of the xen-utils-4.4 binary package. The fix should be implemented in xen-utils-4.4, not xen-utils-common, because the files that fix the bug are architecture dependent. To implement this fix, it is necessary to upgrade the official Debian version of the xen-utils-4.4 binary package (version 4.4.1-9+deb8u8) to my nmu version (4.4.1-9+deb8u8.1) on the target amd64 or i386 system running jessie. The other xen binary packages need not be upgraded. Even though this fix changes hvmloader by adding rombios support to hvmloader, the seabios support remains in hvmloader and remains the default, and my tests show that my fix does not affect any domain that does not explicitly select the qemu-xen-traditional device model in the config file and such domains will still use the Debian seabios bios and the upstream Debian qemu device model. 2. The second way to package my fix adds a new architecture dependent binary package, which I named xen-qemu-dm-4.4, to the list of binary packages that are built by the modified xen source package, my nmu version 4.4.1-9+deb8u8.2, for amd64 and i386. This package consists of the /usr/lib/xen-4.4/bin/qemu-dm binary and a modified version of the /usr/lib/xen-4.4/boot/hvmloader binary that overrides the version of the same file from xen-utils-4.4 using dpkg-divert. The diversion is added or removed as needed using preinst and postrm maintainer scripts as described in the Debian Policy Manual. This fix also rebuilds the entire xen source package although this is not really necessary because the fix only requires the new xen-qemu-dm-4.4 binary package, and the fix is implemented by installing the new xen-qemu-dm-4.4 binary package, my nmu version 4.4.1-9+deb8u8.2, on an amd64 or i386 system that already has the normal up-to-date xen system installed on jessie with xen-utils-4.4 and its recommended packages installed. None of the other binary packages from my nmu build of xen need to be installed to implement the fix, because they are identical to the official Debian versions, but they have different version numbers because they are built from the modified xen source package with a different version number. Once the package is built, all that needs to done is run 'sudo dpkg -i xen-qemu-dm-4.4_4.4.1-9+deb8u8.1_amd64.deb' on the target amd64 or i386 system. This solution has the advantage of not making any modifications to the official xen binary packages, but it does require modifications to the xen source package which may cause problems unless the build process is tested extensively to verify that it behaves as intended. This fix also keeps the upstream Debian qemu and the Debian seabios bios as the defaults. 3. The third way to package my fix starts from a new source package, which I named xen-qemu-traditional, to which I assigned the nmu version number 4.4.1-9+deb8u8.1 because its source files are derived from version 4.4.1-9+deb8u8 of the official xen source package for jessie. This source package builds a single binary package named xen-qemu-traditional-4.4 on amd64 and i386 that consists of the /usr/lib/xen-4.4/bin/qemu-dm binary and a modified version of the /usr/lib/xen-4.4/boot/hvmloader binary that overrides the version of the same file from xen-utils-4.4 using dpkg-divert. The diversion is added or removed as needed using preinst and postrm maintainer scripts as described in the Debian Policy Manual. This fix does not require rebuilding anything in the official Debian xen source package for jessie and in fact does not modify it or the binaries it builds in any way, with the single exception that the hvmloader binary from xen-utils-4.4 is diverted when this fix is installed. Only the components that are needed to implement the fix are built from my new xen-qemu-traditional source package, and the fix is implemented by installing the new xen-qemu-traditional-4.4 binary package, my nmu version 4.4.1-9+deb8u8.1, on an amd64 or i386 system that already has the xen system installed using dpkg -i as described in my second solution. This binary package is essentially identical to the xen-qemu-dm-4.4 binary package produced by my second solution, but this way of packaging the fix has the advantage of not modifying the current xen source package for jessie in any way and therefore minimizes any negative unintended consequences of adding my fix to the Debian repository. This way of packaging the fix also makes it easy to add my fix to the contrib or non-free areas of the repository if it is not appropriate for main or for inclusion as part of the current official xen source package for jessie. Other notes about my fixes: 1. In the first two ways of packaging my fix for the bug, it was necessary to add the original source files from version 4.4.1 of the qemu-xen-traditional.git repository at xenbits.xen.org to the xen source package. This was implemented by generating a new original source archive named xen_4.4.1.orig-qemu-dm.tar.xz and adding it to the xen source package. In the third fix, new original source file archives needed to be generated from the exact same original source files in the first two fixes. 2. In all these fixes, the hvmloader binary had to be modified or overridden because the traditional qemu device model requires support for the rombios bios in hvmloader, but the official Debian build of xen-utils-4.4 does not include this support in the hvmloader binary. The modified hvmloader in all these fixes also supports the seabios bios which is required when using the upstream qemu device model, and no changes are made to the other components of xen so Debian's upstream qemu device model and Debian's system seabios bios remain the defaults. 3. In all these fixes, VGA passthrough is enabled by setting device_model_version = 'qemu-xen-traditional' in an HVM DomU config file, along with all the other requirements such as setting up the VGA pci device to be passed through using the xen-pciback kernel module and running on hardware with the necessary features to support VGA passthrough. Also, setting gfx_passthru = '1' will make the passed through VGA adapter the primary adapter in an HVM DomU that uses qemu-xen-traditional. I verified that without explicitly setting the device model version to qemu-xen-traditional, the HVM will default to the upstream qemu-xen device model and the seabios bios but there will not be support for VGA passthrough in this default case. I also verified that setting gfx_passthru = '1' with the default upstream qemu-xen device model will generate an error, but this option of gfx_passthru works fine with the qemu-xen-traditional device model after applying any one of my three fixes and properly configuring the system for VGA passthrough. 4. In all these fixes, I included the 44 upstream security and stability patches to the stable-4.4 branch of the qemu-xen-traditional.git repositiory on xenbits.xen.org since the 4.4.1 release of xen and did my best to handle dependencies in a reasonable way for nmu versions so that dpkg -i will work without needing to upgrade the official Debian xen binary packages that do not need to be upgraded. If older versions of the xen 4.4.x xen binary packages for jessie are installed, these fixes might not work, and they definitely won't work if the upstream version is less than 4.4. I have only tested these fixes with the current version of xen for jessie (4.4.1-9+deb8u8). 5. I spent some time tweaking my nmu source packages that fix this bug in order to document my solution to the VGA passthrough bug using a debian/README.source file, comments in the patchfiles, and a README.Debian file in the binary package that implements the fix. There are three 'source-is-missing' lintian errors reported when building my source packages that is caused by three binaries in the original source archive of qemu-xen-traditional from xenbits.xen.org, but I verified that with a simple patch these binaries are not needed for the build process, and they are not installed in any of the binary packages produced by my builds. 6. I am willing to contribute a fix based on one of my nmu packages to the Debian project if the Debian Xen team is interested in adding it to the Debian packages archive, either in main, contrib, or non-free as appropriate. I am not including any debdiff patches here because they are too large. Chuck Zmudzinski