xref: /openbmc/qemu/tests/qtest/virtio-ccw-test.c (revision 1e8a1fae)
1*1e8a1faeSThomas Huth /*
2*1e8a1faeSThomas Huth  * QTest testcase for VirtIO CCW
3*1e8a1faeSThomas Huth  *
4*1e8a1faeSThomas Huth  * Copyright (c) 2014 SUSE LINUX Products GmbH
5*1e8a1faeSThomas Huth  * Copyright (c) 2018 Red Hat, Inc.
6*1e8a1faeSThomas Huth  *
7*1e8a1faeSThomas Huth  * This work is licensed under the terms of the GNU GPL, version 2 or later.
8*1e8a1faeSThomas Huth  * See the COPYING file in the top-level directory.
9*1e8a1faeSThomas Huth  */
10*1e8a1faeSThomas Huth 
11*1e8a1faeSThomas Huth /* Until we have a full libqos implementation of virtio-ccw (which requires
12*1e8a1faeSThomas Huth  * also to add support for I/O channels to qtest), we can only do simple
13*1e8a1faeSThomas Huth  * tests that initialize the devices.
14*1e8a1faeSThomas Huth  */
15*1e8a1faeSThomas Huth 
16*1e8a1faeSThomas Huth #include "qemu/osdep.h"
17*1e8a1faeSThomas Huth #include "libqtest-single.h"
18*1e8a1faeSThomas Huth #include "libqos/virtio.h"
19*1e8a1faeSThomas Huth 
20*1e8a1faeSThomas Huth static void virtio_balloon_nop(void)
21*1e8a1faeSThomas Huth {
22*1e8a1faeSThomas Huth     global_qtest = qtest_initf("-device virtio-balloon-ccw");
23*1e8a1faeSThomas Huth     qtest_end();
24*1e8a1faeSThomas Huth }
25*1e8a1faeSThomas Huth 
26*1e8a1faeSThomas Huth static void virtconsole_nop(void)
27*1e8a1faeSThomas Huth {
28*1e8a1faeSThomas Huth     global_qtest = qtest_initf("-device virtio-serial-ccw,id=vser0 "
29*1e8a1faeSThomas Huth                                 "-device virtconsole,bus=vser0.0");
30*1e8a1faeSThomas Huth     qtest_end();
31*1e8a1faeSThomas Huth }
32*1e8a1faeSThomas Huth 
33*1e8a1faeSThomas Huth static void virtserialport_nop(void)
34*1e8a1faeSThomas Huth {
35*1e8a1faeSThomas Huth     global_qtest = qtest_initf("-device virtio-serial-ccw,id=vser0 "
36*1e8a1faeSThomas Huth                                 "-device virtserialport,bus=vser0.0");
37*1e8a1faeSThomas Huth     qtest_end();
38*1e8a1faeSThomas Huth }
39*1e8a1faeSThomas Huth 
40*1e8a1faeSThomas Huth static void virtio_serial_nop(void)
41*1e8a1faeSThomas Huth {
42*1e8a1faeSThomas Huth     global_qtest = qtest_initf("-device virtio-serial-ccw");
43*1e8a1faeSThomas Huth     qtest_end();
44*1e8a1faeSThomas Huth }
45*1e8a1faeSThomas Huth 
46*1e8a1faeSThomas Huth static void virtio_serial_hotplug(void)
47*1e8a1faeSThomas Huth {
48*1e8a1faeSThomas Huth     QTestState *qts = qtest_initf("-device virtio-serial-ccw");
49*1e8a1faeSThomas Huth 
50*1e8a1faeSThomas Huth     qtest_qmp_device_add(qts, "virtserialport", "hp-port", "{}");
51*1e8a1faeSThomas Huth     qtest_qmp_device_del(qts, "hp-port");
52*1e8a1faeSThomas Huth 
53*1e8a1faeSThomas Huth     qtest_quit(qts);
54*1e8a1faeSThomas Huth }
55*1e8a1faeSThomas Huth 
56*1e8a1faeSThomas Huth static void virtio_blk_nop(void)
57*1e8a1faeSThomas Huth {
58*1e8a1faeSThomas Huth     global_qtest = qtest_initf("-drive if=none,id=drv0,file=null-co://,"
59*1e8a1faeSThomas Huth                                "file.read-zeroes=on,format=raw "
60*1e8a1faeSThomas Huth                                 "-device virtio-blk-ccw,drive=drv0");
61*1e8a1faeSThomas Huth     qtest_end();
62*1e8a1faeSThomas Huth }
63*1e8a1faeSThomas Huth 
64*1e8a1faeSThomas Huth static void virtio_net_nop(void)
65*1e8a1faeSThomas Huth {
66*1e8a1faeSThomas Huth     global_qtest = qtest_initf("-device virtio-net-ccw");
67*1e8a1faeSThomas Huth     qtest_end();
68*1e8a1faeSThomas Huth }
69*1e8a1faeSThomas Huth 
70*1e8a1faeSThomas Huth static void virtio_rng_nop(void)
71*1e8a1faeSThomas Huth {
72*1e8a1faeSThomas Huth     global_qtest = qtest_initf("-device virtio-rng-ccw");
73*1e8a1faeSThomas Huth     qtest_end();
74*1e8a1faeSThomas Huth }
75*1e8a1faeSThomas Huth 
76*1e8a1faeSThomas Huth static void virtio_scsi_nop(void)
77*1e8a1faeSThomas Huth {
78*1e8a1faeSThomas Huth     global_qtest = qtest_initf("-device virtio-scsi-ccw");
79*1e8a1faeSThomas Huth     qtest_end();
80*1e8a1faeSThomas Huth }
81*1e8a1faeSThomas Huth 
82*1e8a1faeSThomas Huth static void virtio_scsi_hotplug(void)
83*1e8a1faeSThomas Huth {
84*1e8a1faeSThomas Huth     QTestState *s = qtest_initf("-drive if=none,id=drv0,file=null-co://,"
85*1e8a1faeSThomas Huth                                 "file.read-zeroes=on,format=raw "
86*1e8a1faeSThomas Huth                                 "-drive if=none,id=drv1,file=null-co://,"
87*1e8a1faeSThomas Huth                                 "file.read-zeroes=on,format=raw "
88*1e8a1faeSThomas Huth                                 "-device virtio-scsi-ccw "
89*1e8a1faeSThomas Huth                                 "-device scsi-hd,drive=drv0");
90*1e8a1faeSThomas Huth     qtest_qmp_device_add(s, "scsi-hd", "scsihd", "{'drive': 'drv1'}");
91*1e8a1faeSThomas Huth     qtest_qmp_device_del(s, "scsihd");
92*1e8a1faeSThomas Huth 
93*1e8a1faeSThomas Huth     qtest_quit(s);
94*1e8a1faeSThomas Huth }
95*1e8a1faeSThomas Huth 
96*1e8a1faeSThomas Huth int main(int argc, char **argv)
97*1e8a1faeSThomas Huth {
98*1e8a1faeSThomas Huth     int ret;
99*1e8a1faeSThomas Huth 
100*1e8a1faeSThomas Huth     g_test_init(&argc, &argv, NULL);
101*1e8a1faeSThomas Huth     qtest_add_func("/virtio/balloon/nop", virtio_balloon_nop);
102*1e8a1faeSThomas Huth     qtest_add_func("/virtio/console/nop", virtconsole_nop);
103*1e8a1faeSThomas Huth     qtest_add_func("/virtio/serialport/nop", virtserialport_nop);
104*1e8a1faeSThomas Huth     qtest_add_func("/virtio/serial/nop", virtio_serial_nop);
105*1e8a1faeSThomas Huth     qtest_add_func("/virtio/serial/hotplug", virtio_serial_hotplug);
106*1e8a1faeSThomas Huth     qtest_add_func("/virtio/block/nop", virtio_blk_nop);
107*1e8a1faeSThomas Huth     qtest_add_func("/virtio/net/nop", virtio_net_nop);
108*1e8a1faeSThomas Huth     qtest_add_func("/virtio/rng/nop", virtio_rng_nop);
109*1e8a1faeSThomas Huth     qtest_add_func("/virtio/scsi/nop", virtio_scsi_nop);
110*1e8a1faeSThomas Huth     qtest_add_func("/virtio/scsi/hotplug", virtio_scsi_hotplug);
111*1e8a1faeSThomas Huth 
112*1e8a1faeSThomas Huth     ret = g_test_run();
113*1e8a1faeSThomas Huth 
114*1e8a1faeSThomas Huth     return ret;
115*1e8a1faeSThomas Huth }
116