Add upstream patch to release all auto-allocated graphics ports

OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=922
This commit is contained in:
James Fehlig 2022-02-08 17:58:16 +00:00 committed by Git OBS Bridge
parent 80517cd1b1
commit 66a8bd2960
3 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,69 @@
commit 18ec405a36e24c86abe1104699c0bffdc91d5169
Author: Jim Fehlig <jfehlig@suse.com>
Date: Mon Feb 7 13:57:07 2022 -0700
libxl: Release auto-allocated spice ports
While VNC ports auto-allocated by the libxl driver are released in
libxlDomainCleanup, spice ports are overlooked. Rework the existing
logic to release any auto-allocated graphics ports, not just the VNC
port of the first graphics device.
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Index: libvirt-8.0.0/src/libxl/libxl_domain.c
===================================================================
--- libvirt-8.0.0.orig/src/libxl/libxl_domain.c
+++ libvirt-8.0.0/src/libxl/libxl_domain.c
@@ -906,10 +906,10 @@ libxlDomainCleanup(libxlDriverPrivate *d
{
libxlDomainObjPrivate *priv = vm->privateData;
g_autoptr(libxlDriverConfig) cfg = libxlDriverConfigGet(driver);
- int vnc_port;
char *file;
virHostdevManager *hostdev_mgr = driver->hostdevMgr;
unsigned int hostdev_flags = VIR_HOSTDEV_SP_PCI;
+ size_t i;
VIR_DEBUG("Cleaning up domain with id '%d' and name '%s'",
vm->def->id, vm->def->name);
@@ -944,13 +944,31 @@ libxlDomainCleanup(libxlDriverPrivate *d
if (!!g_atomic_int_dec_and_test(&driver->nactive) && driver->inhibitCallback)
driver->inhibitCallback(false, driver->inhibitOpaque);
- if ((vm->def->ngraphics == 1) &&
- vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
- vm->def->graphics[0]->data.vnc.autoport) {
- vnc_port = vm->def->graphics[0]->data.vnc.port;
- if (vnc_port >= LIBXL_VNC_PORT_MIN) {
- if (virPortAllocatorRelease(vnc_port) < 0)
- VIR_DEBUG("Could not mark port %d as unused", vnc_port);
+ /* Release auto-allocated graphics ports */
+ for (i = 0; i < vm->def->ngraphics; i++) {
+ virDomainGraphicsDef *graphics = vm->def->graphics[i];
+ int gport = -1;
+
+ switch (graphics->type) {
+ case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
+ if (graphics->data.vnc.autoport &&
+ graphics->data.vnc.port >= LIBXL_VNC_PORT_MIN)
+ gport = graphics->data.vnc.port;
+ break;
+ case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
+ if (graphics->data.spice.autoport)
+ gport = graphics->data.spice.port;
+ break;
+ case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
+ case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
+ case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
+ case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
+ case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
+ break;
+ }
+ if (gport != -1) {
+ if (virPortAllocatorRelease(gport) < 0)
+ VIR_DEBUG("Could not mark port %d as unused", gport);
}
}

View File

@ -3,6 +3,8 @@ Mon Feb 7 21:32:20 UTC 2022 - James Fehlig <jfehlig@suse.com>
- libxl: Mark auto-allocated graphics ports to used on reconnect
e0241f33-libxl-mark-allocated-graphics-ports.patch
- libxl: Release all auto-allocated graphics ports
18ec405a-libxl-release-graphics-ports.patch
bsc#1191668
-------------------------------------------------------------------

View File

@ -307,6 +307,7 @@ Patch2: 8eb44616-remove-sysconfig-files.patch
Patch3: 31e937fb-libxl-save-lock-indicator.patch
Patch4: 105dace2-revert-virProcessGetStatInfo.patch
Patch5: e0241f33-libxl-mark-allocated-graphics-ports.patch
Patch6: 18ec405a-libxl-release-graphics-ports.patch
# Patches pending upstream review
Patch100: libxl-dom-reset.patch
Patch101: network-don-t-use-dhcp-authoritative-on-static-netwo.patch