mirror of https://gitee.com/openkylin/libvirt.git
domain: backfill listen address to parent <graphics> listen attribute
Prior to 0.9.4, libvirt only supported a single listen, and it had to be an IP address: <graphics listen='1.2.3.4' ..../> Starting with 0.9.4, a graphics element could have a <listen> subelement (actually the grammar supports multiples, but all of the drivers only support a single <listen> per <graphics>), and that listen element can be of type='address' or type='network'. For type='address', <listen> also has an attribute called 'address' which contains the IP address for listening: <graphics ....> <listen type='address' address='1.2.3.4' .../> </graphics> type can also be "network", and in that case listen will have a "network" attribute which will contain the name of a libvirt network: <graphics ....> <listen type='network' network='testnet' .../> </graphics> At domain start (or migrate) time, libvirt will attempt to find an IP address associated with that network (e.g. the IP address of the bridge device used by the network, or the physical device listed in <forward dev='physdev'/>) and fill in that address in the status XML: <graphics ....> <listen type='network' network='testnet' address='1.2.3.4' .../> </graphics> In the case that a <graphics> element has a <listen> subelement of type='address', that listen subelement's "address" attribute is backfilled into the parent graphics element's "listen" *attribute* for backward compatibility (so that a management application unaware of the separate <listen> element can still learn the listen address). This backfill should be done with the IP learned from type='network' as well, and that's what this patch does: <graphics listen='1.2.3.4' ....> <listen type='network' network='testnet' address='1.2.3.4' .../> </graphics> This is a continuation of the fix for: https://bugzilla.redhat.com/show_bug.cgi?id=1191016
This commit is contained in:
parent
1ba8156cc9
commit
699299419b
|
@ -18915,17 +18915,23 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* find the first listen element of type='address' and duplicate
|
||||
* its address attribute as the listen attribute of
|
||||
* <graphics>. This is done to improve backward compatibility. */
|
||||
/* find the first listen subelement with a valid address and
|
||||
* duplicate its address attribute as the listen attribute of
|
||||
* <graphics>. This is done to improve backward compatibility.
|
||||
*/
|
||||
for (i = 0; i < def->nListens; i++) {
|
||||
if (virDomainGraphicsListenGetType(def, i)
|
||||
== VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) {
|
||||
if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE &&
|
||||
def->listens[i].fromConfig)
|
||||
continue;
|
||||
listenAddr = virDomainGraphicsListenGetAddress(def, i);
|
||||
break;
|
||||
virDomainGraphicsListenType listenType;
|
||||
|
||||
if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE &&
|
||||
def->listens[i].fromConfig)
|
||||
continue;
|
||||
listenType = virDomainGraphicsListenGetType(def, i);
|
||||
|
||||
if (listenType == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS ||
|
||||
(listenType == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK &&
|
||||
!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE))) {
|
||||
if ((listenAddr = virDomainGraphicsListenGetAddress(def, i)))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue