4 * Copyright (c) 2016 Red Hat Inc.
7 * Michael S. Tsirkin <mst@redhat.com>,
8 * Victor Kaplansky <victork@redhat.com>
10 * This work is licensed under the terms of the GNU GPL, version 2 or later.
11 * See the COPYING file in the top-level directory.
14 #include "qemu/osdep.h"
15 #include <glib/gstdio.h>
16 #include "qemu-common.h"
18 #include "boot-sector.h"
20 #define NETNAME "net0"
22 static char disk
[] = "tests/pxe-test-disk-XXXXXX";
24 static void test_pxe_one(const char *params
, bool ipv6
)
28 args
= g_strdup_printf("-machine accel=kvm:tcg -nodefaults -boot order=n "
29 "-netdev user,id=" NETNAME
",tftp=./,bootfile=%s,"
30 "ipv4=%s,ipv6=%s %s", disk
, ipv6
? "off" : "on",
31 ipv6
? "on" : "off", params
);
35 qtest_quit(global_qtest
);
39 static void test_pxe_e1000(void)
41 test_pxe_one("-device e1000,netdev=" NETNAME
, false);
44 static void test_pxe_virtio_pci(void)
46 test_pxe_one("-device virtio-net-pci,netdev=" NETNAME
, false);
49 static void test_pxe_spapr_vlan(void)
51 test_pxe_one("-device spapr-vlan,netdev=" NETNAME
, true);
54 static void test_pxe_virtio_ccw(void)
56 test_pxe_one("-device virtio-net-ccw,bootindex=1,netdev=" NETNAME
, false);
59 int main(int argc
, char *argv
[])
62 const char *arch
= qtest_get_arch();
64 ret
= boot_sector_init(disk
);
68 g_test_init(&argc
, &argv
, NULL
);
70 if (strcmp(arch
, "i386") == 0 || strcmp(arch
, "x86_64") == 0) {
71 qtest_add_func("pxe/e1000", test_pxe_e1000
);
72 qtest_add_func("pxe/virtio", test_pxe_virtio_pci
);
73 } else if (strcmp(arch
, "ppc64") == 0) {
74 qtest_add_func("pxe/virtio", test_pxe_virtio_pci
);
75 qtest_add_func("pxe/spapr-vlan", test_pxe_spapr_vlan
);
76 } else if (g_str_equal(arch
, "s390x")) {
77 qtest_add_func("pxe/virtio-ccw", test_pxe_virtio_ccw
);
80 boot_sector_cleanup(disk
);