- libxl: Mark auto-allocated graphics ports to used on reconnect

e0241f33-libxl-mark-allocated-graphics-ports.patch
  bsc#1191668

OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=921
This commit is contained in:
James Fehlig 2022-02-07 21:35:33 +00:00 committed by Git OBS Bridge
parent bf3e3feba0
commit 80517cd1b1
6 changed files with 75 additions and 7 deletions

View File

@ -23,7 +23,7 @@ Index: libvirt-8.0.0/src/libxl/libxl_driver.c
===================================================================
--- libvirt-8.0.0.orig/src/libxl/libxl_driver.c
+++ libvirt-8.0.0/src/libxl/libxl_driver.c
@@ -5241,6 +5241,95 @@ libxlDomainMemoryStats(virDomainPtr dom,
@@ -5264,6 +5264,95 @@ libxlDomainMemoryStats(virDomainPtr dom,
#undef LIBXL_SET_MEMSTAT
@ -119,7 +119,7 @@ Index: libvirt-8.0.0/src/libxl/libxl_driver.c
static int
libxlDomainGetJobInfo(virDomainPtr dom,
virDomainJobInfoPtr info)
@@ -6554,6 +6643,7 @@ static virHypervisorDriver libxlHypervis
@@ -6577,6 +6666,7 @@ static virHypervisorDriver libxlHypervis
.domainGetNumaParameters = libxlDomainGetNumaParameters, /* 1.1.1 */
.nodeGetFreeMemory = libxlNodeGetFreeMemory, /* 0.9.0 */
.nodeGetCellsFreeMemory = libxlNodeGetCellsFreeMemory, /* 1.1.1 */

View File

@ -0,0 +1,60 @@
commit e0241f334d4e8da2e36cda48c225d5a6edcc3a50
Author: Jim Fehlig <jfehlig@suse.com>
Date: Tue Feb 1 17:03:11 2022 -0700
libxl: Set auto-allocated graphics ports to used on reconnect
The libxl driver reconnects to all running VMs when libvirtd is restarted,
but it failed to mark auto-allocated graphics ports as set in the port
allocator. If many VMs are running that use port auto-allocation and
libvirtd is restarted, the port allocator is likely to hand out a port
already in use when a new VM is created that uses auto-allocation. VM
creation will fail due to the port clash.
When reconnecting to running VMs after a libvirtd restart, let the port
allocator know about previously allocated ports.
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Index: libvirt-8.0.0/src/libxl/libxl_driver.c
===================================================================
--- libvirt-8.0.0.orig/src/libxl/libxl_driver.c
+++ libvirt-8.0.0/src/libxl/libxl_driver.c
@@ -393,6 +393,7 @@ libxlReconnectDomain(virDomainObj *vm,
virHostdevManager *hostdev_mgr = driver->hostdevMgr;
unsigned int hostdev_flags = VIR_HOSTDEV_SP_PCI;
int ret = -1;
+ size_t i;
hostdev_flags |= VIR_HOSTDEV_SP_USB;
@@ -447,6 +448,28 @@ libxlReconnectDomain(virDomainObj *vm,
libxlReconnectNotifyNets(vm->def);
+ /* Set any auto-allocated graphics ports to used */
+ for (i = 0; i < vm->def->ngraphics; i++) {
+ virDomainGraphicsDef *graphics = vm->def->graphics[i];
+
+ switch (graphics->type) {
+ case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
+ if (graphics->data.vnc.autoport)
+ virPortAllocatorSetUsed(graphics->data.vnc.port);
+ break;
+ case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
+ if (graphics->data.spice.autoport)
+ virPortAllocatorSetUsed(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 (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
VIR_WARN("Cannot update XML for running Xen guest %s", vm->def->name);

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
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
bsc#1191668
-------------------------------------------------------------------
Wed Jan 26 19:13:24 UTC 2022 - James Fehlig <jfehlig@suse.com>

View File

@ -306,6 +306,7 @@ Patch1: 16172741-libvirt-guests-manpage.patch
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
# Patches pending upstream review
Patch100: libxl-dom-reset.patch
Patch101: network-don-t-use-dhcp-authoritative-on-static-netwo.patch

View File

@ -12,7 +12,7 @@ Index: libvirt-8.0.0/src/libxl/libxl_driver.c
===================================================================
--- libvirt-8.0.0.orig/src/libxl/libxl_driver.c
+++ libvirt-8.0.0/src/libxl/libxl_driver.c
@@ -1338,6 +1338,63 @@ libxlDomainReboot(virDomainPtr dom, unsi
@@ -1361,6 +1361,63 @@ libxlDomainReboot(virDomainPtr dom, unsi
}
static int
@ -76,7 +76,7 @@ Index: libvirt-8.0.0/src/libxl/libxl_driver.c
libxlDomainDestroyFlags(virDomainPtr dom,
unsigned int flags)
{
@@ -6432,6 +6489,7 @@ static virHypervisorDriver libxlHypervis
@@ -6455,6 +6512,7 @@ static virHypervisorDriver libxlHypervis
.domainShutdown = libxlDomainShutdown, /* 0.9.0 */
.domainShutdownFlags = libxlDomainShutdownFlags, /* 0.9.10 */
.domainReboot = libxlDomainReboot, /* 0.9.0 */

View File

@ -75,7 +75,7 @@ Index: libvirt-8.0.0/src/libxl/libxl_driver.c
===================================================================
--- libvirt-8.0.0.orig/src/libxl/libxl_driver.c
+++ libvirt-8.0.0/src/libxl/libxl_driver.c
@@ -5973,6 +5973,9 @@ libxlDomainMigratePerform3Params(virDoma
@@ -5996,6 +5996,9 @@ libxlDomainMigratePerform3Params(virDoma
const char *dname = NULL;
const char *uri = NULL;
int ret = -1;
@ -85,7 +85,7 @@ Index: libvirt-8.0.0/src/libxl/libxl_driver.c
#ifdef LIBXL_HAVE_NO_SUSPEND_RESUME
virReportUnsupportedError();
@@ -5989,6 +5992,15 @@ libxlDomainMigratePerform3Params(virDoma
@@ -6012,6 +6015,15 @@ libxlDomainMigratePerform3Params(virDoma
virTypedParamsGetString(params, nparams,
VIR_MIGRATE_PARAM_DEST_NAME,
&dname) < 0 ||
@ -101,7 +101,7 @@ Index: libvirt-8.0.0/src/libxl/libxl_driver.c
virTypedParamsGetString(params, nparams,
VIR_MIGRATE_PARAM_URI,
&uri) < 0)
@@ -6003,11 +6015,11 @@ libxlDomainMigratePerform3Params(virDoma
@@ -6026,11 +6038,11 @@ libxlDomainMigratePerform3Params(virDoma
if ((flags & (VIR_MIGRATE_TUNNELLED | VIR_MIGRATE_PEER2PEER))) {
if (libxlDomainMigrationSrcPerformP2P(driver, vm, dom->conn, dom_xml,