mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 16:53:55 -06:00
tests/qtest/migration: Move bootfile code to its own file
Move the code that creates the guest binary out of migration-test and into the qtest/migration/ directory, along with the rest of the a-b-kernel code. That code is part of the basic infrastructure of migration tests, it shouldn't be among the tests themselves. Also take the chance and rename migration-test.h, which is too generic a name for this header which contains only values related to guest memory offsets. Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Fabiano Rosas <farosas@suse.de>
This commit is contained in:
parent
212c19331b
commit
537f23fb9e
5 changed files with 86 additions and 60 deletions
|
@ -24,7 +24,7 @@
|
|||
#include "ppc-util.h"
|
||||
|
||||
#include "migration-helpers.h"
|
||||
#include "migration/migration-test.h"
|
||||
#include "migration/bootfile.h"
|
||||
#ifdef CONFIG_GNUTLS
|
||||
# include "tests/unit/crypto-tls-psk-helpers.h"
|
||||
# ifdef CONFIG_TASN1
|
||||
|
@ -135,58 +135,6 @@ static bool ufd_version_check(void)
|
|||
static char *tmpfs;
|
||||
static char *bootpath;
|
||||
|
||||
/* The boot file modifies memory area in [start_address, end_address)
|
||||
* repeatedly. It outputs a 'B' at a fixed rate while it's still running.
|
||||
*/
|
||||
#include "migration/i386/a-b-bootblock.h"
|
||||
#include "migration/aarch64/a-b-kernel.h"
|
||||
#include "migration/ppc64/a-b-kernel.h"
|
||||
#include "migration/s390x/a-b-bios.h"
|
||||
|
||||
static void bootfile_delete(void)
|
||||
{
|
||||
if (!bootpath) {
|
||||
return;
|
||||
}
|
||||
unlink(bootpath);
|
||||
g_free(bootpath);
|
||||
bootpath = NULL;
|
||||
}
|
||||
|
||||
static void bootfile_create(char *dir, bool suspend_me)
|
||||
{
|
||||
const char *arch = qtest_get_arch();
|
||||
unsigned char *content;
|
||||
size_t len;
|
||||
|
||||
bootfile_delete();
|
||||
bootpath = g_strdup_printf("%s/bootsect", dir);
|
||||
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
|
||||
/* the assembled x86 boot sector should be exactly one sector large */
|
||||
g_assert(sizeof(x86_bootsect) == 512);
|
||||
x86_bootsect[SYM_suspend_me - SYM_start] = suspend_me;
|
||||
content = x86_bootsect;
|
||||
len = sizeof(x86_bootsect);
|
||||
} else if (g_str_equal(arch, "s390x")) {
|
||||
content = s390x_elf;
|
||||
len = sizeof(s390x_elf);
|
||||
} else if (strcmp(arch, "ppc64") == 0) {
|
||||
content = ppc64_kernel;
|
||||
len = sizeof(ppc64_kernel);
|
||||
} else if (strcmp(arch, "aarch64") == 0) {
|
||||
content = aarch64_kernel;
|
||||
len = sizeof(aarch64_kernel);
|
||||
g_assert(sizeof(aarch64_kernel) <= ARM_TEST_MAX_KERNEL_SIZE);
|
||||
} else {
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
FILE *bootfile = fopen(bootpath, "wb");
|
||||
|
||||
g_assert_cmpint(fwrite(content, len, 1, bootfile), ==, 1);
|
||||
fclose(bootfile);
|
||||
}
|
||||
|
||||
/*
|
||||
* Wait for some output in the serial output file,
|
||||
* we get an 'A' followed by an endless string of 'B's
|
||||
|
@ -737,7 +685,7 @@ static int migrate_start(QTestState **from, QTestState **to,
|
|||
|
||||
dst_state = (QTestMigrationState) { };
|
||||
src_state = (QTestMigrationState) { };
|
||||
bootfile_create(tmpfs, args->suspend_me);
|
||||
bootpath = bootfile_create(arch, tmpfs, args->suspend_me);
|
||||
src_state.suspend_me = args->suspend_me;
|
||||
|
||||
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
|
||||
|
@ -3488,7 +3436,7 @@ static QTestState *dirtylimit_start_vm(void)
|
|||
QTestState *vm = NULL;
|
||||
g_autofree gchar *cmd = NULL;
|
||||
|
||||
bootfile_create(tmpfs, false);
|
||||
bootpath = bootfile_create(qtest_get_arch(), tmpfs, false);
|
||||
cmd = g_strdup_printf("-accel kvm,dirty-ring-size=4096 "
|
||||
"-name dirtylimit-test,debug-threads=on "
|
||||
"-m 150M -smp 1 "
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue