Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/stsquad/tags/pull-testing-and-t…
Browse files Browse the repository at this point in the history
…cg-121119-1' into staging

Testing and plugins for rc1

  - add plugin API versioning
  - tests/vm add netbsd autoinstall
  - disable ipmi-bt-test for non-Linux
  - single-thread make check

# gpg: Signature made Tue 12 Nov 2019 14:34:30 GMT
# gpg:                using RSA key 6685AE99E75167BCAFC8DF35FBD0DB095A9E2A44
# gpg: Good signature from "Alex Bennée (Master Work Key) <[email protected]>" [full]
# Primary key fingerprint: 6685 AE99 E751 67BC AFC8  DF35 FBD0 DB09 5A9E 2A44

* remotes/stsquad/tags/pull-testing-and-tcg-121119-1:
  tcg plugins: expose an API version concept
  .travis.yml: don't run make check with multiple jobs
  tests/vm: support sites with sha512 checksums
  tests: only run ipmi-bt-test if CONFIG_LINUX
  tests/vm: update netbsd to version 8.1
  tests/vm: use console_consume for netbsd
  tests/vm: add console_consume helper
  tests/vm: netbsd autoinstall, using serial console

Signed-off-by: Peter Maydell <[email protected]>
  • Loading branch information
pm215 committed Nov 12, 2019
2 parents 039e285 + 3fb356c commit 2a7e7c3
Show file tree
Hide file tree
Showing 14 changed files with 264 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ env:
- SRC_DIR="."
- BUILD_DIR="."
- BASE_CONFIG="--disable-docs --disable-tools"
- TEST_CMD="make check -j3 V=1"
- TEST_CMD="make check V=1"
# This is broadly a list of "mainline" softmmu targets which have support across the major distros
- MAIN_SOFTMMU_TARGETS="aarch64-softmmu,arm-softmmu,i386-softmmu,mips-softmmu,mips64-softmmu,ppc64-softmmu,riscv64-softmmu,s390x-softmmu,x86_64-softmmu"
- CCACHE_SLOPPINESS="include_file_ctime,include_file_mtime"
Expand Down
19 changes: 19 additions & 0 deletions include/qemu/qemu-plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,28 @@

typedef uint64_t qemu_plugin_id_t;

/*
* Versioning plugins:
*
* The plugin API will pass a minimum and current API version that
* QEMU currently supports. The minimum API will be incremented if an
* API needs to be deprecated.
*
* The plugins export the API they were built against by exposing the
* symbol qemu_plugin_version which can be checked.
*/

extern QEMU_PLUGIN_EXPORT int qemu_plugin_version;

#define QEMU_PLUGIN_VERSION 0

typedef struct {
/* string describing architecture */
const char *target_name;
struct {
int min;
int cur;
} version;
/* is this a full system emulation? */
bool system_emulation;
union {
Expand Down
21 changes: 21 additions & 0 deletions plugins/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,25 @@ static int plugin_load(struct qemu_plugin_desc *desc, const qemu_info_t *info)
goto err_symbol;
}

if (!g_module_symbol(ctx->handle, "qemu_plugin_version", &sym)) {
error_report("TCG plugin %s does not declare API version %s",
desc->path, g_module_error());
goto err_symbol;
} else {
int version = *(int *)sym;
if (version < QEMU_PLUGIN_MIN_VERSION) {
error_report("TCG plugin %s requires API version %d, but "
"this QEMU supports only a minimum version of %d",
desc->path, version, QEMU_PLUGIN_MIN_VERSION);
goto err_symbol;
} else if (version > QEMU_PLUGIN_VERSION) {
error_report("TCG plugin %s requires API version %d, but "
"this QEMU supports only up to version %d",
desc->path, version, QEMU_PLUGIN_VERSION);
goto err_symbol;
}
}

qemu_rec_mutex_lock(&plugin.lock);

/* find an unused random id with &ctx as the seed */
Expand Down Expand Up @@ -248,6 +267,8 @@ int qemu_plugin_load_list(QemuPluginList *head)
g_autofree qemu_info_t *info = g_new0(qemu_info_t, 1);

info->target_name = TARGET_NAME;
info->version.min = QEMU_PLUGIN_MIN_VERSION;
info->version.cur = QEMU_PLUGIN_VERSION;
#ifndef CONFIG_USER_ONLY
MachineState *ms = MACHINE(qdev_get_machine());
info->system_emulation = true;
Expand Down
2 changes: 2 additions & 0 deletions plugins/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include <gmodule.h>

#define QEMU_PLUGIN_MIN_VERSION 0

/* global state */
struct qemu_plugin_state {
QTAILQ_HEAD(, qemu_plugin_ctx) ctxs;
Expand Down
2 changes: 2 additions & 0 deletions tests/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ check-qtest-i386-$(CONFIG_SGA) += tests/boot-serial-test$(EXESUF)
check-qtest-i386-$(CONFIG_SLIRP) += tests/pxe-test$(EXESUF)
check-qtest-i386-y += tests/rtc-test$(EXESUF)
check-qtest-i386-$(CONFIG_ISA_IPMI_KCS) += tests/ipmi-kcs-test$(EXESUF)
ifdef CONFIG_LINUX
check-qtest-i386-$(CONFIG_ISA_IPMI_BT) += tests/ipmi-bt-test$(EXESUF)
endif
check-qtest-i386-y += tests/i440fx-test$(EXESUF)
check-qtest-i386-y += tests/fw_cfg-test$(EXESUF)
check-qtest-i386-y += tests/device-plug-test$(EXESUF)
Expand Down
2 changes: 2 additions & 0 deletions tests/plugin/bb.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include <qemu-plugin.h>

QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;

static uint64_t bb_count;
static uint64_t insn_count;
static bool do_inline;
Expand Down
2 changes: 2 additions & 0 deletions tests/plugin/empty.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

#include <qemu-plugin.h>

QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;

/*
* Empty TB translation callback.
* This allows us to measure the overhead of injecting and then
Expand Down
2 changes: 2 additions & 0 deletions tests/plugin/hotblocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#include <qemu-plugin.h>

QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;

static bool do_inline;

/* Plugins need to take care of their own locking */
Expand Down
2 changes: 2 additions & 0 deletions tests/plugin/hotpages.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#include <qemu-plugin.h>

QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;

#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))

static uint64_t page_size = 4096;
Expand Down
2 changes: 2 additions & 0 deletions tests/plugin/howvec.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#include <qemu-plugin.h>

QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;

#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))

typedef enum {
Expand Down
2 changes: 2 additions & 0 deletions tests/plugin/insn.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include <qemu-plugin.h>

QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;

static uint64_t insn_count;
static bool do_inline;

Expand Down
2 changes: 2 additions & 0 deletions tests/plugin/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include <qemu-plugin.h>

QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;

static uint64_t mem_count;
static uint64_t io_count;
static bool do_inline;
Expand Down
29 changes: 27 additions & 2 deletions tests/vm/basevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,25 @@ def __init__(self, debug=False, vcpus=None):
logging.info("KVM not available, not using -enable-kvm")
self._data_args = []

def _download_with_cache(self, url, sha256sum=None):
def _download_with_cache(self, url, sha256sum=None, sha512sum=None):
def check_sha256sum(fname):
if not sha256sum:
return True
checksum = subprocess.check_output(["sha256sum", fname]).split()[0]
return sha256sum == checksum.decode("utf-8")

def check_sha512sum(fname):
if not sha512sum:
return True
checksum = subprocess.check_output(["sha512sum", fname]).split()[0]
return sha512sum == checksum.decode("utf-8")

cache_dir = os.path.expanduser("~/.cache/qemu-vm/download")
if not os.path.exists(cache_dir):
os.makedirs(cache_dir)
fname = os.path.join(cache_dir,
hashlib.sha1(url.encode("utf-8")).hexdigest())
if os.path.exists(fname) and check_sha256sum(fname):
if os.path.exists(fname) and check_sha256sum(fname) and check_sha512sum(fname):
return fname
logging.debug("Downloading %s to %s...", url, fname)
subprocess.check_call(["wget", "-c", url, "-O", fname + ".download"],
Expand Down Expand Up @@ -242,6 +248,25 @@ def console_wait(self, expect, expectalt = None):
return False
return True

def console_consume(self):
vm = self._guest
output = ""
vm.console_socket.setblocking(0)
while True:
try:
chars = vm.console_socket.recv(1)
except:
break
output += chars.decode("latin1")
if "\r" in output or "\n" in output:
lines = re.split("[\r\n]", output)
output = lines.pop()
if self.debug:
self.console_log("\n".join(lines))
if self.debug:
self.console_log(output)
vm.console_socket.setblocking(1)

def console_send(self, command):
vm = self._guest
if self.debug:
Expand Down
Loading

0 comments on commit 2a7e7c3

Please sign in to comment.