]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
vl.c: new function serial_max_hds()
authorPeter Maydell <peter.maydell@linaro.org>
Fri, 20 Apr 2018 14:52:49 +0000 (15:52 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Thu, 26 Apr 2018 12:58:29 +0000 (13:58 +0100)
Create a new function serial_max_hds() which returns the number of
serial ports defined by the user. This is needed only by spapr.

This allows us to remove the MAX_SERIAL_PORTS define.

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-14-peter.maydell@linaro.org

hw/ppc/spapr.c
include/sysemu/sysemu.h
vl.c

index b0ecfaca9ec0820cd913cefc3112fdd72fce1385..92194a9a5356d3cbbfbb8236eacadb429d00731a 100644 (file)
@@ -2589,7 +2589,7 @@ static void spapr_machine_init(MachineState *machine)
     /* Set up VIO bus */
     spapr->vio_bus = spapr_vio_bus_init();
 
-    for (i = 0; i < MAX_SERIAL_PORTS; i++) {
+    for (i = 0; i < serial_max_hds(); i++) {
         if (serial_hd(i)) {
             spapr_vty_create(spapr->vio_bus, serial_hd(i));
         }
index 989cbc2b7b9f1a1efa3d8c0fb0f10f481f3200a6..544ab77a2b32c1f71f715b529b266d33d59e73c6 100644 (file)
@@ -159,10 +159,12 @@ void hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict);
 
 /* serial ports */
 
-#define MAX_SERIAL_PORTS 4
-
 /* Return the Chardev for serial port i, or NULL if none */
 Chardev *serial_hd(int i);
+/* return the number of serial ports defined by the user. serial_hd(i)
+ * will always return NULL for any i which is greater than or equal to this.
+ */
+int serial_max_hds(void);
 
 /* parallel ports */
 
diff --git a/vl.c b/vl.c
index a8a98c5a37b649c56dcc0f5a418bb71715aa671b..616956adf17f541acf0903ea3cb1182f2e0b521e 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -2524,6 +2524,11 @@ Chardev *serial_hd(int i)
     return NULL;
 }
 
+int serial_max_hds(void)
+{
+    return num_serial_hds;
+}
+
 static int parallel_parse(const char *devname)
 {
     static int index = 0;