xref: /openbmc/qemu/tests/qtest/virtio-ccw-test.c (revision 66997c42)
11e8a1faeSThomas Huth /*
21e8a1faeSThomas Huth  * QTest testcase for VirtIO CCW
31e8a1faeSThomas Huth  *
41e8a1faeSThomas Huth  * Copyright (c) 2014 SUSE LINUX Products GmbH
51e8a1faeSThomas Huth  * Copyright (c) 2018 Red Hat, Inc.
61e8a1faeSThomas Huth  *
71e8a1faeSThomas Huth  * This work is licensed under the terms of the GNU GPL, version 2 or later.
81e8a1faeSThomas Huth  * See the COPYING file in the top-level directory.
91e8a1faeSThomas Huth  */
101e8a1faeSThomas Huth 
111e8a1faeSThomas Huth /* Until we have a full libqos implementation of virtio-ccw (which requires
121e8a1faeSThomas Huth  * also to add support for I/O channels to qtest), we can only do simple
131e8a1faeSThomas Huth  * tests that initialize the devices.
141e8a1faeSThomas Huth  */
151e8a1faeSThomas Huth 
161e8a1faeSThomas Huth #include "qemu/osdep.h"
171e8a1faeSThomas Huth #include "libqtest-single.h"
181e8a1faeSThomas Huth #include "libqos/virtio.h"
191e8a1faeSThomas Huth 
201e8a1faeSThomas Huth static void virtio_balloon_nop(void)
211e8a1faeSThomas Huth {
221e8a1faeSThomas Huth     global_qtest = qtest_initf("-device virtio-balloon-ccw");
231e8a1faeSThomas Huth     qtest_end();
241e8a1faeSThomas Huth }
251e8a1faeSThomas Huth 
261e8a1faeSThomas Huth static void virtconsole_nop(void)
271e8a1faeSThomas Huth {
281e8a1faeSThomas Huth     global_qtest = qtest_initf("-device virtio-serial-ccw,id=vser0 "
291e8a1faeSThomas Huth                                 "-device virtconsole,bus=vser0.0");
301e8a1faeSThomas Huth     qtest_end();
311e8a1faeSThomas Huth }
321e8a1faeSThomas Huth 
331e8a1faeSThomas Huth static void virtserialport_nop(void)
341e8a1faeSThomas Huth {
351e8a1faeSThomas Huth     global_qtest = qtest_initf("-device virtio-serial-ccw,id=vser0 "
361e8a1faeSThomas Huth                                 "-device virtserialport,bus=vser0.0");
371e8a1faeSThomas Huth     qtest_end();
381e8a1faeSThomas Huth }
391e8a1faeSThomas Huth 
401e8a1faeSThomas Huth static void virtio_serial_nop(void)
411e8a1faeSThomas Huth {
421e8a1faeSThomas Huth     global_qtest = qtest_initf("-device virtio-serial-ccw");
431e8a1faeSThomas Huth     qtest_end();
441e8a1faeSThomas Huth }
451e8a1faeSThomas Huth 
461e8a1faeSThomas Huth static void virtio_serial_hotplug(void)
471e8a1faeSThomas Huth {
481e8a1faeSThomas Huth     QTestState *qts = qtest_initf("-device virtio-serial-ccw");
491e8a1faeSThomas Huth 
501e8a1faeSThomas Huth     qtest_qmp_device_add(qts, "virtserialport", "hp-port", "{}");
511e8a1faeSThomas Huth     qtest_qmp_device_del(qts, "hp-port");
521e8a1faeSThomas Huth 
531e8a1faeSThomas Huth     qtest_quit(qts);
541e8a1faeSThomas Huth }
551e8a1faeSThomas Huth 
561e8a1faeSThomas Huth static void virtio_blk_nop(void)
571e8a1faeSThomas Huth {
581e8a1faeSThomas Huth     global_qtest = qtest_initf("-drive if=none,id=drv0,file=null-co://,"
591e8a1faeSThomas Huth                                "file.read-zeroes=on,format=raw "
601e8a1faeSThomas Huth                                 "-device virtio-blk-ccw,drive=drv0");
611e8a1faeSThomas Huth     qtest_end();
621e8a1faeSThomas Huth }
631e8a1faeSThomas Huth 
641e8a1faeSThomas Huth static void virtio_net_nop(void)
651e8a1faeSThomas Huth {
661e8a1faeSThomas Huth     global_qtest = qtest_initf("-device virtio-net-ccw");
671e8a1faeSThomas Huth     qtest_end();
681e8a1faeSThomas Huth }
691e8a1faeSThomas Huth 
701e8a1faeSThomas Huth static void virtio_rng_nop(void)
711e8a1faeSThomas Huth {
721e8a1faeSThomas Huth     global_qtest = qtest_initf("-device virtio-rng-ccw");
731e8a1faeSThomas Huth     qtest_end();
741e8a1faeSThomas Huth }
751e8a1faeSThomas Huth 
761e8a1faeSThomas Huth static void virtio_scsi_nop(void)
771e8a1faeSThomas Huth {
781e8a1faeSThomas Huth     global_qtest = qtest_initf("-device virtio-scsi-ccw");
791e8a1faeSThomas Huth     qtest_end();
801e8a1faeSThomas Huth }
811e8a1faeSThomas Huth 
821e8a1faeSThomas Huth static void virtio_scsi_hotplug(void)
831e8a1faeSThomas Huth {
841e8a1faeSThomas Huth     QTestState *s = qtest_initf("-drive if=none,id=drv0,file=null-co://,"
851e8a1faeSThomas Huth                                 "file.read-zeroes=on,format=raw "
861e8a1faeSThomas Huth                                 "-drive if=none,id=drv1,file=null-co://,"
871e8a1faeSThomas Huth                                 "file.read-zeroes=on,format=raw "
881e8a1faeSThomas Huth                                 "-device virtio-scsi-ccw "
891e8a1faeSThomas Huth                                 "-device scsi-hd,drive=drv0");
901e8a1faeSThomas Huth     qtest_qmp_device_add(s, "scsi-hd", "scsihd", "{'drive': 'drv1'}");
911e8a1faeSThomas Huth     qtest_qmp_device_del(s, "scsihd");
921e8a1faeSThomas Huth 
931e8a1faeSThomas Huth     qtest_quit(s);
941e8a1faeSThomas Huth }
951e8a1faeSThomas Huth 
961e8a1faeSThomas Huth int main(int argc, char **argv)
971e8a1faeSThomas Huth {
981e8a1faeSThomas Huth     g_test_init(&argc, &argv, NULL);
991e8a1faeSThomas Huth     qtest_add_func("/virtio/balloon/nop", virtio_balloon_nop);
1001e8a1faeSThomas Huth     qtest_add_func("/virtio/console/nop", virtconsole_nop);
1011e8a1faeSThomas Huth     qtest_add_func("/virtio/serialport/nop", virtserialport_nop);
1021e8a1faeSThomas Huth     qtest_add_func("/virtio/serial/nop", virtio_serial_nop);
1031e8a1faeSThomas Huth     qtest_add_func("/virtio/serial/hotplug", virtio_serial_hotplug);
1041e8a1faeSThomas Huth     qtest_add_func("/virtio/block/nop", virtio_blk_nop);
1051e8a1faeSThomas Huth     qtest_add_func("/virtio/net/nop", virtio_net_nop);
1061e8a1faeSThomas Huth     qtest_add_func("/virtio/rng/nop", virtio_rng_nop);
1071e8a1faeSThomas Huth     qtest_add_func("/virtio/scsi/nop", virtio_scsi_nop);
1081e8a1faeSThomas Huth     qtest_add_func("/virtio/scsi/hotplug", virtio_scsi_hotplug);
1091e8a1faeSThomas Huth 
110*66997c42SMarkus Armbruster     return g_test_run();
1111e8a1faeSThomas Huth }
112