diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2014-12-11 12:36:32 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2014-12-11 12:36:32 +0000 |
commit | 7c3843332db39c2f27405b882a505144d62b3664 (patch) | |
tree | daac220f4cb19a2fec8457c00f2c4aeae1092824 /block/qapi.c | |
parent | a09f2d16f6b9f5bcdedb4d116bb54da86e9a3f6e (diff) | |
parent | d899d2e248b900c53dd9081bde9f110e05747433 (diff) |
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Block patches for 2.3
# gpg: Signature made Wed 10 Dec 2014 09:31:53 GMT using RSA key ID C88F2FD6
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>"
* remotes/kevin/tags/for-upstream: (73 commits)
vmdk: Set errp on failures in vmdk_open_vmdk4
vmdk: Remove unnecessary initialization
vmdk: Check descriptor file length when reading it
vmdk: Clean up descriptor file reading
vmdk: Fix comment to match code of extent lines
vmdk: Use g_random_int to generate CID
block: Use g_new0() for a bit of extra type checking
block: remove BLOCK_OPT_NOCOW from vpc_create_opts
block: remove BLOCK_OPT_NOCOW from vdi_create_opts
qemu-iotests: Skip 099 for VMDK subformats with desc file
block/raw-posix: Fix ret in raw_open_common()
qcow2: Respect bdrv_truncate() error
qcow2: Flushing the caches in qcow2_close may fail
qcow2: Prevent numerical overflow
iotests: Add test for unsupported image creation
iotests: Only kill NBD server if it runs
qemu-img: Check create_opts before image amendment
qemu-img: Check create_opts before image creation
block: Check create_opts before image creation
block/nfs: Add create_opts
...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'block/qapi.c')
-rw-r--r-- | block/qapi.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/block/qapi.c b/block/qapi.c index a87a34a8b..fa68ba731 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -40,6 +40,13 @@ BlockDeviceInfo *bdrv_block_device_info(BlockDriverState *bs) info->encrypted = bs->encrypted; info->encryption_key_missing = bdrv_key_required(bs); + info->cache = g_new(BlockdevCacheInfo, 1); + *info->cache = (BlockdevCacheInfo) { + .writeback = bdrv_enable_write_cache(bs), + .direct = !!(bs->open_flags & BDRV_O_NOCACHE), + .no_flush = !!(bs->open_flags & BDRV_O_NO_FLUSH), + }; + if (bs->node_name[0]) { info->has_node_name = true; info->node_name = g_strdup(bs->node_name); @@ -300,7 +307,8 @@ static void bdrv_query_info(BlockBackend *blk, BlockInfo **p_info, qapi_free_BlockInfo(info); } -static BlockStats *bdrv_query_stats(const BlockDriverState *bs) +static BlockStats *bdrv_query_stats(const BlockDriverState *bs, + bool query_backing) { BlockStats *s; @@ -311,6 +319,11 @@ static BlockStats *bdrv_query_stats(const BlockDriverState *bs) s->device = g_strdup(bdrv_get_device_name(bs)); } + if (bdrv_get_node_name(bs)[0]) { + s->has_node_name = true; + s->node_name = g_strdup(bdrv_get_node_name(bs)); + } + s->stats = g_malloc0(sizeof(*s->stats)); s->stats->rd_bytes = bs->stats.nr_bytes[BLOCK_ACCT_READ]; s->stats->wr_bytes = bs->stats.nr_bytes[BLOCK_ACCT_WRITE]; @@ -325,12 +338,12 @@ static BlockStats *bdrv_query_stats(const BlockDriverState *bs) if (bs->file) { s->has_parent = true; - s->parent = bdrv_query_stats(bs->file); + s->parent = bdrv_query_stats(bs->file, query_backing); } - if (bs->backing_hd) { + if (query_backing && bs->backing_hd) { s->has_backing = true; - s->backing = bdrv_query_stats(bs->backing_hd); + s->backing = bdrv_query_stats(bs->backing_hd, query_backing); } return s; @@ -361,17 +374,22 @@ BlockInfoList *qmp_query_block(Error **errp) return NULL; } -BlockStatsList *qmp_query_blockstats(Error **errp) +BlockStatsList *qmp_query_blockstats(bool has_query_nodes, + bool query_nodes, + Error **errp) { BlockStatsList *head = NULL, **p_next = &head; BlockDriverState *bs = NULL; - while ((bs = bdrv_next(bs))) { + /* Just to be safe if query_nodes is not always initialized */ + query_nodes = has_query_nodes && query_nodes; + + while ((bs = query_nodes ? bdrv_next_node(bs) : bdrv_next(bs))) { BlockStatsList *info = g_malloc0(sizeof(*info)); AioContext *ctx = bdrv_get_aio_context(bs); aio_context_acquire(ctx); - info->value = bdrv_query_stats(bs); + info->value = bdrv_query_stats(bs, !query_nodes); aio_context_release(ctx); *p_next = info; |