qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [patch 1/5] block: add bdrv_find_backing_image


From: Marcelo Tosatti
Subject: [Qemu-devel] [patch 1/5] block: add bdrv_find_backing_image
Date: Fri, 30 Dec 2011 08:03:38 -0200
User-agent: quilt/0.48-1

Add bdrv_find_backing_image: given a BlockDriverState pointer, and an id,
traverse the backing image chain to locate the id.

Signed-off-by: Marcelo Tosatti <address@hidden>

Index: stefanha/block.c
===================================================================
--- stefanha.orig/block.c
+++ stefanha/block.c
@@ -2580,6 +2580,23 @@ int bdrv_snapshot_load_tmp(BlockDriverSt
     return -ENOTSUP;
 }
 
+/*
+ * Return the BlockDriverState pointer for a backing image
+ * with 'id'.
+ */
+BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs,
+                                          const char *id)
+{
+    BlockDriver *drv = bs->drv;
+    if (!drv) {
+        return NULL;
+    }
+    if (drv->bdrv_find_backing_image) {
+            return drv->bdrv_find_backing_image(bs, id);
+    }
+    return NULL;
+}
+
 #define NB_SUFFIXES 4
 
 char *get_human_readable_size(char *buf, int buf_size, int64_t size)
Index: stefanha/block.h
===================================================================
--- stefanha.orig/block.h
+++ stefanha/block.h
@@ -146,6 +146,7 @@ int coroutine_fn bdrv_co_writev(BlockDri
     int nb_sectors, QEMUIOVector *qiov);
 int coroutine_fn bdrv_co_is_allocated(BlockDriverState *bs, int64_t sector_num,
     int nb_sectors, int *pnum);
+BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs, const char 
*id);
 int bdrv_truncate(BlockDriverState *bs, int64_t offset);
 int64_t bdrv_getlength(BlockDriverState *bs);
 int64_t bdrv_get_allocated_file_size(BlockDriverState *bs);
Index: stefanha/block_int.h
===================================================================
--- stefanha.orig/block_int.h
+++ stefanha/block_int.h
@@ -136,6 +136,9 @@ struct BlockDriver {
     int coroutine_fn (*bdrv_co_is_allocated)(BlockDriverState *bs,
         int64_t sector_num, int nb_sectors, int *pnum);
 
+    BlockDriverState *(*bdrv_find_backing_image)(BlockDriverState *bs,
+        const char *id);
+
     /*
      * Invalidate any cached meta-data.
      */





reply via email to

[Prev in Thread] Current Thread [Next in Thread]