mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
virDomainDefAddConsoleCompat: Fix numbering of console targets after modification
The XML parser for consoles sets the 'port=' attribute of '<target' to be always the index of the console. Thus when the "really crazy backcompat stuff for consoles" function modifies the order of consoles by inserting the default one for a serial port it must re-number the ports to ensure that the value will not change on subsequent parse. This luckily didn't cause any visible changes to the VM as the port number isn't used for anything. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
f51c6b5b02
commit
55839c154d
@ -4958,6 +4958,7 @@ virDomainDefHasDeviceAddress(virDomainDef *def,
|
|||||||
static int
|
static int
|
||||||
virDomainDefAddConsoleCompat(virDomainDef *def)
|
virDomainDefAddConsoleCompat(virDomainDef *def)
|
||||||
{
|
{
|
||||||
|
bool renumber_consoles = false;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -5024,6 +5025,8 @@ virDomainDefAddConsoleCompat(virDomainDef *def)
|
|||||||
/* Create an console alias for the serial port */
|
/* Create an console alias for the serial port */
|
||||||
def->consoles[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
|
def->consoles[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
|
||||||
def->consoles[0]->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
|
def->consoles[0]->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
|
||||||
|
|
||||||
|
renumber_consoles = true;
|
||||||
}
|
}
|
||||||
} else if (def->os.type == VIR_DOMAIN_OSTYPE_HVM && def->nserials > 0 &&
|
} else if (def->os.type == VIR_DOMAIN_OSTYPE_HVM && def->nserials > 0 &&
|
||||||
def->serials[0]->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL) {
|
def->serials[0]->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL) {
|
||||||
@ -5051,6 +5054,8 @@ virDomainDefAddConsoleCompat(virDomainDef *def)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renumber_consoles = true;
|
||||||
|
|
||||||
def->consoles[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
|
def->consoles[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
|
||||||
def->consoles[0]->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
|
def->consoles[0]->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
|
||||||
|
|
||||||
@ -5066,6 +5071,16 @@ virDomainDefAddConsoleCompat(virDomainDef *def)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* When consoles are parsed in 'virDomainDefParseXML' the value of
|
||||||
|
* 'target.port' is overriden by the index of the console in the
|
||||||
|
* 'def->consoles' array. Thus if we are modifying the list here we
|
||||||
|
* must ensure that the numbering will be identical as if we've parsed
|
||||||
|
* this definition */
|
||||||
|
if (renumber_consoles) {
|
||||||
|
for (i = 0; i < def->nconsoles; i++)
|
||||||
|
def->consoles[i]->target.port = i;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
<target type='serial' port='0'/>
|
<target type='serial' port='0'/>
|
||||||
</console>
|
</console>
|
||||||
<console type='pty'>
|
<console type='pty'>
|
||||||
<target type='virtio' port='0'/>
|
<target type='virtio' port='1'/>
|
||||||
</console>
|
</console>
|
||||||
<input type='mouse' bus='ps2'/>
|
<input type='mouse' bus='ps2'/>
|
||||||
<input type='keyboard' bus='ps2'/>
|
<input type='keyboard' bus='ps2'/>
|
||||||
|
Loading…
Reference in New Issue
Block a user