aboutsummaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2018-04-20 15:52:48 +0100
committerPeter Maydell <peter.maydell@linaro.org>2018-04-26 13:57:00 +0100
commit6af2692e86f9fdfb3d3d291c2708e81c3125d8e5 (patch)
tree33a4d343ec5fbb347d122405c8cd345e4b098b0f /vl.c
parent2cd4f8acb0e3416c7431d0e48d03f1a4c4a64cc1 (diff)
downloadqemu-6af2692e86f9fdfb3d3d291c2708e81c3125d8e5.zip
qemu-6af2692e86f9fdfb3d3d291c2708e81c3125d8e5.tar.gz
qemu-6af2692e86f9fdfb3d3d291c2708e81c3125d8e5.tar.bz2
vl.c: Remove compile time limit on number of serial ports
Instead of having a fixed sized global serial_hds[] array, use a local dynamically reallocated one, so we don't have a compile time limit on how many serial ports a system has. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Thomas Huth <thuth@redhat.com> Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-id: 20180420145249.32435-13-peter.maydell@linaro.org
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/vl.c b/vl.c
index 6daf026..a8a98c5 100644
--- a/vl.c
+++ b/vl.c
@@ -154,7 +154,8 @@ QEMUClockType rtc_clock;
int vga_interface_type = VGA_NONE;
static DisplayOptions dpy;
int no_frame;
-Chardev *serial_hds[MAX_SERIAL_PORTS];
+static int num_serial_hds = 0;
+static Chardev **serial_hds = NULL;
Chardev *parallel_hds[MAX_PARALLEL_PORTS];
Chardev *virtcon_hds[MAX_VIRTIO_CONSOLES];
Chardev *sclp_hds[MAX_SCLP_CONSOLES];
@@ -2496,30 +2497,28 @@ static int foreach_device_config(int type, int (*func)(const char *cmdline))
static int serial_parse(const char *devname)
{
- static int index = 0;
+ int index = num_serial_hds;
char label[32];
if (strcmp(devname, "none") == 0)
return 0;
- if (index == MAX_SERIAL_PORTS) {
- error_report("too many serial ports");
- exit(1);
- }
snprintf(label, sizeof(label), "serial%d", index);
+ serial_hds = g_renew(Chardev *, serial_hds, index + 1);
+
serial_hds[index] = qemu_chr_new(label, devname);
if (!serial_hds[index]) {
error_report("could not connect serial device"
" to character backend '%s'", devname);
return -1;
}
- index++;
+ num_serial_hds++;
return 0;
}
Chardev *serial_hd(int i)
{
assert(i >= 0);
- if (i < ARRAY_SIZE(serial_hds)) {
+ if (i < num_serial_hds) {
return serial_hds[i];
}
return NULL;