提交 7c8df1e8 编写于 作者: P Pavel Hrdina

domain: fix migration to older libvirt

Since TLS was introduced hostwide for libvirt 2.3.0 and a domain
configurable haveTLS was implemented for libvirt 2.4.0, we have to
modify the migratable XML for specific case where the 'tls' attribute
is based on setting from qemu.conf.

The "tlsFromConfig" is libvirt internal attribute and is stored only in
status XML to ensure that when libvirtd is restarted this internal flag
is not lost by the restart.

That flag is used to decide whether we should put *tls* attribute to
migratable XML or not.
Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 0298531b
...@@ -1999,6 +1999,7 @@ virDomainChrSourceDefCopy(virDomainChrSourceDefPtr dest, ...@@ -1999,6 +1999,7 @@ virDomainChrSourceDefCopy(virDomainChrSourceDefPtr dest,
return -1; return -1;
dest->data.tcp.haveTLS = src->data.tcp.haveTLS; dest->data.tcp.haveTLS = src->data.tcp.haveTLS;
dest->data.tcp.tlsFromConfig = src->data.tcp.tlsFromConfig;
break; break;
case VIR_DOMAIN_CHR_TYPE_UNIX: case VIR_DOMAIN_CHR_TYPE_UNIX:
...@@ -10042,6 +10043,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def, ...@@ -10042,6 +10043,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
char *slave = NULL; char *slave = NULL;
char *append = NULL; char *append = NULL;
char *haveTLS = NULL; char *haveTLS = NULL;
char *tlsFromConfig = NULL;
int remaining = 0; int remaining = 0;
while (cur != NULL) { while (cur != NULL) {
...@@ -10051,6 +10053,8 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def, ...@@ -10051,6 +10053,8 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
mode = virXMLPropString(cur, "mode"); mode = virXMLPropString(cur, "mode");
if (!haveTLS) if (!haveTLS)
haveTLS = virXMLPropString(cur, "tls"); haveTLS = virXMLPropString(cur, "tls");
if (!tlsFromConfig)
tlsFromConfig = virXMLPropString(cur, "tlsFromConfig");
switch ((virDomainChrType) def->type) { switch ((virDomainChrType) def->type) {
case VIR_DOMAIN_CHR_TYPE_FILE: case VIR_DOMAIN_CHR_TYPE_FILE:
...@@ -10236,6 +10240,18 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def, ...@@ -10236,6 +10240,18 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
goto error; goto error;
} }
if (tlsFromConfig &&
flags & VIR_DOMAIN_DEF_PARSE_STATUS) {
int tmp;
if (virStrToLong_i(tlsFromConfig, NULL, 10, &tmp) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("Invalid tlsFromConfig value: %s"),
tlsFromConfig);
goto error;
}
def->data.tcp.tlsFromConfig = !!tmp;
}
if (!protocol) if (!protocol)
def->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW; def->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW;
else if ((def->data.tcp.protocol = else if ((def->data.tcp.protocol =
...@@ -10321,6 +10337,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def, ...@@ -10321,6 +10337,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
VIR_FREE(logappend); VIR_FREE(logappend);
VIR_FREE(logfile); VIR_FREE(logfile);
VIR_FREE(haveTLS); VIR_FREE(haveTLS);
VIR_FREE(tlsFromConfig);
return remaining; return remaining;
...@@ -21508,9 +21525,14 @@ virDomainChrSourceDefFormat(virBufferPtr buf, ...@@ -21508,9 +21525,14 @@ virDomainChrSourceDefFormat(virBufferPtr buf,
def->data.tcp.listen ? "bind" : "connect"); def->data.tcp.listen ? "bind" : "connect");
virBufferEscapeString(buf, "host='%s' ", def->data.tcp.host); virBufferEscapeString(buf, "host='%s' ", def->data.tcp.host);
virBufferEscapeString(buf, "service='%s'", def->data.tcp.service); virBufferEscapeString(buf, "service='%s'", def->data.tcp.service);
if (def->data.tcp.haveTLS != VIR_TRISTATE_BOOL_ABSENT) if (def->data.tcp.haveTLS != VIR_TRISTATE_BOOL_ABSENT &&
!(flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE &&
def->data.tcp.tlsFromConfig))
virBufferAsprintf(buf, " tls='%s'", virBufferAsprintf(buf, " tls='%s'",
virTristateBoolTypeToString(def->data.tcp.haveTLS)); virTristateBoolTypeToString(def->data.tcp.haveTLS));
if (flags & VIR_DOMAIN_DEF_FORMAT_STATUS)
virBufferAsprintf(buf, " tlsFromConfig='%d'",
def->data.tcp.tlsFromConfig);
virBufferAddLit(buf, "/>\n"); virBufferAddLit(buf, "/>\n");
virBufferAsprintf(buf, "<protocol type='%s'/>\n", virBufferAsprintf(buf, "<protocol type='%s'/>\n",
......
...@@ -1096,6 +1096,7 @@ struct _virDomainChrSourceDef { ...@@ -1096,6 +1096,7 @@ struct _virDomainChrSourceDef {
int protocol; int protocol;
bool tlscreds; bool tlscreds;
int haveTLS; /* enum virTristateBool */ int haveTLS; /* enum virTristateBool */
bool tlsFromConfig;
} tcp; } tcp;
struct { struct {
char *bindHost; char *bindHost;
......
...@@ -6204,6 +6204,7 @@ qemuDomainPrepareChardevSourceTLS(virDomainChrSourceDefPtr source, ...@@ -6204,6 +6204,7 @@ qemuDomainPrepareChardevSourceTLS(virDomainChrSourceDefPtr source,
source->data.tcp.haveTLS = VIR_TRISTATE_BOOL_YES; source->data.tcp.haveTLS = VIR_TRISTATE_BOOL_YES;
else else
source->data.tcp.haveTLS = VIR_TRISTATE_BOOL_NO; source->data.tcp.haveTLS = VIR_TRISTATE_BOOL_NO;
source->data.tcp.tlsFromConfig = true;
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册