From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53179) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wx9Y2-0007Zw-Pc for qemu-devel@nongnu.org; Wed, 18 Jun 2014 02:40:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wx9Xw-0001RM-AZ for qemu-devel@nongnu.org; Wed, 18 Jun 2014 02:40:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50099) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wx9Xv-0001R6-TE for qemu-devel@nongnu.org; Wed, 18 Jun 2014 02:40:36 -0400 Date: Wed, 18 Jun 2014 14:40:24 +0800 From: Amos Kong Message-ID: <20140618064024.GB18929@z.redhat.com> References: <1402065233-31894-1-git-send-email-akong@redhat.com> <1402065233-31894-4-git-send-email-akong@redhat.com> <53A041CE.1060408@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <53A041CE.1060408@suse.de> 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: Andreas =?iso-8859-1?Q?F=E4rber?= Cc: stefanha@gmail.com, arei.gonglei@huawei.com, qemu-devel@nongnu.org On Tue, Jun 17, 2014 at 03:25:34PM +0200, Andreas F=E4rber wrote: > 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 */ >=20 > "3-0x1f" or "3 to 0x1f"? >=20 > > + 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= ,id=3Ddrv-%x.%x", > > + i, j); > > + qmp_exec_hmp_cmd("", > > + "device_add virtio-blk-pci,id=3Ddev-%x.%x,dri= ve=3Ddrv-%x.%x," > > + "addr=3D0x%x.%x,multifunction=3Don", i, j, i,= j, i, j); Hi Andreas, =20 > Why are you using HMP-via-QMP here and not QMP directly? I referenced existed test code. =20 > > + } > > + } > > + > > + /* 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--) { >=20 > While the function is still small, using a define or static const would > be a small improvement. :) Could be a follow-up of course. Sorry I don't get it.=20 test_blk_hotplug() was already decorated by 'static' and we can't decorate a function that returns nothing. tests/virtio-blk-test.c:16:19: error: function definition has qualified void return type [-Werror] static const void test_blk_hotplug(void) =20 > Test looks good, thanks for your effort. >=20 > Regards, > Andreas Thanks, Amos =20 > > + 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 >=20 > --=20 > SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany > GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrn= berg --=20 Amos.