1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 06:50:22 +03:00

domain_conf: graphics: extract listen formatting to separate function

This will be used in specific graphics types that are using listen
elements.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Pavel Hrdina 2025-03-06 12:14:14 +01:00
parent 4c2c7720fe
commit 5f97b846f0

View File

@ -26365,6 +26365,44 @@ virDomainGraphicsListenDefFormat(virBuffer *buf,
}
static void
virDomainGraphicsDefFormatListnes(virBuffer *childBuf,
virDomainGraphicsDef *def,
unsigned int flags)
{
size_t i;
for (i = 0; i < def->nListens; i++) {
if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE) {
/* If the listen is based on config options from qemu.conf we need
* to skip it. It's up to user to properly configure both hosts for
* migration. */
if (def->listens[i].fromConfig)
continue;
/* If the socket is provided by user in the XML we need to skip this
* listen type to support migration back to old libvirt since old
* libvirt supports specifying socket path inside graphics element
* as 'socket' attribute. Auto-generated socket is a new feature
* thus we can generate it in the migrateble XML. */
if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
def->listens[i].type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET &&
def->listens[i].socket &&
!def->listens[i].autoGenerated)
continue;
/* The new listen type none is in the migratable XML represented as
* port=0 and autoport=no because old libvirt support this
* configuration for spice. */
if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE &&
def->listens[i].type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE)
continue;
}
virDomainGraphicsListenDefFormat(childBuf, &def->listens[i], flags);
}
}
/**
* virDomainGraphicsListenDefFormatAddr:
* @buf: buffer where the output XML is written
@ -26680,34 +26718,7 @@ virDomainGraphicsDefFormat(virBuffer *buf,
break;
}
for (i = 0; i < def->nListens; i++) {
if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE) {
/* If the listen is based on config options from qemu.conf we need
* to skip it. It's up to user to properly configure both hosts for
* migration. */
if (def->listens[i].fromConfig)
continue;
/* If the socket is provided by user in the XML we need to skip this
* listen type to support migration back to old libvirt since old
* libvirt supports specifying socket path inside graphics element
* as 'socket' attribute. Auto-generated socket is a new feature
* thus we can generate it in the migrateble XML. */
if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
def->listens[i].type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET &&
def->listens[i].socket &&
!def->listens[i].autoGenerated)
continue;
/* The new listen type none is in the migratable XML represented as
* port=0 and autoport=no because old libvirt support this
* configuration for spice. */
if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE &&
def->listens[i].type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE)
continue;
}
virDomainGraphicsListenDefFormat(&childBuf, &def->listens[i], flags);
}
virDomainGraphicsDefFormatListnes(&childBuf, def, flags);
if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
g_auto(virBuffer) spiceBuf = VIR_BUFFER_INITIALIZER;