Skip to content

Commit

Permalink
Merge tag 'pull-char-2024-02-12' of https://repo.or.cz/qemu/armbru in…
Browse files Browse the repository at this point in the history
…to staging

Character device backend patches for 2024-02-12

# -----BEGIN PGP SIGNATURE-----
#
# iQJGBAABCAAwFiEENUvIs9frKmtoZ05fOHC0AOuRhlMFAmXJ2jkSHGFybWJydUBy
# ZWRoYXQuY29tAAoJEDhwtADrkYZTe+YP/isehYTM4uP2hn93p1KyQ2AZ6hQTJca4
# zJVkNoCwV/7qXH0JESBY29x5o1VV0MKgxXORyb2gRYuHVQN7IrBKWk4+vqXoTJ8L
# r3fR0Cchz/2FDdNAnkGV8LDB0adbFMFHLR80Gfofgbnxaw5VQzMPamWUlsocGzs+
# e6NYXRJssjP9G2IMVbJC6/ZLpv0z41A0Er0K1KhAcupRsrgG9FjxwfzFo8edOrkz
# HM5NTq3Pg00J26VI60Gu3BTn8QlUDmnWlsob2VuUpQF+B5makA2M+7Pu07oxnV+Q
# jDm2mICillKG4c0cVciLcikzKyPMdUCTf3+nU3PneKInyVKZXAKBsC5ntC1wl5dn
# 0nfsvO8YoZVBxrSGMOqkqzGq/9DpWAiCQ8dEtUXR0X59pyIl1qywq5dY/4c0W3G/
# B9oVGebHQG8dENz/t7Ps+Wl51Dd+3XTjVTYplREUzgCdvwzQgy7/mA99CKDaGjtA
# JVsYIkyIhpQG9n7WXtOo0BC4ZFjC9WnFl7CReVwZFMma4ggnYTfPYJ0HmZPqAYgD
# ZpUM4WW4IYxVbIUbkmrVOBhZ1aRT4M4W8Vybb8V63orYX0R/kjNKRg9LfnmKy1Ql
# 4WFhJwp0MOJz5stupe3QiEidfFBYtGJiPsc91TGpwlar0nNZH0WgSGFGY7rbA5RY
# W3Tb+ARki7YF
# =lWRZ
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 12 Feb 2024 08:43:37 GMT
# gpg:                using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653
# gpg:                issuer "armbru@redhat.com"
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full]
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>" [full]
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* tag 'pull-char-2024-02-12' of https://repo.or.cz/qemu/armbru:
  qapi/char: Deprecate backend type "memory"
  qapi/char: Make backend types properly conditional
  tests/unit/test-char: Fix qemu_socket(), make_udp_socket() check
  chardev/parallel: Don't close stdin on inappropriate device

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Feb 12, 2024
2 parents 5005aed + 684d03a commit df381b8
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 19 deletions.
7 changes: 5 additions & 2 deletions chardev/char-parallel.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,13 @@ static void qemu_chr_open_pp_fd(Chardev *chr,
{
ParallelChardev *drv = PARALLEL_CHARDEV(chr);

drv->fd = fd;

if (ioctl(fd, PPCLAIM) < 0) {
error_setg_errno(errp, errno, "not a parallel port");
close(fd);
return;
}

drv->fd = fd;
drv->mode = IEEE1284_MODE_COMPAT;
}
#endif /* __linux__ */
Expand Down Expand Up @@ -238,6 +238,7 @@ static void qemu_chr_open_pp_fd(Chardev *chr,
}
#endif

#ifdef HAVE_CHARDEV_PARALLEL
static void qmp_chardev_open_parallel(Chardev *chr,
ChardevBackend *backend,
bool *be_opened,
Expand Down Expand Up @@ -306,3 +307,5 @@ static void register_types(void)
}

type_init(register_types);

#endif /* HAVE_CHARDEV_PARALLEL */
4 changes: 1 addition & 3 deletions chardev/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ if host_os == 'windows'
else
chardev_ss.add(files(
'char-fd.c',
'char-parallel.c',
'char-pty.c',
), util)
if host_os in ['linux', 'gnu/kfreebsd', 'freebsd', 'dragonfly']
chardev_ss.add(files('char-parallel.c'))
endif
endif

chardev_ss = chardev_ss.apply({})
Expand Down
8 changes: 8 additions & 0 deletions docs/about/deprecated.rst
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,14 @@ Specifying the iSCSI password in plain text on the command line using the
used instead, to refer to a ``--object secret...`` instance that provides
a password via a file, or encrypted.

Character device options
''''''''''''''''''''''''

Backend ``memory`` (since 9.0)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

``memory`` is a deprecated synonym for ``ringbuf``.

CPU device properties
'''''''''''''''''''''

Expand Down
9 changes: 8 additions & 1 deletion include/qemu/osdep.h
Original file line number Diff line number Diff line change
Expand Up @@ -508,11 +508,18 @@ void qemu_anon_ram_free(void *ptr, size_t size);

#ifdef _WIN32
#define HAVE_CHARDEV_SERIAL 1
#elif defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \
#define HAVE_CHARDEV_PARALLEL 1
#else
#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \
|| defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) \
|| defined(__GLIBC__) || defined(__APPLE__)
#define HAVE_CHARDEV_SERIAL 1
#endif
#if defined(__linux__) || defined(__FreeBSD__) \
|| defined(__FreeBSD_kernel__) || defined(__DragonFly__)
#define HAVE_CHARDEV_PARALLEL 1
#endif
#endif

#if defined(__HAIKU__)
#define SIGIO SIGPOLL
Expand Down
28 changes: 17 additions & 11 deletions qapi/char.json
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,16 @@
#
# @memory: Since 1.5
#
# Features:
#
# @deprecated: Member @memory is deprecated. Use @ringbuf instead.
#
# Since: 1.4
##
{ 'enum': 'ChardevBackendKind',
'data': [ 'file',
'serial',
'parallel',
{ 'name': 'serial', 'if': 'HAVE_CHARDEV_SERIAL' },
{ 'name': 'parallel', 'if': 'HAVE_CHARDEV_PARALLEL' },
'pipe',
'socket',
'udp',
Expand All @@ -482,18 +486,17 @@
'mux',
'msmouse',
'wctablet',
'braille',
{ 'name': 'braille', 'if': 'CONFIG_BRLAPI' },
'testdev',
'stdio',
'console',
{ 'name': 'console', 'if': 'CONFIG_WIN32' },
{ 'name': 'spicevmc', 'if': 'CONFIG_SPICE' },
{ 'name': 'spiceport', 'if': 'CONFIG_SPICE' },
{ 'name': 'qemu-vdagent', 'if': 'CONFIG_SPICE_PROTOCOL' },
{ 'name': 'dbus', 'if': 'CONFIG_DBUS_DISPLAY' },
'vc',
'ringbuf',
# next one is just for compatibility
'memory' ] }
{ 'name': 'memory', 'features': [ 'deprecated' ] } ] }

##
# @ChardevFileWrapper:
Expand Down Expand Up @@ -614,8 +617,10 @@
'base': { 'type': 'ChardevBackendKind' },
'discriminator': 'type',
'data': { 'file': 'ChardevFileWrapper',
'serial': 'ChardevHostdevWrapper',
'parallel': 'ChardevHostdevWrapper',
'serial': { 'type': 'ChardevHostdevWrapper',
'if': 'HAVE_CHARDEV_SERIAL' },
'parallel': { 'type': 'ChardevHostdevWrapper',
'if': 'HAVE_CHARDEV_PARALLEL' },
'pipe': 'ChardevHostdevWrapper',
'socket': 'ChardevSocketWrapper',
'udp': 'ChardevUdpWrapper',
Expand All @@ -624,10 +629,12 @@
'mux': 'ChardevMuxWrapper',
'msmouse': 'ChardevCommonWrapper',
'wctablet': 'ChardevCommonWrapper',
'braille': 'ChardevCommonWrapper',
'braille': { 'type': 'ChardevCommonWrapper',
'if': 'CONFIG_BRLAPI' },
'testdev': 'ChardevCommonWrapper',
'stdio': 'ChardevStdioWrapper',
'console': 'ChardevCommonWrapper',
'console': { 'type': 'ChardevCommonWrapper',
'if': 'CONFIG_WIN32' },
'spicevmc': { 'type': 'ChardevSpiceChannelWrapper',
'if': 'CONFIG_SPICE' },
'spiceport': { 'type': 'ChardevSpicePortWrapper',
Expand All @@ -638,7 +645,6 @@
'if': 'CONFIG_DBUS_DISPLAY' },
'vc': 'ChardevVCWrapper',
'ringbuf': 'ChardevRingbufWrapper',
# next one is just for compatibility
'memory': 'ChardevRingbufWrapper' } }

##
Expand Down
25 changes: 23 additions & 2 deletions tests/unit/test-char.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ static int make_udp_socket(int *port)
socklen_t alen = sizeof(addr);
int ret, sock = qemu_socket(PF_INET, SOCK_DGRAM, 0);

g_assert_cmpint(sock, >, 0);
g_assert_cmpint(sock, >=, 0);
addr.sin_family = AF_INET ;
addr.sin_addr.s_addr = htonl(INADDR_ANY);
addr.sin_port = 0;
Expand Down Expand Up @@ -1203,6 +1203,24 @@ static void char_serial_test(void)
}
#endif

#if defined(HAVE_CHARDEV_PARALLEL) && !defined(WIN32)
static void char_parallel_test(void)
{
QemuOpts *opts;
Chardev *chr;

opts = qemu_opts_create(qemu_find_opts("chardev"), "parallel-id",
1, &error_abort);
qemu_opt_set(opts, "backend", "parallel", &error_abort);
qemu_opt_set(opts, "path", "/dev/null", &error_abort);

chr = qemu_chr_new_from_opts(opts, NULL, NULL);
g_assert_null(chr);

qemu_opts_del(opts);
}
#endif

#ifndef _WIN32
static void char_file_fifo_test(void)
{
Expand Down Expand Up @@ -1383,7 +1401,7 @@ static void char_hotswap_test(void)

int port;
int sock = make_udp_socket(&port);
g_assert_cmpint(sock, >, 0);
g_assert_cmpint(sock, >=, 0);

chr_args = g_strdup_printf("udp:127.0.0.1:%d", port);

Expand Down Expand Up @@ -1544,6 +1562,9 @@ int main(int argc, char **argv)
g_test_add_func("/char/udp", char_udp_test);
#if defined(HAVE_CHARDEV_SERIAL) && !defined(WIN32)
g_test_add_func("/char/serial", char_serial_test);
#endif
#if defined(HAVE_CHARDEV_PARALLEL) && !defined(WIN32)
g_test_add_func("/char/parallel", char_parallel_test);
#endif
g_test_add_func("/char/hotswap", char_hotswap_test);
g_test_add_func("/char/websocket", char_websock_test);
Expand Down

0 comments on commit df381b8

Please sign in to comment.