* [Qemu-devel] [PATCH 0/9] block: -device drive=<node-name> fixes @ 2017-07-12 12:57 Kevin Wolf 2017-07-12 12:57 ` [Qemu-devel] [PATCH 1/9] block: Make blk_get_attached_dev_id() public Kevin Wolf ` (8 more replies) 0 siblings, 9 replies; 20+ messages in thread From: Kevin Wolf @ 2017-07-12 12:57 UTC (permalink / raw) To: qemu-block; +Cc: kwolf, mreitz, eblake, jsnow, pbonzini, armbru, qemu-devel Since 2.9 it is possible for a user to care only about nodes and qdev devices, but not about BlockBackends, by defining with -blockdev and using their node name in -device. Devices create an anonymous BlockBackend internally then. One of the major problems in this setup is that such devices are not listed in query-block or HMP 'info block' because the BBs are not monitor-owned. A recent discussion concluded that we really want to replace query-block and friends with something that matches QEMU's internals better, but there's no way to do that in 2.10 (and I wouldn't bet on it to be completed for 2.11). So for now, just make the devices appear in query-block and add the qdev ID there in order to make the devices identifiable (they have 'device': '' because the BB is anonymous). With the additional qdev field, it turned out that with empty drives, ide-cd and scsi-cd weren't even properly attached to the BlockBackend. If you do it right, this even results in crashes. (Floppy already gets it right, in case you wondered.) After this series, -device drive=<node-name> should be reasonably usable without a major loss of functionality like before. Kevin Wolf (9): block: Make blk_get_attached_dev_id() public block/qapi: Add qdev device name to query-block block: Make blk_all_next() public block/qapi: Use blk_all_next() for query-block block: List anonymous device BBs in query-block ide: bdrv_attach_dev() for empty CD-ROM scsi-disk: bdrv_attach_dev() for empty CD-ROM qemu-iotests: Test 'info block' qemu-iotests: Test unplug of -device without drive block/block-backend.c | 5 +- block/qapi.c | 20 +- hmp.c | 11 +- hw/ide/qdev.c | 3 + hw/scsi/scsi-disk.c | 5 + include/sysemu/block-backend.h | 2 + qapi/block-core.json | 5 +- tests/qemu-iotests/067 | 13 ++ tests/qemu-iotests/067.out | 40 ++++ tests/qemu-iotests/186 | 147 +++++++++++++ tests/qemu-iotests/186.out | 489 +++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 12 files changed, 731 insertions(+), 10 deletions(-) create mode 100755 tests/qemu-iotests/186 create mode 100644 tests/qemu-iotests/186.out -- 1.8.3.1 ^ permalink raw reply [flat|nested] 20+ messages in thread
* [Qemu-devel] [PATCH 1/9] block: Make blk_get_attached_dev_id() public 2017-07-12 12:57 [Qemu-devel] [PATCH 0/9] block: -device drive=<node-name> fixes Kevin Wolf @ 2017-07-12 12:57 ` Kevin Wolf 2017-07-12 14:53 ` Eric Blake 2017-07-12 12:57 ` [Qemu-devel] [PATCH 2/9] block/qapi: Add qdev device name to query-block Kevin Wolf ` (7 subsequent siblings) 8 siblings, 1 reply; 20+ messages in thread From: Kevin Wolf @ 2017-07-12 12:57 UTC (permalink / raw) To: qemu-block; +Cc: kwolf, mreitz, eblake, jsnow, pbonzini, armbru, qemu-devel Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- block/block-backend.c | 3 +-- include/sysemu/block-backend.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 0df3457..d60e53b 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -83,7 +83,6 @@ static const AIOCBInfo block_backend_aiocb_info = { static void drive_info_del(DriveInfo *dinfo); static BlockBackend *bdrv_first_blk(BlockDriverState *bs); -static char *blk_get_attached_dev_id(BlockBackend *blk); /* All BlockBackends */ static QTAILQ_HEAD(, BlockBackend) block_backends = @@ -726,7 +725,7 @@ void *blk_get_attached_dev(BlockBackend *blk) /* Return the qdev ID, or if no ID is assigned the QOM path, of the block * device attached to the BlockBackend. */ -static char *blk_get_attached_dev_id(BlockBackend *blk) +char *blk_get_attached_dev_id(BlockBackend *blk) { DeviceState *dev; diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 1e05281..80096f2 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -126,6 +126,7 @@ int blk_attach_dev(BlockBackend *blk, DeviceState *dev); void blk_attach_dev_legacy(BlockBackend *blk, void *dev); void blk_detach_dev(BlockBackend *blk, void *dev); void *blk_get_attached_dev(BlockBackend *blk); +char *blk_get_attached_dev_id(BlockBackend *blk); BlockBackend *blk_by_dev(void *dev); BlockBackend *blk_by_qdev_id(const char *id, Error **errp); void blk_set_dev_ops(BlockBackend *blk, const BlockDevOps *ops, void *opaque); -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] [PATCH 1/9] block: Make blk_get_attached_dev_id() public 2017-07-12 12:57 ` [Qemu-devel] [PATCH 1/9] block: Make blk_get_attached_dev_id() public Kevin Wolf @ 2017-07-12 14:53 ` Eric Blake 0 siblings, 0 replies; 20+ messages in thread From: Eric Blake @ 2017-07-12 14:53 UTC (permalink / raw) To: Kevin Wolf, qemu-block; +Cc: mreitz, jsnow, pbonzini, armbru, qemu-devel [-- Attachment #1: Type: text/plain, Size: 418 bytes --] On 07/12/2017 07:57 AM, Kevin Wolf wrote: > Signed-off-by: Kevin Wolf <kwolf@redhat.com> > --- > block/block-backend.c | 3 +-- > include/sysemu/block-backend.h | 1 + > 2 files changed, 2 insertions(+), 2 deletions(-) > Reviewed-by: Eric Blake <eblake@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 604 bytes --] ^ permalink raw reply [flat|nested] 20+ messages in thread
* [Qemu-devel] [PATCH 2/9] block/qapi: Add qdev device name to query-block 2017-07-12 12:57 [Qemu-devel] [PATCH 0/9] block: -device drive=<node-name> fixes Kevin Wolf 2017-07-12 12:57 ` [Qemu-devel] [PATCH 1/9] block: Make blk_get_attached_dev_id() public Kevin Wolf @ 2017-07-12 12:57 ` Kevin Wolf 2017-07-12 15:06 ` Eric Blake 2017-07-12 12:57 ` [Qemu-devel] [PATCH 3/9] block: Make blk_all_next() public Kevin Wolf ` (6 subsequent siblings) 8 siblings, 1 reply; 20+ messages in thread From: Kevin Wolf @ 2017-07-12 12:57 UTC (permalink / raw) To: qemu-block; +Cc: kwolf, mreitz, eblake, jsnow, pbonzini, armbru, qemu-devel With -blockdev/-device, users can indirectly create anonymous BlockBackends, in the state of which they are still interested. As a preparation for making such BBs visible in query-block, make sure that they can be identified even without a name by adding the ID/QOM path of their qdev device to BlockInfo. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- block/qapi.c | 10 ++++++++++ hmp.c | 3 +++ qapi/block-core.json | 5 ++++- tests/qemu-iotests/067.out | 1 + 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/block/qapi.c b/block/qapi.c index 0a41d59..705cd11 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -322,11 +322,21 @@ static void bdrv_query_info(BlockBackend *blk, BlockInfo **p_info, { BlockInfo *info = g_malloc0(sizeof(*info)); BlockDriverState *bs = blk_bs(blk); + char *qdev; + info->device = g_strdup(blk_name(blk)); info->type = g_strdup("unknown"); info->locked = blk_dev_is_medium_locked(blk); info->removable = blk_dev_has_removable_media(blk); + qdev = blk_get_attached_dev_id(blk); + if (qdev && *qdev) { + info->has_qdev = true; + info->qdev = qdev; + } else { + g_free(qdev); + } + if (blk_dev_has_tray(blk)) { info->has_tray_open = true; info->tray_open = blk_dev_is_tray_open(blk); diff --git a/hmp.c b/hmp.c index dee4028..d1d769e 100644 --- a/hmp.c +++ b/hmp.c @@ -425,6 +425,9 @@ static void print_block_info(Monitor *mon, BlockInfo *info, } if (info) { + if (info->has_qdev) { + monitor_printf(mon, " Attached to: %s\n", info->qdev); + } if (info->has_io_status && info->io_status != BLOCK_DEVICE_IO_STATUS_OK) { monitor_printf(mon, " I/O status: %s\n", BlockDeviceIoStatus_lookup[info->io_status]); diff --git a/qapi/block-core.json b/qapi/block-core.json index f85c223..69b3c3c 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -433,6 +433,9 @@ # # @device: The device name associated with the virtual device. # +# @qdev: The qdev ID, or if no ID is assigned the QOM path, of the block +# device. +# # @type: This field is returned only for compatibility reasons, it should # not be used (always returns 'unknown') # @@ -458,7 +461,7 @@ # Since: 0.14.0 ## { 'struct': 'BlockInfo', - 'data': {'device': 'str', 'type': 'str', 'removable': 'bool', + 'data': {'device': 'str', '*qdev': 'str', 'type': 'str', 'removable': 'bool', 'locked': 'bool', '*inserted': 'BlockDeviceInfo', '*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus', '*dirty-bitmaps': ['BlockDirtyInfo'] } } diff --git a/tests/qemu-iotests/067.out b/tests/qemu-iotests/067.out index 782eae2..e3c4496 100644 --- a/tests/qemu-iotests/067.out +++ b/tests/qemu-iotests/067.out @@ -57,6 +57,7 @@ Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,if=none,id=disk -device virti "file": "TEST_DIR/t.qcow2", "encryption_key_missing": false }, + "qdev": "/machine/peripheral/virtio0/virtio-backend", "type": "unknown" } ] -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] [PATCH 2/9] block/qapi: Add qdev device name to query-block 2017-07-12 12:57 ` [Qemu-devel] [PATCH 2/9] block/qapi: Add qdev device name to query-block Kevin Wolf @ 2017-07-12 15:06 ` Eric Blake 0 siblings, 0 replies; 20+ messages in thread From: Eric Blake @ 2017-07-12 15:06 UTC (permalink / raw) To: Kevin Wolf, qemu-block; +Cc: mreitz, jsnow, pbonzini, armbru, qemu-devel [-- Attachment #1: Type: text/plain, Size: 2183 bytes --] On 07/12/2017 07:57 AM, Kevin Wolf wrote: > With -blockdev/-device, users can indirectly create anonymous > BlockBackends, in the state of which they are still interested. As a Reads awkwardly. Maybe: BlockBackends, although it is still of interest to learn the state of such backends. > preparation for making such BBs visible in query-block, make sure that > they can be identified even without a name by adding the ID/QOM path of > their qdev device to BlockInfo. > > Signed-off-by: Kevin Wolf <kwolf@redhat.com> > --- > +++ b/qapi/block-core.json > @@ -433,6 +433,9 @@ > # > # @device: The device name associated with the virtual device. > # > +# @qdev: The qdev ID, or if no ID is assigned the QOM path, of the block s/assigned the QOM path, of/assigned, the QOM path of/ > +# device. Missing a (since 2.10) tag. > +# > # @type: This field is returned only for compatibility reasons, it should > # not be used (always returns 'unknown') > # > @@ -458,7 +461,7 @@ > # Since: 0.14.0 > ## > { 'struct': 'BlockInfo', > - 'data': {'device': 'str', 'type': 'str', 'removable': 'bool', > + 'data': {'device': 'str', '*qdev': 'str', 'type': 'str', 'removable': 'bool', > 'locked': 'bool', '*inserted': 'BlockDeviceInfo', > '*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus', > '*dirty-bitmaps': ['BlockDirtyInfo'] } } Besides the testsuite, are there any example outputs that need to be adjusted? > diff --git a/tests/qemu-iotests/067.out b/tests/qemu-iotests/067.out > index 782eae2..e3c4496 100644 > --- a/tests/qemu-iotests/067.out > +++ b/tests/qemu-iotests/067.out > @@ -57,6 +57,7 @@ Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,if=none,id=disk -device virti > "file": "TEST_DIR/t.qcow2", > "encryption_key_missing": false > }, > + "qdev": "/machine/peripheral/virtio0/virtio-backend", > "type": "unknown" > } > ] > -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 604 bytes --] ^ permalink raw reply [flat|nested] 20+ messages in thread
* [Qemu-devel] [PATCH 3/9] block: Make blk_all_next() public 2017-07-12 12:57 [Qemu-devel] [PATCH 0/9] block: -device drive=<node-name> fixes Kevin Wolf 2017-07-12 12:57 ` [Qemu-devel] [PATCH 1/9] block: Make blk_get_attached_dev_id() public Kevin Wolf 2017-07-12 12:57 ` [Qemu-devel] [PATCH 2/9] block/qapi: Add qdev device name to query-block Kevin Wolf @ 2017-07-12 12:57 ` Kevin Wolf 2017-07-12 15:25 ` Eric Blake 2017-07-12 12:57 ` [Qemu-devel] [PATCH 4/9] block/qapi: Use blk_all_next() for query-block Kevin Wolf ` (5 subsequent siblings) 8 siblings, 1 reply; 20+ messages in thread From: Kevin Wolf @ 2017-07-12 12:57 UTC (permalink / raw) To: qemu-block; +Cc: kwolf, mreitz, eblake, jsnow, pbonzini, armbru, qemu-devel Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- block/block-backend.c | 2 +- include/sysemu/block-backend.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/block/block-backend.c b/block/block-backend.c index d60e53b..15072f8 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -342,7 +342,7 @@ void blk_unref(BlockBackend *blk) * Behaves similarly to blk_next() but iterates over all BlockBackends, even the * ones which are hidden (i.e. are not referenced by the monitor). */ -static BlockBackend *blk_all_next(BlockBackend *blk) +BlockBackend *blk_all_next(BlockBackend *blk) { return blk ? QTAILQ_NEXT(blk, link) : QTAILQ_FIRST(&block_backends); diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 80096f2..dfdd3b8 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -100,6 +100,7 @@ void blk_remove_all_bs(void); const char *blk_name(const BlockBackend *blk); BlockBackend *blk_by_name(const char *name); BlockBackend *blk_next(BlockBackend *blk); +BlockBackend *blk_all_next(BlockBackend *blk); bool monitor_add_blk(BlockBackend *blk, const char *name, Error **errp); void monitor_remove_blk(BlockBackend *blk); -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] [PATCH 3/9] block: Make blk_all_next() public 2017-07-12 12:57 ` [Qemu-devel] [PATCH 3/9] block: Make blk_all_next() public Kevin Wolf @ 2017-07-12 15:25 ` Eric Blake 0 siblings, 0 replies; 20+ messages in thread From: Eric Blake @ 2017-07-12 15:25 UTC (permalink / raw) To: Kevin Wolf, qemu-block; +Cc: mreitz, jsnow, pbonzini, armbru, qemu-devel [-- Attachment #1: Type: text/plain, Size: 546 bytes --] On 07/12/2017 07:57 AM, Kevin Wolf wrote: > Signed-off-by: Kevin Wolf <kwolf@redhat.com> > --- > block/block-backend.c | 2 +- > include/sysemu/block-backend.h | 1 + > 2 files changed, 2 insertions(+), 1 deletion(-) Reviewed-by: Eric Blake <eblake@redhat.com> (although the commit message could mention WHY it is useful to be public, because of a pending patch that will need it to do XYZ) -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 604 bytes --] ^ permalink raw reply [flat|nested] 20+ messages in thread
* [Qemu-devel] [PATCH 4/9] block/qapi: Use blk_all_next() for query-block 2017-07-12 12:57 [Qemu-devel] [PATCH 0/9] block: -device drive=<node-name> fixes Kevin Wolf ` (2 preceding siblings ...) 2017-07-12 12:57 ` [Qemu-devel] [PATCH 3/9] block: Make blk_all_next() public Kevin Wolf @ 2017-07-12 12:57 ` Kevin Wolf 2017-07-12 15:27 ` Eric Blake 2017-07-12 12:57 ` [Qemu-devel] [PATCH 5/9] block: List anonymous device BBs in query-block Kevin Wolf ` (4 subsequent siblings) 8 siblings, 1 reply; 20+ messages in thread From: Kevin Wolf @ 2017-07-12 12:57 UTC (permalink / raw) To: qemu-block; +Cc: kwolf, mreitz, eblake, jsnow, pbonzini, armbru, qemu-devel This patch replaces the blk_next() loop in query-block by a blk_all_next() one so that we also get access to BlockBackends that aren't owned by the monitor. For now, the next thing we do is check whether each BB has a name, so there is no semantical difference. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- block/qapi.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index 705cd11..2f86c79 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -472,8 +472,14 @@ BlockInfoList *qmp_query_block(Error **errp) BlockBackend *blk; Error *local_err = NULL; - for (blk = blk_next(NULL); blk; blk = blk_next(blk)) { - BlockInfoList *info = g_malloc0(sizeof(*info)); + for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) { + BlockInfoList *info; + + if (!*blk_name(blk)) { + continue; + } + + info = g_malloc0(sizeof(*info)); bdrv_query_info(blk, &info->value, &local_err); if (local_err) { error_propagate(errp, local_err); -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] [PATCH 4/9] block/qapi: Use blk_all_next() for query-block 2017-07-12 12:57 ` [Qemu-devel] [PATCH 4/9] block/qapi: Use blk_all_next() for query-block Kevin Wolf @ 2017-07-12 15:27 ` Eric Blake 0 siblings, 0 replies; 20+ messages in thread From: Eric Blake @ 2017-07-12 15:27 UTC (permalink / raw) To: Kevin Wolf, qemu-block; +Cc: mreitz, jsnow, pbonzini, armbru, qemu-devel [-- Attachment #1: Type: text/plain, Size: 672 bytes --] On 07/12/2017 07:57 AM, Kevin Wolf wrote: > This patch replaces the blk_next() loop in query-block by a > blk_all_next() one so that we also get access to BlockBackends that > aren't owned by the monitor. For now, the next thing we do is check > whether each BB has a name, so there is no semantical difference. s/semantical/semantic/ > > Signed-off-by: Kevin Wolf <kwolf@redhat.com> > --- > block/qapi.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > Reviewed-by: Eric Blake <eblake@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 604 bytes --] ^ permalink raw reply [flat|nested] 20+ messages in thread
* [Qemu-devel] [PATCH 5/9] block: List anonymous device BBs in query-block 2017-07-12 12:57 [Qemu-devel] [PATCH 0/9] block: -device drive=<node-name> fixes Kevin Wolf ` (3 preceding siblings ...) 2017-07-12 12:57 ` [Qemu-devel] [PATCH 4/9] block/qapi: Use blk_all_next() for query-block Kevin Wolf @ 2017-07-12 12:57 ` Kevin Wolf 2017-07-12 15:47 ` Eric Blake 2017-07-12 12:57 ` [Qemu-devel] [PATCH 6/9] ide: bdrv_attach_dev() for empty CD-ROM Kevin Wolf ` (3 subsequent siblings) 8 siblings, 1 reply; 20+ messages in thread From: Kevin Wolf @ 2017-07-12 12:57 UTC (permalink / raw) To: qemu-block; +Cc: kwolf, mreitz, eblake, jsnow, pbonzini, armbru, qemu-devel Instead of listing only monitor-owned BlockBackends in query-block, also add those anonymous BlockBackends that are owned by a qdev device and as such under the control of the user. This allows to use query-block to inspect BlockBackends for the modern configuration syntax with -blockdev and -device. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- block/qapi.c | 2 +- hmp.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index 2f86c79..b5bb42b 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -475,7 +475,7 @@ BlockInfoList *qmp_query_block(Error **errp) for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) { BlockInfoList *info; - if (!*blk_name(blk)) { + if (!*blk_name(blk) && !blk_get_attached_dev(blk)) { continue; } diff --git a/hmp.c b/hmp.c index d1d769e..4caa9c1 100644 --- a/hmp.c +++ b/hmp.c @@ -401,16 +401,16 @@ static void print_block_info(Monitor *mon, BlockInfo *info, assert(!info || !info->has_inserted || info->inserted == inserted); - if (info) { + if (info && *info->device) { monitor_printf(mon, "%s", info->device); if (inserted && inserted->has_node_name) { monitor_printf(mon, " (%s)", inserted->node_name); } } else { - assert(inserted); + assert(info || inserted); monitor_printf(mon, "%s", - inserted->has_node_name - ? inserted->node_name + inserted && inserted->has_node_name ? inserted->node_name + : info && info->has_qdev ? info->qdev : "<anonymous>"); } -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] [PATCH 5/9] block: List anonymous device BBs in query-block 2017-07-12 12:57 ` [Qemu-devel] [PATCH 5/9] block: List anonymous device BBs in query-block Kevin Wolf @ 2017-07-12 15:47 ` Eric Blake 2017-07-13 11:25 ` Kevin Wolf 0 siblings, 1 reply; 20+ messages in thread From: Eric Blake @ 2017-07-12 15:47 UTC (permalink / raw) To: Kevin Wolf, qemu-block; +Cc: mreitz, jsnow, pbonzini, armbru, qemu-devel [-- Attachment #1: Type: text/plain, Size: 1056 bytes --] On 07/12/2017 07:57 AM, Kevin Wolf wrote: > Instead of listing only monitor-owned BlockBackends in query-block, also > add those anonymous BlockBackends that are owned by a qdev device and as > such under the control of the user. > > This allows to use query-block to inspect BlockBackends for the modern "allows to VERB" is not idiomatic; better is "allows VERBing" (as in "allows using query-block"); or "allows SUBJECT to VERB" (as in the verbose "allows the client to use query-block"). For your particular wording choice, it is also possible to do "allows the use of query-block", although that rewrite is not possible for all VERB. > configuration syntax with -blockdev and -device. > > Signed-off-by: Kevin Wolf <kwolf@redhat.com> > --- > block/qapi.c | 2 +- > hmp.c | 8 ++++---- > 2 files changed, 5 insertions(+), 5 deletions(-) > Reviewed-by: Eric Blake <eblake@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 604 bytes --] ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] [PATCH 5/9] block: List anonymous device BBs in query-block 2017-07-12 15:47 ` Eric Blake @ 2017-07-13 11:25 ` Kevin Wolf 0 siblings, 0 replies; 20+ messages in thread From: Kevin Wolf @ 2017-07-13 11:25 UTC (permalink / raw) To: Eric Blake; +Cc: qemu-block, mreitz, jsnow, pbonzini, armbru, qemu-devel [-- Attachment #1: Type: text/plain, Size: 750 bytes --] Am 12.07.2017 um 17:47 hat Eric Blake geschrieben: > On 07/12/2017 07:57 AM, Kevin Wolf wrote: > > Instead of listing only monitor-owned BlockBackends in query-block, also > > add those anonymous BlockBackends that are owned by a qdev device and as > > such under the control of the user. > > > > This allows to use query-block to inspect BlockBackends for the modern > > "allows to VERB" is not idiomatic; better is "allows VERBing" (as in > "allows using query-block"); or "allows SUBJECT to VERB" (as in the > verbose "allows the client to use query-block"). Is this inconsistency a known problem in English or should we file a new bug report against it? But as long as this isn't fixed yet, I'll apply your workaround. Kevin [-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 20+ messages in thread
* [Qemu-devel] [PATCH 6/9] ide: bdrv_attach_dev() for empty CD-ROM 2017-07-12 12:57 [Qemu-devel] [PATCH 0/9] block: -device drive=<node-name> fixes Kevin Wolf ` (4 preceding siblings ...) 2017-07-12 12:57 ` [Qemu-devel] [PATCH 5/9] block: List anonymous device BBs in query-block Kevin Wolf @ 2017-07-12 12:57 ` Kevin Wolf 2017-07-12 15:52 ` Eric Blake 2017-07-12 12:57 ` [Qemu-devel] [PATCH 7/9] scsi-disk: " Kevin Wolf ` (2 subsequent siblings) 8 siblings, 1 reply; 20+ messages in thread From: Kevin Wolf @ 2017-07-12 12:57 UTC (permalink / raw) To: qemu-block; +Cc: kwolf, mreitz, eblake, jsnow, pbonzini, armbru, qemu-devel If no drive=... option is passed (for an empty drive), we don't only lack the BlockBackend normally created by parse_drive(), but we also need to manually call blk_attach_dev(). IDE does not support hot unplug, but if it did, qdev would take care to call the matching blk_detach_dev() on unplug. This fixes at least the bug that such devices didn't show up in query-block, and probably some more problems. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- hw/ide/qdev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 299e592..cc2f5bd 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -164,6 +164,7 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind) IDEBus *bus = DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus); IDEState *s = bus->ifs + dev->unit; Error *err = NULL; + int ret; if (!dev->conf.blk) { if (kind != IDE_CD) { @@ -172,6 +173,8 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind) } else { /* Anonymous BlockBackend for an empty drive */ dev->conf.blk = blk_new(0, BLK_PERM_ALL); + ret = blk_attach_dev(dev->conf.blk, &dev->qdev); + assert(ret == 0); } } -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] [PATCH 6/9] ide: bdrv_attach_dev() for empty CD-ROM 2017-07-12 12:57 ` [Qemu-devel] [PATCH 6/9] ide: bdrv_attach_dev() for empty CD-ROM Kevin Wolf @ 2017-07-12 15:52 ` Eric Blake 0 siblings, 0 replies; 20+ messages in thread From: Eric Blake @ 2017-07-12 15:52 UTC (permalink / raw) To: Kevin Wolf, qemu-block; +Cc: mreitz, jsnow, pbonzini, armbru, qemu-devel [-- Attachment #1: Type: text/plain, Size: 778 bytes --] On 07/12/2017 07:57 AM, Kevin Wolf wrote: > If no drive=... option is passed (for an empty drive), we don't only > lack the BlockBackend normally created by parse_drive(), but we also > need to manually call blk_attach_dev(). > > IDE does not support hot unplug, but if it did, qdev would take care to > call the matching blk_detach_dev() on unplug. > > This fixes at least the bug that such devices didn't show up in > query-block, and probably some more problems. > > Signed-off-by: Kevin Wolf <kwolf@redhat.com> > --- > hw/ide/qdev.c | 3 +++ > 1 file changed, 3 insertions(+) Reviewed-by: Eric Blake <eblake@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 604 bytes --] ^ permalink raw reply [flat|nested] 20+ messages in thread
* [Qemu-devel] [PATCH 7/9] scsi-disk: bdrv_attach_dev() for empty CD-ROM 2017-07-12 12:57 [Qemu-devel] [PATCH 0/9] block: -device drive=<node-name> fixes Kevin Wolf ` (5 preceding siblings ...) 2017-07-12 12:57 ` [Qemu-devel] [PATCH 6/9] ide: bdrv_attach_dev() for empty CD-ROM Kevin Wolf @ 2017-07-12 12:57 ` Kevin Wolf 2017-07-12 15:58 ` Eric Blake 2017-07-12 12:57 ` [Qemu-devel] [PATCH 8/9] qemu-iotests: Test 'info block' Kevin Wolf 2017-07-12 12:57 ` [Qemu-devel] [PATCH 9/9] qemu-iotests: Test unplug of -device without drive Kevin Wolf 8 siblings, 1 reply; 20+ messages in thread From: Kevin Wolf @ 2017-07-12 12:57 UTC (permalink / raw) To: qemu-block; +Cc: kwolf, mreitz, eblake, jsnow, pbonzini, armbru, qemu-devel If no drive=... option is passed (for an empty drive), we don't only lack the BlockBackend normally created by parse_drive(), but we also need to manually call blk_attach_dev(). This fixes at least a segfault when unplugging such devices, the bug that they didn't show up in query-block, and probably some more problems. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- hw/scsi/scsi-disk.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index a53f058..5f1e5e8 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -2384,9 +2384,14 @@ static void scsi_hd_realize(SCSIDevice *dev, Error **errp) static void scsi_cd_realize(SCSIDevice *dev, Error **errp) { SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev); + int ret; if (!dev->conf.blk) { + /* Anonymous BlockBackend for an empty drive. As we put it into + * dev->conf, qdev takes care of detaching on unplug. */ dev->conf.blk = blk_new(0, BLK_PERM_ALL); + ret = blk_attach_dev(dev->conf.blk, &dev->qdev); + assert(ret == 0); } s->qdev.blocksize = 2048; -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] [PATCH 7/9] scsi-disk: bdrv_attach_dev() for empty CD-ROM 2017-07-12 12:57 ` [Qemu-devel] [PATCH 7/9] scsi-disk: " Kevin Wolf @ 2017-07-12 15:58 ` Eric Blake 0 siblings, 0 replies; 20+ messages in thread From: Eric Blake @ 2017-07-12 15:58 UTC (permalink / raw) To: Kevin Wolf, qemu-block; +Cc: mreitz, jsnow, pbonzini, armbru, qemu-devel [-- Attachment #1: Type: text/plain, Size: 698 bytes --] On 07/12/2017 07:57 AM, Kevin Wolf wrote: > If no drive=... option is passed (for an empty drive), we don't only > lack the BlockBackend normally created by parse_drive(), but we also > need to manually call blk_attach_dev(). > > This fixes at least a segfault when unplugging such devices, the bug > that they didn't show up in query-block, and probably some more > problems. > > Signed-off-by: Kevin Wolf <kwolf@redhat.com> > --- > hw/scsi/scsi-disk.c | 5 +++++ > 1 file changed, 5 insertions(+) > Reviewed-by: Eric Blake <eblake@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 604 bytes --] ^ permalink raw reply [flat|nested] 20+ messages in thread
* [Qemu-devel] [PATCH 8/9] qemu-iotests: Test 'info block' 2017-07-12 12:57 [Qemu-devel] [PATCH 0/9] block: -device drive=<node-name> fixes Kevin Wolf ` (6 preceding siblings ...) 2017-07-12 12:57 ` [Qemu-devel] [PATCH 7/9] scsi-disk: " Kevin Wolf @ 2017-07-12 12:57 ` Kevin Wolf 2017-07-12 16:22 ` Eric Blake 2017-07-12 12:57 ` [Qemu-devel] [PATCH 9/9] qemu-iotests: Test unplug of -device without drive Kevin Wolf 8 siblings, 1 reply; 20+ messages in thread From: Kevin Wolf @ 2017-07-12 12:57 UTC (permalink / raw) To: qemu-block; +Cc: kwolf, mreitz, eblake, jsnow, pbonzini, armbru, qemu-devel This test makes sure that all block devices show up on 'info block', with all of the expected information, in different configurations. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- tests/qemu-iotests/186 | 147 ++++++++++++++ tests/qemu-iotests/186.out | 489 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 637 insertions(+) create mode 100755 tests/qemu-iotests/186 create mode 100644 tests/qemu-iotests/186.out diff --git a/tests/qemu-iotests/186 b/tests/qemu-iotests/186 new file mode 100755 index 0000000..ab83ee4 --- /dev/null +++ b/tests/qemu-iotests/186 @@ -0,0 +1,147 @@ +#!/bin/bash +# +# Test 'info block' with all kinds of configurations +# +# Copyright (C) 2017 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +# creator +owner=kwolf@redhat.com + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt qcow2 +_supported_proto file +_supported_os Linux + +if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then + _notrun "Requires a PC machine" +fi + +function do_run_qemu() +{ + echo Testing: "$@" + + ( + if ! test -t 0; then + while read cmd; do + echo $cmd + done + fi + echo quit + ) | $QEMU -S -nodefaults -display none -device virtio-scsi-pci -monitor stdio "$@" + echo +} + +function check_info_block() +{ + echo "info block" | + QEMU_OPTIONS="" do_run_qemu "$@" | _filter_win32 | _filter_hmp | + _filter_qemu | _filter_generated_node_ids +} + + +size=64M +_make_test_img $size + +removable="floppy ide-cd scsi-cd" +fixed="ide-hd scsi-hd virtio-blk-pci" + +echo +echo "=== Empty drives ===" +echo + +for dev in $removable; do + check_info_block -device $dev + check_info_block -device $dev,id=qdev_id +done + +echo +echo "=== -blockdev/-device=<node-name> ===" +echo + +for dev in $fixed $removable; do + check_info_block -blockdev driver=null-co,node-name=null -device $dev,drive=null + check_info_block -blockdev driver=null-co,node-name=null -device $dev,drive=null,id=qdev_id +done + +echo +echo "=== -drive if=none/-device=<node-name> ===" +echo + +# This creates two BlockBackends that will show up in 'info block'! +# A monitor-owned one from -drive, and anonymous one from -device +for dev in $fixed $removable; do + check_info_block -drive if=none,driver=null-co,node-name=null -device $dev,drive=null,id=qdev_id +done + +echo +echo "=== -drive if=none/-device=<bb-name> (with medium) ===" +echo + +for dev in $fixed $removable; do + check_info_block -drive if=none,driver=null-co,node-name=null -device $dev,drive=none0 + check_info_block -drive if=none,driver=null-co,node-name=null -device $dev,drive=none0,id=qdev_id +done + +echo +echo "=== -drive if=none/-device=<bb-name> (without medium) ===" +echo + +check_info_block -drive if=none + +for dev in $removable; do + check_info_block -drive if=none -device $dev,drive=none0 + check_info_block -drive if=none -device $dev,drive=none0,id=qdev_id +done + +echo +echo "=== -drive if=... ===" +echo + +check_info_block -drive if=floppy +check_info_block -drive if=floppy,driver=null-co + +check_info_block -drive if=ide,driver=null-co +check_info_block -drive if=ide,media=cdrom +check_info_block -drive if=ide,driver=null-co,media=cdrom + +check_info_block -drive if=scsi,driver=null-co +check_info_block -drive if=scsi,media=cdrom +check_info_block -drive if=scsi,driver=null-co,media=cdrom + +check_info_block -drive if=virtio,driver=null-co + +check_info_block -drive if=pflash,driver=null-co,size=1M + +# success, all done +echo "*** done" +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/186.out b/tests/qemu-iotests/186.out new file mode 100644 index 0000000..3cf19be --- /dev/null +++ b/tests/qemu-iotests/186.out @@ -0,0 +1,489 @@ +QA output created by 186 +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 + +=== Empty drives === + +Testing: -device floppy +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +/machine/peripheral-anon/device[1]: [not inserted] + Attached to: /machine/peripheral-anon/device[1] + Removable device: not locked, tray closed +(qemu) quit + +Testing: -device floppy,id=qdev_id +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +qdev_id: [not inserted] + Attached to: qdev_id + Removable device: not locked, tray closed +(qemu) quit + +Testing: -device ide-cd +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +/machine/peripheral-anon/device[1]: [not inserted] + Attached to: /machine/peripheral-anon/device[1] + Removable device: not locked, tray closed +(qemu) quit + +Testing: -device ide-cd,id=qdev_id +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +qdev_id: [not inserted] + Attached to: qdev_id + Removable device: not locked, tray closed +(qemu) quit + +Testing: -device scsi-cd +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +/machine/peripheral-anon/device[1]: [not inserted] + Attached to: /machine/peripheral-anon/device[1] + Removable device: not locked, tray closed +(qemu) quit + +Testing: -device scsi-cd,id=qdev_id +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +qdev_id: [not inserted] + Attached to: qdev_id + Removable device: not locked, tray closed +(qemu) quit + + +=== -blockdev/-device=<node-name> === + +Testing: -blockdev driver=null-co,node-name=null -device ide-hd,drive=null +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +null: null-co:// (null-co) + Attached to: /machine/peripheral-anon/device[1] + Cache mode: writeback +(qemu) quit + +Testing: -blockdev driver=null-co,node-name=null -device ide-hd,drive=null,id=qdev_id +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +null: null-co:// (null-co) + Attached to: qdev_id + Cache mode: writeback +(qemu) quit + +Testing: -blockdev driver=null-co,node-name=null -device scsi-hd,drive=null +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +null: null-co:// (null-co) + Attached to: /machine/peripheral-anon/device[1] + Cache mode: writeback +(qemu) quit + +Testing: -blockdev driver=null-co,node-name=null -device scsi-hd,drive=null,id=qdev_id +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +null: null-co:// (null-co) + Attached to: qdev_id + Cache mode: writeback +(qemu) quit + +Testing: -blockdev driver=null-co,node-name=null -device virtio-blk-pci,drive=null +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +null: null-co:// (null-co) + Attached to: /machine/peripheral-anon/device[1]/virtio-backend + Cache mode: writeback +(qemu) quit + +Testing: -blockdev driver=null-co,node-name=null -device virtio-blk-pci,drive=null,id=qdev_id +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +null: null-co:// (null-co) + Attached to: /machine/peripheral/qdev_id/virtio-backend + Cache mode: writeback +(qemu) quit + +Testing: -blockdev driver=null-co,node-name=null -device floppy,drive=null +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +null: null-co:// (null-co) + Attached to: /machine/peripheral-anon/device[1] + Removable device: not locked, tray closed + Cache mode: writeback +(qemu) quit + +Testing: -blockdev driver=null-co,node-name=null -device floppy,drive=null,id=qdev_id +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +null: null-co:// (null-co) + Attached to: qdev_id + Removable device: not locked, tray closed + Cache mode: writeback +(qemu) quit + +Testing: -blockdev driver=null-co,node-name=null -device ide-cd,drive=null +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +null: null-co:// (null-co) + Attached to: /machine/peripheral-anon/device[1] + Removable device: not locked, tray closed + Cache mode: writeback +(qemu) quit + +Testing: -blockdev driver=null-co,node-name=null -device ide-cd,drive=null,id=qdev_id +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +null: null-co:// (null-co) + Attached to: qdev_id + Removable device: not locked, tray closed + Cache mode: writeback +(qemu) quit + +Testing: -blockdev driver=null-co,node-name=null -device scsi-cd,drive=null +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +null: null-co:// (null-co) + Attached to: /machine/peripheral-anon/device[1] + Removable device: not locked, tray closed + Cache mode: writeback +(qemu) quit + +Testing: -blockdev driver=null-co,node-name=null -device scsi-cd,drive=null,id=qdev_id +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +null: null-co:// (null-co) + Attached to: qdev_id + Removable device: not locked, tray closed + Cache mode: writeback +(qemu) quit + + +=== -drive if=none/-device=<node-name> === + +Testing: -drive if=none,driver=null-co,node-name=null -device ide-hd,drive=null,id=qdev_id +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0 (null): null-co:// (null-co) + Removable device: not locked, tray closed + Cache mode: writeback + +null: null-co:// (null-co) + Attached to: qdev_id + Cache mode: writeback +(qemu) quit + +Testing: -drive if=none,driver=null-co,node-name=null -device scsi-hd,drive=null,id=qdev_id +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0 (null): null-co:// (null-co) + Removable device: not locked, tray closed + Cache mode: writeback + +null: null-co:// (null-co) + Attached to: qdev_id + Cache mode: writeback +(qemu) quit + +Testing: -drive if=none,driver=null-co,node-name=null -device virtio-blk-pci,drive=null,id=qdev_id +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0 (null): null-co:// (null-co) + Removable device: not locked, tray closed + Cache mode: writeback + +null: null-co:// (null-co) + Attached to: /machine/peripheral/qdev_id/virtio-backend + Cache mode: writeback +(qemu) quit + +Testing: -drive if=none,driver=null-co,node-name=null -device floppy,drive=null,id=qdev_id +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0 (null): null-co:// (null-co) + Removable device: not locked, tray closed + Cache mode: writeback + +null: null-co:// (null-co) + Attached to: qdev_id + Removable device: not locked, tray closed + Cache mode: writeback +(qemu) quit + +Testing: -drive if=none,driver=null-co,node-name=null -device ide-cd,drive=null,id=qdev_id +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0 (null): null-co:// (null-co) + Removable device: not locked, tray closed + Cache mode: writeback + +null: null-co:// (null-co) + Attached to: qdev_id + Removable device: not locked, tray closed + Cache mode: writeback +(qemu) quit + +Testing: -drive if=none,driver=null-co,node-name=null -device scsi-cd,drive=null,id=qdev_id +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0 (null): null-co:// (null-co) + Removable device: not locked, tray closed + Cache mode: writeback + +null: null-co:// (null-co) + Attached to: qdev_id + Removable device: not locked, tray closed + Cache mode: writeback +(qemu) quit + + +=== -drive if=none/-device=<bb-name> (with medium) === + +Testing: -drive if=none,driver=null-co,node-name=null -device ide-hd,drive=none0 +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0 (null): null-co:// (null-co) + Attached to: /machine/peripheral-anon/device[1] + Cache mode: writeback +(qemu) quit + +Testing: -drive if=none,driver=null-co,node-name=null -device ide-hd,drive=none0,id=qdev_id +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0 (null): null-co:// (null-co) + Attached to: qdev_id + Cache mode: writeback +(qemu) quit + +Testing: -drive if=none,driver=null-co,node-name=null -device scsi-hd,drive=none0 +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0 (null): null-co:// (null-co) + Attached to: /machine/peripheral-anon/device[1] + Cache mode: writeback +(qemu) quit + +Testing: -drive if=none,driver=null-co,node-name=null -device scsi-hd,drive=none0,id=qdev_id +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0 (null): null-co:// (null-co) + Attached to: qdev_id + Cache mode: writeback +(qemu) quit + +Testing: -drive if=none,driver=null-co,node-name=null -device virtio-blk-pci,drive=none0 +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0 (null): null-co:// (null-co) + Attached to: /machine/peripheral-anon/device[1]/virtio-backend + Cache mode: writeback +(qemu) quit + +Testing: -drive if=none,driver=null-co,node-name=null -device virtio-blk-pci,drive=none0,id=qdev_id +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0 (null): null-co:// (null-co) + Attached to: /machine/peripheral/qdev_id/virtio-backend + Cache mode: writeback +(qemu) quit + +Testing: -drive if=none,driver=null-co,node-name=null -device floppy,drive=none0 +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0 (null): null-co:// (null-co) + Attached to: /machine/peripheral-anon/device[1] + Removable device: not locked, tray closed + Cache mode: writeback +(qemu) quit + +Testing: -drive if=none,driver=null-co,node-name=null -device floppy,drive=none0,id=qdev_id +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0 (null): null-co:// (null-co) + Attached to: qdev_id + Removable device: not locked, tray closed + Cache mode: writeback +(qemu) quit + +Testing: -drive if=none,driver=null-co,node-name=null -device ide-cd,drive=none0 +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0 (null): null-co:// (null-co) + Attached to: /machine/peripheral-anon/device[1] + Removable device: not locked, tray closed + Cache mode: writeback +(qemu) quit + +Testing: -drive if=none,driver=null-co,node-name=null -device ide-cd,drive=none0,id=qdev_id +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0 (null): null-co:// (null-co) + Attached to: qdev_id + Removable device: not locked, tray closed + Cache mode: writeback +(qemu) quit + +Testing: -drive if=none,driver=null-co,node-name=null -device scsi-cd,drive=none0 +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0 (null): null-co:// (null-co) + Attached to: /machine/peripheral-anon/device[1] + Removable device: not locked, tray closed + Cache mode: writeback +(qemu) quit + +Testing: -drive if=none,driver=null-co,node-name=null -device scsi-cd,drive=none0,id=qdev_id +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0 (null): null-co:// (null-co) + Attached to: qdev_id + Removable device: not locked, tray closed + Cache mode: writeback +(qemu) quit + + +=== -drive if=none/-device=<bb-name> (without medium) === + +Testing: -drive if=none +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0: [not inserted] + Removable device: not locked, tray closed +(qemu) quit + +Testing: -drive if=none -device floppy,drive=none0 +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0: [not inserted] + Attached to: /machine/peripheral-anon/device[1] + Removable device: not locked, tray closed +(qemu) quit + +Testing: -drive if=none -device floppy,drive=none0,id=qdev_id +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0: [not inserted] + Attached to: qdev_id + Removable device: not locked, tray closed +(qemu) quit + +Testing: -drive if=none -device ide-cd,drive=none0 +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0: [not inserted] + Attached to: /machine/peripheral-anon/device[1] + Removable device: not locked, tray closed +(qemu) quit + +Testing: -drive if=none -device ide-cd,drive=none0,id=qdev_id +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0: [not inserted] + Attached to: qdev_id + Removable device: not locked, tray closed +(qemu) quit + +Testing: -drive if=none -device scsi-cd,drive=none0 +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0: [not inserted] + Attached to: /machine/peripheral-anon/device[1] + Removable device: not locked, tray closed +(qemu) quit + +Testing: -drive if=none -device scsi-cd,drive=none0,id=qdev_id +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +none0: [not inserted] + Attached to: qdev_id + Removable device: not locked, tray closed +(qemu) quit + + +=== -drive if=... === + +Testing: -drive if=floppy +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +floppy0: [not inserted] + Attached to: /machine/unattached/device[17] + Removable device: not locked, tray closed +(qemu) quit + +Testing: -drive if=floppy,driver=null-co +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +floppy0 (NODE_NAME): null-co:// (null-co) + Attached to: /machine/unattached/device[17] + Removable device: not locked, tray closed + Cache mode: writeback +(qemu) quit + +Testing: -drive if=ide,driver=null-co +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +ide0-hd0 (NODE_NAME): null-co:// (null-co) + Attached to: /machine/unattached/device[18] + Cache mode: writeback +(qemu) quit + +Testing: -drive if=ide,media=cdrom +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +ide0-cd0: [not inserted] + Attached to: /machine/unattached/device[18] + Removable device: not locked, tray closed +(qemu) quit + +Testing: -drive if=ide,driver=null-co,media=cdrom +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +ide0-cd0 (NODE_NAME): null-co:// (null-co, read-only) + Attached to: /machine/unattached/device[18] + Removable device: not locked, tray closed + Cache mode: writeback +(qemu) quit + +qemu: -drive if=scsi,driver=null-co: warning: bus=0,unit=0 is deprecated with this machine type +Testing: -drive if=scsi,driver=null-co +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +scsi0-hd0 (NODE_NAME): null-co:// (null-co) + Attached to: /machine/unattached/device[27]/scsi.0/legacy[0] + Cache mode: writeback +(qemu) quit + +qemu: -drive if=scsi,media=cdrom: warning: bus=0,unit=0 is deprecated with this machine type +Testing: -drive if=scsi,media=cdrom +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +scsi0-cd0: [not inserted] + Attached to: /machine/unattached/device[27]/scsi.0/legacy[0] + Removable device: not locked, tray closed +(qemu) quit + +qemu: -drive if=scsi,driver=null-co,media=cdrom: warning: bus=0,unit=0 is deprecated with this machine type +Testing: -drive if=scsi,driver=null-co,media=cdrom +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +scsi0-cd0 (NODE_NAME): null-co:// (null-co, read-only) + Attached to: /machine/unattached/device[27]/scsi.0/legacy[0] + Removable device: not locked, tray closed + Cache mode: writeback +(qemu) quit + +Testing: -drive if=virtio,driver=null-co +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +virtio0 (NODE_NAME): null-co:// (null-co) + Attached to: /machine/peripheral-anon/device[1]/virtio-backend + Cache mode: writeback +(qemu) quit + +Testing: -drive if=pflash,driver=null-co,size=1M +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +pflash0 (NODE_NAME): json:{"driver": "null-co", "size": "1M"} (null-co) + Attached to: /machine/unattached/device[2] + Cache mode: writeback +(qemu) quit + +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 318ae74..a6c7e1f 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -176,3 +176,4 @@ 182 rw auto quick 183 rw auto migration 185 rw auto +186 rw auto -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] [PATCH 8/9] qemu-iotests: Test 'info block' 2017-07-12 12:57 ` [Qemu-devel] [PATCH 8/9] qemu-iotests: Test 'info block' Kevin Wolf @ 2017-07-12 16:22 ` Eric Blake 0 siblings, 0 replies; 20+ messages in thread From: Eric Blake @ 2017-07-12 16:22 UTC (permalink / raw) To: Kevin Wolf, qemu-block; +Cc: mreitz, jsnow, pbonzini, armbru, qemu-devel [-- Attachment #1: Type: text/plain, Size: 734 bytes --] On 07/12/2017 07:57 AM, Kevin Wolf wrote: > This test makes sure that all block devices show up on 'info block', > with all of the expected information, in different configurations. > > Signed-off-by: Kevin Wolf <kwolf@redhat.com> > --- > tests/qemu-iotests/186 | 147 ++++++++++++++ > tests/qemu-iotests/186.out | 489 +++++++++++++++++++++++++++++++++++++++++++++ > tests/qemu-iotests/group | 1 + > 3 files changed, 637 insertions(+) > create mode 100755 tests/qemu-iotests/186 > create mode 100644 tests/qemu-iotests/186.out > Reviewed-by: Eric Blake <eblake@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 604 bytes --] ^ permalink raw reply [flat|nested] 20+ messages in thread
* [Qemu-devel] [PATCH 9/9] qemu-iotests: Test unplug of -device without drive 2017-07-12 12:57 [Qemu-devel] [PATCH 0/9] block: -device drive=<node-name> fixes Kevin Wolf ` (7 preceding siblings ...) 2017-07-12 12:57 ` [Qemu-devel] [PATCH 8/9] qemu-iotests: Test 'info block' Kevin Wolf @ 2017-07-12 12:57 ` Kevin Wolf 2017-07-12 16:23 ` Eric Blake 8 siblings, 1 reply; 20+ messages in thread From: Kevin Wolf @ 2017-07-12 12:57 UTC (permalink / raw) To: qemu-block; +Cc: kwolf, mreitz, eblake, jsnow, pbonzini, armbru, qemu-devel This caused an assertion failure until recently because the BlockBackend would be detached on unplug, but was in fact never attached in the first place. Add a regression test. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- tests/qemu-iotests/067 | 13 +++++++++++++ tests/qemu-iotests/067.out | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/tests/qemu-iotests/067 b/tests/qemu-iotests/067 index 38d23fc..5d4ca4b 100755 --- a/tests/qemu-iotests/067 +++ b/tests/qemu-iotests/067 @@ -137,6 +137,19 @@ run_qemu <<EOF { "execute": "quit" } EOF +echo +echo === Empty drive with -device and device_del === +echo + +run_qemu -device virtio-scsi-pci -device scsi-cd,id=cd0 <<EOF +{ "execute": "qmp_capabilities" } +{ "execute": "query-block" } +{ "execute": "device_del", "arguments": { "id": "cd0" } } +{ "execute": "system_reset" } +{ "execute": "query-block" } +{ "execute": "quit" } +EOF + # success, all done echo "*** done" rm -f $seq.full diff --git a/tests/qemu-iotests/067.out b/tests/qemu-iotests/067.out index e3c4496..bd70557 100644 --- a/tests/qemu-iotests/067.out +++ b/tests/qemu-iotests/067.out @@ -416,4 +416,43 @@ Testing: "return": { } } + +=== Empty drive with -device and device_del === + +Testing: -device virtio-scsi-pci -device scsi-cd,id=cd0 +{ + QMP_VERSION +} +{ + "return": { + } +} +{ + "return": [ + { + "device": "", + "locked": false, + "removable": true, + "qdev": "cd0", + "tray_open": false, + "type": "unknown" + } + ] +} +{ + "return": { + } +} +{ + "return": { + } +} +{ + "return": [ + ] +} +{ + "return": { + } +} *** done -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] [PATCH 9/9] qemu-iotests: Test unplug of -device without drive 2017-07-12 12:57 ` [Qemu-devel] [PATCH 9/9] qemu-iotests: Test unplug of -device without drive Kevin Wolf @ 2017-07-12 16:23 ` Eric Blake 0 siblings, 0 replies; 20+ messages in thread From: Eric Blake @ 2017-07-12 16:23 UTC (permalink / raw) To: Kevin Wolf, qemu-block; +Cc: mreitz, jsnow, pbonzini, armbru, qemu-devel [-- Attachment #1: Type: text/plain, Size: 634 bytes --] On 07/12/2017 07:57 AM, Kevin Wolf wrote: > This caused an assertion failure until recently because the BlockBackend > would be detached on unplug, but was in fact never attached in the first > place. Add a regression test. > > Signed-off-by: Kevin Wolf <kwolf@redhat.com> > --- > tests/qemu-iotests/067 | 13 +++++++++++++ > tests/qemu-iotests/067.out | 39 +++++++++++++++++++++++++++++++++++++++ > 2 files changed, 52 insertions(+) > Reviewed-by: Eric Blake <eblake@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 604 bytes --] ^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2017-07-13 11:25 UTC | newest] Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-07-12 12:57 [Qemu-devel] [PATCH 0/9] block: -device drive=<node-name> fixes Kevin Wolf 2017-07-12 12:57 ` [Qemu-devel] [PATCH 1/9] block: Make blk_get_attached_dev_id() public Kevin Wolf 2017-07-12 14:53 ` Eric Blake 2017-07-12 12:57 ` [Qemu-devel] [PATCH 2/9] block/qapi: Add qdev device name to query-block Kevin Wolf 2017-07-12 15:06 ` Eric Blake 2017-07-12 12:57 ` [Qemu-devel] [PATCH 3/9] block: Make blk_all_next() public Kevin Wolf 2017-07-12 15:25 ` Eric Blake 2017-07-12 12:57 ` [Qemu-devel] [PATCH 4/9] block/qapi: Use blk_all_next() for query-block Kevin Wolf 2017-07-12 15:27 ` Eric Blake 2017-07-12 12:57 ` [Qemu-devel] [PATCH 5/9] block: List anonymous device BBs in query-block Kevin Wolf 2017-07-12 15:47 ` Eric Blake 2017-07-13 11:25 ` Kevin Wolf 2017-07-12 12:57 ` [Qemu-devel] [PATCH 6/9] ide: bdrv_attach_dev() for empty CD-ROM Kevin Wolf 2017-07-12 15:52 ` Eric Blake 2017-07-12 12:57 ` [Qemu-devel] [PATCH 7/9] scsi-disk: " Kevin Wolf 2017-07-12 15:58 ` Eric Blake 2017-07-12 12:57 ` [Qemu-devel] [PATCH 8/9] qemu-iotests: Test 'info block' Kevin Wolf 2017-07-12 16:22 ` Eric Blake 2017-07-12 12:57 ` [Qemu-devel] [PATCH 9/9] qemu-iotests: Test unplug of -device without drive Kevin Wolf 2017-07-12 16:23 ` Eric Blake
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.