Patchwork [RFC,06/12] qorum: Add qorum_getlength().

login
register
mail settings
Submitter Benoit Canet
Date Aug. 2, 2012, 10:16 a.m.
Message ID <1343902604-13981-7-git-send-email-benoit@irqsave.net>
Download mbox | patch
Permalink /patch/174726/
State New
Headers show

Comments

Benoit Canet - Aug. 2, 2012, 10:16 a.m.
Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 block/qorum.c |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Patch

diff --git a/block/qorum.c b/block/qorum.c
index 006ab8c..37f6514 100644
--- a/block/qorum.c
+++ b/block/qorum.c
@@ -119,12 +119,29 @@  static void qorum_close(BlockDriverState *bs)
     }
 }
 
+static int64_t qorum_getlength(BlockDriverState *bs)
+{
+    BDRVQorumState *s = bs->opaque;
+    int i;
+    int64_t ret;
+
+    /* return the length of the first available qorum file */
+    for (i = 0, ret = bdrv_getlength(s->bs[i]);
+         ret == -ENOMEDIUM && i <= 2;
+         i++, ret = bdrv_getlength(s->bs[i])) {
+    }
+
+    return ret;
+}
+
 static BlockDriver bdrv_qorum = {
     .format_name        = "qorum",
     .protocol_name      = "qorum",
 
     .instance_size      = sizeof(BDRVQorumState),
 
+    .bdrv_getlength     = qorum_getlength,
+
     .bdrv_file_open     = qorum_open,
     .bdrv_close         = qorum_close,
 };