summaryrefslogtreecommitdiff
path: root/block/qapi.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2014-10-07 13:59:23 +0200
committerKevin Wolf <kwolf@redhat.com>2014-10-20 14:03:50 +0200
commitd829a2115f0817993e2b683601cb544a27980a8f (patch)
tree083f268c445c9d4a6473e79a3e964bb45ded9c06 /block/qapi.c
parent26f8b3a84750546342d4397f86efb1ea7798d5dd (diff)
downloadqemu-d829a2115f0817993e2b683601cb544a27980a8f.tar.gz
qemu-d829a2115f0817993e2b683601cb544a27980a8f.tar.bz2
qemu-d829a2115f0817993e2b683601cb544a27980a8f.zip
block/qapi: Convert qmp_query_block() to BlockBackend
Much more command code needs conversion. I start with this one because it's using bdrv_dev_* functions, which I'm about to lift into BlockBackend. While there, give bdrv_query_info() internal linkage. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: BenoƮt Canet <benoit.canet@nodalink.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/qapi.c')
-rw-r--r--block/qapi.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/block/qapi.c b/block/qapi.c
index d071ee564e..fca981d94e 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -28,6 +28,7 @@
#include "qapi-visit.h"
#include "qapi/qmp-output-visitor.h"
#include "qapi/qmp/types.h"
+#include "sysemu/block-backend.h"
#ifdef __linux__
#include <linux/fs.h>
#include <sys/ioctl.h>
@@ -264,15 +265,15 @@ void bdrv_query_image_info(BlockDriverState *bs,
}
/* @p_info will be set only on success. */
-void bdrv_query_info(BlockDriverState *bs,
- BlockInfo **p_info,
- Error **errp)
+static void bdrv_query_info(BlockBackend *blk, BlockInfo **p_info,
+ Error **errp)
{
BlockInfo *info = g_malloc0(sizeof(*info));
+ BlockDriverState *bs = blk_bs(blk);
BlockDriverState *bs0;
ImageInfo **p_image_info;
Error *local_err = NULL;
- info->device = g_strdup(bdrv_get_device_name(bs));
+ info->device = g_strdup(blk_name(blk));
info->type = g_strdup("unknown");
info->locked = bdrv_dev_is_medium_locked(bs);
info->removable = bdrv_dev_has_removable_media(bs);
@@ -360,12 +361,12 @@ static BlockStats *bdrv_query_stats(const BlockDriverState *bs)
BlockInfoList *qmp_query_block(Error **errp)
{
BlockInfoList *head = NULL, **p_next = &head;
- BlockDriverState *bs = NULL;
+ BlockBackend *blk;
Error *local_err = NULL;
- while ((bs = bdrv_next(bs))) {
+ for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {
BlockInfoList *info = g_malloc0(sizeof(*info));
- bdrv_query_info(bs, &info->value, &local_err);
+ bdrv_query_info(blk, &info->value, &local_err);
if (local_err) {
error_propagate(errp, local_err);
goto err;