From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37081) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeExz-0005ya-Ha for qemu-devel@nongnu.org; Tue, 14 Oct 2014 23:09:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XeExs-0004jd-1C for qemu-devel@nongnu.org; Tue, 14 Oct 2014 23:09:35 -0400 Received: from cantor2.suse.de ([195.135.220.15]:49304 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeExr-0004fZ-Pq 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:50 +0200 Message-Id: <1413342561-4754-17-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 16/47] tests: usb: usb-uas 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 checks that it's possible to hotplug usb-uas HBA and then if it's possible to hot(un)plug scsi-disk to it. Thest basically covers hot(un)plug on dummy HBAs without means of hot(un)plug notification of the guest. Signed-off-by: Igor Mammedov Reviewed-by: Paolo Bonzini Signed-off-by: Andreas F=C3=A4rber --- tests/usb-hcd-xhci-test.c | 61 +++++++++++++++++++++++++++++++++++++++++= +++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/tests/usb-hcd-xhci-test.c b/tests/usb-hcd-xhci-test.c index d16963d..b1a7dec 100644 --- a/tests/usb-hcd-xhci-test.c +++ b/tests/usb-hcd-xhci-test.c @@ -23,6 +23,63 @@ static void test_xhci_hotplug(void) usb_test_hotplug("xhci", 1, NULL); } =20 +static void test_usb_uas_hotplug(void) +{ + QDict *response; + + response =3D qmp("{'execute': 'device_add'," + " 'arguments': {" + " 'driver': 'usb-uas'," + " 'id': 'uas'" + "}}"); + g_assert(response); + g_assert(!qdict_haskey(response, "error")); + QDECREF(response); + + response =3D qmp("{'execute': 'device_add'," + " 'arguments': {" + " 'driver': 'scsi-hd'," + " 'drive': 'drive0'," + " 'id': 'scsi-hd'" + "}}"); + g_assert(response); + g_assert(!qdict_haskey(response, "error")); + QDECREF(response); + + /* TODO: + UAS HBA driver in libqos, to check that + added disk is visible after BUS rescan + */ + + response =3D qmp("{'execute': 'device_del'," + " 'arguments': {" + " 'id': 'scsi-hd'" + "}}"); + g_assert(response); + g_assert(!qdict_haskey(response, "error")); + QDECREF(response); + + response =3D qmp(""); + g_assert(qdict_haskey(response, "event")); + g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED")= ); + QDECREF(response); + + + response =3D qmp("{'execute': 'device_del'," + " 'arguments': {" + " 'id': 'uas'" + "}}"); + 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; @@ -31,8 +88,10 @@ int main(int argc, char **argv) =20 qtest_add_func("/xhci/pci/init", test_xhci_init); qtest_add_func("/xhci/pci/hotplug", test_xhci_hotplug); + qtest_add_func("/xhci/pci/hotplug/usb-uas", test_usb_uas_hotplug); =20 - qtest_start("-device nec-usb-xhci,id=3Dxhci"); + qtest_start("-device nec-usb-xhci,id=3Dxhci" + " -drive id=3Ddrive0,if=3Dnone,file=3D/dev/null"); ret =3D g_test_run(); qtest_end(); =20 --=20 1.8.4.5