File 18ec405a-libxl-release-graphics-ports.patch of Package libvirt
xxxxxxxxxx
1
commit 18ec405a36e24c86abe1104699c0bffdc91d5169
2
Author: Jim Fehlig <jfehlig@suse.com>
3
Date: Mon Feb 7 13:57:07 2022 -0700
4
5
libxl: Release auto-allocated spice ports
6
7
While VNC ports auto-allocated by the libxl driver are released in
8
libxlDomainCleanup, spice ports are overlooked. Rework the existing
9
logic to release any auto-allocated graphics ports, not just the VNC
10
port of the first graphics device.
11
12
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
13
Reviewed-by: Ján Tomko <jtomko@redhat.com>
14
15
Index: libvirt-7.1.0/src/libxl/libxl_domain.c
16
===================================================================
17
--- libvirt-7.1.0.orig/src/libxl/libxl_domain.c
18
+++ libvirt-7.1.0/src/libxl/libxl_domain.c
19
20
{
21
libxlDomainObjPrivatePtr priv = vm->privateData;
22
g_autoptr(libxlDriverConfig) cfg = libxlDriverConfigGet(driver);
23
- int vnc_port;
24
char *file;
25
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
26
unsigned int hostdev_flags = VIR_HOSTDEV_SP_PCI;
27
g_autoptr(virConnect) conn = NULL;
28
+ size_t i;
29
30
VIR_DEBUG("Cleaning up domain with id '%d' and name '%s'",
31
vm->def->id, vm->def->name);
32
33
if (!!g_atomic_int_dec_and_test(&driver->nactive) && driver->inhibitCallback)
34
driver->inhibitCallback(false, driver->inhibitOpaque);
35
36
- if ((vm->def->ngraphics == 1) &&
37
- vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
38
- vm->def->graphics[0]->data.vnc.autoport) {
39
- vnc_port = vm->def->graphics[0]->data.vnc.port;
40
- if (vnc_port >= LIBXL_VNC_PORT_MIN) {
41
- if (virPortAllocatorRelease(vnc_port) < 0)
42
- VIR_DEBUG("Could not mark port %d as unused", vnc_port);
43
+ /* Release auto-allocated graphics ports */
44
+ for (i = 0; i < vm->def->ngraphics; i++) {
45
+ virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
46
+ int gport = -1;
47
+
48
+ switch (graphics->type) {
49
+ case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
50
+ if (graphics->data.vnc.autoport &&
51
+ graphics->data.vnc.port >= LIBXL_VNC_PORT_MIN)
52
+ gport = graphics->data.vnc.port;
53
+ break;
54
+ case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
55
+ if (graphics->data.spice.autoport)
56
+ gport = graphics->data.spice.port;
57
+ break;
58
+ case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
59
+ case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
60
+ case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
61
+ case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
62
+ case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
63
+ break;
64
+ }
65
+ if (gport != -1) {
66
+ if (virPortAllocatorRelease(gport) < 0)
67
+ VIR_DEBUG("Could not mark port %d as unused", gport);
68
}
69
}
70
71
if ((vm->def->nnets)) {
72
- size_t i;
73
-
74
for (i = 0; i < vm->def->nnets; i++) {
75
virDomainNetDefPtr net = vm->def->nets[i];
76
77