[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [XEN PATCH 0/3] Configure qemu upstream correctly by default for igd-passthru
Sorry for the length of this cover letter but it is helpful to put all the pros and cons of the two different approaches to solving the problem of configuring the Intel IGD with qemu upstream and libxl in one place, which I attempt to do here. Of course the other approach involves a patch to qemu [1] instead of using this patch series for libxl. The quick answer: I think the other patch to qemu is the better option, but I would be OK if you use this patch series instead. Details with my reasons for preferring the other patch to qemu over this patch series to libxl: I call attention to the commit message of the first patch which points out that using the "pc" machine and adding the xen platform device on the qemu upstream command line is not functionally equivalent to using the "xenfv" machine which automatically adds the xen platform device earlier in the guest creation process. As a result, there is a noticeable reduction in the performance of the guest during startup with the "pc" machne type even if the xen platform device is added via the qemu command line options, although eventually both Linux and Windows guests perform equally well once the guest operating system is fully loaded. Specifically, startup time is longer and neither the grub vga drivers nor the windows vga drivers in early startup perform as well when the xen platform device is added via the qemu command line instead of being added immediately after the other emulated i440fx pci devices when the "xenfv" machine type is used. For example, when using the "pc" machine, which adds the xen platform device using a command line option, the Linux guest could not display the grub boot menu at the native resolution of the monitor, but with the "xenfv" machine, the grub menu is displayed at the full 1920x1080 native resolution of the monitor for testing. So improved startup performance is an advantage for the patch for qemu. I also call attention to the last point of the commit message of the second patch and the comments for reviewers section of the second patch. This approach, as opposed to fixing this in qemu upstream, makes maintaining the code in libxl__build_device_model_args_new more difficult and therefore increases the chances of problems caused by coding errors and typos for users of libxl. So that is another advantage of the patch for qemu. OTOH, fixing this in qemu causes newer qemu versions to behave differently than previous versions of qemu, which the qemu community does not like, although they seem OK with the other patch since it only affects qemu "xenfv" machine types, but they do not want the patch to affect toolstacks like libvirt that do not use qemu upstream's autoconfiguration options as much as libxl does, and, of course, libvirt can manage qemu "xenfv" machines so exising "xenfv" guests configured manually by libvirt could be adversely affected by the patch to qemu, but only if those same guests are also configured for igd-passthrough, which is likely a very small number of possibly affected libvirt users of qemu. A year or two ago I tried to configure guests for pci passthrough on xen using libvirt's tool to convert a libxl xl.cfg file to libvirt xml. It could not convert an xl.cfg file with a configuration item pci = [ "PCI_SPEC_STRING", "PCI_SPEC_STRING", ...] for pci passthrough. So it is unlikely there are any users out there using libvirt to configure xen hvm guests for igd passthrough on xen, and those are the only users that could be adversely affected by the simpler patch to qemu to fix this. The only advantage of this patch series over the qemu patch is that this patch series does not need any patches to qemu to make Intel IGD configuration easier with libxl so the risk of affecting other qemu users is entirely eliminated if we use this patch instead of patching qemu. The cost of patching libxl instead of qemu is reduced startup performance compared to what could be achieved by patching qemu instead and an increased risk that the tedious process of manually managing the slot addresses of all the emulated devices will make it more difficult to keep the libxl code free of bugs. I will leave it to the maintainer of the code in both qemu and libxl (Anthony) to decide which, if any, of the patches to apply. I am OK with either this patch series to libxl or the proposed patch to qemu to fix this problem, but I do recommend the other patch to qemu over this patch series because of the improved performance during startup with that patch and the relatively low risk that any libvirt users will be adversely affected by that patch. Brief statement of the problem this patch series solves: Currently only the qemu traditional device model reserves slot 2 for the Intel Integrated Graphics Device (IGD) with default settings. Assigning the Intel IGD to slot 2 is necessary for the device to operate properly when passed through as the primary graphics adapter. The qemu traditional device model takes care of this by reserving slot 2 for the Intel IGD, but the upstream qemu device model currently does not reserve slot 2 for the Intel IGD. This patch series modifies libxl so the upstream qemu device model will also, with default settings, assign slot 2 for the Intel IGD. There are three reasons why it is difficult to configure the guest so the Intel IGD is assigned to slot 2 in the guest using libxl and the upstream device model, so the patch series is logically organized in three separate patches; each patch resolves one of the three reasons that cause problems: The description of what each of the three libxl patches do: 1. With the default "xenfv" machine type, qemu upstream is hard-coded to assign the xen platform device to slot 2. The first patch fixes that by using the "pc" machine instead when gfx_passthru type is igd and, if xen_platform_pci is set in the guest config, libxl now assigns the xen platform device to slot 3, making it possible to assign the IGD to slot 2. The patch only affects guests with the gfx_passthru option enabled. The default behavior (xen_platform_pci is enabled but gfx_passthru option is disabled) of using the "xenfv" machine type is preserved. Another way to describe what the patch does is to say that it adds a second exception to the default choice of the "xenfv" machine type, with the first exception being that the "pc" machine type is also used instead of "xenfv" if the xen platform pci device is disabled in the guest xl.cfg file. 2. Currently, with libxl and qemu upstream, most emulated pci devices are by default automatically assigned a pci slot, and the emulated ones are assigned before the passed through ones, which means that even if libxl is patched so the xen platform device will not be assigned to slot 2, any other emulated device will be assigned slot 2 unless libxl explicitly assigns the slot address of each emulated pci device in such a way that the IGD will be assigned slot 2. The second patch fixes this by hard coding the slot assignment for the emulated devices instead of deferring to qemu upstream's auto-assignment which does not do what is necessary to configure the Intel IGD correctly. With the second patch applied, it is possible to configure the Intel IGD correctly by using the @VSLOT parameter in xl.cfg to specify the slot address of each passed through pci device in the guest. The second patch is also designed to not change the default behavior of letting qemu autoconfigure the pci slot addresses when igd gfx_pasthru is disabled in xl.cfg. 3. For convenience, the third patch automatically assigns slot 2 to the Intel IGD when the gfx_passthru type is igd so with the third patch appled it is not necessary to set the @VSLOT parameter to configure the Intel IGD correctly. Testing: I tested a system with Intel IGD passthrough and two other pci devices passed through, with and without the xen platform device. I also did tests on guests without any pci passthrough configured. In all cases tested, libxl behaved as expected. For example, the device model arguments are only changed if gfx_passthru is set for the IGD, libxl respected administrator settings such as @VSLOT and xen_platform_pci with the patch series applied, and not adding the xen platform device to the guest caused reduced performance because in that case the guest could not take advantage of the improvements offered by the Xen PV drivers in the guest. I tested the following emulated devices on my setup: xen-platform, e1000, and VGA. I also verified the device that is added by the "hdtype = 'ahci'" xl.cfg option is configured correctly with the patch applied. I did not test all 12 devices that could be affected by patch 2 of the series. These include the intel-hda high definition audio device, a virtio-serial, device, etc. Once can look at the second patch for the full list of qemu emulated devices whose behavior is affected by the second patch of the series when the guest is configured for igd gfx_passthru. These devices are also subject to mistakes in the patch not discovered by the compiler, as mentioned in the comments for reviewers section of the second patch. [1] https://lore.kernel.org/qemu-devel/8349506149de6d81b0762f17623552c248439e93.1673297742.git.brchuckz@xxxxxxx/ Chuck Zmudzinski (3): libxl/dm: Use "pc" machine type for Intel IGD passthrough libxl/dm: Manage pci slot assignment for Intel IGD passthrough libxl/dm: Assign slot 2 by default for Intel IGD passthrough tools/libs/light/libxl_dm.c | 227 +++++++++++++++++++++++++++++------- 1 file changed, 183 insertions(+), 44 deletions(-) -- 2.39.0
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |