4 * Copyright (c) 2016, 2017 Red Hat Inc.
7 * Michael S. Tsirkin <mst@redhat.com>,
8 * Victor Kaplansky <victork@redhat.com>
9 * Thomas Huth <thuth@redhat.com>
11 * This work is licensed under the terms of the GNU GPL, version 2 or later.
12 * See the COPYING file in the top-level directory.
15 #include "qemu/osdep.h"
16 #include <glib/gstdio.h>
17 #include "qemu-common.h"
19 #include "boot-sector.h"
21 #define NETNAME "net0"
23 static char disk
[] = "tests/pxe-test-disk-XXXXXX";
25 static void test_pxe_one(const char *params
, bool ipv6
)
29 args
= g_strdup_printf("-machine accel=kvm:tcg -nodefaults -boot order=n "
30 "-netdev user,id=" NETNAME
",tftp=./,bootfile=%s,"
31 "ipv4=%s,ipv6=%s %s", disk
, ipv6
? "off" : "on",
32 ipv6
? "on" : "off", params
);
36 qtest_quit(global_qtest
);
40 static void test_pxe_ipv4(gconstpointer data
)
42 const char *model
= data
;
45 dev_arg
= g_strdup_printf("-device %s,netdev=" NETNAME
, model
);
46 test_pxe_one(dev_arg
, false);
50 static void test_pxe_spapr_vlan(void)
52 test_pxe_one("-device spapr-vlan,netdev=" NETNAME
, true);
55 static void test_pxe_virtio_ccw(void)
57 test_pxe_one("-device virtio-net-ccw,bootindex=1,netdev=" NETNAME
, false);
60 int main(int argc
, char *argv
[])
63 const char *arch
= qtest_get_arch();
65 ret
= boot_sector_init(disk
);
69 g_test_init(&argc
, &argv
, NULL
);
71 if (strcmp(arch
, "i386") == 0 || strcmp(arch
, "x86_64") == 0) {
72 qtest_add_data_func("pxe/e1000", "e1000", test_pxe_ipv4
);
73 qtest_add_data_func("pxe/virtio", "virtio-net-pci", test_pxe_ipv4
);
75 qtest_add_data_func("pxe/ne2000", "ne2k_pci", test_pxe_ipv4
);
76 qtest_add_data_func("pxe/eepro100", "i82550", test_pxe_ipv4
);
77 qtest_add_data_func("pxe/pcnet", "pcnet", test_pxe_ipv4
);
78 qtest_add_data_func("pxe/rtl8139", "rtl8139", test_pxe_ipv4
);
79 qtest_add_data_func("pxe/vmxnet3", "vmxnet3", test_pxe_ipv4
);
81 } else if (strcmp(arch
, "ppc64") == 0) {
82 qtest_add_func("pxe/spapr-vlan", test_pxe_spapr_vlan
);
84 qtest_add_data_func("pxe/virtio", "virtio-net-pci", test_pxe_ipv4
);
85 qtest_add_data_func("pxe/e1000", "e1000", test_pxe_ipv4
);
87 } else if (g_str_equal(arch
, "s390x")) {
88 qtest_add_func("pxe/virtio-ccw", test_pxe_virtio_ccw
);
91 boot_sector_cleanup(disk
);