Patchwork [RFC,12/24] qed: add bdrv_qed_copy_header()

login
register
mail settings
Submitter Devin Nakamura
Date July 29, 2011, 4:49 a.m.
Message ID <1311914994-20482-13-git-send-email-devin122@gmail.com>
Download mbox | patch
Permalink /patch/107351/
State New
Headers show

Comments

Devin Nakamura - July 29, 2011, 4:49 a.m.
Signed-off-by: Devin Nakamura <devin122@gmail.com>
---
 block/qed.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

Patch

diff --git a/block/qed.c b/block/qed.c
index b05224a..556512b 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -1579,6 +1579,21 @@  static int bdrv_qed_map(BlockDriverState *bs, uint64_t guest_offset,
     return 0;
 }
 
+static int bdrv_qed_copy_header(BlockDriverState *bs)
+{
+    BlockDriverState *backup;
+    uint8_t buffer[512];
+    /*TODO: change filename*/
+    bdrv_create_file("headerbackup.temp", NULL);
+    bdrv_file_open(&backup, "headerbackup.temp", BDRV_O_RDWR);
+    bdrv_read(bs->file, 0, buffer, 1); /*TODO: check return code*/
+    bdrv_write(backup, 0, buffer, 1); /*TODO: check return code*/
+    bdrv_close(backup);
+
+    qed_write_header_sync(bs->opaque);
+    return 0;
+}
+
 static QEMUOptionParameter qed_create_options[] = {
     {
         .name = BLOCK_OPT_SIZE,
@@ -1628,6 +1643,7 @@  static BlockDriver bdrv_qed = {
     .bdrv_open_conversion_target = bdrv_qed_open_conversion_target,
     .bdrv_get_mapping            = bdrv_qed_get_mapping,
     .bdrv_map                    = bdrv_qed_map,
+    .bdrv_copy_header            = bdrv_qed_copy_header,
 };
 
 static void bdrv_qed_init(void)