* qtest improvements

* Remove the deprecated OTP config of sifive_u
 * Add libfdt to some of our CI jobs that were still missing it
 * Use __builtin_bswap() everywhere (all compiler versions support it now)
 * Deprecate the HAXM accelerator
 * Document PCI devices handling on s390x
 * Make Audiodev introspectable
 * Improve the runtime of some CI jobs
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEJ7iIR+7gJQEY8+q5LtnXdP5wLbUFAmPY59YRHHRodXRoQHJl
 ZGhhdC5jb20ACgkQLtnXdP5wLbXzhxAAmoq2j2sbAf2Vr9tz6Ez2p9oKNYnzUEWb
 NGXdvQMcVFKIdjvSYt5ozLC53OFIzuS74X7oHKbdLvGzez3nMCijZIbzN6vNnvd9
 HNGum4blNwHEfQcY9hr9y30Iurc7CQu6VtwGF+XXdzQZDbPz1Z4AWvtPTLcTbkxa
 PskYJfFvow/oaTHDA/7t+90cxCOixKvQMKXL5ATCtMRGnjlbOAEoPbXUB+yM24mk
 9qp1L/8h8pvXfeXlFj+KETmu+eE5ETEOQtqc2KhQqqze2+VMKYxSX2H+sNkJBPDP
 En8Mpy+fEdefu8Jcu+M2kMLhf1f3LVf9uARhLZY4/xmOYFg+F3xzwpshnH1bs+Kw
 IzWP84uHjE77jSy/wKvYiCx2hdCDwO0G+zym67D1fPzvjzKzUNprV4OIuRzTWah3
 6Zli5uuaLrBNjR8SJB1HDmLGKDFgToH9dzfLPtDmW8UPJGkAGcBbPKktLTe5y/4E
 del99NqpTx5SAqMmbSMRPZ/vZ7ITdfB0Av3a0GdO8j7eSPb9BOsoZOVD2/iUzab/
 P0dBuNqMM8fwywVKqcK+0CJ/npWIJvOqqlwSDqhY1A78G/uRuapOqUwsB/LWRFv5
 /1VvHfA2rv4l9o66N5jssS5/D1v5p/UBB6JvlTUvuoJMFTXa9de9XFxYxfkyiaAz
 LJl+Dh+aeWk=
 =uq7y
 -----END PGP SIGNATURE-----

Merge tag 'pull-request-2023-01-31' of https://gitlab.com/thuth/qemu into staging

* qtest improvements
* Remove the deprecated OTP config of sifive_u
* Add libfdt to some of our CI jobs that were still missing it
* Use __builtin_bswap() everywhere (all compiler versions support it now)
* Deprecate the HAXM accelerator
* Document PCI devices handling on s390x
* Make Audiodev introspectable
* Improve the runtime of some CI jobs

# -----BEGIN PGP SIGNATURE-----
#
# iQJFBAABCAAvFiEEJ7iIR+7gJQEY8+q5LtnXdP5wLbUFAmPY59YRHHRodXRoQHJl
# ZGhhdC5jb20ACgkQLtnXdP5wLbXzhxAAmoq2j2sbAf2Vr9tz6Ez2p9oKNYnzUEWb
# NGXdvQMcVFKIdjvSYt5ozLC53OFIzuS74X7oHKbdLvGzez3nMCijZIbzN6vNnvd9
# HNGum4blNwHEfQcY9hr9y30Iurc7CQu6VtwGF+XXdzQZDbPz1Z4AWvtPTLcTbkxa
# PskYJfFvow/oaTHDA/7t+90cxCOixKvQMKXL5ATCtMRGnjlbOAEoPbXUB+yM24mk
# 9qp1L/8h8pvXfeXlFj+KETmu+eE5ETEOQtqc2KhQqqze2+VMKYxSX2H+sNkJBPDP
# En8Mpy+fEdefu8Jcu+M2kMLhf1f3LVf9uARhLZY4/xmOYFg+F3xzwpshnH1bs+Kw
# IzWP84uHjE77jSy/wKvYiCx2hdCDwO0G+zym67D1fPzvjzKzUNprV4OIuRzTWah3
# 6Zli5uuaLrBNjR8SJB1HDmLGKDFgToH9dzfLPtDmW8UPJGkAGcBbPKktLTe5y/4E
# del99NqpTx5SAqMmbSMRPZ/vZ7ITdfB0Av3a0GdO8j7eSPb9BOsoZOVD2/iUzab/
# P0dBuNqMM8fwywVKqcK+0CJ/npWIJvOqqlwSDqhY1A78G/uRuapOqUwsB/LWRFv5
# /1VvHfA2rv4l9o66N5jssS5/D1v5p/UBB6JvlTUvuoJMFTXa9de9XFxYxfkyiaAz
# LJl+Dh+aeWk=
# =uq7y
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 31 Jan 2023 10:05:10 GMT
# gpg:                using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5
# gpg:                issuer "thuth@redhat.com"
# gpg: Good signature from "Thomas Huth <th.huth@gmx.de>" [full]
# gpg:                 aka "Thomas Huth <thuth@redhat.com>" [full]
# gpg:                 aka "Thomas Huth <huth@tuxfamily.org>" [full]
# gpg:                 aka "Thomas Huth <th.huth@posteo.de>" [unknown]
# Primary key fingerprint: 27B8 8847 EEE0 2501 18F3  EAB9 2ED9 D774 FE70 2DB5

* tag 'pull-request-2023-01-31' of https://gitlab.com/thuth/qemu: (27 commits)
  gitlab-ci.d/buildtest: Merge the --without-default-* jobs
  tests/qtest/display-vga-test: Add proper checks if a device is available
  gitlab-ci.d/buildtest: Remove ppc-softmmu from the clang-system job
  qapi, audio: Make introspection reflect build configuration more closely
  qapi, audio: add query-audiodev command
  docs/s390x/pcidevices: document pci devices on s390x
  tests/qtest/boot-serial-test: Constify tests[] array
  tests/qtest/vnc-display-test: Disable on Darwin
  tests/qtest/vnc-display-test: Use the 'none' machine
  tests/qtest/vnc-display-test: Suppress build warnings on Windows
  tests/tcg: Do not build/run TCG tests if TCG is disabled
  docs/about/deprecated: Mark HAXM in QEMU as deprecated
  MAINTAINERS: Abort HAXM maintenance
  qemu/bswap: Use compiler __builtin_bswap() on NetBSD
  qemu/bswap: Use compiler __builtin_bswap() on FreeBSD
  qemu/bswap: Use compiler __builtin_bswap() on Haiku
  qemu/bswap: Remove <byteswap.h> dependency
  qemu/bswap: Replace bswapXXs() by compiler __builtin_bswap()
  qemu/bswap: Replace bswapXX() by compiler __builtin_bswap()
  tests/docker/dockerfiles: Add libfdt to the i386 and to the riscv64 container
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
master
Peter Maydell 2023-02-02 13:42:56 +00:00
commit 387b2b5255
25 changed files with 731 additions and 210 deletions

View File

@ -316,8 +316,7 @@ clang-system:
IMAGE: fedora
CONFIGURE_ARGS: --cc=clang --cxx=clang++
--extra-cflags=-fsanitize=undefined --extra-cflags=-fno-sanitize-recover=undefined
TARGETS: alpha-softmmu arm-softmmu m68k-softmmu mips64-softmmu
ppc-softmmu s390x-softmmu
TARGETS: alpha-softmmu arm-softmmu m68k-softmmu mips64-softmmu s390x-softmmu
MAKE_CHECK_ARGS: check-qtest check-tcg
clang-user:
@ -558,29 +557,22 @@ build-coroutine-sigaltstack:
MAKE_CHECK_ARGS: check-unit
# Check our reduced build configurations
build-without-default-devices:
build-without-defaults:
extends: .native_build_job_template
needs:
job: amd64-centos8-container
variables:
IMAGE: centos8
CONFIGURE_ARGS: --without-default-devices --disable-user
build-without-default-features:
extends: .native_build_job_template
needs:
job: amd64-fedora-container
variables:
IMAGE: fedora
CONFIGURE_ARGS:
--without-default-devices
--without-default-features
--disable-capstone
--disable-fdt
--disable-pie
--disable-qom-cast-debug
--disable-strip
TARGETS: avr-softmmu i386-softmmu mips64-softmmu s390x-softmmu sh4-softmmu
TARGETS: avr-softmmu mips64-softmmu s390x-softmmu sh4-softmmu
sparc64-softmmu hexagon-linux-user i386-linux-user s390x-linux-user
MAKE_CHECK_ARGS: check-unit check-qtest SPEED=slow
MAKE_CHECK_ARGS: check-unit check-qtest-avr check-qtest-mips64
build-libvhost-user:
extends: .base_job_template

View File

@ -16,43 +16,6 @@ cache:
- $HOME/avocado/data/cache
addons:
apt:
packages:
# Build dependencies
- libaio-dev
- libattr1-dev
- libbrlapi-dev
- libcap-ng-dev
- libcacard-dev
- libgcc-7-dev
- libgnutls28-dev
- libgtk-3-dev
- libiscsi-dev
- liblttng-ust-dev
- libncurses5-dev
- libnfs-dev
- libpixman-1-dev
- libpng-dev
- librados-dev
- libsdl2-dev
- libsdl2-image-dev
- libseccomp-dev
- libspice-protocol-dev
- libspice-server-dev
- libssh-dev
- liburcu-dev
- libusb-1.0-0-dev
- libvdeplug-dev
- libvte-2.91-dev
- libzstd-dev
- ninja-build
- sparse
- uuid-dev
# Tests dependencies
- genisoimage
# The channel name "irc.oftc.net#qemu" is encrypted against qemu/qemu
# to prevent IRC notifications from forks. This was created using:
# $ travis encrypt -r "qemu/qemu" "irc.oftc.net#qemu"
@ -128,6 +91,7 @@ jobs:
- libbrlapi-dev
- libcacard-dev
- libcap-ng-dev
- libfdt-dev
- libgcrypt20-dev
- libgnutls28-dev
- libgtk-3-dev
@ -149,7 +113,8 @@ jobs:
- genisoimage
env:
- TEST_CMD="make check check-tcg V=1"
- CONFIG="--disable-containers --target-list=${MAIN_SOFTMMU_TARGETS} --cxx=/bin/false"
- CONFIG="--disable-containers --enable-fdt=system
--target-list=${MAIN_SOFTMMU_TARGETS} --cxx=/bin/false"
- UNRELIABLE=true
- name: "[ppc64] GCC check-tcg"
@ -162,6 +127,7 @@ jobs:
- libbrlapi-dev
- libcacard-dev
- libcap-ng-dev
- libfdt-dev
- libgcrypt20-dev
- libgnutls28-dev
- libgtk-3-dev
@ -183,7 +149,8 @@ jobs:
- genisoimage
env:
- TEST_CMD="make check check-tcg V=1"
- CONFIG="--disable-containers --target-list=ppc64-softmmu,ppc64le-linux-user"
- CONFIG="--disable-containers --enable-fdt=system
--target-list=ppc64-softmmu,ppc64le-linux-user"
- name: "[s390x] GCC check-tcg"
arch: s390x
@ -195,6 +162,7 @@ jobs:
- libbrlapi-dev
- libcacard-dev
- libcap-ng-dev
- libfdt-dev
- libgcrypt20-dev
- libgnutls28-dev
- libgtk-3-dev
@ -216,7 +184,8 @@ jobs:
- genisoimage
env:
- TEST_CMD="make check check-tcg V=1"
- CONFIG="--disable-containers --target-list=${MAIN_SOFTMMU_TARGETS},s390x-linux-user"
- CONFIG="--disable-containers --enable-fdt=system
--target-list=${MAIN_SOFTMMU_TARGETS},s390x-linux-user"
- UNRELIABLE=true
script:
- BUILD_RC=0 && make -j${JOBS} || BUILD_RC=$?
@ -237,6 +206,7 @@ jobs:
- libattr1-dev
- libcacard-dev
- libcap-ng-dev
- libfdt-dev
- libgnutls28-dev
- libiscsi-dev
- liblttng-ust-dev
@ -255,8 +225,8 @@ jobs:
# Tests dependencies
- genisoimage
env:
- CONFIG="--disable-containers --audio-drv-list=sdl --disable-user
--target-list-exclude=${MAIN_SOFTMMU_TARGETS}"
- CONFIG="--disable-containers --enable-fdt=system --audio-drv-list=sdl
--disable-user --target-list-exclude=${MAIN_SOFTMMU_TARGETS}"
- name: "[s390x] GCC (user)"
arch: s390x
@ -281,6 +251,7 @@ jobs:
- libbrlapi-dev
- libcacard-dev
- libcap-ng-dev
- libfdt-dev
- libgcrypt20-dev
- libgnutls28-dev
- libgtk-3-dev
@ -300,6 +271,6 @@ jobs:
- ninja-build
env:
- TEST_CMD="make check-unit"
- CONFIG="--disable-containers --disable-tcg --enable-kvm
--disable-tools --host-cc=clang --cxx=clang++"
- CONFIG="--disable-containers --disable-tcg --enable-kvm --disable-tools
--enable-fdt=system --host-cc=clang --cxx=clang++"
- UNRELIABLE=true

View File

@ -500,10 +500,7 @@ F: stubs/xen-hw-stub.c
Guest CPU Cores (HAXM)
---------------------
X86 HAXM CPUs
M: Wenchao Wang <wenchao.wang@intel.com>
L: haxm-team@intel.com
W: https://github.com/intel/haxm/issues
S: Maintained
S: Orphan
F: accel/stubs/hax-stub.c
F: include/sysemu/hax.h
F: target/i386/hax/

View File

@ -28,8 +28,10 @@
#include "monitor/monitor.h"
#include "qemu/timer.h"
#include "qapi/error.h"
#include "qapi/clone-visitor.h"
#include "qapi/qobject-input-visitor.h"
#include "qapi/qapi-visit-audio.h"
#include "qapi/qapi-commands-audio.h"
#include "qemu/cutils.h"
#include "qemu/module.h"
#include "qemu/help_option.h"
@ -2046,16 +2048,36 @@ void audio_create_pdos(Audiodev *dev)
break
CASE(NONE, none, );
#ifdef CONFIG_AUDIO_ALSA
CASE(ALSA, alsa, Alsa);
#endif
#ifdef CONFIG_AUDIO_COREAUDIO
CASE(COREAUDIO, coreaudio, Coreaudio);
#endif
#ifdef CONFIG_DBUS_DISPLAY
CASE(DBUS, dbus, );
#endif
#ifdef CONFIG_AUDIO_DSOUND
CASE(DSOUND, dsound, );
#endif
#ifdef CONFIG_AUDIO_JACK
CASE(JACK, jack, Jack);
#endif
#ifdef CONFIG_AUDIO_OSS
CASE(OSS, oss, Oss);
#endif
#ifdef CONFIG_AUDIO_PA
CASE(PA, pa, Pa);
#endif
#ifdef CONFIG_AUDIO_SDL
CASE(SDL, sdl, Sdl);
#endif
#ifdef CONFIG_AUDIO_SNDIO
CASE(SNDIO, sndio, );
#endif
#ifdef CONFIG_SPICE
CASE(SPICE, spice, );
#endif
CASE(WAV, wav, );
case AUDIODEV_DRIVER__MAX:
@ -2311,3 +2333,13 @@ size_t audio_rate_get_bytes(RateCtl *rate, struct audio_pcm_info *info,
return bytes;
}
AudiodevList *qmp_query_audiodevs(Error **errp)
{
AudiodevList *ret = NULL;
AudiodevListEntry *e;
QSIMPLEQ_FOREACH(e, &audiodevs, next) {
QAPI_LIST_PREPEND(ret, QAPI_CLONE(Audiodev, e->dev));
}
return ret;
}

View File

@ -90,6 +90,7 @@ static void get_fmt(const char *env, AudioFormat *dst, bool *has_dst)
}
#if defined(CONFIG_AUDIO_ALSA) || defined(CONFIG_AUDIO_DSOUND)
static void get_millis_to_usecs(const char *env, uint32_t *dst, bool *has_dst)
{
const char *val = getenv(env);
@ -98,15 +99,20 @@ static void get_millis_to_usecs(const char *env, uint32_t *dst, bool *has_dst)
*has_dst = true;
}
}
#endif
#if defined(CONFIG_AUDIO_ALSA) || defined(CONFIG_AUDIO_COREAUDIO) || \
defined(CONFIG_AUDIO_PA) || defined(CONFIG_AUDIO_SDL) || \
defined(CONFIG_AUDIO_DSOUND) || defined(CONFIG_AUDIO_OSS)
static uint32_t frames_to_usecs(uint32_t frames,
AudiodevPerDirectionOptions *pdo)
{
uint32_t freq = pdo->has_frequency ? pdo->frequency : 44100;
return (frames * 1000000 + freq / 2) / freq;
}
#endif
#ifdef CONFIG_AUDIO_COREAUDIO
static void get_frames_to_usecs(const char *env, uint32_t *dst, bool *has_dst,
AudiodevPerDirectionOptions *pdo)
{
@ -116,14 +122,19 @@ static void get_frames_to_usecs(const char *env, uint32_t *dst, bool *has_dst,
*has_dst = true;
}
}
#endif
#if defined(CONFIG_AUDIO_PA) || defined(CONFIG_AUDIO_SDL) || \
defined(CONFIG_AUDIO_DSOUND) || defined(CONFIG_AUDIO_OSS)
static uint32_t samples_to_usecs(uint32_t samples,
AudiodevPerDirectionOptions *pdo)
{
uint32_t channels = pdo->has_channels ? pdo->channels : 2;
return frames_to_usecs(samples / channels, pdo);
}
#endif
#if defined(CONFIG_AUDIO_PA) || defined(CONFIG_AUDIO_SDL)
static void get_samples_to_usecs(const char *env, uint32_t *dst, bool *has_dst,
AudiodevPerDirectionOptions *pdo)
{
@ -133,7 +144,9 @@ static void get_samples_to_usecs(const char *env, uint32_t *dst, bool *has_dst,
*has_dst = true;
}
}
#endif
#if defined(CONFIG_AUDIO_DSOUND) || defined(CONFIG_AUDIO_OSS)
static uint32_t bytes_to_usecs(uint32_t bytes, AudiodevPerDirectionOptions *pdo)
{
AudioFormat fmt = pdo->has_format ? pdo->format : AUDIO_FORMAT_S16;
@ -150,8 +163,11 @@ static void get_bytes_to_usecs(const char *env, uint32_t *dst, bool *has_dst,
*has_dst = true;
}
}
#endif
/* backend specific functions */
#ifdef CONFIG_AUDIO_ALSA
/* ALSA */
static void handle_alsa_per_direction(
AudiodevAlsaPerDirectionOptions *apdo, const char *prefix)
@ -197,7 +213,9 @@ static void handle_alsa(Audiodev *dev)
get_millis_to_usecs("QEMU_ALSA_THRESHOLD",
&aopt->threshold, &aopt->has_threshold);
}
#endif
#ifdef CONFIG_AUDIO_COREAUDIO
/* coreaudio */
static void handle_coreaudio(Audiodev *dev)
{
@ -210,7 +228,9 @@ static void handle_coreaudio(Audiodev *dev)
&dev->u.coreaudio.out->buffer_count,
&dev->u.coreaudio.out->has_buffer_count);
}
#endif
#ifdef CONFIG_AUDIO_DSOUND
/* dsound */
static void handle_dsound(Audiodev *dev)
{
@ -225,7 +245,9 @@ static void handle_dsound(Audiodev *dev)
&dev->u.dsound.in->has_buffer_length,
dev->u.dsound.in);
}
#endif
#ifdef CONFIG_AUDIO_OSS
/* OSS */
static void handle_oss_per_direction(
AudiodevOssPerDirectionOptions *opdo, const char *try_poll_env,
@ -253,7 +275,9 @@ static void handle_oss(Audiodev *dev)
get_bool("QEMU_OSS_EXCLUSIVE", &oopt->exclusive, &oopt->has_exclusive);
get_int("QEMU_OSS_POLICY", &oopt->dsp_policy, &oopt->has_dsp_policy);
}
#endif
#ifdef CONFIG_AUDIO_PA
/* pulseaudio */
static void handle_pa_per_direction(
AudiodevPaPerDirectionOptions *ppdo, const char *env)
@ -277,7 +301,9 @@ static void handle_pa(Audiodev *dev)
get_str("QEMU_PA_SERVER", &dev->u.pa.server);
}
#endif
#ifdef CONFIG_AUDIO_SDL
/* SDL */
static void handle_sdl(Audiodev *dev)
{
@ -286,6 +312,7 @@ static void handle_sdl(Audiodev *dev)
&dev->u.sdl.out->has_buffer_length,
qapi_AudiodevSdlPerDirectionOptions_base(dev->u.sdl.out));
}
#endif
/* wav */
static void handle_wav(Audiodev *dev)
@ -345,29 +372,41 @@ static AudiodevListEntry *legacy_opt(const char *drvname)
}
switch (e->dev->driver) {
#ifdef CONFIG_AUDIO_ALSA
case AUDIODEV_DRIVER_ALSA:
handle_alsa(e->dev);
break;
#endif
#ifdef CONFIG_AUDIO_COREAUDIO
case AUDIODEV_DRIVER_COREAUDIO:
handle_coreaudio(e->dev);
break;
#endif
#ifdef CONFIG_AUDIO_DSOUND
case AUDIODEV_DRIVER_DSOUND:
handle_dsound(e->dev);
break;
#endif
#ifdef CONFIG_AUDIO_OSS
case AUDIODEV_DRIVER_OSS:
handle_oss(e->dev);
break;
#endif
#ifdef CONFIG_AUDIO_PA
case AUDIODEV_DRIVER_PA:
handle_pa(e->dev);
break;
#endif
#ifdef CONFIG_AUDIO_SDL
case AUDIODEV_DRIVER_SDL:
handle_sdl(e->dev);
break;
#endif
case AUDIODEV_DRIVER_WAV:
handle_wav(e->dev);

View File

@ -326,27 +326,47 @@ AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYPE)(Audiodev *dev)
switch (dev->driver) {
case AUDIODEV_DRIVER_NONE:
return dev->u.none.TYPE;
#ifdef CONFIG_AUDIO_ALSA
case AUDIODEV_DRIVER_ALSA:
return qapi_AudiodevAlsaPerDirectionOptions_base(dev->u.alsa.TYPE);
#endif
#ifdef CONFIG_AUDIO_COREAUDIO
case AUDIODEV_DRIVER_COREAUDIO:
return qapi_AudiodevCoreaudioPerDirectionOptions_base(
dev->u.coreaudio.TYPE);
#endif
#ifdef CONFIG_DBUS_DISPLAY
case AUDIODEV_DRIVER_DBUS:
return dev->u.dbus.TYPE;
#endif
#ifdef CONFIG_AUDIO_DSOUND
case AUDIODEV_DRIVER_DSOUND:
return dev->u.dsound.TYPE;
#endif
#ifdef CONFIG_AUDIO_JACK
case AUDIODEV_DRIVER_JACK:
return qapi_AudiodevJackPerDirectionOptions_base(dev->u.jack.TYPE);
#endif
#ifdef CONFIG_AUDIO_OSS
case AUDIODEV_DRIVER_OSS:
return qapi_AudiodevOssPerDirectionOptions_base(dev->u.oss.TYPE);
#endif
#ifdef CONFIG_AUDIO_PA
case AUDIODEV_DRIVER_PA:
return qapi_AudiodevPaPerDirectionOptions_base(dev->u.pa.TYPE);
#endif
#ifdef CONFIG_AUDIO_SDL
case AUDIODEV_DRIVER_SDL:
return qapi_AudiodevSdlPerDirectionOptions_base(dev->u.sdl.TYPE);
#endif
#ifdef CONFIG_AUDIO_SNDIO
case AUDIODEV_DRIVER_SNDIO:
return dev->u.sndio.TYPE;
#endif
#ifdef CONFIG_SPICE
case AUDIODEV_DRIVER_SPICE:
return dev->u.spice.TYPE;
#endif
case AUDIODEV_DRIVER_WAV:
return dev->u.wav.TYPE;

View File

@ -1,2 +1,3 @@
TARGET_ARCH=nios2
TARGET_ALIGNED_ONLY=y
TARGET_NEED_FDT=y

6
configure vendored
View File

@ -2483,7 +2483,11 @@ for target in $target_list; do
tcg_tests_targets="$tcg_tests_targets $target"
fi
done
echo "TCG_TESTS_TARGETS=$tcg_tests_targets" >> config-host.mak)
if test "$tcg" = "enabled"; then
echo "TCG_TESTS_TARGETS=$tcg_tests_targets" >> config-host.mak
fi
)
if test "$skip_meson" = no; then
cross="config-meson.cross.new"

View File

@ -87,18 +87,18 @@ as short-form boolean values, and passed to plugins as ``arg_name=on``.
However, short-form booleans are deprecated and full explicit ``arg_name=on``
form is preferred.
``-drive if=none`` for the sifive_u OTP device (since 6.2)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Using ``-drive if=none`` to configure the OTP device of the sifive_u
RISC-V machine is deprecated. Use ``-drive if=pflash`` instead.
``-no-hpet`` (since 8.0)
''''''''''''''''''''''''
The HPET setting has been turned into a machine property.
Use ``-machine hpet=off`` instead.
``-accel hax`` (since 8.0)
''''''''''''''''''''''''''
The HAXM project has been retired (see https://github.com/intel/haxm#status).
Use "whpx" (on Windows) or "hvf" (on macOS) instead.
QEMU Machine Protocol (QMP) commands
------------------------------------

View File

@ -422,6 +422,13 @@ the value is hexadecimal. That is, '0x20M' should be written either as
``tty`` and ``parport`` used to be aliases for ``serial`` and ``parallel``
respectively. The actual backend names should be used instead.
``-drive if=none`` for the sifive_u OTP device (removed in 8.0)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Use ``-drive if=pflash`` to configure the OTP device of the sifive_u
RISC-V machine instead.
QEMU Machine Protocol (QMP) commands
------------------------------------

View File

@ -0,0 +1,41 @@
PCI devices on s390x
====================
PCI devices on s390x work differently than on other architectures and need to
be configured in a slightly different way.
Every PCI device is linked with an additional ``zpci`` device.
While the ``zpci`` device will be autogenerated if not specified, it is
recommended to specify it explicitly so that you can pass s390-specific
PCI configuration.
For example, in order to pass a PCI device ``0000:00:00.0`` through to the
guest, you would specify::
qemu-system-s390x ... \
-device zpci,uid=1,fid=0,target=hostdev0,id=zpci1 \
-device vfio-pci,host=0000:00:00.0,id=hostdev0
Here, the zpci device is joined with the PCI device via the ``target`` property.
Note that we don't set bus, slot or function here for the guest as is common in
other PCI implementations. Topology information is not available on s390x, and
the guest will not see any of the bus, slot or function information specified
on the command line.
Instead, ``uid`` and ``fid`` determine how the device is presented to the guest
operating system.
In case of Linux, ``uid`` will be used in the ``domain`` part of the PCI
identifier, and ``fid`` identifies the physical slot, i.e.::
qemu-system-s390x ... \
-device zpci,uid=7,fid=8,target=hostdev0,id=zpci1 \
...
will be presented in the guest as::
# lspci -v
0007:00:00.0 ...
Physical Slot: 00000008
...

View File

@ -26,6 +26,7 @@ or vfio-ap is also available.
s390x/css
s390x/3270
s390x/vfio-ccw
s390x/pcidevices
Architectural features
======================

View File

@ -210,13 +210,6 @@ static void sifive_u_otp_realize(DeviceState *dev, Error **errp)
sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mmio);
dinfo = drive_get(IF_PFLASH, 0, 0);
if (!dinfo) {
dinfo = drive_get(IF_NONE, 0, 0);
if (dinfo) {
warn_report("using \"-drive if=none\" for the OTP is deprecated, "
"use \"-drive if=pflash\" instead.");
}
}
if (dinfo) {
int ret;
uint64_t perm;

View File

@ -1,97 +1,44 @@
#ifndef BSWAP_H
#define BSWAP_H
#ifdef CONFIG_MACHINE_BSWAP_H
# include <sys/endian.h>
# include <machine/bswap.h>
#elif defined(__FreeBSD__)
# include <sys/endian.h>
#elif defined(__HAIKU__)
# include <endian.h>
#elif defined(CONFIG_BYTESWAP_H)
# include <byteswap.h>
#define BSWAP_FROM_BYTESWAP
# else
#define BSWAP_FROM_FALLBACKS
#endif /* ! CONFIG_MACHINE_BSWAP_H */
#ifdef __cplusplus
extern "C" {
#endif
#ifdef BSWAP_FROM_BYTESWAP
static inline uint16_t bswap16(uint16_t x)
{
return bswap_16(x);
}
static inline uint32_t bswap32(uint32_t x)
{
return bswap_32(x);
}
static inline uint64_t bswap64(uint64_t x)
{
return bswap_64(x);
}
#endif
#ifdef BSWAP_FROM_FALLBACKS
static inline uint16_t bswap16(uint16_t x)
{
return (((x & 0x00ff) << 8) |
((x & 0xff00) >> 8));
}
static inline uint32_t bswap32(uint32_t x)
{
return (((x & 0x000000ffU) << 24) |
((x & 0x0000ff00U) << 8) |
((x & 0x00ff0000U) >> 8) |
((x & 0xff000000U) >> 24));
}
static inline uint64_t bswap64(uint64_t x)
{
return (((x & 0x00000000000000ffULL) << 56) |
((x & 0x000000000000ff00ULL) << 40) |
((x & 0x0000000000ff0000ULL) << 24) |
((x & 0x00000000ff000000ULL) << 8) |
((x & 0x000000ff00000000ULL) >> 8) |
((x & 0x0000ff0000000000ULL) >> 24) |
((x & 0x00ff000000000000ULL) >> 40) |
((x & 0xff00000000000000ULL) >> 56));
}
#endif
#undef BSWAP_FROM_BYTESWAP
#undef BSWAP_FROM_FALLBACKS
#undef bswap16
#define bswap16(_x) __builtin_bswap16(_x)
#undef bswap32
#define bswap32(_x) __builtin_bswap32(_x)
#undef bswap64
#define bswap64(_x) __builtin_bswap64(_x)
static inline void bswap16s(uint16_t *s)
{
*s = bswap16(*s);
*s = __builtin_bswap16(*s);
}
static inline void bswap32s(uint32_t *s)
{
*s = bswap32(*s);
*s = __builtin_bswap32(*s);
}
static inline void bswap64s(uint64_t *s)
{
*s = bswap64(*s);
*s = __builtin_bswap64(*s);
}
#if HOST_BIG_ENDIAN
#define be_bswap(v, size) (v)
#define le_bswap(v, size) glue(bswap, size)(v)
#define le_bswap(v, size) glue(__builtin_bswap, size)(v)
#define be_bswaps(v, size)
#define le_bswaps(p, size) do { *p = glue(bswap, size)(*p); } while(0)
#define le_bswaps(p, size) \
do { *p = glue(__builtin_bswap, size)(*p); } while (0)
#else
#define le_bswap(v, size) (v)
#define be_bswap(v, size) glue(bswap, size)(v)
#define be_bswap(v, size) glue(__builtin_bswap, size)(v)
#define le_bswaps(v, size)
#define be_bswaps(p, size) do { *p = glue(bswap, size)(*p); } while(0)
#define be_bswaps(p, size) \
do { *p = glue(__builtin_bswap, size)(*p); } while (0)
#endif
/**

View File

@ -2013,8 +2013,6 @@ if rdma.found()
endif
# has_header_symbol
config_host_data.set('CONFIG_BYTESWAP_H',
cc.has_header_symbol('byteswap.h', 'bswap_32'))
config_host_data.set('CONFIG_EPOLL_CREATE1',
cc.has_header_symbol('sys/epoll.h', 'epoll_create1'))
config_host_data.set('CONFIG_FALLOCATE_PUNCH_HOLE',
@ -2032,10 +2030,6 @@ config_host_data.set('CONFIG_INOTIFY',
cc.has_header_symbol('sys/inotify.h', 'inotify_init'))
config_host_data.set('CONFIG_INOTIFY1',
cc.has_header_symbol('sys/inotify.h', 'inotify_init1'))
config_host_data.set('CONFIG_MACHINE_BSWAP_H',
cc.has_header_symbol('machine/bswap.h', 'bswap32',
prefix: '''#include <sys/endian.h>
#include <sys/types.h>'''))
config_host_data.set('CONFIG_PRCTL_PR_SET_TIMERSLACK',
cc.has_header_symbol('sys/prctl.h', 'PR_SET_TIMERSLACK'))
config_host_data.set('CONFIG_RTNETLINK',

View File

@ -408,8 +408,18 @@
# Since: 4.0
##
{ 'enum': 'AudiodevDriver',
'data': [ 'none', 'alsa', 'coreaudio', 'dbus', 'dsound', 'jack', 'oss', 'pa',
'sdl', 'sndio', 'spice', 'wav' ] }
'data': [ 'none',
{ 'name': 'alsa', 'if': 'CONFIG_AUDIO_ALSA' },
{ 'name': 'coreaudio', 'if': 'CONFIG_AUDIO_COREAUDIO' },
{ 'name': 'dbus', 'if': 'CONFIG_DBUS_DISPLAY' },
{ 'name': 'dsound', 'if': 'CONFIG_AUDIO_DSOUND' },
{ 'name': 'jack', 'if': 'CONFIG_AUDIO_JACK' },
{ 'name': 'oss', 'if': 'CONFIG_AUDIO_OSS' },
{ 'name': 'pa', 'if': 'CONFIG_AUDIO_PA' },
{ 'name': 'sdl', 'if': 'CONFIG_AUDIO_SDL' },
{ 'name': 'sndio', 'if': 'CONFIG_AUDIO_SNDIO' },
{ 'name': 'spice', 'if': 'CONFIG_SPICE' },
'wav' ] }
##
# @Audiodev:
@ -432,14 +442,37 @@
'discriminator': 'driver',
'data': {
'none': 'AudiodevGenericOptions',
'alsa': 'AudiodevAlsaOptions',
'coreaudio': 'AudiodevCoreaudioOptions',
'dbus': 'AudiodevGenericOptions',
'dsound': 'AudiodevDsoundOptions',
'jack': 'AudiodevJackOptions',
'oss': 'AudiodevOssOptions',
'pa': 'AudiodevPaOptions',
'sdl': 'AudiodevSdlOptions',
'sndio': 'AudiodevSndioOptions',
'spice': 'AudiodevGenericOptions',
'alsa': { 'type': 'AudiodevAlsaOptions',
'if': 'CONFIG_AUDIO_ALSA' },
'coreaudio': { 'type': 'AudiodevCoreaudioOptions',
'if': 'CONFIG_AUDIO_COREAUDIO' },
'dbus': { 'type': 'AudiodevGenericOptions',
'if': 'CONFIG_DBUS_DISPLAY' },
'dsound': { 'type': 'AudiodevDsoundOptions',
'if': 'CONFIG_AUDIO_DSOUND' },
'jack': { 'type': 'AudiodevJackOptions',
'if': 'CONFIG_AUDIO_JACK' },
'oss': { 'type': 'AudiodevOssOptions',
'if': 'CONFIG_AUDIO_OSS' },
'pa': { 'type': 'AudiodevPaOptions',
'if': 'CONFIG_AUDIO_PA' },
'sdl': { 'type': 'AudiodevSdlOptions',
'if': 'CONFIG_AUDIO_SDL' },
'sndio': { 'type': 'AudiodevSndioOptions',
'if': 'CONFIG_AUDIO_SNDIO' },
'spice': { 'type': 'AudiodevGenericOptions',
'if': 'CONFIG_SPICE' },
'wav': 'AudiodevWavOptions' } }
##
# @query-audiodevs:
#
# Returns information about audiodev configuration
#
# Returns: array of @Audiodev
#
# Since: 8.0
#
##
{ 'command': 'query-audiodevs',
'returns': ['Audiodev'] }

View File

@ -357,6 +357,9 @@ static int hax_accel_init(MachineState *ms)
fprintf(stdout, "HAX is %s and emulator runs in %s mode.\n",
!ret ? "working" : "not working",
!ret ? "fast virt" : "emulation");
fprintf(stdout,
"NOTE: HAX is deprecated and will be removed in a future release.\n"
" Use 'whpx' (on Windows) or 'hvf' (on macOS) instead.\n");
}
return ret;
}

View File

@ -42,6 +42,7 @@ RUN apt update && \
apt install -y --no-install-recommends \
gcc-riscv64-linux-gnu \
libc6-dev-riscv64-cross \
libfdt-dev:riscv64 \
libffi-dev:riscv64 \
libglib2.0-dev:riscv64 \
libpixman-1-dev:riscv64

View File

@ -9,6 +9,7 @@ ENV PACKAGES \
findutils \
gcc \
git \
libfdt-devel.i686 \
libffi-devel.i686 \
libselinux-devel.i686 \
libtasn1-devel.i686 \

View File

@ -139,7 +139,7 @@ typedef struct testdef {
const uint8_t *bios; /* Set in case we use our own mini bios */
} testdef_t;
static testdef_t tests[] = {
static const testdef_t tests[] = {
{ "alpha", "clipper", "", "PCI:" },
{ "avr", "arduino-duemilanove", "", "T", sizeof(bios_avr), NULL, bios_avr },
{ "avr", "arduino-mega-2560-v3", "", "T", sizeof(bios_avr), NULL, bios_avr},

View File

@ -8,61 +8,46 @@
*/
#include "qemu/osdep.h"
#include "libqtest-single.h"
static void pci_cirrus(void)
{
qtest_start("-vga none -device cirrus-vga");
qtest_end();
}
static void pci_stdvga(void)
{
qtest_start("-vga none -device VGA");
qtest_end();
}
static void pci_secondary(void)
{
qtest_start("-vga none -device secondary-vga");
qtest_end();
}
#include "libqtest.h"
static void pci_multihead(void)
{
qtest_start("-vga none -device VGA -device secondary-vga");
qtest_end();
QTestState *qts;
qts = qtest_init("-vga none -device VGA -device secondary-vga");
qtest_quit(qts);
}
static void pci_virtio_gpu(void)
static void test_vga(gconstpointer data)
{
qtest_start("-vga none -device virtio-gpu-pci");
qtest_end();
}
QTestState *qts;
static void pci_virtio_vga(void)
{
qtest_start("-vga none -device virtio-vga");
qtest_end();
qts = qtest_initf("-vga none -device %s", (const char *)data);
qtest_quit(qts);
}
int main(int argc, char **argv)
{
const char *arch = qtest_get_arch();
static const char *devices[] = {
"cirrus-vga",
"VGA",
"secondary-vga",
"virtio-gpu-pci",
"virtio-vga"
};
g_test_init(&argc, &argv, NULL);
if (strcmp(arch, "alpha") == 0 || strcmp(arch, "i386") == 0 ||
strcmp(arch, "mips") == 0 || strcmp(arch, "x86_64") == 0) {
qtest_add_func("/display/pci/cirrus", pci_cirrus);
for (int i = 0; i < ARRAY_SIZE(devices); i++) {
if (qtest_has_device(devices[i])) {
char *testpath = g_strdup_printf("/display/pci/%s", devices[i]);
qtest_add_data_func(testpath, devices[i], test_vga);
g_free(testpath);
}
}
qtest_add_func("/display/pci/stdvga", pci_stdvga);
qtest_add_func("/display/pci/secondary", pci_secondary);
qtest_add_func("/display/pci/multihead", pci_multihead);
qtest_add_func("/display/pci/virtio-gpu", pci_virtio_gpu);
if (g_str_equal(arch, "i386") || g_str_equal(arch, "x86_64") ||
g_str_equal(arch, "hppa") || g_str_equal(arch, "ppc64")) {
qtest_add_func("/display/pci/virtio-vga", pci_virtio_vga);
if (qtest_has_device("secondary-vga")) {
qtest_add_func("/display/pci/multihead", pci_multihead);
}
return g_test_run();

View File

@ -21,6 +21,7 @@ qtests_generic = [
'test-hmp',
'qos-test',
'readconfig-test',
'netdev-socket',
]
if config_host.has_key('CONFIG_MODULES')
qtests_generic += [ 'modules-test' ]
@ -298,6 +299,7 @@ qtests = {
'tpm-tis-device-swtpm-test': [io, tpmemu_files, 'tpm-tis-util.c'],
'tpm-tis-device-test': [io, tpmemu_files, 'tpm-tis-util.c'],
'vmgenid-test': files('boot-sector.c', 'acpi-utils.c'),
'netdev-socket': files('netdev-socket.c', '../unit/socket-helpers.c'),
}
gvnc = dependency('gvnc-1.0', required: false)

448
tests/qtest/netdev-socket.c Normal file
View File

@ -0,0 +1,448 @@
/*
* QTest testcase for netdev stream and dgram
*
* Copyright (c) 2022 Red Hat, Inc.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "qemu/osdep.h"
#include "qemu/sockets.h"
#include <glib/gstdio.h>
#include "../unit/socket-helpers.h"
#include "libqtest.h"
#define CONNECTION_TIMEOUT 5
#define EXPECT_STATE(q, e, t) \
do { \
char *resp = NULL; \
g_test_timer_start(); \
do { \
g_free(resp); \
resp = qtest_hmp(q, "info network"); \
if (t) { \
strrchr(resp, t)[0] = 0; \
} \
if (g_str_equal(resp, e)) { \
break; \
} \
} while (g_test_timer_elapsed() < CONNECTION_TIMEOUT); \
g_assert_cmpstr(resp, ==, e); \
g_free(resp); \
} while (0)
static gchar *tmpdir;
static int inet_get_free_port_socket_ipv4(int sock)
{
struct sockaddr_in addr;
socklen_t len;
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = INADDR_ANY;
addr.sin_port = 0;
if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
return -1;
}
len = sizeof(addr);
if (getsockname(sock, (struct sockaddr *)&addr, &len) < 0) {
return -1;
}
return ntohs(addr.sin_port);
}
static int inet_get_free_port_socket_ipv6(int sock)
{
struct sockaddr_in6 addr;
socklen_t len;
memset(&addr, 0, sizeof(addr));
addr.sin6_family = AF_INET6;
addr.sin6_addr = in6addr_any;
addr.sin6_port = 0;
if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
return -1;
}
len = sizeof(addr);
if (getsockname(sock, (struct sockaddr *)&addr, &len) < 0) {
return -1;
}
return ntohs(addr.sin6_port);
}
static int inet_get_free_port_multiple(int nb, int *port, bool ipv6)
{
int sock[nb];
int i;
for (i = 0; i < nb; i++) {
sock[i] = socket(ipv6 ? AF_INET6 : AF_INET, SOCK_STREAM, 0);
if (sock[i] < 0) {
break;
}
port[i] = ipv6 ? inet_get_free_port_socket_ipv6(sock[i]) :
inet_get_free_port_socket_ipv4(sock[i]);
if (port[i] == -1) {
break;
}
}
nb = i;
for (i = 0; i < nb; i++) {
closesocket(sock[i]);
}
return nb;
}
static int inet_get_free_port(bool ipv6)
{
int nb, port;
nb = inet_get_free_port_multiple(1, &port, ipv6);
g_assert_cmpint(nb, ==, 1);
return port;
}
static void test_stream_inet_ipv4(void)
{
QTestState *qts0, *qts1;
char *expect;
int port;
port = inet_get_free_port(false);
qts0 = qtest_initf("-nodefaults -M none "
"-netdev stream,id=st0,server=true,addr.type=inet,"
"addr.ipv4=on,addr.ipv6=off,"
"addr.host=127.0.0.1,addr.port=%d", port);
EXPECT_STATE(qts0, "st0: index=0,type=stream,\r\n", 0);
qts1 = qtest_initf("-nodefaults -M none "
"-netdev stream,server=false,id=st0,addr.type=inet,"
"addr.ipv4=on,addr.ipv6=off,"
"addr.host=127.0.0.1,addr.port=%d", port);
expect = g_strdup_printf("st0: index=0,type=stream,tcp:127.0.0.1:%d\r\n",
port);
EXPECT_STATE(qts1, expect, 0);
g_free(expect);
/* the port is unknown, check only the address */
EXPECT_STATE(qts0, "st0: index=0,type=stream,tcp:127.0.0.1", ':');
qtest_quit(qts1);
qtest_quit(qts0);
}
static void test_stream_inet_ipv6(void)
{
QTestState *qts0, *qts1;
char *expect;
int port;
port = inet_get_free_port(true);
qts0 = qtest_initf("-nodefaults -M none "
"-netdev stream,id=st0,server=true,addr.type=inet,"
"addr.ipv4=off,addr.ipv6=on,"
"addr.host=::1,addr.port=%d", port);
EXPECT_STATE(qts0, "st0: index=0,type=stream,\r\n", 0);
qts1 = qtest_initf("-nodefaults -M none "
"-netdev stream,server=false,id=st0,addr.type=inet,"
"addr.ipv4=off,addr.ipv6=on,"
"addr.host=::1,addr.port=%d", port);
expect = g_strdup_printf("st0: index=0,type=stream,tcp:::1:%d\r\n",
port);
EXPECT_STATE(qts1, expect, 0);
g_free(expect);
/* the port is unknown, check only the address */
EXPECT_STATE(qts0, "st0: index=0,type=stream,tcp:::1", ':');
qtest_quit(qts1);
qtest_quit(qts0);
}
static void test_stream_unix(void)
{
QTestState *qts0, *qts1;
char *expect;
gchar *path;
path = g_strconcat(tmpdir, "/stream_unix", NULL);
qts0 = qtest_initf("-nodefaults -M none "
"-netdev stream,id=st0,server=true,"
"addr.type=unix,addr.path=%s,",
path);
EXPECT_STATE(qts0, "st0: index=0,type=stream,\r\n", 0);
qts1 = qtest_initf("-nodefaults -M none "
"-netdev stream,id=st0,server=false,"
"addr.type=unix,addr.path=%s",
path);
expect = g_strdup_printf("st0: index=0,type=stream,unix:%s\r\n", path);
EXPECT_STATE(qts1, expect, 0);
EXPECT_STATE(qts0, expect, 0);
g_free(expect);
g_free(path);
qtest_quit(qts1);
qtest_quit(qts0);
}
#ifdef CONFIG_LINUX
static void test_stream_unix_abstract(void)
{
QTestState *qts0, *qts1;
char *expect;
gchar *path;
path = g_strconcat(tmpdir, "/stream_unix_abstract", NULL);
qts0 = qtest_initf("-nodefaults -M none "
"-netdev stream,id=st0,server=true,"
"addr.type=unix,addr.path=%s,"
"addr.abstract=on",
path);
EXPECT_STATE(qts0, "st0: index=0,type=stream,\r\n", 0);
qts1 = qtest_initf("-nodefaults -M none "
"-netdev stream,id=st0,server=false,"
"addr.type=unix,addr.path=%s,addr.abstract=on",
path);
expect = g_strdup_printf("st0: index=0,type=stream,unix:%s\r\n", path);
EXPECT_STATE(qts1, expect, 0);
EXPECT_STATE(qts0, expect, 0);
g_free(expect);
g_free(path);
qtest_quit(qts1);
qtest_quit(qts0);
}
#endif
#ifndef _WIN32
static void test_stream_fd(void)
{
QTestState *qts0, *qts1;
int sock[2];
int ret;
ret = socketpair(AF_LOCAL, SOCK_STREAM, 0, sock);
g_assert_true(ret == 0);
qts0 = qtest_initf("-nodefaults -M none "
"-netdev stream,id=st0,addr.type=fd,addr.str=%d",
sock[0]);
EXPECT_STATE(qts0, "st0: index=0,type=stream,unix:\r\n", 0);
qts1 = qtest_initf("-nodefaults -M none "
"-netdev stream,id=st0,addr.type=fd,addr.str=%d",
sock[1]);
EXPECT_STATE(qts1, "st0: index=0,type=stream,unix:\r\n", 0);
EXPECT_STATE(qts0, "st0: index=0,type=stream,unix:\r\n", 0);
qtest_quit(qts1);
qtest_quit(qts0);
closesocket(sock[0]);
closesocket(sock[1]);
}
#endif
static void test_dgram_inet(void)
{
QTestState *qts0, *qts1;
char *expect;
int port[2];
int nb;
nb = inet_get_free_port_multiple(2, port, false);
g_assert_cmpint(nb, ==, 2);
qts0 = qtest_initf("-nodefaults -M none "
"-netdev dgram,id=st0,"
"local.type=inet,local.host=127.0.0.1,local.port=%d,"
"remote.type=inet,remote.host=127.0.0.1,remote.port=%d",
port[0], port[1]);
expect = g_strdup_printf("st0: index=0,type=dgram,"
"udp=127.0.0.1:%d/127.0.0.1:%d\r\n",
port[0], port[1]);
EXPECT_STATE(qts0, expect, 0);
g_free(expect);
qts1 = qtest_initf("-nodefaults -M none "
"-netdev dgram,id=st0,"
"local.type=inet,local.host=127.0.0.1,local.port=%d,"
"remote.type=inet,remote.host=127.0.0.1,remote.port=%d",
port[1], port[0]);
expect = g_strdup_printf("st0: index=0,type=dgram,"
"udp=127.0.0.1:%d/127.0.0.1:%d\r\n",
port[1], port[0]);
EXPECT_STATE(qts1, expect, 0);
g_free(expect);
qtest_quit(qts1);
qtest_quit(qts0);
}
#ifndef _WIN32
static void test_dgram_mcast(void)
{
QTestState *qts;
qts = qtest_initf("-nodefaults -M none "
"-netdev dgram,id=st0,"
"remote.type=inet,remote.host=230.0.0.1,remote.port=1234");
EXPECT_STATE(qts, "st0: index=0,type=dgram,mcast=230.0.0.1:1234\r\n", 0);
qtest_quit(qts);
}
static void test_dgram_unix(void)
{
QTestState *qts0, *qts1;
char *expect;
gchar *path0, *path1;
path0 = g_strconcat(tmpdir, "/dgram_unix0", NULL);
path1 = g_strconcat(tmpdir, "/dgram_unix1", NULL);
qts0 = qtest_initf("-nodefaults -M none "
"-netdev dgram,id=st0,local.type=unix,local.path=%s,"
"remote.type=unix,remote.path=%s",
path0, path1);
expect = g_strdup_printf("st0: index=0,type=dgram,udp=%s:%s\r\n",
path0, path1);
EXPECT_STATE(qts0, expect, 0);
g_free(expect);
qts1 = qtest_initf("-nodefaults -M none "
"-netdev dgram,id=st0,local.type=unix,local.path=%s,"
"remote.type=unix,remote.path=%s",
path1, path0);
expect = g_strdup_printf("st0: index=0,type=dgram,udp=%s:%s\r\n",
path1, path0);
EXPECT_STATE(qts1, expect, 0);
g_free(expect);
unlink(path0);
g_free(path0);
unlink(path1);
g_free(path1);
qtest_quit(qts1);
qtest_quit(qts0);
}
static void test_dgram_fd(void)
{
QTestState *qts0, *qts1;
char *expect;
int ret;
int sv[2];
ret = socketpair(PF_UNIX, SOCK_DGRAM, 0, sv);
g_assert_cmpint(ret, !=, -1);
qts0 = qtest_initf("-nodefaults -M none "
"-netdev dgram,id=st0,local.type=fd,local.str=%d",
sv[0]);
expect = g_strdup_printf("st0: index=0,type=dgram,fd=%d unix\r\n", sv[0]);
EXPECT_STATE(qts0, expect, 0);
g_free(expect);
qts1 = qtest_initf("-nodefaults -M none "
"-netdev dgram,id=st0,local.type=fd,local.str=%d",
sv[1]);
expect = g_strdup_printf("st0: index=0,type=dgram,fd=%d unix\r\n", sv[1]);
EXPECT_STATE(qts1, expect, 0);
g_free(expect);
qtest_quit(qts1);
qtest_quit(qts0);
closesocket(sv[0]);
closesocket(sv[1]);
}
#endif
int main(int argc, char **argv)
{
int ret;
bool has_ipv4, has_ipv6, has_afunix;
g_autoptr(GError) err = NULL;
socket_init();
g_test_init(&argc, &argv, NULL);
if (socket_check_protocol_support(&has_ipv4, &has_ipv6) < 0) {
g_error("socket_check_protocol_support() failed\n");
}
tmpdir = g_dir_make_tmp("netdev-socket.XXXXXX", &err);
if (tmpdir == NULL) {
g_error("Can't create temporary directory in %s: %s",
g_get_tmp_dir(), err->message);
}
if (has_ipv4) {
qtest_add_func("/netdev/stream/inet/ipv4", test_stream_inet_ipv4);
qtest_add_func("/netdev/dgram/inet", test_dgram_inet);
#ifndef _WIN32
qtest_add_func("/netdev/dgram/mcast", test_dgram_mcast);
#endif
}
if (has_ipv6) {
qtest_add_func("/netdev/stream/inet/ipv6", test_stream_inet_ipv6);
}
socket_check_afunix_support(&has_afunix);
if (has_afunix) {
#ifndef _WIN32
qtest_add_func("/netdev/dgram/unix", test_dgram_unix);
#endif
qtest_add_func("/netdev/stream/unix", test_stream_unix);
#ifdef CONFIG_LINUX
qtest_add_func("/netdev/stream/unix/abstract",
test_stream_unix_abstract);
#endif
#ifndef _WIN32
qtest_add_func("/netdev/stream/fd", test_stream_fd);
qtest_add_func("/netdev/dgram/fd", test_dgram_fd);
#endif
}
ret = g_test_run();
g_rmdir(tmpdir);
g_free(tmpdir);
return ret;
}

View File

@ -14,7 +14,7 @@
#include "qemu/cutils.h"
#include "libqtest.h"
static bool verbose;
static int verbosity_level;
static void test_properties(QTestState *qts, const char *path, bool recurse)
{
@ -24,7 +24,9 @@ static void test_properties(QTestState *qts, const char *path, bool recurse)
QListEntry *entry;
GSList *children = NULL, *links = NULL;
g_test_message("Obtaining properties of %s", path);
if (verbosity_level >= 2) {
g_test_message("Obtaining properties of %s", path);
}
response = qtest_qmp(qts, "{ 'execute': 'qom-list',"
" 'arguments': { 'path': %s } }", path);
g_assert(response);
@ -51,7 +53,7 @@ static void test_properties(QTestState *qts, const char *path, bool recurse)
}
} else {
const char *prop = qdict_get_str(tuple, "name");
if (verbose) {
if (verbosity_level >= 3) {
g_test_message("-> %s", prop);
}
tmp = qtest_qmp(qts,
@ -109,8 +111,8 @@ int main(int argc, char **argv)
{
char *v_env = getenv("V");
if (v_env && atoi(v_env) >= 2) {
verbose = true;
if (v_env) {
verbosity_level = atoi(v_env);
}
g_test_init(&argc, &argv, NULL);

View File

@ -19,6 +19,8 @@ typedef struct Test {
GMainLoop *loop;
} Test;
#if !defined(WIN32) && !defined(CONFIG_DARWIN)
static void on_vnc_error(VncConnection* self,
const char* msg)
{
@ -31,16 +33,21 @@ static void on_vnc_auth_failure(VncConnection *self,
g_error("vnc-auth-failure: %s", msg);
}
#endif
static bool
test_setup(Test *test)
{
#ifdef WIN32
g_test_skip("Not supported on Windows yet");
return false;
#elif defined(CONFIG_DARWIN)
g_test_skip("Broken on Darwin");
return false;
#else
int pair[2];
test->qts = qtest_init("-vnc none -name vnc-test");
test->qts = qtest_init("-M none -vnc none -name vnc-test");
g_assert_cmpint(qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, pair), ==, 0);