| 
									
										
										
										
											2018-08-01 15:26:22 +02:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * QTest testcase for VirtIO CCW | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (c) 2014 SUSE LINUX Products GmbH | 
					
						
							|  |  |  |  * Copyright (c) 2018 Red Hat, Inc. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This work is licensed under the terms of the GNU GPL, version 2 or later. | 
					
						
							|  |  |  |  * See the COPYING file in the top-level directory. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Until we have a full libqos implementation of virtio-ccw (which requires
 | 
					
						
							|  |  |  |  * also to add support for I/O channels to qtest), we can only do simple | 
					
						
							|  |  |  |  * tests that initialize the devices. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "qemu/osdep.h"
 | 
					
						
							| 
									
										
										
										
											2019-09-03 07:50:26 +02:00
										 |  |  | #include "libqtest-single.h"
 | 
					
						
							| 
									
										
										
										
											2018-08-01 15:26:22 +02:00
										 |  |  | #include "libqos/virtio.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void virtconsole_nop(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     global_qtest = qtest_initf("-device virtio-serial-ccw,id=vser0 " | 
					
						
							|  |  |  |                                 "-device virtconsole,bus=vser0.0"); | 
					
						
							|  |  |  |     qtest_end(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void virtserialport_nop(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     global_qtest = qtest_initf("-device virtio-serial-ccw,id=vser0 " | 
					
						
							|  |  |  |                                 "-device virtserialport,bus=vser0.0"); | 
					
						
							|  |  |  |     qtest_end(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void virtio_serial_nop(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     global_qtest = qtest_initf("-device virtio-serial-ccw"); | 
					
						
							|  |  |  |     qtest_end(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void virtio_serial_hotplug(void) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-07-22 17:10:55 +02:00
										 |  |  |     QTestState *qts = qtest_initf("-device virtio-serial-ccw"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     qtest_qmp_device_add(qts, "virtserialport", "hp-port", "{}"); | 
					
						
							|  |  |  |     qtest_qmp_device_del(qts, "hp-port"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     qtest_quit(qts); | 
					
						
							| 
									
										
										
										
											2018-08-01 15:26:22 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void virtio_rng_nop(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     global_qtest = qtest_initf("-device virtio-rng-ccw"); | 
					
						
							|  |  |  |     qtest_end(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void virtio_scsi_nop(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     global_qtest = qtest_initf("-device virtio-scsi-ccw"); | 
					
						
							|  |  |  |     qtest_end(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void virtio_scsi_hotplug(void) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-07-22 17:10:55 +02:00
										 |  |  |     QTestState *s = qtest_initf("-drive if=none,id=drv0,file=null-co://," | 
					
						
							|  |  |  |                                 "file.read-zeroes=on,format=raw " | 
					
						
							| 
									
										
										
										
											2019-07-29 15:46:00 +03:00
										 |  |  |                                 "-drive if=none,id=drv1,file=null-co://," | 
					
						
							|  |  |  |                                 "file.read-zeroes=on,format=raw " | 
					
						
							| 
									
										
										
										
											2018-08-01 15:26:22 +02:00
										 |  |  |                                 "-device virtio-scsi-ccw " | 
					
						
							|  |  |  |                                 "-device scsi-hd,drive=drv0"); | 
					
						
							| 
									
										
										
										
											2019-07-22 17:10:55 +02:00
										 |  |  |     qtest_qmp_device_add(s, "scsi-hd", "scsihd", "{'drive': 'drv1'}"); | 
					
						
							|  |  |  |     qtest_qmp_device_del(s, "scsihd"); | 
					
						
							| 
									
										
										
										
											2018-08-01 15:26:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-22 17:10:55 +02:00
										 |  |  |     qtest_quit(s); | 
					
						
							| 
									
										
										
										
											2018-08-01 15:26:22 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int main(int argc, char **argv) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     g_test_init(&argc, &argv, NULL); | 
					
						
							| 
									
										
										
										
											2023-05-11 15:41:59 +02:00
										 |  |  |     if (qtest_has_device("virtio-serial-ccw")) { | 
					
						
							|  |  |  |         qtest_add_func("/virtio/console/nop", virtconsole_nop); | 
					
						
							|  |  |  |         qtest_add_func("/virtio/serialport/nop", virtserialport_nop); | 
					
						
							|  |  |  |         qtest_add_func("/virtio/serial/nop", virtio_serial_nop); | 
					
						
							|  |  |  |         qtest_add_func("/virtio/serial/hotplug", virtio_serial_hotplug); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (qtest_has_device("virtio-rng-ccw")) { | 
					
						
							|  |  |  |         qtest_add_func("/virtio/rng/nop", virtio_rng_nop); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (qtest_has_device("virtio-rng-ccw")) { | 
					
						
							|  |  |  |         qtest_add_func("/virtio/scsi/nop", virtio_scsi_nop); | 
					
						
							|  |  |  |         qtest_add_func("/virtio/scsi/hotplug", virtio_scsi_hotplug); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-08-01 15:26:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-22 14:49:16 +01:00
										 |  |  |     return g_test_run(); | 
					
						
							| 
									
										
										
										
											2018-08-01 15:26:22 +02:00
										 |  |  | } |