]> Git Repo - qemu.git/commitdiff
vl.c: Remove compile time limit on number of serial ports
authorPeter Maydell <[email protected]>
Fri, 20 Apr 2018 14:52:48 +0000 (15:52 +0100)
committerPeter Maydell <[email protected]>
Thu, 26 Apr 2018 12:57:00 +0000 (13:57 +0100)
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 <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: 20180420145249[email protected]

include/sysemu/sysemu.h
vl.c

index bd5b55c514b958cf82f349f4e8a2affc690b40a6..989cbc2b7b9f1a1efa3d8c0fb0f10f481f3200a6 100644 (file)
@@ -161,8 +161,6 @@ void hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict);
 
 #define MAX_SERIAL_PORTS 4
 
-extern Chardev *serial_hds[MAX_SERIAL_PORTS];
-
 /* Return the Chardev for serial port i, or NULL if none */
 Chardev *serial_hd(int i);
 
diff --git a/vl.c b/vl.c
index 6daf026da66f56877c39f03830adfa6349ca9b9a..a8a98c5a37b649c56dcc0f5a418bb71715aa671b 100644 (file)
--- 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;
This page took 0.03468 seconds and 4 git commands to generate.