From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42633) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwtOS-00085S-2p for qemu-devel@nongnu.org; Tue, 17 Jun 2014 09:25:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WwtOJ-0001aC-M8 for qemu-devel@nongnu.org; Tue, 17 Jun 2014 09:25:44 -0400 Received: from cantor2.suse.de ([195.135.220.15]:60347 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwtOJ-0001Zu-DO for qemu-devel@nongnu.org; Tue, 17 Jun 2014 09:25:35 -0400 Message-ID: <53A041CE.1060408@suse.de> Date: Tue, 17 Jun 2014 15:25:34 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1402065233-31894-1-git-send-email-akong@redhat.com> <1402065233-31894-4-git-send-email-akong@redhat.com> In-Reply-To: <1402065233-31894-4-git-send-email-akong@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v4 3/4] virtio-blk-test.c: add hotplug subtest List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amos Kong , qemu-devel@nongnu.org Cc: stefanha@gmail.com, arei.gonglei@huawei.com Am 06.06.2014 16:33, schrieb Amos Kong: > This patch adds a new subtest, it hotplugs 29 * 8 =3D 232 virtio-blk > devices to guest, and try to hot-unplug them. >=20 > Note: the hot-unplug can't work without cooperation of guest OS. >=20 > Signed-off-by: Amos Kong > Reviewed-by: Stefan Hajnoczi > --- > tests/virtio-blk-test.c | 31 +++++++++++++++++++++++++++++++ > 1 file changed, 31 insertions(+) >=20 > diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c > index 0fdec01..7358203 100644 > --- a/tests/virtio-blk-test.c > +++ b/tests/virtio-blk-test.c > @@ -7,11 +7,41 @@ > * See the COPYING file in the top-level directory. > */ > =20 > +#include > #include > #include > #include "libqtest.h" > #include "qemu/osdep.h" > =20 > +static void test_blk_hotplug(void) > +{ > + int i, j; > + > + /* start with no network/block device, slots 3~0x1f are free */ "3-0x1f" or "3 to 0x1f"? > + qtest_start("-net none"); > + > + for (i =3D 3; i <=3D 0x1f; i++) { > + for (j =3D 7; j >=3D 0; j--) { > + qmp_exec_hmp_cmd("OK\r\n", > + "drive_add 0 if=3Dnone,file=3D/dev/null,i= d=3Ddrv-%x.%x", > + i, j); > + qmp_exec_hmp_cmd("", > + "device_add virtio-blk-pci,id=3Ddev-%x.%x,drive= =3Ddrv-%x.%x," > + "addr=3D0x%x.%x,multifunction=3Don", i, j, i, j= , i, j); Why are you using HMP-via-QMP here and not QMP directly? > + } > + } > + > + /* hot-unplug doesn't work without cooperation of guest OS */ > + for (i =3D 3; i <=3D 0x1f; i++) { > + for (j =3D 7; j >=3D 0; j--) { While the function is still small, using a define or static const would be a small improvement. :) Could be a follow-up of course. Test looks good, thanks for your effort. Regards, Andreas > + qmp_exec_hmp_cmd("", "drive_del drv-%x.%x", i, j); > + qmp_exec_hmp_cmd("", "device_del dev-%x.%x", i, j); > + } > + } > + > + qtest_end(); > +} > + > /* Tests only initialization */ > static void virtblk_init(void) > { > @@ -26,6 +56,7 @@ int main(int argc, char **argv) > =20 > g_test_init(&argc, &argv, NULL); > qtest_add_func("/virtio/blk/pci/init", virtblk_init); > + qtest_add_func("/virtio/blk/pci/hotplug", test_blk_hotplug); > =20 > ret =3D g_test_run(); > =20 >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg