From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeEy0-0005yh-4V for qemu-devel@nongnu.org; Tue, 14 Oct 2014 23:09:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XeExr-0004jN-PJ for qemu-devel@nongnu.org; Tue, 14 Oct 2014 23:09:36 -0400 Received: from cantor2.suse.de ([195.135.220.15]:49319 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeExr-0004ip-Id for qemu-devel@nongnu.org; Tue, 14 Oct 2014 23:09:27 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 15 Oct 2014 05:08:49 +0200 Message-Id: <1413342561-4754-16-git-send-email-afaerber@suse.de> In-Reply-To: <1413342561-4754-1-git-send-email-afaerber@suse.de> References: <1413342561-4754-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 15/47] tests: usb: usb-storage hotplug test List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Igor Mammedov , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Gerd Hoffmann From: Igor Mammedov usb-storage is different from usual usb devices in that it uses a child SCSI bus for underlying storage. This commit verifies that the SCSI bus is hotpluggable, as hotplug operation wouldn't succeed without it. Signed-off-by: Igor Mammedov Reviewed-by: Paolo Bonzini Signed-off-by: Andreas F=C3=A4rber --- tests/usb-hcd-uhci-test.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/usb-hcd-uhci-test.c b/tests/usb-hcd-uhci-test.c index da96f98..8cf2c5b 100644 --- a/tests/usb-hcd-uhci-test.c +++ b/tests/usb-hcd-uhci-test.c @@ -46,6 +46,35 @@ static void test_uhci_hotplug(void) usb_test_hotplug("uhci", 2, test_port_2); } =20 +static void test_usb_storage_hotplug(void) +{ + QDict *response; + + response =3D qmp("{'execute': 'device_add'," + " 'arguments': {" + " 'driver': 'usb-storage'," + " 'drive': 'drive0'," + " 'id': 'usbdev0'" + "}}"); + g_assert(response); + g_assert(!qdict_haskey(response, "error")); + QDECREF(response); + + response =3D qmp("{'execute': 'device_del'," + " 'arguments': {" + " 'id': 'usbdev0'" + "}}"); + g_assert(response); + g_assert(!qdict_haskey(response, "error")); + QDECREF(response); + + response =3D qmp(""); + g_assert(response); + g_assert(qdict_haskey(response, "event")); + g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED")= ); + QDECREF(response); +} + int main(int argc, char **argv) { int ret; @@ -55,8 +84,10 @@ int main(int argc, char **argv) qtest_add_func("/uhci/pci/init", test_uhci_init); qtest_add_func("/uhci/pci/port1", test_port_1); qtest_add_func("/uhci/pci/hotplug", test_uhci_hotplug); + qtest_add_func("/uhci/pci/hotplug/usb-storage", test_usb_storage_hot= plug); =20 qtest_start("-device piix3-usb-uhci,id=3Duhci,addr=3D1d.0" + " -drive id=3Ddrive0,if=3Dnone,file=3D/dev/null" " -device usb-tablet,bus=3Duhci.0,port=3D1"); ret =3D g_test_run(); qtest_end(); --=20 1.8.4.5