Virtio-serial ports that have a number too high are rejected. The
maximum port number is retrieved from the ports attribute of the
controller if present, otherwise defaulting to 31.
---
src/conf/domain_conf.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 2bade1b..bfb3a81 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12257,6 +12257,26 @@ virDomainDefParseXML(xmlDocPtr xml,
maxport = 0;
chr->info.addr.vioserial.port = maxport + 1;
}
+
+ /* verify that port is not out of range */
+ if (chr->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL) {
+ size_t j;
+ int maxports = 31;
+ for (j = 0; j < def->ncontrollers; j++) { /* get maximum supported
ports for ctlr */
+ if (def->controllers[j]->type ==
VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL &&
+ def->controllers[j]->idx ==
chr->info.addr.vioserial.controller) {
+ maxports = (def->controllers[j]->opts.vioserial.ports != -1)
+ ? def->controllers[j]->opts.vioserial.ports : 31;
+ break;
+ }
+ }
+ if (chr->info.addr.vioserial.port >= maxports) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Port number %d of virtio-serial is too high
(maximum is %d)"),
+ chr->info.addr.vioserial.port, maxports-1);
+ goto error;
+ }
+ }
}
VIR_FREE(nodes);
--
1.8.3.1