This will be used in specific graphics types that are using listen elements. Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx> --- src/conf/domain_conf.c | 67 ++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 81068570a0..d39b885101 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -26328,6 +26328,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 @@ -26643,34 +26681,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; -- 2.48.1