This overrides the port number on hotplug, not just
when parsing the domain XML.
https://bugzilla.redhat.com/show_bug.cgi?id=1089991
https://bugzilla.redhat.com/show_bug.cgi?id=1089997
---
src/conf/domain_conf.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 46294fa..3c0d2ff 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2993,18 +2993,25 @@ virDomainDeviceDefPostParseInternal(virDomainDeviceDefPtr dev,
if (dev->type == VIR_DOMAIN_DEVICE_CHR) {
virDomainChrDefPtr chr = dev->data.chr;
const virDomainChrDef **arrPtr;
- size_t i, cnt;
+ size_t i, cnt, idx;
virDomainChrGetDomainPtrs(def, chr->deviceType, &arrPtr, &cnt);
+ for (idx = 0; idx < cnt; idx++) {
+ if (arrPtr[idx] == chr)
+ break;
+ }
+
if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)
chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
+ if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE)
+ chr->target.port = idx;
+
if (chr->target.port == -1 &&
(chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL ||
- chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL ||
- chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE)) {
+ chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL)) {
int maxport = -1;
for (i = 0; i < cnt; i++) {
@@ -12395,7 +12402,6 @@ virDomainDefParseXML(xmlDocPtr xml,
if (!chr)
goto error;
- chr->target.port = i;
def->consoles[def->nconsoles++] = chr;
}
VIR_FREE(nodes);
--
1.8.3.2