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 virtconsole_nop(void) 211e8a1faeSThomas Huth { 221e8a1faeSThomas Huth global_qtest = qtest_initf("-device virtio-serial-ccw,id=vser0 " 231e8a1faeSThomas Huth "-device virtconsole,bus=vser0.0"); 241e8a1faeSThomas Huth qtest_end(); 251e8a1faeSThomas Huth } 261e8a1faeSThomas Huth 271e8a1faeSThomas Huth static void virtserialport_nop(void) 281e8a1faeSThomas Huth { 291e8a1faeSThomas Huth global_qtest = qtest_initf("-device virtio-serial-ccw,id=vser0 " 301e8a1faeSThomas Huth "-device virtserialport,bus=vser0.0"); 311e8a1faeSThomas Huth qtest_end(); 321e8a1faeSThomas Huth } 331e8a1faeSThomas Huth 341e8a1faeSThomas Huth static void virtio_serial_nop(void) 351e8a1faeSThomas Huth { 361e8a1faeSThomas Huth global_qtest = qtest_initf("-device virtio-serial-ccw"); 371e8a1faeSThomas Huth qtest_end(); 381e8a1faeSThomas Huth } 391e8a1faeSThomas Huth 401e8a1faeSThomas Huth static void virtio_serial_hotplug(void) 411e8a1faeSThomas Huth { 421e8a1faeSThomas Huth QTestState *qts = qtest_initf("-device virtio-serial-ccw"); 431e8a1faeSThomas Huth 441e8a1faeSThomas Huth qtest_qmp_device_add(qts, "virtserialport", "hp-port", "{}"); 451e8a1faeSThomas Huth qtest_qmp_device_del(qts, "hp-port"); 461e8a1faeSThomas Huth 471e8a1faeSThomas Huth qtest_quit(qts); 481e8a1faeSThomas Huth } 491e8a1faeSThomas Huth 501e8a1faeSThomas Huth static void virtio_rng_nop(void) 511e8a1faeSThomas Huth { 521e8a1faeSThomas Huth global_qtest = qtest_initf("-device virtio-rng-ccw"); 531e8a1faeSThomas Huth qtest_end(); 541e8a1faeSThomas Huth } 551e8a1faeSThomas Huth 561e8a1faeSThomas Huth static void virtio_scsi_nop(void) 571e8a1faeSThomas Huth { 581e8a1faeSThomas Huth global_qtest = qtest_initf("-device virtio-scsi-ccw"); 591e8a1faeSThomas Huth qtest_end(); 601e8a1faeSThomas Huth } 611e8a1faeSThomas Huth 621e8a1faeSThomas Huth static void virtio_scsi_hotplug(void) 631e8a1faeSThomas Huth { 641e8a1faeSThomas Huth QTestState *s = qtest_initf("-drive if=none,id=drv0,file=null-co://," 651e8a1faeSThomas Huth "file.read-zeroes=on,format=raw " 661e8a1faeSThomas Huth "-drive if=none,id=drv1,file=null-co://," 671e8a1faeSThomas Huth "file.read-zeroes=on,format=raw " 681e8a1faeSThomas Huth "-device virtio-scsi-ccw " 691e8a1faeSThomas Huth "-device scsi-hd,drive=drv0"); 701e8a1faeSThomas Huth qtest_qmp_device_add(s, "scsi-hd", "scsihd", "{'drive': 'drv1'}"); 711e8a1faeSThomas Huth qtest_qmp_device_del(s, "scsihd"); 721e8a1faeSThomas Huth 731e8a1faeSThomas Huth qtest_quit(s); 741e8a1faeSThomas Huth } 751e8a1faeSThomas Huth 761e8a1faeSThomas Huth int main(int argc, char **argv) 771e8a1faeSThomas Huth { 781e8a1faeSThomas Huth g_test_init(&argc, &argv, NULL); 79*65331bf5SThomas Huth if (qtest_has_device("virtio-serial-ccw")) { 801e8a1faeSThomas Huth qtest_add_func("/virtio/console/nop", virtconsole_nop); 811e8a1faeSThomas Huth qtest_add_func("/virtio/serialport/nop", virtserialport_nop); 821e8a1faeSThomas Huth qtest_add_func("/virtio/serial/nop", virtio_serial_nop); 831e8a1faeSThomas Huth qtest_add_func("/virtio/serial/hotplug", virtio_serial_hotplug); 84*65331bf5SThomas Huth } 85*65331bf5SThomas Huth if (qtest_has_device("virtio-rng-ccw")) { 861e8a1faeSThomas Huth qtest_add_func("/virtio/rng/nop", virtio_rng_nop); 87*65331bf5SThomas Huth } 88*65331bf5SThomas Huth if (qtest_has_device("virtio-rng-ccw")) { 891e8a1faeSThomas Huth qtest_add_func("/virtio/scsi/nop", virtio_scsi_nop); 901e8a1faeSThomas Huth qtest_add_func("/virtio/scsi/hotplug", virtio_scsi_hotplug); 91*65331bf5SThomas Huth } 921e8a1faeSThomas Huth 9366997c42SMarkus Armbruster return g_test_run(); 941e8a1faeSThomas Huth } 95