char: Deprecate backend aliases 'tty' and 'parport'
authorKevin Wolf <kwolf@redhat.com>
Thu, 11 Mar 2021 16:42:52 +0000 (17:42 +0100)
committerKevin Wolf <kwolf@redhat.com>
Fri, 19 Mar 2021 09:18:06 +0000 (10:18 +0100)
QAPI doesn't know the aliases 'tty' and 'parport' and there is no
reason to prefer them to the real names of the backends 'serial' and
'parallel'.

Since warnings are not allowed in 'make check' output, we can't test
the deprecated alias any more. Remove it from test-char.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210311164253.338723-3-kwolf@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
chardev/char.c
docs/system/deprecated.rst
tests/unit/test-char.c

index dd925cf9a4a2a17c3a2d2c0c66b44cf225ff4627..7be9579dd85fff83dd099eb89ed315e1608cd009 100644 (file)
@@ -534,9 +534,10 @@ static const ChardevClass *char_get_class(const char *driver, Error **errp)
     return cc;
 }
 
-static const struct ChardevAlias {
+static struct ChardevAlias {
     const char *typename;
     const char *alias;
+    bool deprecation_warning_printed;
 } chardev_alias_table[] = {
 #ifdef HAVE_CHARDEV_PARPORT
     { "parallel", "parport" },
@@ -584,6 +585,10 @@ help_string_append(const char *name, bool is_cli_alias, void *opaque)
 {
     GString *str = opaque;
 
+    if (is_cli_alias) {
+        return;
+    }
+
     g_string_append_printf(str, "\n  %s", name);
 }
 
@@ -592,6 +597,11 @@ static const char *chardev_alias_translate(const char *name)
     int i;
     for (i = 0; i < (int)ARRAY_SIZE(chardev_alias_table); i++) {
         if (g_strcmp0(chardev_alias_table[i].alias, name) == 0) {
+            if (!chardev_alias_table[i].deprecation_warning_printed) {
+                warn_report("The alias '%s' is deprecated, use '%s' instead",
+                            name, chardev_alias_table[i].typename);
+                chardev_alias_table[i].deprecation_warning_printed = true;
+            }
             return chardev_alias_table[i].typename;
         }
     }
index 15b9767ba51ca620de6b023dbfdaf275c2b806cc..dfc12eef51307e2ba667ba6c77989399c35fafba 100644 (file)
@@ -46,6 +46,12 @@ needs two devices (``-device intel-hda -device hda-duplex``) and
 ``pcspk`` which can be activated using ``-machine
 pcspk-audiodev=<name>``.
 
+``-chardev`` backend aliases ``tty`` and ``parport`` (since 6.0)
+''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+
+``tty`` and ``parport`` are aliases that will be removed. Instead, the
+actual backend names ``serial`` and ``parallel`` should be used.
+
 RISC-V ``-bios`` (since 5.1)
 ''''''''''''''''''''''''''''
 
index 755d54c15e770014baf403c6d843ed2f6a2c87d6..5b3b48ebacd353d4525226e3aaf5f4c249e608b0 100644 (file)
@@ -1199,12 +1199,6 @@ static void char_serial_test(void)
     /* TODO: add more tests with a pty */
     object_unparent(OBJECT(chr));
 
-    /* test tty alias */
-    qemu_opt_set(opts, "backend", "tty", &error_abort);
-    chr = qemu_chr_new_from_opts(opts, NULL, &error_abort);
-    g_assert_nonnull(chr);
-    object_unparent(OBJECT(chr));
-
     qemu_opts_del(opts);
 }
 #endif