
* Update to QEMU v9.0.0 --------- Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Fabiano Rosas <farosas@suse.de> Signed-off-by: Peter Xu <peterx@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Cédric Le Goater <clg@redhat.com> Signed-off-by: Zheyu Ma <zheyuma97@gmail.com> Signed-off-by: Ido Plat <ido.plat@ibm.com> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Signed-off-by: David Hildenbrand <david@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com> Signed-off-by: Gregory Price <gregory.price@memverge.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Lorenz Brun <lorenz@brun.one> Signed-off-by: Yao Xingtao <yaoxt.fnst@fujitsu.com> Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Signed-off-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Sven Schnelle <svens@stackframe.org> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com> Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Benjamin Gray <bgray@linux.ibm.com> Signed-off-by: Avihai Horon <avihaih@nvidia.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Joonas Kankaala <joonas.a.kankaala@gmail.com> Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Glenn Miles <milesg@linux.ibm.com> Signed-off-by: Oleg Sviridov <oleg.sviridov@red-soft.ru> Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru> Signed-off-by: Yajun Wu <yajunw@nvidia.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Signed-off-by: Pierre-Clément Tosi <ptosi@google.com> Signed-off-by: Lei Wang <lei4.wang@intel.com> Signed-off-by: Wei Wang <wei.w.wang@intel.com> Signed-off-by: Martin Hundebøll <martin@geanix.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Signed-off-by: Wafer <wafer@jaguarmicro.com> Signed-off-by: Yuxue Liu <yuxue.liu@jaguarmicro.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Nguyen Dinh Phi <phind.uet@gmail.com> Signed-off-by: Zack Buhman <zack@buhman.org> Signed-off-by: Keith Packard <keithp@keithp.com> Signed-off-by: Yuquan Wang wangyuquan1236@phytium.com.cn Signed-off-by: Matheus Tavares Bernardino <quic_mathbern@quicinc.com> Signed-off-by: Cindy Lu <lulu@redhat.com> Co-authored-by: Peter Maydell <peter.maydell@linaro.org> Co-authored-by: Fabiano Rosas <farosas@suse.de> Co-authored-by: Peter Xu <peterx@redhat.com> Co-authored-by: Thomas Huth <thuth@redhat.com> Co-authored-by: Cédric Le Goater <clg@redhat.com> Co-authored-by: Zheyu Ma <zheyuma97@gmail.com> Co-authored-by: Ido Plat <ido.plat@ibm.com> Co-authored-by: Ilya Leoshkevich <iii@linux.ibm.com> Co-authored-by: Markus Armbruster <armbru@redhat.com> Co-authored-by: Marc-André Lureau <marcandre.lureau@redhat.com> Co-authored-by: Paolo Bonzini <pbonzini@redhat.com> Co-authored-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Co-authored-by: David Hildenbrand <david@redhat.com> Co-authored-by: Kevin Wolf <kwolf@redhat.com> Co-authored-by: Stefan Reiter <s.reiter@proxmox.com> Co-authored-by: Fiona Ebner <f.ebner@proxmox.com> Co-authored-by: Gregory Price <gregory.price@memverge.com> Co-authored-by: Lorenz Brun <lorenz@brun.one> Co-authored-by: Yao Xingtao <yaoxt.fnst@fujitsu.com> Co-authored-by: Philippe Mathieu-Daudé <philmd@linaro.org> Co-authored-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> Co-authored-by: BALATON Zoltan <balaton@eik.bme.hu> Co-authored-by: Igor Mammedov <imammedo@redhat.com> Co-authored-by: Akihiko Odaki <akihiko.odaki@daynix.com> Co-authored-by: Richard Henderson <richard.henderson@linaro.org> Co-authored-by: Sven Schnelle <svens@stackframe.org> Co-authored-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Co-authored-by: Helge Deller <deller@kernel.org> Co-authored-by: Harsh Prateek Bora <harshpb@linux.ibm.com> Co-authored-by: Benjamin Gray <bgray@linux.ibm.com> Co-authored-by: Nicholas Piggin <npiggin@gmail.com> Co-authored-by: Avihai Horon <avihaih@nvidia.com> Co-authored-by: Michael Tokarev <mjt@tls.msk.ru> Co-authored-by: Joonas Kankaala <joonas.a.kankaala@gmail.com> Co-authored-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> Co-authored-by: Stefan Weil <sw@weilnetz.de> Co-authored-by: Dayu Liu <liu.dayu@zte.com.cn> Co-authored-by: Zhao Liu <zhao1.liu@intel.com> Co-authored-by: Glenn Miles <milesg@linux.vnet.ibm.com> Co-authored-by: Artem Chernyshev <artem.chernyshev@red-soft.ru> Co-authored-by: Yajun Wu <yajunw@nvidia.com> Co-authored-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Co-authored-by: Pierre-Clément Tosi <ptosi@google.com> Co-authored-by: Wei Wang <wei.w.wang@intel.com> Co-authored-by: Martin Hundebøll <martin@geanix.com> Co-authored-by: Michael S. Tsirkin <mst@redhat.com> Co-authored-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Co-authored-by: Wafer <wafer@jaguarmicro.com> Co-authored-by: lyx634449800 <yuxue.liu@jaguarmicro.com> Co-authored-by: Gerd Hoffmann <kraxel@redhat.com> Co-authored-by: Nguyen Dinh Phi <phind.uet@gmail.com> Co-authored-by: Zack Buhman <zack@buhman.org> Co-authored-by: Keith Packard <keithp@keithp.com> Co-authored-by: Yuquan Wang <wangyuquan1236@phytium.com.cn> Co-authored-by: Matheus Tavares Bernardino <quic_mathbern@quicinc.com> Co-authored-by: Cindy Lu <lulu@redhat.com>
290 lines
9.3 KiB
C
290 lines
9.3 KiB
C
/*
|
|
* Various tests for emulated CD-ROM drives.
|
|
*
|
|
* Copyright (c) 2018 Red Hat Inc.
|
|
*
|
|
* Author:
|
|
* Thomas Huth <thuth@redhat.com>
|
|
*
|
|
* This work is licensed under the terms of the GNU GPL, version 2
|
|
* or later. See the COPYING file in the top-level directory.
|
|
*/
|
|
|
|
#include "qemu/osdep.h"
|
|
#include "libqtest.h"
|
|
#include "boot-sector.h"
|
|
#include "qapi/qmp/qdict.h"
|
|
|
|
static char isoimage[] = "cdrom-boot-iso-XXXXXX";
|
|
|
|
static int exec_xorrisofs(const char **args)
|
|
{
|
|
gchar *out_err = NULL;
|
|
gint exit_status = -1;
|
|
bool success;
|
|
|
|
success = g_spawn_sync(NULL, (gchar **)args, NULL,
|
|
G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL,
|
|
NULL, NULL, NULL, &out_err, &exit_status, NULL);
|
|
if (!success) {
|
|
return -ENOENT;
|
|
}
|
|
if (out_err) {
|
|
fputs(out_err, stderr);
|
|
g_free(out_err);
|
|
}
|
|
|
|
return exit_status;
|
|
}
|
|
|
|
static int prepare_image(const char *arch, char *isoimagepath)
|
|
{
|
|
char srcdir[] = "cdrom-test-dir-XXXXXX";
|
|
char *codefile = NULL;
|
|
int ifh, ret = -1;
|
|
const char *args[] = {
|
|
"xorrisofs", "-quiet", "-l", "-no-emul-boot",
|
|
"-b", NULL, "-o", isoimagepath, srcdir, NULL
|
|
};
|
|
|
|
ifh = mkstemp(isoimagepath);
|
|
if (ifh < 0) {
|
|
perror("Error creating temporary iso image file");
|
|
return -1;
|
|
}
|
|
if (!g_mkdtemp(srcdir)) {
|
|
perror("Error creating temporary directory");
|
|
goto cleanup;
|
|
}
|
|
|
|
if (g_str_equal(arch, "i386") || g_str_equal(arch, "x86_64") ||
|
|
g_str_equal(arch, "s390x")) {
|
|
codefile = g_strdup_printf("%s/bootcode-XXXXXX", srcdir);
|
|
ret = boot_sector_init(codefile);
|
|
if (ret) {
|
|
goto cleanup;
|
|
}
|
|
} else {
|
|
/* Just create a dummy file */
|
|
char txt[] = "empty disc";
|
|
codefile = g_strdup_printf("%s/readme.txt", srcdir);
|
|
if (!g_file_set_contents(codefile, txt, sizeof(txt) - 1, NULL)) {
|
|
fprintf(stderr, "Failed to create '%s'\n", codefile);
|
|
goto cleanup;
|
|
}
|
|
}
|
|
|
|
args[5] = strchr(codefile, '/') + 1;
|
|
ret = exec_xorrisofs(args);
|
|
if (ret) {
|
|
fprintf(stderr, "xorrisofs failed: %i\n", ret);
|
|
}
|
|
|
|
unlink(codefile);
|
|
|
|
cleanup:
|
|
g_free(codefile);
|
|
rmdir(srcdir);
|
|
close(ifh);
|
|
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* Check that at least the -cdrom parameter is basically working, i.e. we can
|
|
* see the filename of the ISO image in the output of "info block" afterwards
|
|
*/
|
|
static void test_cdrom_param(gconstpointer data)
|
|
{
|
|
QTestState *qts;
|
|
char *resp;
|
|
|
|
qts = qtest_initf("-M %s -cdrom %s", (const char *)data, isoimage);
|
|
resp = qtest_hmp(qts, "info block");
|
|
g_assert(strstr(resp, isoimage) != 0);
|
|
g_free(resp);
|
|
qtest_quit(qts);
|
|
}
|
|
|
|
static void add_cdrom_param_tests(const char **machines)
|
|
{
|
|
while (*machines) {
|
|
if (qtest_has_machine(*machines)) {
|
|
char *testname = g_strdup_printf("cdrom/param/%s", *machines);
|
|
qtest_add_data_func(testname, *machines, test_cdrom_param);
|
|
g_free(testname);
|
|
}
|
|
machines++;
|
|
}
|
|
}
|
|
|
|
static void test_cdboot(gconstpointer data)
|
|
{
|
|
QTestState *qts;
|
|
|
|
qts = qtest_initf("-accel kvm -accel tcg -no-shutdown %s%s", (const char *)data,
|
|
isoimage);
|
|
boot_sector_test(qts);
|
|
qtest_quit(qts);
|
|
}
|
|
|
|
static void add_x86_tests(void)
|
|
{
|
|
if (!qtest_has_accel("tcg") && !qtest_has_accel("kvm")) {
|
|
g_test_skip("No KVM or TCG accelerator available, skipping boot tests");
|
|
return;
|
|
}
|
|
|
|
qtest_add_data_func("cdrom/boot/default", "-cdrom ", test_cdboot);
|
|
if (qtest_has_device("virtio-scsi-ccw")) {
|
|
qtest_add_data_func("cdrom/boot/virtio-scsi",
|
|
"-device virtio-scsi -device scsi-cd,drive=cdr "
|
|
"-blockdev file,node-name=cdr,filename=",
|
|
test_cdboot);
|
|
}
|
|
/*
|
|
* Unstable CI test under load
|
|
* See https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg05509.html
|
|
*/
|
|
if (g_test_slow() && qtest_has_machine("isapc")) {
|
|
qtest_add_data_func("cdrom/boot/isapc", "-M isapc "
|
|
"-drive if=ide,media=cdrom,file=", test_cdboot);
|
|
}
|
|
if (qtest_has_device("am53c974")) {
|
|
qtest_add_data_func("cdrom/boot/am53c974",
|
|
"-device am53c974 -device scsi-cd,drive=cd1 "
|
|
"-drive if=none,id=cd1,format=raw,file=",
|
|
test_cdboot);
|
|
}
|
|
if (qtest_has_device("dc390")) {
|
|
qtest_add_data_func("cdrom/boot/dc390",
|
|
"-device dc390 -device scsi-cd,drive=cd1 "
|
|
"-blockdev file,node-name=cd1,filename=",
|
|
test_cdboot);
|
|
}
|
|
if (qtest_has_device("lsi53c895a")) {
|
|
qtest_add_data_func("cdrom/boot/lsi53c895a",
|
|
"-device lsi53c895a -device scsi-cd,drive=cd1 "
|
|
"-blockdev file,node-name=cd1,filename=",
|
|
test_cdboot);
|
|
}
|
|
if (qtest_has_device("megasas")) {
|
|
qtest_add_data_func("cdrom/boot/megasas", "-M q35 "
|
|
"-device megasas -device scsi-cd,drive=cd1 "
|
|
"-blockdev file,node-name=cd1,filename=",
|
|
test_cdboot);
|
|
}
|
|
if (qtest_has_device("megasas-gen2")) {
|
|
qtest_add_data_func("cdrom/boot/megasas-gen2", "-M q35 "
|
|
"-device megasas-gen2 -device scsi-cd,drive=cd1 "
|
|
"-blockdev file,node-name=cd1,filename=",
|
|
test_cdboot);
|
|
}
|
|
}
|
|
|
|
static void add_s390x_tests(void)
|
|
{
|
|
if (!qtest_has_accel("tcg") && !qtest_has_accel("kvm")) {
|
|
g_test_skip("No KVM or TCG accelerator available, skipping boot tests");
|
|
}
|
|
if (!qtest_has_device("virtio-blk-ccw")) {
|
|
return;
|
|
}
|
|
|
|
qtest_add_data_func("cdrom/boot/default", "-cdrom ", test_cdboot);
|
|
|
|
if (!qtest_has_device("virtio-scsi-ccw")) {
|
|
return;
|
|
}
|
|
|
|
qtest_add_data_func("cdrom/boot/virtio-scsi",
|
|
"-device virtio-scsi -device scsi-cd,drive=cdr "
|
|
"-blockdev file,node-name=cdr,filename=", test_cdboot);
|
|
qtest_add_data_func("cdrom/boot/with-bootindex",
|
|
"-device virtio-serial -device virtio-scsi "
|
|
"-device virtio-blk,drive=d1 "
|
|
"-drive driver=null-co,read-zeroes=on,if=none,id=d1 "
|
|
"-device virtio-blk,drive=d2,bootindex=1 "
|
|
"-drive if=none,id=d2,media=cdrom,file=", test_cdboot);
|
|
if (qtest_has_device("x-terminal3270")) {
|
|
qtest_add_data_func("cdrom/boot/without-bootindex",
|
|
"-device virtio-scsi -device virtio-serial "
|
|
"-device x-terminal3270 -device virtio-blk,drive=d1 "
|
|
"-drive driver=null-co,read-zeroes=on,if=none,id=d1 "
|
|
"-device virtio-blk,drive=d2 "
|
|
"-drive if=none,id=d2,media=cdrom,file=",
|
|
test_cdboot);
|
|
}
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
int ret;
|
|
const char *arch = qtest_get_arch();
|
|
const char *xorrisocheck[] = { "xorrisofs", "-version", NULL };
|
|
|
|
g_test_init(&argc, &argv, NULL);
|
|
|
|
if (exec_xorrisofs(xorrisocheck)) {
|
|
/* xorrisofs not available - so can't run tests */
|
|
return g_test_run();
|
|
}
|
|
|
|
ret = prepare_image(arch, isoimage);
|
|
if (ret) {
|
|
return ret;
|
|
}
|
|
|
|
if (g_str_equal(arch, "i386") || g_str_equal(arch, "x86_64")) {
|
|
add_x86_tests();
|
|
} else if (g_str_equal(arch, "s390x")) {
|
|
add_s390x_tests();
|
|
} else if (g_str_equal(arch, "ppc64")) {
|
|
const char *ppcmachines[] = {
|
|
"pseries", "mac99", "g3beige", "40p", NULL
|
|
};
|
|
add_cdrom_param_tests(ppcmachines);
|
|
} else if (g_str_equal(arch, "sparc")) {
|
|
const char *sparcmachines[] = {
|
|
"LX", "SPARCClassic", "SPARCbook", "SS-10", "SS-20", "SS-4",
|
|
"SS-5", "SS-600MP", "Voyager", "leon3_generic", NULL
|
|
};
|
|
add_cdrom_param_tests(sparcmachines);
|
|
} else if (g_str_equal(arch, "sparc64")) {
|
|
const char *sparc64machines[] = {
|
|
"niagara", "sun4u", "sun4v", NULL
|
|
};
|
|
add_cdrom_param_tests(sparc64machines);
|
|
} else if (!strncmp(arch, "mips64", 6)) {
|
|
const char *mips64machines[] = {
|
|
"magnum", "malta", "pica61", NULL
|
|
};
|
|
add_cdrom_param_tests(mips64machines);
|
|
} else if (g_str_equal(arch, "arm") || g_str_equal(arch, "aarch64")) {
|
|
const char *armmachines[] = {
|
|
"realview-eb", "realview-eb-mpcore", "realview-pb-a8",
|
|
"realview-pbx-a9", "versatileab", "versatilepb", "vexpress-a15",
|
|
"vexpress-a9", NULL
|
|
};
|
|
add_cdrom_param_tests(armmachines);
|
|
if (qtest_has_device("virtio-blk-pci")) {
|
|
const char *virtmachine[] = { "virt", NULL };
|
|
add_cdrom_param_tests(virtmachine);
|
|
}
|
|
} else if (g_str_equal(arch, "loongarch64")) {
|
|
if (qtest_has_device("virtio-blk-pci")) {
|
|
const char *virtmachine[] = { "virt", NULL };
|
|
add_cdrom_param_tests(virtmachine);
|
|
}
|
|
} else {
|
|
const char *nonemachine[] = { "none", NULL };
|
|
add_cdrom_param_tests(nonemachine);
|
|
}
|
|
|
|
ret = g_test_run();
|
|
|
|
unlink(isoimage);
|
|
|
|
return ret;
|
|
}
|