* Improve virtio-net failover test

* Some small fixes for the qtests
 * Misc header cleanups by Philippe
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEJ7iIR+7gJQEY8+q5LtnXdP5wLbUFAmITejURHHRodXRoQHJl
 ZGhhdC5jb20ACgkQLtnXdP5wLbUFaBAAsj/mMIHbP0pIetfbimxopqg85HhryO8R
 P3a2k3+clN0dhIMaZKfnXKM2S03/xWDtXYATidiRpliRfaeZ8oPM9j3U1kqbsjQ9
 u+IdVgYdy0ZoLINvSdLZQp+5ZdBL34KP7OYBdkJUyFV8n2CwFk9c/8tjazkqA3Il
 8OwkrdMu+7E5KyhjeDByPAOyONN53vOZT4nXdD2EsQ7AbIzKfw41Bo2wJzJCOqB+
 uX9JHv+mpKhhv5NZle/oaUF5lg+rqveg4LxSe8D9FIGfYiFMYG3HNq38St4NVXVc
 knBqzQiQZm2MLviXQQ4ym9Q3BFd1QZLJH3TB9SfvJjGEvrErb0Xylcqra1EIxseG
 xI34f9ER0usWSUcIe4t/WjzAjEr3ez+uDJ6ItNFRqPwsV4PGaSgP4auhNzMGlkTo
 zr1O5o/hJdh3otDzM6Qu8FtnNUsKLb2KerveQW+a0uJj3BDKshbn7Au7d3+6eORJ
 DuugBwzrtgvAKr1z/6pYFT8eXyhvI7w/rwtUJwNiBsHXvTBQ4UxEXlKpUCKqEQls
 oqlTK3bezKJuURnuND88L410qUAuvTABjoYx9Y9abbrSqq91F/52bpB/jY2Lke+y
 YoWPV13npdguG1eHB8DowF7MQRLVcULTshXLuM0A9NXkSLJfNY2gLb/I9+hXuQr0
 PuLO5BfVyLE=
 =/azS
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/thuth-gitlab/tags/pull-request-2022-02-21' into staging

* Improve virtio-net failover test
* Some small fixes for the qtests
* Misc header cleanups by Philippe

# gpg: Signature made Mon 21 Feb 2022 11:40:37 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

* remotes/thuth-gitlab/tags/pull-request-2022-02-21: (25 commits)
  hw/tricore: Remove unused and incorrect header
  hw/m68k/mcf: Add missing 'exec/hwaddr.h' header
  exec/exec-all: Move 'qemu/log.h' include in units requiring it
  softmmu/runstate: Clean headers
  linux-user: Add missing "qemu/timer.h" include
  target: Add missing "qemu/timer.h" include
  core/ptimers: Remove unnecessary 'sysemu/cpus.h' include
  exec/ramblock: Add missing includes
  qtest: Add missing 'hw/qdev-core.h' include
  hw/acpi/memory_hotplug: Remove unused 'hw/acpi/pc-hotplug.h' header
  hw/remote: Add missing include
  hw/tpm: Clean includes
  scripts: Remove the old switch-timer-api script
  tests/qtest: failover: migration abort test with failover off
  tests/qtest: failover: test migration if the guest doesn't support failover
  tests/qtest: failover: check migration with failover off
  tests/qtest: failover: check missing guest feature
  tests/qtest: failover: check the feature is correctly provided
  tests/qtest: failover: use a macro for check_one_card()
  tests/qtest: failover: clean up pathname of tests
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2022-02-22 13:07:32 +00:00
commit 5abccc7922
74 changed files with 771 additions and 334 deletions

View File

@ -19,6 +19,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "qemu.h"
#include "signal-common.h"
#include "trace.h"

View File

@ -1,6 +1,5 @@
#include "qemu/osdep.h"
#include "hw/acpi/memory_hotplug.h"
#include "hw/acpi/pc-hotplug.h"
#include "hw/mem/pc-dimm.h"
#include "hw/qdev-core.h"
#include "migration/vmstate.h"

View File

@ -18,6 +18,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "qemu/error-report.h"
#include "qemu/main-loop.h"
#include "qapi/error.h"

View File

@ -14,7 +14,6 @@
#include "sysemu/cpu-timers.h"
#include "sysemu/qtest.h"
#include "block/aio.h"
#include "sysemu/cpus.h"
#include "hw/clock.h"
#define DELTA_ADJUST 1

View File

@ -19,6 +19,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "hw/hw.h"
#include "hw/irq.h"
#include "ui/console.h"

View File

@ -19,6 +19,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "hw/irq.h"
#include "hw/qdev-properties.h"
#include "hw/arm/omap.h"

View File

@ -20,6 +20,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "hw/hw.h"
#include "audio/audio.h"
#include "qemu/timer.h"

View File

@ -16,6 +16,7 @@
#include "exec/cpu-common.h"
#include "exec/ram_addr.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
#include "hw/remote/mpqemu-link.h"
#include "hw/remote/proxy-memory-listener.h"

View File

@ -18,6 +18,7 @@
#include "qemu/module.h"
#include "qapi/error.h"
#include "exec/address-spaces.h"
#include "hw/qdev-properties.h"
#include "hw/pci/pci_ids.h"
#include "hw/acpi/tpm.h"

View File

@ -14,9 +14,9 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "cpu.h"
#include "sysemu/memory_mapping.h"
#include "migration/vmstate.h"
#include "hw/qdev-core.h"
#include "hw/acpi/tpm.h"
#include "tpm_ppi.h"
#include "trace.h"
@ -44,7 +44,7 @@ void tpm_ppi_reset(TPMPPI *tpmppi)
}
}
void tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
void tpm_ppi_init(TPMPPI *tpmppi, MemoryRegion *m,
hwaddr addr, Object *obj)
{
tpmppi->buf = qemu_memalign(qemu_real_host_page_size,

View File

@ -12,7 +12,7 @@
#ifndef TPM_TPM_PPI_H
#define TPM_TPM_PPI_H
#include "exec/address-spaces.h"
#include "exec/memory.h"
typedef struct TPMPPI {
MemoryRegion ram;
@ -29,7 +29,7 @@ typedef struct TPMPPI {
* Register the TPM PPI memory region at @addr on the given address
* space for the object @obj.
**/
void tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
void tpm_ppi_init(TPMPPI *tpmppi, MemoryRegion *m,
hwaddr addr, Object *obj);
/**

View File

@ -40,8 +40,6 @@ typedef ram_addr_t tb_page_addr_t;
#define TB_PAGE_ADDR_FMT RAM_ADDR_FMT
#endif
#include "qemu/log.h"
void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns);
void restore_state_to_opc(CPUArchState *env, TranslationBlock *tb,
target_ulong *data);

View File

@ -21,6 +21,8 @@
#ifndef CONFIG_USER_ONLY
#include "cpu-common.h"
#include "qemu/rcu.h"
#include "exec/ramlist.h"
struct RAMBlock {
struct rcu_head rcu;

View File

@ -2,6 +2,7 @@
#define HW_MCF_H
/* Motorola ColdFire device prototypes. */
#include "exec/hwaddr.h"
#include "target/m68k/cpu-qom.h"
/* mcf_uart.c */

View File

@ -21,7 +21,6 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "hw/boards.h"
#include "hw/arm/boot.h"
#include "sysemu/sysemu.h"
#include "exec/address-spaces.h"
#include "qom/object.h"

View File

@ -20,6 +20,7 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qemu.h"
#include "qemu/timer.h"
#include "user-internals.h"
#include "cpu_loop-common.h"
#include "signal-common.h"

View File

@ -20,6 +20,7 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qemu.h"
#include "qemu/timer.h"
#include "user-internals.h"
#include "cpu_loop-common.h"
#include "signal-common.h"

View File

@ -41,6 +41,7 @@
#include "disas/disas.h"
#include "sysemu/balloon.h"
#include "qemu/timer.h"
#include "qemu/log.h"
#include "sysemu/hw_accel.h"
#include "sysemu/runstate.h"
#include "authz/list.h"

View File

@ -36,6 +36,7 @@
#include "qemu/osdep.h"
#include "qemu/plugin.h"
#include "qemu/log.h"
#include "tcg/tcg.h"
#include "exec/exec-all.h"
#include "exec/ram_addr.h"

View File

@ -1,178 +0,0 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long;
use FindBin;
my @legacy = qw(qemu_clock_ptr qemu_get_clock_ns qemu_get_clock_ms qemu_register_clock_reset_notifier qemu_unregister_clock_reset_notifier qemu_new_timer qemu_free_timer qemu_del_timer qemu_mod_timer_ns qemu_mod_timer qemu_run_timers qemu_new_timer_ns qemu_new_timer_us qemu_new_timer_ms);
my $legacyre = '\b('.join('|', @legacy).')\b';
my $option_git;
my $option_dryrun;
my $option_quiet;
my $option_rtc;
my $suffix=".tmp.$$";
my @files;
my $getfiles = 'git grep -l -E \'\b((host|rt|vm|rtc)_clock\b|qemu_\w*timer)\' | egrep \'\.[ch]$\' | egrep -v \'qemu-timer\.c$|include/qemu/timer\.h$\'';
sub Syntax
{
print STDERR <<STOP;
Usage: $FindBin::Script [options] FILE ...
Translate each FILE to the new QEMU timer API. If no files
are passed, a reasonable guess is taken.
Options:
-q, --quiet Do not show warnings etc
-d, --dry-run Do a dry run
-g, --git Generate a git commit for each change
-r, --rtc Only fix up rtc usage
-h, --help Print this message
STOP
return;
}
sub ParseOptions
{
if (!GetOptions (
"dry-run|d" => \$option_dryrun,
"git|g" => \$option_git,
"quiet|q" => \$option_quiet,
"rtc|r" => \$option_rtc,
"help|h" => sub { Syntax(); exit(0); }
))
{
Syntax();
die "Bad options";
}
if ($#ARGV >=0)
{
@files = @ARGV;
}
else
{
@files = split(/\s+/, `$getfiles`);
}
foreach my $file (@files)
{
die "Cannot find $file" unless (-f $file && -r $file);
}
}
sub DoWarn
{
my $text = shift @_;
my $line = shift @_;
return if ($option_quiet);
chomp ($line);
print STDERR "$text\n";
print STDERR "$line\n\n";
}
sub Process
{
my $ifn = shift @_;
my $ofn = $ifn.$suffix;
my $intext;
my $outtext;
my $linenum = 0;
open my $input, "<", $ifn || die "Cannot open $ifn for read: $!";
while (<$input>)
{
my $line = $_;
$intext .= $line;
$linenum++;
# fix the specific uses
unless ($option_rtc)
{
$line =~ s/\bqemu_new_timer(_[num]s)\s*\((vm_|rt_|host_)clock\b/timer_new$1(XXX_$2clock/g;
$line =~ s/\bqemu_new_timer\s*\((vm_|rt_|host_)clock\b/timer_new(XXX_$1clock/g;
$line =~ s/\bqemu_get_clock(_[num]s)\s*\((vm_|rt_|host_)clock\b/qemu_clock_get$1(XXX_$2clock/g;
}
# rtc is different
$line =~ s/\bqemu_new_timer(_[num]s)\s*\(rtc_clock\b/timer_new$1(rtc_clock/g;
$line =~ s/\bqemu_new_timer\s*\(rtc_clock\b/timer_new(rtc_clock/g;
$line =~ s/\bqemu_get_clock(_[num]s)\s*\(rtc_clock\b/qemu_clock_get$1(rtc_clock/g;
$line =~ s/\bqemu_register_clock_reset_notifier\s*\(rtc_clock\b/qemu_register_clock_reset_notifier(qemu_clock_ptr(rtc_clock)/g;
unless ($option_rtc)
{
# fix up comments
$line =~ s/\b(vm_|rt_|host_)clock\b/XXX_$1clock/g if ($line =~ m,^[/ ]+\*,);
# spurious fprintf error reporting
$line =~ s/: qemu_new_timer_ns failed/: timer_new_ns failed/g;
# these have just changed name
$line =~ s/\bqemu_mod_timer\b/timer_mod/g;
$line =~ s/\bqemu_mod_timer_(ns|us|ms)\b/timer_mod_$1/g;
$line =~ s/\bqemu_free_timer\b/timer_free/g;
$line =~ s/\bqemu_del_timer\b/timer_del/g;
}
# fix up rtc_clock
$line =~ s/QEMUClock \*rtc_clock;/QEMUClockType rtc_clock;/g;
$line =~ s/\brtc_clock = (vm_|rt_|host_)clock\b/rtc_clock = XXX_$1clock/g;
unless ($option_rtc)
{
# replace any more general uses
$line =~ s/\b(vm_|rt_|host_)clock\b/qemu_clock_ptr(XXX_$1clock)/g;
}
# fix up the place holders
$line =~ s/\bXXX_vm_clock\b/QEMU_CLOCK_VIRTUAL/g;
$line =~ s/\bXXX_rt_clock\b/QEMU_CLOCK_REALTIME/g;
$line =~ s/\bXXX_host_clock\b/QEMU_CLOCK_HOST/g;
unless ($option_rtc)
{
DoWarn("$ifn:$linenum WARNING: timer $1 not fixed up", $line) if ($line =~ /\b((vm_|rt_|host_)clock)\b/);
DoWarn("$ifn:$linenum WARNING: function $1 not fixed up", $line) if ($line =~ /\b(qemu_new_timer\w+)\b/);
DoWarn("$ifn:$linenum WARNING: legacy function $1 remains", $line) if ($line =~ /$legacyre/o);
}
$outtext .= $line;
}
close $input;
if ($intext ne $outtext)
{
print STDERR "Patching $ifn\n" unless ($option_quiet);
unless ($option_dryrun)
{
open my $output, ">", $ofn || die "Cannot open $ofn for write: $!";
print $output $outtext;
close $output;
rename ($ofn, $ifn) || die "Cannot rename temp file to $ifn: $!";
return 1;
}
}
return 0;
}
sub DoCommit
{
my $file = shift @_;
open (my $git, "| git commit -F - $file") || die "Cannot run git commit on $file: $!";
print $git "timers api: use new timer api in $file\n\nConvert $file to use new timer API.\nThis is an automated commit made by scripts/switch-timer-api\n";
close ($git);
}
ParseOptions;
foreach my $file (@files)
{
my $changed = Process ($file);
DoCommit($file) if ($changed && $option_git);
}

View File

@ -19,6 +19,7 @@
#include "chardev/char-fe.h"
#include "exec/ioport.h"
#include "exec/memory.h"
#include "hw/qdev-core.h"
#include "hw/irq.h"
#include "qemu/accel.h"
#include "sysemu/cpu-timers.h"

View File

@ -30,7 +30,6 @@
#include "crypto/cipher.h"
#include "crypto/init.h"
#include "exec/cpu-common.h"
#include "exec/exec-all.h"
#include "exec/gdbstub.h"
#include "hw/boards.h"
#include "migration/misc.h"
@ -43,7 +42,9 @@
#include "qapi/qapi-events-run-state.h"
#include "qemu-common.h"
#include "qemu/error-report.h"
#include "qemu/log.h"
#include "qemu/job.h"
#include "qemu/log.h"
#include "qemu/module.h"
#include "qemu/plugin.h"
#include "qemu/sockets.h"

View File

@ -18,7 +18,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "exec/exec-all.h"
#include "fpu/softfloat-types.h"

View File

@ -20,6 +20,7 @@
#include "qemu/osdep.h"
#include "qemu/qemu-print.h"
#include "qemu/timer.h"
#include "qemu-common.h"
#include "target/arm/idau.h"
#include "qemu/module.h"

View File

@ -8,6 +8,7 @@
#include "qemu/osdep.h"
#include "qemu/units.h"
#include "qemu/log.h"
#include "target/arm/idau.h"
#include "trace.h"
#include "cpu.h"
@ -15,6 +16,7 @@
#include "exec/helper-proto.h"
#include "qemu/host-utils.h"
#include "qemu/main-loop.h"
#include "qemu/timer.h"
#include "qemu/bitops.h"
#include "qemu/crc32c.h"
#include "qemu/qemu-print.h"

View File

@ -19,6 +19,7 @@
#include "qemu/bitops.h"
#include "qemu/crc32c.h"
#include "qemu/qemu-print.h"
#include "qemu/log.h"
#include "exec/exec-all.h"
#include <zlib.h> /* For crc32 */
#include "semihosting/semihost.h"

View File

@ -18,6 +18,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "internals.h"
#include "exec/exec-all.h"

View File

@ -19,6 +19,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "hw/core/tcg-cpu-ops.h"
#include "exec/exec-all.h"

View File

@ -19,6 +19,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "hw/core/tcg-cpu-ops.h"
#include "mmu.h"

View File

@ -18,6 +18,8 @@
#ifndef HEXAGON_INTERNAL_H
#define HEXAGON_INTERNAL_H
#include "qemu/log.h"
/*
* Change HEX_DEBUG to 1 to turn on debugging output
*/

View File

@ -19,6 +19,7 @@
#define HEXAGON_TRANSLATE_H
#include "qemu/bitmap.h"
#include "qemu/log.h"
#include "cpu.h"
#include "exec/translator.h"
#include "tcg/tcg-op.h"

View File

@ -21,6 +21,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qemu/qemu-print.h"
#include "qemu/timer.h"
#include "cpu.h"
#include "qemu/module.h"
#include "exec/exec-all.h"

View File

@ -18,7 +18,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "fpu/softfloat.h"
#include "exec/exec-all.h"

View File

@ -18,6 +18,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "exec/exec-all.h"
#include "exec/helper-proto.h"

View File

@ -18,6 +18,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "exec/exec-all.h"
#include "exec/helper-proto.h"

View File

@ -27,6 +27,7 @@
#include "sysemu/hw_accel.h"
#include "monitor/monitor.h"
#endif
#include "qemu/log.h"
void cpu_sync_bndcs_hflags(CPUX86State *env)
{

View File

@ -18,6 +18,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "exec/exec-all.h"
#include "qemu/host-utils.h"

View File

@ -18,6 +18,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "exec/helper-proto.h"
#include "exec/exec-all.h"

View File

@ -19,6 +19,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "exec/helper-proto.h"
#include "exec/cpu_ldst.h"

View File

@ -18,6 +18,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "exec/helper-proto.h"
#include "exec/exec-all.h"

View File

@ -17,6 +17,7 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "exec/helper-proto.h"
#include "exec/exec-all.h"

View File

@ -22,6 +22,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "qapi/error.h"
#include "cpu.h"
#include "qemu/module.h"

View File

@ -19,6 +19,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "exec/exec-all.h"

View File

@ -19,6 +19,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "exec/helper-proto.h"
#include "qemu/host-utils.h"

View File

@ -19,6 +19,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "internal.h"
#include "exec/helper-proto.h"

View File

@ -19,6 +19,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "exec/helper-proto.h"
#include "exec/exec-all.h"

View File

@ -8,6 +8,7 @@
#ifndef TARGET_MIPS_TRANSLATE_H
#define TARGET_MIPS_TRANSLATE_H
#include "qemu/log.h"
#include "exec/translator.h"
#define MIPS_DEBUG_DISAS 0

View File

@ -18,6 +18,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "exec/exec-all.h"
#include "exec/gdbstub.h"

View File

@ -19,6 +19,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "exec/exec-all.h"
#include "exec/gdbstub.h"

View File

@ -18,6 +18,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/main-loop.h"
#include "qemu/log.h"
#include "cpu.h"
#include "exec/exec-all.h"
#include "internal.h"

View File

@ -18,6 +18,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "exec/exec-all.h"
#include "exec/helper-proto.h"

View File

@ -19,6 +19,7 @@
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "qemu/timer.h"
#include "cpu.h"
#include "qemu/main-loop.h"
#include "exec/exec-all.h"

View File

@ -19,6 +19,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "s390x-internal.h"
#include "exec/helper-proto.h"

View File

@ -19,6 +19,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "s390x-internal.h"
#include "tcg_s390x.h"

View File

@ -20,6 +20,7 @@
#include "qemu/osdep.h"
#include "cpu.h"
#include "exec/exec-all.h"
#include "qemu/timer.h"
#include "qemu/host-utils.h"
#include "exec/helper-proto.h"

View File

@ -18,6 +18,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "tcg/tcg.h"
#include "exec/helper-proto.h"

View File

@ -18,6 +18,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "exec/exec-all.h"
#include "qemu/qemu-print.h"

View File

@ -16,7 +16,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "exec/exec-all.h"
#include "fpu/softfloat-helpers.h"

View File

@ -26,6 +26,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "qemu/main-loop.h"
#include "cpu.h"
#include "exec/helper-proto.h"

View File

@ -26,6 +26,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "qemu/main-loop.h"
#include "cpu.h"
#include "exec/helper-proto.h"

View File

@ -26,6 +26,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "qemu/main-loop.h"
#include "cpu.h"
#include "exec/helper-proto.h"

View File

@ -26,6 +26,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "cpu.h"
#include "exec/exec-all.h"
#include "exec/gdbstub.h"

View File

@ -26,6 +26,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "qemu/main-loop.h"
#include "qemu/qemu-print.h"
#include "qemu/units.h"

View File

@ -26,6 +26,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "qemu/main-loop.h"
#include "cpu.h"
#include "exec/helper-proto.h"

View File

@ -63,7 +63,15 @@ static void wait_device_deleted_event(QTestState *qtest, const char *id)
static void test_pci_unplug_request(void)
{
QTestState *qtest = qtest_initf("-device virtio-mouse-pci,id=dev0");
const char *arch = qtest_get_arch();
const char *machine_addition = "";
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
machine_addition = "-machine pc";
}
QTestState *qtest = qtest_initf("%s -device virtio-mouse-pci,id=dev0",
machine_addition);
/*
* Request device removal. As the guest is not running, the request won't
@ -79,8 +87,16 @@ static void test_pci_unplug_request(void)
static void test_pci_unplug_json_request(void)
{
const char *arch = qtest_get_arch();
const char *machine_addition = "";
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
machine_addition = "-machine pc";
}
QTestState *qtest = qtest_initf(
"-device '{\"driver\": \"virtio-mouse-pci\", \"id\": \"dev0\"}'");
"%s -device '{\"driver\": \"virtio-mouse-pci\", \"id\": \"dev0\"}'",
machine_addition);
/*
* Request device removal. As the guest is not running, the request won't

View File

@ -235,14 +235,21 @@ static void test_drive_del_device_del(void)
static void test_cli_device_del(void)
{
QTestState *qts;
const char *arch = qtest_get_arch();
const char *machine_addition = "";
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
machine_addition = "-machine pc";
}
/*
* -drive/-device and device_del. Start with a drive used by a
* device that unplugs after reset.
*/
qts = qtest_initf("-drive if=none,id=drive0,file=null-co://,"
qts = qtest_initf("%s -drive if=none,id=drive0,file=null-co://,"
"file.read-zeroes=on,format=raw"
" -device virtio-blk-%s,drive=drive0,id=dev0",
machine_addition,
qvirtio_get_dev_type());
device_del(qts, true);
@ -266,13 +273,19 @@ static void test_empty_device_del(void)
static void test_device_add_and_del(void)
{
QTestState *qts;
const char *arch = qtest_get_arch();
const char *machine_addition = "";
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
machine_addition = "-machine pc";
}
/*
* -drive/device_add and device_del. Start with a drive used by a
* device that unplugs after reset.
*/
qts = qtest_init("-drive if=none,id=drive0,file=null-co://,"
"file.read-zeroes=on,format=raw");
qts = qtest_initf("%s -drive if=none,id=drive0,file=null-co://,"
"file.read-zeroes=on,format=raw", machine_addition);
device_add(qts);
device_del(qts, true);
@ -284,8 +297,14 @@ static void test_device_add_and_del(void)
static void test_drive_add_device_add_and_del(void)
{
QTestState *qts;
const char *arch = qtest_get_arch();
const char *machine_addition = "";
qts = qtest_init("");
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
machine_addition = "-machine pc";
}
qts = qtest_init(machine_addition);
/*
* drive_add/device_add and device_del. The drive is used by a
@ -302,8 +321,14 @@ static void test_drive_add_device_add_and_del(void)
static void test_blockdev_add_device_add_and_del(void)
{
QTestState *qts;
const char *arch = qtest_get_arch();
const char *machine_addition = "";
qts = qtest_init("");
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
machine_addition = "-machine pc";
}
qts = qtest_init(machine_addition);
/*
* blockdev_add/device_add and device_del. The it drive is used by a

View File

@ -75,7 +75,7 @@ static inline uint64_t in_reg64(ERSTState *s, unsigned reg)
uint64_t res;
res = qpci_io_readq(s->dev, s->reg_bar, reg);
g_test_message("*%s -> %016llx", name, (unsigned long long)res);
g_test_message("*%s -> %016" PRIx64, name, res);
return res;
}

View File

@ -598,7 +598,7 @@ int main(int argc, char **argv)
/* Run the tests */
g_test_init(&argc, &argv, NULL);
qtest_start("-device floppy,id=floppy0");
qtest_start("-machine pc -device floppy,id=floppy0");
qtest_irq_intercept_in(global_qtest, "ioapic");
qtest_add_func("/fdc/cmos", test_cmos);
qtest_add_func("/fdc/no_media_on_start", test_no_media_on_start);

View File

@ -178,9 +178,15 @@ static int append_arg(int argc, char *argv[], int argv_sz, char *arg)
static int setup_common(char *argv[], int argv_sz)
{
int new_argc;
memset(cur_ide, 0, sizeof(cur_ide));
return append_arg(0, argv, argv_sz,
g_strdup("-nodefaults"));
new_argc = append_arg(0, argv, argv_sz,
g_strdup("-nodefaults"));
new_argc = append_arg(new_argc, argv, argv_sz,
g_strdup("-machine"));
new_argc = append_arg(new_argc, argv, argv_sz,
g_strdup("pc"));
return new_argc;
}
static void setup_mbr(int img_idx, MBRcontents mbr)
@ -697,7 +703,7 @@ static void test_override(TestArgs *args, CHSResult expected[])
joined_args = g_strjoinv(" ", args->argv);
qts = qtest_init(joined_args);
qts = qtest_initf("-machine pc %s", joined_args);
fw_cfg = pc_fw_cfg_init(qts);
read_bootdevices(fw_cfg, expected);
@ -833,7 +839,7 @@ static void test_override_scsi_hot_unplug(void)
joined_args = g_strjoinv(" ", args->argv);
qts = qtest_init(joined_args);
qts = qtest_initf("-machine pc %s", joined_args);
fw_cfg = pc_fw_cfg_init(qts);
read_bootdevices(fw_cfg, expected);
@ -893,7 +899,7 @@ static void test_override_virtio_hot_unplug(void)
joined_args = g_strjoinv(" ", args->argv);
qts = qtest_init(joined_args);
qts = qtest_initf("-machine pc %s", joined_args);
fw_cfg = pc_fw_cfg_init(qts);
read_bootdevices(fw_cfg, expected);

View File

@ -35,7 +35,7 @@ static QPCIBus *test_start_get_bus(const TestData *s)
{
char *cmdline;
cmdline = g_strdup_printf("-smp %d", s->num_cpus);
cmdline = g_strdup_printf("-machine pc -smp %d", s->num_cpus);
qtest_start(cmdline);
g_free(cmdline);
return qpci_new_pc(global_qtest, NULL);

View File

@ -128,10 +128,11 @@ static char debug_path[] = "/tmp/qtest-blkdebug.XXXXXX";
static QTestState *ide_test_start(const char *cmdline_fmt, ...)
{
QTestState *qts;
g_autofree char *full_fmt = g_strdup_printf("-machine pc %s", cmdline_fmt);
va_list ap;
va_start(ap, cmdline_fmt);
qts = qtest_vinitf(cmdline_fmt, ap);
qts = qtest_vinitf(full_fmt, ap);
va_end(ap);
pc_alloc_init(&guest_malloc, qts, 0);
@ -701,7 +702,7 @@ static void test_flush(void)
free_pci_device(dev);
}
static void test_retry_flush(const char *machine)
static void test_pci_retry_flush(void)
{
QTestState *qts;
QPCIDevice *dev;
@ -790,16 +791,6 @@ static void test_flush_empty_drive(void)
ide_test_quit(qts);
}
static void test_pci_retry_flush(void)
{
test_retry_flush("pc");
}
static void test_isa_retry_flush(void)
{
test_retry_flush("isapc");
}
typedef struct Read10CDB {
uint8_t opcode;
uint8_t flags;
@ -1050,7 +1041,6 @@ int main(int argc, char **argv)
qtest_add_func("/ide/flush/nodev", test_flush_nodev);
qtest_add_func("/ide/flush/empty_drive", test_flush_empty_drive);
qtest_add_func("/ide/flush/retry_pci", test_pci_retry_flush);
qtest_add_func("/ide/flush/retry_isa", test_isa_retry_flush);
qtest_add_func("/ide/cdrom/pio", test_cdrom_pio);
qtest_add_func("/ide/cdrom/pio_large", test_cdrom_pio_large);

View File

@ -385,7 +385,12 @@ static void test_ivshmem_hotplug(void)
QTestState *qts;
const char *arch = qtest_get_arch();
qts = qtest_init("-object memory-backend-ram,size=1M,id=mb1");
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
qts = qtest_init("-object memory-backend-ram,size=1M,id=mb1"
" -machine pc");
} else {
qts = qtest_init("-object memory-backend-ram,size=1M,id=mb1");
}
qtest_qmp_device_add(qts, "ivshmem-plain", "iv1",
"{'addr': %s, 'memdev': 'mb1'}",

View File

@ -42,7 +42,7 @@
#define QEMU_CMD_MEMFD " -m %d -object memory-backend-memfd,id=mem,size=%dM," \
" -numa node,memdev=mem"
#define QEMU_CMD_CHR " -chardev socket,id=%s,path=%s%s"
#define QEMU_CMD_NETDEV " -netdev vhost-user,id=hs0,chardev=%s,vhostforce"
#define QEMU_CMD_NETDEV " -netdev vhost-user,id=hs0,chardev=%s,vhostforce=on"
#define HUGETLBFS_MAGIC 0x958458f6

View File

@ -18,6 +18,8 @@
#include "libqos/virtio-pci.h"
#include "hw/pci/pci.h"
#define VIRTIO_NET_F_STANDBY 62
#define ACPI_PCIHP_ADDR_ICH9 0x0cc0
#define PCI_EJ_BASE 0x0008
#define PCI_SEL_BASE 0x0010
@ -224,88 +226,27 @@ static char *get_mac(QTestState *qts, const char *name)
return mac;
}
static void check_one_card(QTestState *qts, bool present,
const char *id, const char *mac)
{
QDict *device;
QDict *bus;
char *addr;
bus = get_bus(qts, 0);
device = find_device(bus, id);
if (present) {
char *path;
g_assert_nonnull(device);
qobject_unref(device);
path = g_strdup_printf("/machine/peripheral/%s", id);
addr = get_mac(qts, path);
g_free(path);
g_assert_cmpstr(mac, ==, addr);
g_free(addr);
} else {
g_assert_null(device);
}
qobject_unref(bus);
}
static void test_on(void)
{
QTestState *qts;
qts = machine_start(BASE_MACHINE
"-netdev user,id=hs0 "
"-device virtio-net,bus=root0,id=standby0,"
"failover=on,netdev=hs0,mac="MAC_STANDBY0" "
"-device virtio-net,bus=root1,id=primary0,"
"failover_pair_id=standby0,netdev=hs1,mac="MAC_PRIMARY0,
2);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
machine_stop(qts);
}
static void test_on_mismatch(void)
{
QTestState *qts;
qts = machine_start(BASE_MACHINE
"-netdev user,id=hs0 "
"-device virtio-net,bus=root0,id=standby0,"
"failover=on,netdev=hs0,mac="MAC_STANDBY0" "
"-netdev user,id=hs1 "
"-device virtio-net,bus=root1,id=primary0,"
"failover_pair_id=standby1,netdev=hs1,mac="MAC_PRIMARY0,
2);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
machine_stop(qts);
}
static void test_off(void)
{
QTestState *qts;
qts = machine_start(BASE_MACHINE
"-netdev user,id=hs0 "
"-device virtio-net,bus=root0,id=standby0,"
"failover=off,netdev=hs0,mac="MAC_STANDBY0" "
"-netdev user,id=hs1 "
"-device virtio-net,bus=root1,id=primary0,"
"failover_pair_id=standby0,netdev=hs1,mac="MAC_PRIMARY0,
2);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
machine_stop(qts);
}
#define check_one_card(qts, present, id, mac) \
do { \
QDict *device; \
QDict *bus; \
char *addr; \
bus = get_bus(qts, 0); \
device = find_device(bus, id); \
if (present) { \
char *path; \
g_assert_nonnull(device); \
qobject_unref(device); \
path = g_strdup_printf("/machine/peripheral/%s", id); \
addr = get_mac(qts, path); \
g_free(path); \
g_assert_cmpstr(mac, ==, addr); \
g_free(addr); \
} else { \
g_assert_null(device); \
} \
qobject_unref(bus); \
} while (0)
static QDict *get_failover_negociated_event(QTestState *qts)
{
@ -323,33 +264,120 @@ static QDict *get_failover_negociated_event(QTestState *qts)
return data;
}
static QVirtioPCIDevice *start_virtio_net(QTestState *qts, int bus, int slot,
const char *id)
static QVirtioPCIDevice *start_virtio_net_internal(QTestState *qts,
int bus, int slot,
uint64_t *features)
{
QVirtioPCIDevice *dev;
uint64_t features;
QPCIAddress addr;
QDict *resp;
addr.devfn = QPCI_DEVFN((bus << 5) + slot, 0);
dev = virtio_pci_new(pcibus, &addr);
g_assert_nonnull(dev);
qvirtio_pci_device_enable(dev);
qvirtio_start_device(&dev->vdev);
features = qvirtio_get_features(&dev->vdev);
features = features & ~(QVIRTIO_F_BAD_FEATURE |
(1ull << VIRTIO_RING_F_INDIRECT_DESC) |
(1ull << VIRTIO_RING_F_EVENT_IDX));
qvirtio_set_features(&dev->vdev, features);
*features &= qvirtio_get_features(&dev->vdev);
qvirtio_set_features(&dev->vdev, *features);
qvirtio_set_driver_ok(&dev->vdev);
return dev;
}
resp = get_failover_negociated_event(qts);
g_assert_cmpstr(qdict_get_str(resp, "device-id"), ==, id);
qobject_unref(resp);
static QVirtioPCIDevice *start_virtio_net(QTestState *qts, int bus, int slot,
const char *id, bool failover)
{
QVirtioPCIDevice *dev;
uint64_t features;
features = ~(QVIRTIO_F_BAD_FEATURE |
(1ull << VIRTIO_RING_F_INDIRECT_DESC) |
(1ull << VIRTIO_RING_F_EVENT_IDX));
dev = start_virtio_net_internal(qts, bus, slot, &features);
g_assert(!!(features & (1ull << VIRTIO_NET_F_STANDBY)) == failover);
if (failover) {
QDict *resp;
resp = get_failover_negociated_event(qts);
g_assert_cmpstr(qdict_get_str(resp, "device-id"), ==, id);
qobject_unref(resp);
}
return dev;
}
static void test_on(void)
{
QTestState *qts;
qts = machine_start(BASE_MACHINE
"-netdev user,id=hs0 "
"-device virtio-net,bus=root0,id=standby0,"
"failover=on,netdev=hs0,mac="MAC_STANDBY0" "
"-netdev user,id=hs1 "
"-device virtio-net,bus=root1,id=primary0,"
"failover_pair_id=standby0,netdev=hs1,mac="MAC_PRIMARY0,
2);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
machine_stop(qts);
}
static void test_on_mismatch(void)
{
QTestState *qts;
QVirtioPCIDevice *vdev;
qts = machine_start(BASE_MACHINE
"-netdev user,id=hs0 "
"-device virtio-net,bus=root0,id=standby0,"
"failover=on,netdev=hs0,mac="MAC_STANDBY0" "
"-netdev user,id=hs1 "
"-device virtio-net,bus=root1,id=primary0,"
"failover_pair_id=standby1,netdev=hs1,mac="MAC_PRIMARY0,
2);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
vdev = start_virtio_net(qts, 1, 0, "standby0", true);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
qos_object_destroy((QOSGraphObject *)vdev);
machine_stop(qts);
}
static void test_off(void)
{
QTestState *qts;
QVirtioPCIDevice *vdev;
qts = machine_start(BASE_MACHINE
"-netdev user,id=hs0 "
"-device virtio-net,bus=root0,id=standby0,"
"failover=off,netdev=hs0,mac="MAC_STANDBY0" "
"-netdev user,id=hs1 "
"-device virtio-net,bus=root1,id=primary0,"
"failover_pair_id=standby0,netdev=hs1,mac="MAC_PRIMARY0,
2);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
vdev = start_virtio_net(qts, 1, 0, "standby0", false);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
qos_object_destroy((QOSGraphObject *)vdev);
machine_stop(qts);
}
static void test_enabled(void)
{
QTestState *qts;
@ -367,7 +395,7 @@ static void test_enabled(void)
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
vdev = start_virtio_net(qts, 1, 0, "standby0");
vdev = start_virtio_net(qts, 1, 0, "standby0", true);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
@ -376,6 +404,38 @@ static void test_enabled(void)
machine_stop(qts);
}
static void test_guest_off(void)
{
QTestState *qts;
QVirtioPCIDevice *vdev;
uint64_t features;
qts = machine_start(BASE_MACHINE
"-netdev user,id=hs0 "
"-device virtio-net,bus=root0,id=standby0,"
"failover=on,netdev=hs0,mac="MAC_STANDBY0" "
"-netdev user,id=hs1 "
"-device virtio-net,bus=root1,id=primary0,"
"failover_pair_id=standby0,netdev=hs1,mac="MAC_PRIMARY0" ",
2);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
features = ~(QVIRTIO_F_BAD_FEATURE |
(1ull << VIRTIO_RING_F_INDIRECT_DESC) |
(1ull << VIRTIO_RING_F_EVENT_IDX) |
(1ull << VIRTIO_NET_F_STANDBY));
vdev = start_virtio_net_internal(qts, 1, 0, &features);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
qos_object_destroy((QOSGraphObject *)vdev);
machine_stop(qts);
}
static void test_hotplug_1(void)
{
QTestState *qts;
@ -390,7 +450,7 @@ static void test_hotplug_1(void)
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
vdev = start_virtio_net(qts, 1, 0, "standby0");
vdev = start_virtio_net(qts, 1, 0, "standby0", true);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
@ -432,7 +492,7 @@ static void test_hotplug_1_reverse(void)
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
vdev = start_virtio_net(qts, 1, 0, "standby0");
vdev = start_virtio_net(qts, 1, 0, "standby0", true);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
@ -463,7 +523,7 @@ static void test_hotplug_2(void)
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
vdev = start_virtio_net(qts, 1, 0, "standby0");
vdev = start_virtio_net(qts, 1, 0, "standby0", true);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
@ -519,7 +579,7 @@ static void test_hotplug_2_reverse(void)
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
vdev = start_virtio_net(qts, 1, 0, "standby0");
vdev = start_virtio_net(qts, 1, 0, "standby0", true);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
@ -584,7 +644,7 @@ static void test_migrate_out(gconstpointer opaque)
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
vdev = start_virtio_net(qts, 1, 0, "standby0");
vdev = start_virtio_net(qts, 1, 0, "standby0", true);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
@ -755,6 +815,364 @@ static void test_migrate_in(gconstpointer opaque)
machine_stop(qts);
}
static void test_off_migrate_out(gconstpointer opaque)
{
QTestState *qts;
QDict *resp, *args, *ret;
g_autofree gchar *uri = g_strdup_printf("exec: cat > %s", (gchar *)opaque);
const gchar *status;
QVirtioPCIDevice *vdev;
qts = machine_start(BASE_MACHINE
"-netdev user,id=hs0 "
"-netdev user,id=hs1 ",
2);
check_one_card(qts, false, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
qtest_qmp_device_add(qts, "virtio-net", "standby0",
"{'bus': 'root0',"
"'failover': 'off',"
"'netdev': 'hs0',"
"'mac': '"MAC_STANDBY0"'}");
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
qtest_qmp_device_add(qts, "virtio-net", "primary0",
"{'bus': 'root1',"
"'failover_pair_id': 'standby0',"
"'netdev': 'hs1',"
"'rombar': 0,"
"'romfile': '',"
"'mac': '"MAC_PRIMARY0"'}");
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
vdev = start_virtio_net(qts, 1, 0, "standby0", false);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
args = qdict_from_jsonf_nofail("{}");
g_assert_nonnull(args);
qdict_put_str(args, "uri", uri);
resp = qtest_qmp(qts, "{ 'execute': 'migrate', 'arguments': %p}", args);
g_assert(qdict_haskey(resp, "return"));
qobject_unref(resp);
while (true) {
ret = migrate_status(qts);
status = qdict_get_str(ret, "status");
if (strcmp(status, "completed") == 0) {
qobject_unref(ret);
break;
}
g_assert_cmpstr(status, !=, "failed");
g_assert_cmpstr(status, !=, "cancelling");
g_assert_cmpstr(status, !=, "cancelled");
qobject_unref(ret);
}
qtest_qmp_eventwait(qts, "STOP");
qos_object_destroy((QOSGraphObject *)vdev);
machine_stop(qts);
}
static void test_off_migrate_in(gconstpointer opaque)
{
QTestState *qts;
QDict *resp, *args, *ret;
g_autofree gchar *uri = g_strdup_printf("exec: cat %s", (gchar *)opaque);
qts = machine_start(BASE_MACHINE
"-netdev user,id=hs0 "
"-netdev user,id=hs1 "
"-incoming defer ",
2);
check_one_card(qts, false, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
qtest_qmp_device_add(qts, "virtio-net", "standby0",
"{'bus': 'root0',"
"'failover': 'off',"
"'netdev': 'hs0',"
"'mac': '"MAC_STANDBY0"'}");
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
qtest_qmp_device_add(qts, "virtio-net", "primary0",
"{'bus': 'root1',"
"'failover_pair_id': 'standby0',"
"'netdev': 'hs1',"
"'rombar': 0,"
"'romfile': '',"
"'mac': '"MAC_PRIMARY0"'}");
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
args = qdict_from_jsonf_nofail("{}");
g_assert_nonnull(args);
qdict_put_str(args, "uri", uri);
resp = qtest_qmp(qts, "{ 'execute': 'migrate-incoming', 'arguments': %p}",
args);
g_assert(qdict_haskey(resp, "return"));
qobject_unref(resp);
resp = get_migration_event(qts);
g_assert_cmpstr(qdict_get_str(resp, "status"), ==, "setup");
qobject_unref(resp);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
qtest_qmp_eventwait(qts, "RESUME");
ret = migrate_status(qts);
g_assert_cmpstr(qdict_get_str(ret, "status"), ==, "completed");
qobject_unref(ret);
machine_stop(qts);
}
static void test_guest_off_migrate_out(gconstpointer opaque)
{
QTestState *qts;
QDict *resp, *args, *ret;
g_autofree gchar *uri = g_strdup_printf("exec: cat > %s", (gchar *)opaque);
const gchar *status;
QVirtioPCIDevice *vdev;
uint64_t features;
qts = machine_start(BASE_MACHINE
"-netdev user,id=hs0 "
"-netdev user,id=hs1 ",
2);
check_one_card(qts, false, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
qtest_qmp_device_add(qts, "virtio-net", "standby0",
"{'bus': 'root0',"
"'failover': 'on',"
"'netdev': 'hs0',"
"'mac': '"MAC_STANDBY0"'}");
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
qtest_qmp_device_add(qts, "virtio-net", "primary0",
"{'bus': 'root1',"
"'failover_pair_id': 'standby0',"
"'netdev': 'hs1',"
"'rombar': 0,"
"'romfile': '',"
"'mac': '"MAC_PRIMARY0"'}");
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
features = ~(QVIRTIO_F_BAD_FEATURE |
(1ull << VIRTIO_RING_F_INDIRECT_DESC) |
(1ull << VIRTIO_RING_F_EVENT_IDX) |
(1ull << VIRTIO_NET_F_STANDBY));
vdev = start_virtio_net_internal(qts, 1, 0, &features);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
args = qdict_from_jsonf_nofail("{}");
g_assert_nonnull(args);
qdict_put_str(args, "uri", uri);
resp = qtest_qmp(qts, "{ 'execute': 'migrate', 'arguments': %p}", args);
g_assert(qdict_haskey(resp, "return"));
qobject_unref(resp);
while (true) {
ret = migrate_status(qts);
status = qdict_get_str(ret, "status");
if (strcmp(status, "completed") == 0) {
qobject_unref(ret);
break;
}
g_assert_cmpstr(status, !=, "failed");
g_assert_cmpstr(status, !=, "cancelling");
g_assert_cmpstr(status, !=, "cancelled");
qobject_unref(ret);
}
qtest_qmp_eventwait(qts, "STOP");
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
qos_object_destroy((QOSGraphObject *)vdev);
machine_stop(qts);
}
static void test_guest_off_migrate_in(gconstpointer opaque)
{
QTestState *qts;
QDict *resp, *args, *ret;
g_autofree gchar *uri = g_strdup_printf("exec: cat %s", (gchar *)opaque);
qts = machine_start(BASE_MACHINE
"-netdev user,id=hs0 "
"-netdev user,id=hs1 "
"-incoming defer ",
2);
check_one_card(qts, false, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
qtest_qmp_device_add(qts, "virtio-net", "standby0",
"{'bus': 'root0',"
"'failover': 'on',"
"'netdev': 'hs0',"
"'mac': '"MAC_STANDBY0"'}");
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
qtest_qmp_device_add(qts, "virtio-net", "primary0",
"{'bus': 'root1',"
"'failover_pair_id': 'standby0',"
"'netdev': 'hs1',"
"'rombar': 0,"
"'romfile': '',"
"'mac': '"MAC_PRIMARY0"'}");
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
args = qdict_from_jsonf_nofail("{}");
g_assert_nonnull(args);
qdict_put_str(args, "uri", uri);
resp = qtest_qmp(qts, "{ 'execute': 'migrate-incoming', 'arguments': %p}",
args);
g_assert(qdict_haskey(resp, "return"));
qobject_unref(resp);
resp = get_migration_event(qts);
g_assert_cmpstr(qdict_get_str(resp, "status"), ==, "setup");
qobject_unref(resp);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
qtest_qmp_eventwait(qts, "RESUME");
ret = migrate_status(qts);
g_assert_cmpstr(qdict_get_str(ret, "status"), ==, "completed");
qobject_unref(ret);
machine_stop(qts);
}
static void test_migrate_guest_off_abort(gconstpointer opaque)
{
QTestState *qts;
QDict *resp, *args, *ret;
g_autofree gchar *uri = g_strdup_printf("exec: cat > %s", (gchar *)opaque);
const gchar *status;
QVirtioPCIDevice *vdev;
uint64_t features;
qts = machine_start(BASE_MACHINE
"-netdev user,id=hs0 "
"-netdev user,id=hs1 ",
2);
check_one_card(qts, false, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
qtest_qmp_device_add(qts, "virtio-net", "standby0",
"{'bus': 'root0',"
"'failover': 'on',"
"'netdev': 'hs0',"
"'mac': '"MAC_STANDBY0"'}");
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
qtest_qmp_device_add(qts, "virtio-net", "primary0",
"{'bus': 'root1',"
"'failover_pair_id': 'standby0',"
"'netdev': 'hs1',"
"'rombar': 0,"
"'romfile': '',"
"'mac': '"MAC_PRIMARY0"'}");
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
features = ~(QVIRTIO_F_BAD_FEATURE |
(1ull << VIRTIO_RING_F_INDIRECT_DESC) |
(1ull << VIRTIO_RING_F_EVENT_IDX) |
(1ull << VIRTIO_NET_F_STANDBY));
vdev = start_virtio_net_internal(qts, 1, 0, &features);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
args = qdict_from_jsonf_nofail("{}");
g_assert_nonnull(args);
qdict_put_str(args, "uri", uri);
resp = qtest_qmp(qts, "{ 'execute': 'migrate', 'arguments': %p}", args);
g_assert(qdict_haskey(resp, "return"));
qobject_unref(resp);
while (true) {
ret = migrate_status(qts);
status = qdict_get_str(ret, "status");
if (strcmp(status, "active") == 0) {
qobject_unref(ret);
break;
}
g_assert_cmpstr(status, !=, "failed");
qobject_unref(ret);
}
resp = qtest_qmp(qts, "{ 'execute': 'migrate_cancel' }");
g_assert(qdict_haskey(resp, "return"));
qobject_unref(resp);
while (true) {
ret = migrate_status(qts);
status = qdict_get_str(ret, "status");
if (strcmp(status, "cancelled") == 0) {
qobject_unref(ret);
break;
}
g_assert_cmpstr(status, !=, "failed");
g_assert_cmpstr(status, !=, "active");
qobject_unref(ret);
}
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
qos_object_destroy((QOSGraphObject *)vdev);
machine_stop(qts);
}
static void test_migrate_abort_wait_unplug(gconstpointer opaque)
{
QTestState *qts;
@ -780,7 +1198,7 @@ static void test_migrate_abort_wait_unplug(gconstpointer opaque)
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
vdev = start_virtio_net(qts, 1, 0, "standby0");
vdev = start_virtio_net(qts, 1, 0, "standby0", true);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
@ -870,7 +1288,7 @@ static void test_migrate_abort_active(gconstpointer opaque)
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
vdev = start_virtio_net(qts, 1, 0, "standby0");
vdev = start_virtio_net(qts, 1, 0, "standby0", true);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
@ -938,6 +1356,91 @@ static void test_migrate_abort_active(gconstpointer opaque)
machine_stop(qts);
}
static void test_migrate_off_abort(gconstpointer opaque)
{
QTestState *qts;
QDict *resp, *args, *ret;
g_autofree gchar *uri = g_strdup_printf("exec: cat > %s", (gchar *)opaque);
const gchar *status;
QVirtioPCIDevice *vdev;
qts = machine_start(BASE_MACHINE
"-netdev user,id=hs0 "
"-netdev user,id=hs1 ",
2);
check_one_card(qts, false, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
qtest_qmp_device_add(qts, "virtio-net", "standby0",
"{'bus': 'root0',"
"'failover': 'off',"
"'netdev': 'hs0',"
"'mac': '"MAC_STANDBY0"'}");
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
vdev = start_virtio_net(qts, 1, 0, "standby0", false);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
qtest_qmp_device_add(qts, "virtio-net", "primary0",
"{'bus': 'root1',"
"'failover_pair_id': 'standby0',"
"'netdev': 'hs1',"
"'rombar': 0,"
"'romfile': '',"
"'mac': '"MAC_PRIMARY0"'}");
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
args = qdict_from_jsonf_nofail("{}");
g_assert_nonnull(args);
qdict_put_str(args, "uri", uri);
resp = qtest_qmp(qts, "{ 'execute': 'migrate', 'arguments': %p}", args);
g_assert(qdict_haskey(resp, "return"));
qobject_unref(resp);
while (true) {
ret = migrate_status(qts);
status = qdict_get_str(ret, "status");
if (strcmp(status, "active") == 0) {
qobject_unref(ret);
break;
}
g_assert_cmpstr(status, !=, "failed");
qobject_unref(ret);
}
resp = qtest_qmp(qts, "{ 'execute': 'migrate_cancel' }");
g_assert(qdict_haskey(resp, "return"));
qobject_unref(resp);
while (true) {
ret = migrate_status(qts);
status = qdict_get_str(ret, "status");
if (strcmp(status, "cancelled") == 0) {
qobject_unref(ret);
break;
}
g_assert_cmpstr(status, !=, "failed");
g_assert_cmpstr(status, !=, "active");
qobject_unref(ret);
}
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
qos_object_destroy((QOSGraphObject *)vdev);
machine_stop(qts);
}
static void test_migrate_abort_timeout(gconstpointer opaque)
{
QTestState *qts;
@ -964,7 +1467,7 @@ static void test_migrate_abort_timeout(gconstpointer opaque)
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
vdev = start_virtio_net(qts, 1, 0, "standby0");
vdev = start_virtio_net(qts, 1, 0, "standby0", true);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
@ -1075,7 +1578,7 @@ static void test_multi_out(gconstpointer opaque)
check_one_card(qts, false, "standby1", MAC_STANDBY1);
check_one_card(qts, false, "primary1", MAC_PRIMARY1);
vdev0 = start_virtio_net(qts, 1, 0, "standby0");
vdev0 = start_virtio_net(qts, 1, 0, "standby0", true);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
@ -1106,7 +1609,7 @@ static void test_multi_out(gconstpointer opaque)
check_one_card(qts, true, "standby1", MAC_STANDBY1);
check_one_card(qts, false, "primary1", MAC_PRIMARY1);
vdev1 = start_virtio_net(qts, 3, 0, "standby1");
vdev1 = start_virtio_net(qts, 3, 0, "standby1", true);
check_one_card(qts, true, "standby0", MAC_STANDBY0);
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
@ -1315,6 +1818,7 @@ int main(int argc, char **argv)
g_assert_true(ret >= 0);
close(ret);
/* parameters tests */
qtest_add_func("failover-virtio-net/params/error/id", test_error_id);
qtest_add_func("failover-virtio-net/params/error/pcie", test_error_pcie);
qtest_add_func("failover-virtio-net/params/on", test_on);
@ -1322,16 +1826,33 @@ int main(int argc, char **argv)
test_on_mismatch);
qtest_add_func("failover-virtio-net/params/off", test_off);
qtest_add_func("failover-virtio-net/params/enabled", test_enabled);
qtest_add_func("failover-virtio-net/hotplug_1", test_hotplug_1);
qtest_add_func("failover-virtio-net/hotplug_1_reverse",
qtest_add_func("failover-virtio-net/params/guest_off", test_guest_off);
/* hotplug tests */
qtest_add_func("failover-virtio-net/hotplug/1", test_hotplug_1);
qtest_add_func("failover-virtio-net/hotplug/1_reverse",
test_hotplug_1_reverse);
qtest_add_func("failover-virtio-net/hotplug_2", test_hotplug_2);
qtest_add_func("failover-virtio-net/hotplug_2_reverse",
qtest_add_func("failover-virtio-net/hotplug/2", test_hotplug_2);
qtest_add_func("failover-virtio-net/hotplug/2_reverse",
test_hotplug_2_reverse);
qtest_add_data_func("failover-virtio-net/migrate/out", tmpfile,
/* migration tests */
qtest_add_data_func("failover-virtio-net/migrate/on/out", tmpfile,
test_migrate_out);
qtest_add_data_func("failover-virtio-net/migrate/in", tmpfile,
qtest_add_data_func("failover-virtio-net/migrate/on/in", tmpfile,
test_migrate_in);
qtest_add_data_func("failover-virtio-net/migrate/off/out", tmpfile,
test_off_migrate_out);
qtest_add_data_func("failover-virtio-net/migrate/off/in", tmpfile,
test_off_migrate_in);
qtest_add_data_func("failover-virtio-net/migrate/off/abort", tmpfile,
test_migrate_off_abort);
qtest_add_data_func("failover-virtio-net/migrate/guest_off/out", tmpfile,
test_guest_off_migrate_out);
qtest_add_data_func("failover-virtio-net/migrate/guest_off/in", tmpfile,
test_guest_off_migrate_in);
qtest_add_data_func("failover-virtio-net/migrate/guest_off/abort", tmpfile,
test_migrate_guest_off_abort);
qtest_add_data_func("failover-virtio-net/migrate/abort/wait-unplug",
tmpfile, test_migrate_abort_wait_unplug);
qtest_add_data_func("failover-virtio-net/migrate/abort/active", tmpfile,
@ -1340,9 +1861,9 @@ int main(int argc, char **argv)
qtest_add_data_func("failover-virtio-net/migrate/abort/timeout",
tmpfile, test_migrate_abort_timeout);
}
qtest_add_data_func("failover-virtio-net/multi/out",
qtest_add_data_func("failover-virtio-net/migrate/multi/out",
tmpfile, test_multi_out);
qtest_add_data_func("failover-virtio-net/multi/in",
qtest_add_data_func("failover-virtio-net/migrate/multi/in",
tmpfile, test_multi_in);
ret = g_test_run();