[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC V8 13/13] quorum: Add quorum_open() and quorum_close()
From: |
Benoît Canet |
Subject: |
[Qemu-devel] [RFC V8 13/13] quorum: Add quorum_open() and quorum_close(). |
Date: |
Mon, 28 Jan 2013 18:07:25 +0100 |
Valid quorum resources look like
quorum:threshold/total:path/to/image_1: ... :path/to/image_total
':' is used as a separator
'\' is the escaping character for filename containing ':'
'\' escape itself
',' must be escaped with ','
On the command line for quorum files "img:test.raw", "img2,raw"
and "img3.raw" invocation look like:
-drive file=quorum:2/3:img\\:test.raw:img2,,raw:img3.raw
(note the double \\ and the double ,,)
Signed-off-by: Benoit Canet <address@hidden>
---
block/quorum.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
diff --git a/block/quorum.c b/block/quorum.c
index 4d86c32..cf9fd22 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -814,12 +814,77 @@ static int quorum_snapshot_reopen(BlockDriverState *bs,
int bdrv_flags,
return ret;
}
+/* Valid quorum resources look like
+ * quorum:threshold/total:path/to/image_1: ... :path/to/image_total
+ *
+ * ':' is used as a separator
+ * '\' is the escaping character for filename containing ':'
+ */
+static int quorum_open(BlockDriverState *bs, const char *filename, int flags)
+{
+ BDRVQuorumState *s = bs->opaque;
+ Error *local_err = NULL;
+ int ret = 0;
+ int i;
+
+ ret = quorum_parse_url(s, filename, &local_err);
+ if (ret < 0) {
+ goto exit;
+ }
+
+ ret = quorum_validate_url(s, ret, &local_err);
+ if (ret < 0) {
+ goto free_exit;
+ }
+
+ /* Open files */
+ for (i = 0; i < s->total; i++) {
+ s->bs[i] = bdrv_new("");
+ ret = bdrv_open(s->bs[i], s->filenames[i], flags, NULL);
+ if (ret < 0) {
+ goto error_exit;
+ }
+ }
+
+ goto exit;
+
+error_exit:
+ for (; i >= 0; i--) {
+ bdrv_delete(s->bs[i]);
+ s->bs[i] = NULL;
+ }
+free_exit:
+ quorum_free(s);
+exit:
+ if (error_is_set(&local_err)) {
+ qerror_report_err(local_err);
+ }
+ return ret;
+}
+
+static void quorum_close(BlockDriverState *bs)
+{
+ BDRVQuorumState *s = bs->opaque;
+ int i;
+
+ for (i = 0; i < s->total; i++) {
+ /* Ensure writes reach stable storage */
+ bdrv_flush(s->bs[i]);
+ bdrv_delete(s->bs[i]);
+ }
+
+ quorum_free(s);
+}
+
static BlockDriver bdrv_quorum = {
.format_name = "quorum",
.protocol_name = "quorum",
.instance_size = sizeof(BDRVQuorumState),
+ .bdrv_file_open = quorum_open,
+ .bdrv_close = quorum_close,
+
.bdrv_co_flush_to_disk = quorum_co_flush,
.bdrv_getlength = quorum_getlength,
--
1.7.10.4
- [Qemu-devel] [RFC V8 03/13] quorum: Add quorum_aio_writev and its dependencies., (continued)
- [Qemu-devel] [RFC V8 03/13] quorum: Add quorum_aio_writev and its dependencies., Benoît Canet, 2013/01/28
- [Qemu-devel] [RFC V8 05/13] quorum: Add quorum_aio_readv., Benoît Canet, 2013/01/28
- [Qemu-devel] [RFC V8 04/13] blkverify: Extract qemu_iovec_clone() and qemu_iovec_compare() from blkverify., Benoît Canet, 2013/01/28
- [Qemu-devel] [RFC V8 06/13] quorum: Add quorum mechanism., Benoît Canet, 2013/01/28
- [Qemu-devel] [RFC V8 09/13] quorum: Add quorum_co_is_allocated., Benoît Canet, 2013/01/28
- [Qemu-devel] [RFC V8 08/13] quorum: Add quorum_invalidate_cache()., Benoît Canet, 2013/01/28
- [Qemu-devel] [RFC V8 10/13] quorum: Add quorum_co_flush()., Benoît Canet, 2013/01/28
- [Qemu-devel] [RFC V8 11/13] quorum: Add quorum_snapshot_img_create., Benoît Canet, 2013/01/28
- [Qemu-devel] [RFC V8 07/13] quorum: Add quorum_getlength()., Benoît Canet, 2013/01/28
- [Qemu-devel] [RFC V8 12/13] quorum: Add quorum_snapshot_reopen., Benoît Canet, 2013/01/28
- [Qemu-devel] [RFC V8 13/13] quorum: Add quorum_open() and quorum_close().,
Benoît Canet <=