Character device backend patches for 2024-02-12

-----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEENUvIs9frKmtoZ05fOHC0AOuRhlMFAmXMYY0SHGFybWJydUBy
 ZWRoYXQuY29tAAoJEDhwtADrkYZTTGYQALEO48lySVjvKEYjUpjFNkwL4sA2wLyp
 JMUuUresuH2w/a/pornhgW6ICQWLbxXSinfBy7G68/BqFiqxdLEFe7VE0zzg3wXV
 MNY1SHZDQ6nvREqvpj2uAj5nq1dxqbcAnTbGbJeDWKi2+JtvZ3IO9CA6zLfMDd6D
 bJpTOoNeGEogFel9enISJteiLJYTRU50Rdn73epSJ8NGoMQja9YoM2sA1VqNuscH
 sjzNRMfpAboMkkTCPhi3RivQUUzt45zEwRHFy30Gz9YK9BDKmqJbqfhTAiBgsDBk
 TUqwnoyMQwHZ3xkT46s62Z2qy1uSautJOtnbNpnQlEZgc42T0Kli61+p+iPmKr+H
 ZxZAKUUtsz7PSBMcnl91VTJZA3+FaWTkm5IPd2bVPuxFtZl0C1EdflsxFY1/3tEy
 tr3GbIs6DkXpzmf+o8OXm72XTF7DPgDfsdn0K+9dJLO+G/C5r9euWCTeQeW2QR8d
 PfpuNo9iZcRbp3BS/7zsr6dwdW9jVWPE3U3spORRqjX4eS6B6UMmug54EDdnZaM8
 abLDRf2KQuXBD5IazGSQZfC6Kvx2FOqyJD67gWsv0A83sAfhfC+JyIVp67sJPpdf
 KoXTjPn2jiBfzibrMWxDJiFS8TiYI5jO28BPPERlrWZ+AojHAnY+ytQ1avggZaCU
 Ypv+CgoMG1gC
 =bOef
 -----END PGP SIGNATURE-----

Merge tag 'pull-char-2024-02-12-v2' of https://repo.or.cz/qemu/armbru into staging

Character device backend patches for 2024-02-12

# -----BEGIN PGP SIGNATURE-----
#
# iQJGBAABCAAwFiEENUvIs9frKmtoZ05fOHC0AOuRhlMFAmXMYY0SHGFybWJydUBy
# ZWRoYXQuY29tAAoJEDhwtADrkYZTTGYQALEO48lySVjvKEYjUpjFNkwL4sA2wLyp
# JMUuUresuH2w/a/pornhgW6ICQWLbxXSinfBy7G68/BqFiqxdLEFe7VE0zzg3wXV
# MNY1SHZDQ6nvREqvpj2uAj5nq1dxqbcAnTbGbJeDWKi2+JtvZ3IO9CA6zLfMDd6D
# bJpTOoNeGEogFel9enISJteiLJYTRU50Rdn73epSJ8NGoMQja9YoM2sA1VqNuscH
# sjzNRMfpAboMkkTCPhi3RivQUUzt45zEwRHFy30Gz9YK9BDKmqJbqfhTAiBgsDBk
# TUqwnoyMQwHZ3xkT46s62Z2qy1uSautJOtnbNpnQlEZgc42T0Kli61+p+iPmKr+H
# ZxZAKUUtsz7PSBMcnl91VTJZA3+FaWTkm5IPd2bVPuxFtZl0C1EdflsxFY1/3tEy
# tr3GbIs6DkXpzmf+o8OXm72XTF7DPgDfsdn0K+9dJLO+G/C5r9euWCTeQeW2QR8d
# PfpuNo9iZcRbp3BS/7zsr6dwdW9jVWPE3U3spORRqjX4eS6B6UMmug54EDdnZaM8
# abLDRf2KQuXBD5IazGSQZfC6Kvx2FOqyJD67gWsv0A83sAfhfC+JyIVp67sJPpdf
# KoXTjPn2jiBfzibrMWxDJiFS8TiYI5jO28BPPERlrWZ+AojHAnY+ytQ1avggZaCU
# Ypv+CgoMG1gC
# =bOef
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 14 Feb 2024 06:45:33 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-v2' 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>
This commit is contained in:
Peter Maydell 2024-02-14 13:00:19 +00:00
commit 708322660e
6 changed files with 68 additions and 19 deletions

View File

@ -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__ */
@ -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,
@ -306,3 +307,5 @@ static void register_types(void)
}
type_init(register_types);
#endif /* HAVE_CHARDEV_PARALLEL */

View File

@ -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({})

View File

@ -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
'''''''''''''''''''''

View File

@ -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

View File

@ -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',
@ -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:
@ -642,8 +645,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',
@ -652,10 +657,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',
@ -666,7 +673,6 @@
'if': 'CONFIG_DBUS_DISPLAY' },
'vc': 'ChardevVCWrapper',
'ringbuf': 'ChardevRingbufWrapper',
# next one is just for compatibility
'memory': 'ChardevRingbufWrapper' } }
##

View File

@ -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;
@ -1203,6 +1203,30 @@ 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);
#ifdef __linux__
/* fails to PPCLAIM, see qemu_chr_open_pp_fd() */
g_assert_null(chr);
#else
g_assert_nonnull(chr);
object_unparent(OBJECT(chr));
#endif
qemu_opts_del(opts);
}
#endif
#ifndef _WIN32
static void char_file_fifo_test(void)
{
@ -1383,7 +1407,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);
@ -1544,6 +1568,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);