mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
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: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
0298531b29
commit
7c8df1e82f
@ -1999,6 +1999,7 @@ virDomainChrSourceDefCopy(virDomainChrSourceDefPtr dest,
|
||||
return -1;
|
||||
|
||||
dest->data.tcp.haveTLS = src->data.tcp.haveTLS;
|
||||
dest->data.tcp.tlsFromConfig = src->data.tcp.tlsFromConfig;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CHR_TYPE_UNIX:
|
||||
@ -10042,6 +10043,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
|
||||
char *slave = NULL;
|
||||
char *append = NULL;
|
||||
char *haveTLS = NULL;
|
||||
char *tlsFromConfig = NULL;
|
||||
int remaining = 0;
|
||||
|
||||
while (cur != NULL) {
|
||||
@ -10051,6 +10053,8 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
|
||||
mode = virXMLPropString(cur, "mode");
|
||||
if (!haveTLS)
|
||||
haveTLS = virXMLPropString(cur, "tls");
|
||||
if (!tlsFromConfig)
|
||||
tlsFromConfig = virXMLPropString(cur, "tlsFromConfig");
|
||||
|
||||
switch ((virDomainChrType) def->type) {
|
||||
case VIR_DOMAIN_CHR_TYPE_FILE:
|
||||
@ -10236,6 +10240,18 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
|
||||
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)
|
||||
def->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW;
|
||||
else if ((def->data.tcp.protocol =
|
||||
@ -10321,6 +10337,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
|
||||
VIR_FREE(logappend);
|
||||
VIR_FREE(logfile);
|
||||
VIR_FREE(haveTLS);
|
||||
VIR_FREE(tlsFromConfig);
|
||||
|
||||
return remaining;
|
||||
|
||||
@ -21508,9 +21525,14 @@ virDomainChrSourceDefFormat(virBufferPtr buf,
|
||||
def->data.tcp.listen ? "bind" : "connect");
|
||||
virBufferEscapeString(buf, "host='%s' ", def->data.tcp.host);
|
||||
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'",
|
||||
virTristateBoolTypeToString(def->data.tcp.haveTLS));
|
||||
if (flags & VIR_DOMAIN_DEF_FORMAT_STATUS)
|
||||
virBufferAsprintf(buf, " tlsFromConfig='%d'",
|
||||
def->data.tcp.tlsFromConfig);
|
||||
virBufferAddLit(buf, "/>\n");
|
||||
|
||||
virBufferAsprintf(buf, "<protocol type='%s'/>\n",
|
||||
|
@ -1096,6 +1096,7 @@ struct _virDomainChrSourceDef {
|
||||
int protocol;
|
||||
bool tlscreds;
|
||||
int haveTLS; /* enum virTristateBool */
|
||||
bool tlsFromConfig;
|
||||
} tcp;
|
||||
struct {
|
||||
char *bindHost;
|
||||
|
@ -6204,6 +6204,7 @@ qemuDomainPrepareChardevSourceTLS(virDomainChrSourceDefPtr source,
|
||||
source->data.tcp.haveTLS = VIR_TRISTATE_BOOL_YES;
|
||||
else
|
||||
source->data.tcp.haveTLS = VIR_TRISTATE_BOOL_NO;
|
||||
source->data.tcp.tlsFromConfig = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user