From: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, Dong Xu Wang <wdongxu@linux.vnet.ibm.com>,
stefanha@linux.vnet.ibm.com
Subject: [Qemu-devel] [PATCH 1/2 v2] block: add dirty flag status to qemu-img
Date: Thu, 12 Jan 2012 16:56:01 +0800 [thread overview]
Message-ID: <1326358562-20525-1-git-send-email-wdongxu@linux.vnet.ibm.com> (raw)
From: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Some block drivers can verify their image files are clean or not. So we can show
it while using "qemu-img info.
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
Changes from v1:
1. rename bdrv_is_dirty to bdrv_not_cleanly_down, and change its return value
from int to bool.
2. Change description from "dirty,need check: yes" to "cleanly shut down: no"
block.c | 14 ++++++++++++++
block.h | 2 ++
block_int.h | 1 +
qemu-img.c | 3 +++
4 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/block.c b/block.c
index 3f072f6..0718466 100644
--- a/block.c
+++ b/block.c
@@ -186,6 +186,20 @@ static void bdrv_io_limits_intercept(BlockDriverState *bs,
qemu_co_queue_next(&bs->throttled_reqs);
}
+/* check if the image was cleanly shut down */
+bool bdrv_not_cleanly_down(BlockDriverState *bs)
+{
+ BlockDriver *drv = bs->drv;
+
+ if (!drv) {
+ return 0;
+ }
+ if (!drv->bdrv_not_cleanly_down) {
+ return 0;
+ }
+ return drv->bdrv_not_cleanly_down(bs);
+}
+
/* check if the path starts with "<protocol>:" */
static int path_has_protocol(const char *path)
{
diff --git a/block.h b/block.h
index 3bd4398..72cf744 100644
--- a/block.h
+++ b/block.h
@@ -104,6 +104,8 @@ void bdrv_io_limits_enable(BlockDriverState *bs);
void bdrv_io_limits_disable(BlockDriverState *bs);
bool bdrv_io_limits_enabled(BlockDriverState *bs);
+bool bdrv_not_cleanly_down(BlockDriverState *bs);
+
void bdrv_init(void);
void bdrv_init_with_whitelist(void);
BlockDriver *bdrv_find_protocol(const char *filename);
diff --git a/block_int.h b/block_int.h
index 311bd2a..f5168f6 100644
--- a/block_int.h
+++ b/block_int.h
@@ -84,6 +84,7 @@ struct BlockDriver {
int (*bdrv_create)(const char *filename, QEMUOptionParameter *options);
int (*bdrv_set_key)(BlockDriverState *bs, const char *key);
int (*bdrv_make_empty)(BlockDriverState *bs);
+ bool (*bdrv_not_cleanly_down)(BlockDriverState *bs);
/* aio */
BlockDriverAIOCB *(*bdrv_aio_readv)(BlockDriverState *bs,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
diff --git a/qemu-img.c b/qemu-img.c
index 01cc0d3..d19cae1 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1153,6 +1153,9 @@ static int img_info(int argc, char **argv)
if (bdrv_is_encrypted(bs)) {
printf("encrypted: yes\n");
}
+ if (bdrv_not_cleanly_down(bs)) {
+ printf("cleanly shut down: no\n");
+ }
if (bdrv_get_info(bs, &bdi) >= 0) {
if (bdi.cluster_size != 0) {
printf("cluster_size: %d\n", bdi.cluster_size);
--
1.7.5.4
next reply other threads:[~2012-01-12 8:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-12 8:56 Dong Xu Wang [this message]
2012-01-12 8:56 ` [Qemu-devel] [PATCH 2/2 v2] block: track dirty flag status in qed Dong Xu Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1326358562-20525-1-git-send-email-wdongxu@linux.vnet.ibm.com \
--to=wdongxu@linux.vnet.ibm.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).