Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/bonzini-gitlab/tags/for-upstrea…
Browse files Browse the repository at this point in the history
…m' into staging

* NetBSD NVMM support
* RateLimit mutex
* Prepare for Meson 0.57 upgrade

# gpg: Signature made Tue 04 May 2021 13:15:37 BST
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "pbonzini@redhat.com"
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full]
# gpg:                 aka "Paolo Bonzini <pbonzini@redhat.com>" [full]
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4  E2F7 7E15 100C CD36 69B1
#      Subkey fingerprint: F133 3857 4B66 2389 866C  7682 BFFB D25F 78C7 AE83

* remotes/bonzini-gitlab/tags/for-upstream:
  glib-compat: accept G_TEST_SLOW environment variable
  gitlab-ci: use --meson=internal for CFI jobs
  configure: handle meson options that have changed type
  configure: reindent meson invocation
  slirp: add configure option to disable smbd
  ratelimit: protect with a mutex
  Add NVMM Accelerator: add maintainers for NetBSD/NVMM
  Add NVMM accelerator: acceleration enlightenments
  Add NVMM accelerator: x86 CPU support
  Add NVMM accelerator: configure and build logic
  oslib-win32: do not rely on macro to get redefined function name

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed May 6, 2021
2 parents d90f154 + 9ba5db4 commit 4cc10ca
Show file tree
Hide file tree
Showing 21 changed files with 1,562 additions and 60 deletions.
10 changes: 7 additions & 3 deletions .gitlab-ci.yml
Expand Up @@ -19,17 +19,21 @@ include:
before_script:
- JOBS=$(expr $(nproc) + 1)
script:
- if test -n "$LD_JOBS";
then
scripts/git-submodule.sh update meson ;
fi
- mkdir build
- cd build
- if test -n "$TARGETS";
then
../configure --enable-werror --disable-docs $CONFIGURE_ARGS --target-list="$TARGETS" ;
../configure --enable-werror --disable-docs ${LD_JOBS:+--meson=internal} $CONFIGURE_ARGS --target-list="$TARGETS" ;
else
../configure --enable-werror --disable-docs $CONFIGURE_ARGS ;
../configure --enable-werror --disable-docs ${LD_JOBS:+--meson=internal} $CONFIGURE_ARGS ;
fi || { cat config.log meson-logs/meson-log.txt && exit 1; }
- if test -n "$LD_JOBS";
then
meson configure . -Dbackend_max_links="$LD_JOBS" ;
../meson/meson.py configure . -Dbackend_max_links="$LD_JOBS" ;
fi || exit 1;
- make -j"$JOBS"
- if test -n "$MAKE_CHECK_ARGS";
Expand Down
11 changes: 11 additions & 0 deletions MAINTAINERS
Expand Up @@ -510,6 +510,15 @@ F: accel/stubs/hax-stub.c
F: include/sysemu/hax.h
F: target/i386/hax/

Guest CPU Cores (NVMM)
----------------------
NetBSD Virtual Machine Monitor (NVMM) CPU support
M: Kamil Rytarowski <kamil@netbsd.org>
M: Reinoud Zandijk <reinoud@netbsd.org>
S: Maintained
F: include/sysemu/nvmm.h
F: target/i386/nvmm/

Hosts
-----
LINUX
Expand All @@ -530,6 +539,8 @@ F: include/qemu/*posix*.h

NETBSD
M: Kamil Rytarowski <kamil@netbsd.org>
M: Reinoud Zandijk <reinoud@netbsd.org>
M: Ryo ONODERA <ryoon@netbsd.org>
S: Maintained
K: ^Subject:.*(?i)NetBSD

Expand Down
3 changes: 3 additions & 0 deletions accel/Kconfig
@@ -1,6 +1,9 @@
config WHPX
bool

config NVMM
bool

config HAX
bool

Expand Down
2 changes: 2 additions & 0 deletions block/block-copy.c
Expand Up @@ -230,6 +230,7 @@ void block_copy_state_free(BlockCopyState *s)
return;
}

ratelimit_destroy(&s->rate_limit);
bdrv_release_dirty_bitmap(s->copy_bitmap);
shres_destroy(s->mem);
g_free(s);
Expand Down Expand Up @@ -289,6 +290,7 @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
s->copy_size = MAX(s->cluster_size, BLOCK_COPY_MAX_BUFFER);
}

ratelimit_init(&s->rate_limit);
QLIST_INIT(&s->tasks);
QLIST_INIT(&s->calls);

Expand Down
3 changes: 3 additions & 0 deletions blockjob.c
Expand Up @@ -87,6 +87,7 @@ void block_job_free(Job *job)

block_job_remove_all_bdrv(bjob);
blk_unref(bjob->blk);
ratelimit_destroy(&bjob->limit);
error_free(bjob->blocker);
}

Expand Down Expand Up @@ -442,6 +443,8 @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver,
assert(job->job.driver->free == &block_job_free);
assert(job->job.driver->user_resume == &block_job_user_resume);

ratelimit_init(&job->limit);

job->blk = blk;

job->finalize_cancelled_notifier.notify = block_job_event_cancelled;
Expand Down
119 changes: 77 additions & 42 deletions configure
Expand Up @@ -352,6 +352,7 @@ kvm="auto"
hax="auto"
hvf="auto"
whpx="auto"
nvmm="auto"
rdma="$default_feature"
pvrdma="$default_feature"
gprof="no"
Expand Down Expand Up @@ -463,6 +464,7 @@ gettext="auto"
fuse="auto"
fuse_lseek="auto"
multiprocess="auto"
slirp_smbd="$default_feature"

malloc_trim="auto"
gio="$default_feature"
Expand Down Expand Up @@ -835,8 +837,6 @@ do
fi
done

: ${smbd=${SMBD-/usr/sbin/smbd}}

# Default objcc to clang if available, otherwise use CC
if has clang; then
objcc=clang
Expand Down Expand Up @@ -1107,6 +1107,10 @@ for opt do
;;
--enable-hvf) hvf="enabled"
;;
--disable-nvmm) nvmm="disabled"
;;
--enable-nvmm) nvmm="enabled"
;;
--disable-whpx) whpx="disabled"
;;
--enable-whpx) whpx="enabled"
Expand Down Expand Up @@ -1565,6 +1569,10 @@ for opt do
;;
--disable-gio) gio=no
;;
--enable-slirp-smbd) slirp_smbd=yes
;;
--disable-slirp-smbd) slirp_smbd=no
;;
*)
echo "ERROR: unknown option $opt"
echo "Try '$0 --help' for more information"
Expand Down Expand Up @@ -1848,6 +1856,7 @@ disabled with --disable-FEATURE, default is enabled if available
kvm KVM acceleration support
hax HAX acceleration support
hvf Hypervisor.framework acceleration support
nvmm NVMM acceleration support
whpx Windows Hypervisor Platform acceleration support
rdma Enable RDMA-based migration
pvrdma Enable PVRDMA support
Expand Down Expand Up @@ -1919,6 +1928,7 @@ disabled with --disable-FEATURE, default is enabled if available
fuse-lseek SEEK_HOLE/SEEK_DATA support for FUSE exports
multiprocess Out of process device emulation support
gio libgio support
slirp-smbd use smbd (at path --smbd=*) in slirp networking
NOTE: The object files are built at the place where configure is launched
EOF
Expand Down Expand Up @@ -5255,6 +5265,19 @@ case "$slirp" in
;;
esac

# Check for slirp smbd dupport
: ${smbd=${SMBD-/usr/sbin/smbd}}
if test "$slirp_smbd" != "no" ; then
if test "$mingw32" = "yes" ; then
if test "$slirp_smbd" = "yes" ; then
error_exit "Host smbd not supported on this platform."
fi
slirp_smbd=no
else
slirp_smbd=yes
fi
fi

##########################################
# check for usable __NR_keyctl syscall

Expand Down Expand Up @@ -5530,7 +5553,10 @@ fi
if test "$guest_agent" = "yes" ; then
echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
fi
echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
if test "$slirp_smbd" = "yes" ; then
echo "CONFIG_SLIRP_SMBD=y" >> $config_host_mak
echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
fi
if test "$vde" = "yes" ; then
echo "CONFIG_VDE=y" >> $config_host_mak
echo "VDE_LIBS=$vde_libs" >> $config_host_mak
Expand Down Expand Up @@ -6319,33 +6345,33 @@ for rom in seabios; do
done

if test "$skip_meson" = no; then
cross="config-meson.cross.new"
meson_quote() {
cross="config-meson.cross.new"
meson_quote() {
echo "'$(echo $* | sed "s/ /','/g")'"
}

echo "# Automatically generated by configure - do not modify" > $cross
echo "[properties]" >> $cross
test -z "$cxx" && echo "link_language = 'c'" >> $cross
echo "[built-in options]" >> $cross
echo "c_args = [${CFLAGS:+$(meson_quote $CFLAGS)}]" >> $cross
echo "cpp_args = [${CXXFLAGS:+$(meson_quote $CXXFLAGS)}]" >> $cross
echo "c_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
echo "cpp_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
echo "[binaries]" >> $cross
echo "c = [$(meson_quote $cc)]" >> $cross
test -n "$cxx" && echo "cpp = [$(meson_quote $cxx)]" >> $cross
test -n "$objcc" && echo "objc = [$(meson_quote $objcc)]" >> $cross
echo "ar = [$(meson_quote $ar)]" >> $cross
echo "nm = [$(meson_quote $nm)]" >> $cross
echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
if has $sdl2_config; then
echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
fi
echo "strip = [$(meson_quote $strip)]" >> $cross
echo "windres = [$(meson_quote $windres)]" >> $cross
if test "$cross_compile" = "yes"; then
}

echo "# Automatically generated by configure - do not modify" > $cross
echo "[properties]" >> $cross
test -z "$cxx" && echo "link_language = 'c'" >> $cross
echo "[built-in options]" >> $cross
echo "c_args = [${CFLAGS:+$(meson_quote $CFLAGS)}]" >> $cross
echo "cpp_args = [${CXXFLAGS:+$(meson_quote $CXXFLAGS)}]" >> $cross
echo "c_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
echo "cpp_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
echo "[binaries]" >> $cross
echo "c = [$(meson_quote $cc)]" >> $cross
test -n "$cxx" && echo "cpp = [$(meson_quote $cxx)]" >> $cross
test -n "$objcc" && echo "objc = [$(meson_quote $objcc)]" >> $cross
echo "ar = [$(meson_quote $ar)]" >> $cross
echo "nm = [$(meson_quote $nm)]" >> $cross
echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
if has $sdl2_config; then
echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
fi
echo "strip = [$(meson_quote $strip)]" >> $cross
echo "windres = [$(meson_quote $windres)]" >> $cross
if test "$cross_compile" = "yes"; then
cross_arg="--cross-file config-meson.cross"
echo "[host_machine]" >> $cross
if test "$mingw32" = "yes" ; then
Expand Down Expand Up @@ -6377,17 +6403,17 @@ if test "$cross_compile" = "yes"; then
else
echo "endian = 'little'" >> $cross
fi
else
else
cross_arg="--native-file config-meson.cross"
fi
mv $cross config-meson.cross
fi
mv $cross config-meson.cross

rm -rf meson-private meson-info meson-logs
unset staticpic
if ! version_ge "$($meson --version)" 0.56.0; then
staticpic=$(if test "$pie" = yes; then echo true; else echo false; fi)
fi
NINJA=$ninja $meson setup \
rm -rf meson-private meson-info meson-logs
unset staticpic
if ! version_ge "$($meson --version)" 0.56.0; then
staticpic=$(if test "$pie" = yes; then echo true; else echo false; fi)
fi
NINJA=$ninja $meson setup \
--prefix "$prefix" \
--libdir "$libdir" \
--libexecdir "$libexecdir" \
Expand All @@ -6410,7 +6436,7 @@ NINJA=$ninja $meson setup \
-Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
-Db_lto=$lto -Dcfi=$cfi -Dcfi_debug=$cfi_debug \
-Dmalloc=$malloc -Dmalloc_trim=$malloc_trim -Dsparse=$sparse \
-Dkvm=$kvm -Dhax=$hax -Dwhpx=$whpx -Dhvf=$hvf \
-Dkvm=$kvm -Dhax=$hax -Dwhpx=$whpx -Dhvf=$hvf -Dnvmm=$nvmm \
-Dxen=$xen -Dxen_pci_passthrough=$xen_pci_passthrough -Dtcg=$tcg \
-Dcocoa=$cocoa -Dgtk=$gtk -Dmpath=$mpath -Dsdl=$sdl -Dsdl_image=$sdl_image \
-Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
Expand All @@ -6429,9 +6455,18 @@ NINJA=$ninja $meson setup \
$cross_arg \
"$PWD" "$source_path"

if test "$?" -ne 0 ; then
error_exit "meson setup failed"
fi
if test "$?" -ne 0 ; then
error_exit "meson setup failed"
fi
else
if test -f meson-private/cmd_line.txt; then
# Adjust old command line options whose type was changed
# Avoids having to use "setup --wipe" when Meson is upgraded
perl -i -ne '
s/^gettext = true$/gettext = auto/;
s/^gettext = false$/gettext = disabled/;
print;' meson-private/cmd_line.txt
fi
fi

if test -n "${deprecated_features}"; then
Expand Down
17 changes: 17 additions & 0 deletions include/glib-compat.h
Expand Up @@ -100,6 +100,23 @@ g_unix_get_passwd_entry_qemu(const gchar *user_name, GError **error)
}
#endif /* G_OS_UNIX */

static inline bool
qemu_g_test_slow(void)
{
static int cached = -1;
if (cached == -1) {
cached = g_test_slow() || getenv("G_TEST_SLOW") != NULL;
}
return cached;
}

#undef g_test_slow
#undef g_test_thorough
#undef g_test_quick
#define g_test_slow() qemu_g_test_slow()
#define g_test_thorough() qemu_g_test_slow()
#define g_test_quick() (!qemu_g_test_slow())

#pragma GCC diagnostic pop

#endif
14 changes: 14 additions & 0 deletions include/qemu/ratelimit.h
Expand Up @@ -14,9 +14,11 @@
#ifndef QEMU_RATELIMIT_H
#define QEMU_RATELIMIT_H

#include "qemu/lockable.h"
#include "qemu/timer.h"

typedef struct {
QemuMutex lock;
int64_t slice_start_time;
int64_t slice_end_time;
uint64_t slice_quota;
Expand All @@ -40,6 +42,7 @@ static inline int64_t ratelimit_calculate_delay(RateLimit *limit, uint64_t n)
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
double delay_slices;

QEMU_LOCK_GUARD(&limit->lock);
assert(limit->slice_quota && limit->slice_ns);

if (limit->slice_end_time < now) {
Expand All @@ -65,9 +68,20 @@ static inline int64_t ratelimit_calculate_delay(RateLimit *limit, uint64_t n)
return limit->slice_end_time - now;
}

static inline void ratelimit_init(RateLimit *limit)
{
qemu_mutex_init(&limit->lock);
}

static inline void ratelimit_destroy(RateLimit *limit)
{
qemu_mutex_destroy(&limit->lock);
}

static inline void ratelimit_set_speed(RateLimit *limit, uint64_t speed,
uint64_t slice_ns)
{
QEMU_LOCK_GUARD(&limit->lock);
limit->slice_ns = slice_ns;
limit->slice_quota = MAX(((double)speed * slice_ns) / 1000000000ULL, 1);
}
Expand Down
1 change: 1 addition & 0 deletions include/sysemu/hw_accel.h
Expand Up @@ -16,6 +16,7 @@
#include "sysemu/kvm.h"
#include "sysemu/hvf.h"
#include "sysemu/whpx.h"
#include "sysemu/nvmm.h"

void cpu_synchronize_state(CPUState *cpu);
void cpu_synchronize_post_reset(CPUState *cpu);
Expand Down

0 comments on commit 4cc10ca

Please sign in to comment.