mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
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.
This commit is contained in:
parent
9313a6a7fc
commit
6546017c50
@ -7688,6 +7688,8 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
|
|||||||
char *type = virXMLPropString(node, "type");
|
char *type = virXMLPropString(node, "type");
|
||||||
char *address = virXMLPropString(node, "address");
|
char *address = virXMLPropString(node, "address");
|
||||||
char *network = virXMLPropString(node, "network");
|
char *network = virXMLPropString(node, "network");
|
||||||
|
char *fromConfig = virXMLPropString(node, "fromConfig");
|
||||||
|
int tmp;
|
||||||
|
|
||||||
if (!type) {
|
if (!type) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
@ -7724,6 +7726,17 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
|
|||||||
network = NULL;
|
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;
|
ret = 0;
|
||||||
error:
|
error:
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -7731,6 +7744,7 @@ error:
|
|||||||
VIR_FREE(type);
|
VIR_FREE(type);
|
||||||
VIR_FREE(address);
|
VIR_FREE(address);
|
||||||
VIR_FREE(network);
|
VIR_FREE(network);
|
||||||
|
VIR_FREE(fromConfig);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15365,6 +15379,11 @@ virDomainGraphicsListenDefFormat(virBufferPtr buf,
|
|||||||
virDomainGraphicsListenDefPtr def,
|
virDomainGraphicsListenDefPtr def,
|
||||||
unsigned int flags)
|
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, " <listen");
|
virBufferAddLit(buf, " <listen");
|
||||||
|
|
||||||
if (def->type) {
|
if (def->type) {
|
||||||
@ -15386,6 +15405,9 @@ virDomainGraphicsListenDefFormat(virBufferPtr buf,
|
|||||||
virBufferEscapeString(buf, " network='%s'", def->network);
|
virBufferEscapeString(buf, " network='%s'", def->network);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flags & VIR_DOMAIN_XML_INTERNAL_STATUS)
|
||||||
|
virBufferAsprintf(buf, " fromConfig='%d'", def->fromConfig);
|
||||||
|
|
||||||
virBufferAddLit(buf, "/>\n");
|
virBufferAddLit(buf, "/>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15412,6 +15434,9 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
|
|||||||
for (i = 0; i < def->nListens; i++) {
|
for (i = 0; i < def->nListens; i++) {
|
||||||
if (virDomainGraphicsListenGetType(def, i)
|
if (virDomainGraphicsListenGetType(def, i)
|
||||||
== VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) {
|
== VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) {
|
||||||
|
if (flags & VIR_DOMAIN_XML_MIGRATABLE &&
|
||||||
|
def->listens[i].fromConfig)
|
||||||
|
continue;
|
||||||
listenAddr = virDomainGraphicsListenGetAddress(def, i);
|
listenAddr = virDomainGraphicsListenGetAddress(def, i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -15531,6 +15556,9 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
|
|||||||
if (virDomainGraphicsListenGetType(def, i)
|
if (virDomainGraphicsListenGetType(def, i)
|
||||||
== VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE)
|
== VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE)
|
||||||
continue;
|
continue;
|
||||||
|
if (flags & VIR_DOMAIN_XML_MIGRATABLE &&
|
||||||
|
def->listens[i].fromConfig)
|
||||||
|
continue;
|
||||||
if (!children) {
|
if (!children) {
|
||||||
virBufferAddLit(buf, ">\n");
|
virBufferAddLit(buf, ">\n");
|
||||||
children = true;
|
children = true;
|
||||||
|
@ -1420,6 +1420,7 @@ struct _virDomainGraphicsListenDef {
|
|||||||
int type; /* enum virDomainGraphicsListenType */
|
int type; /* enum virDomainGraphicsListenType */
|
||||||
char *address;
|
char *address;
|
||||||
char *network;
|
char *network;
|
||||||
|
bool fromConfig; /* true if the @address is config file originated */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _virDomainGraphicsDef {
|
struct _virDomainGraphicsDef {
|
||||||
|
@ -3486,6 +3486,7 @@ int qemuProcessStart(virConnectPtr conn,
|
|||||||
VIR_SHRINK_N(graphics->listens, graphics->nListens, 1);
|
VIR_SHRINK_N(graphics->listens, graphics->nListens, 1);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
graphics->listens[0].fromConfig = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user