From ca305a756d467de09bc51608800e089ced0cca55 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Mon, 10 Jun 2013 17:51:46 +0200 Subject: [PATCH] qemu_migrate: Dispose listen address if set from config https://bugzilla.redhat.com/show_bug.cgi?id=971485 As of d7f9d827531bc843b7c5aa9d3e8c08738a1de248 we copy the listen address from the qemu.conf config file in case none has been provided via XML. But later, when migrating, we should not include such listen address in the migratable XML as it is something autogenerated, not requested by user. Moreover, the binding to the listen address will likely fail, unless the address is '0.0.0.0' or its IPv6 equivalent. This patch introduces a new boolean attribute to virDomainGraphicsListenDef to distinguish autofilled listen addresses. However, we must keep the attribute over libvirtd restarts, so it must be kept within status XML. (cherry picked from commit 6546017c50c104d0b9867137b64ab1f4a312e436) --- src/conf/domain_conf.c | 28 ++++++++++++++++++++++++++++ src/conf/domain_conf.h | 1 + src/qemu/qemu_process.c | 1 + 3 files changed, 30 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3c54f72e3a..7e72cfd5ea 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7398,6 +7398,8 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, char *type = virXMLPropString(node, "type"); char *address = virXMLPropString(node, "address"); char *network = virXMLPropString(node, "network"); + char *fromConfig = virXMLPropString(node, "fromConfig"); + int tmp; if (!type) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -7434,6 +7436,17 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, network = NULL; } + if (fromConfig && + flags & VIR_DOMAIN_XML_INTERNAL_STATUS) { + if (virStrToLong_i(fromConfig, NULL, 10, &tmp) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid fromConfig value: %s"), + fromConfig); + goto error; + } + def->fromConfig = tmp != 0; + } + ret = 0; error: if (ret < 0) @@ -7441,6 +7454,7 @@ error: VIR_FREE(type); VIR_FREE(address); VIR_FREE(network); + VIR_FREE(fromConfig); return ret; } @@ -14926,6 +14940,11 @@ virDomainGraphicsListenDefFormat(virBufferPtr buf, virDomainGraphicsListenDefPtr def, unsigned int flags) { + /* If generating migratable XML, skip listen address + * dragged in from config file */ + if ((flags & VIR_DOMAIN_XML_MIGRATABLE) && def->fromConfig) + return; + virBufferAddLit(buf, " type) { @@ -14947,6 +14966,9 @@ virDomainGraphicsListenDefFormat(virBufferPtr buf, virBufferEscapeString(buf, " network='%s'", def->network); } + if (flags & VIR_DOMAIN_XML_INTERNAL_STATUS) + virBufferAsprintf(buf, " fromConfig='%d'", def->fromConfig); + virBufferAddLit(buf, "/>\n"); } @@ -14973,6 +14995,9 @@ virDomainGraphicsDefFormat(virBufferPtr buf, for (i = 0; i < def->nListens; i++) { if (virDomainGraphicsListenGetType(def, i) == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) { + if (flags & VIR_DOMAIN_XML_MIGRATABLE && + def->listens[i].fromConfig) + continue; listenAddr = virDomainGraphicsListenGetAddress(def, i); break; } @@ -15084,6 +15109,9 @@ virDomainGraphicsDefFormat(virBufferPtr buf, if (virDomainGraphicsListenGetType(def, i) == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE) continue; + if (flags & VIR_DOMAIN_XML_MIGRATABLE && + def->listens[i].fromConfig) + continue; if (!children) { virBufferAddLit(buf, ">\n"); children = 1; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a2a9ff507a..0da85cffc3 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1389,6 +1389,7 @@ struct _virDomainGraphicsListenDef { int type; /* enum virDomainGraphicsListenType */ char *address; char *network; + bool fromConfig; /* true if the @address is config file originated */ }; struct _virDomainGraphicsDef { diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index e169f4d002..0db5e72531 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3509,6 +3509,7 @@ int qemuProcessStart(virConnectPtr conn, virReportOOMError(); goto cleanup; } + graphics->listens[0].fromConfig = true; } } } -- GitLab