Patchwork [03/11] qemu-img: remove parameter filename in collect_image_info()

login
register
mail settings
Submitter Wayne Xia
Date Dec. 29, 2012, 8:45 a.m.
Message ID <1356770725-4804-4-git-send-email-xiawenc@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/208625/
State New
Headers show

Comments

Wayne Xia - Dec. 29, 2012, 8:45 a.m.
Switch the filename getting from parameter to block function,
now collect_image_info depends only on *bs.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
 qemu-img.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
Eric Blake - Jan. 3, 2013, 6:03 p.m.
On 12/29/2012 01:45 AM, Wenchao Xia wrote:
>   Switch the filename getting from parameter to block function,
> now collect_image_info depends only on *bs.
> 
> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> ---
>  qemu-img.c |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/qemu-img.c b/qemu-img.c
> index 5a4df3a..d70435f 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -1180,15 +1180,17 @@ static void dump_json_image_info(ImageInfo *info)
>      QDECREF(str);
>  }
>  
> +/* Assume bs is already openned. */

s/openned/opened/

Once that is fixed,
Reviewed-by: Eric Blake <eblake@redhat.com>

Patch

diff --git a/qemu-img.c b/qemu-img.c
index 5a4df3a..d70435f 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1180,15 +1180,17 @@  static void dump_json_image_info(ImageInfo *info)
     QDECREF(str);
 }
 
+/* Assume bs is already openned. */
 static void collect_image_info(BlockDriverState *bs,
-                   ImageInfo *info,
-                   const char *filename)
+                               ImageInfo *info)
 {
     uint64_t total_sectors;
     char backing_filename[1024];
     char backing_filename2[1024];
     BlockDriverInfo bdi;
+    const char *filename;
 
+    filename = bdrv_get_filename(bs);
     bdrv_get_geometry(bs, &total_sectors);
 
     info->filename        = g_strdup(filename);
@@ -1356,7 +1358,7 @@  static ImageInfoList *collect_image_info_list(const char *filename,
         }
 
         info = g_new0(ImageInfo, 1);
-        collect_image_info(bs, info, filename);
+        collect_image_info(bs, info);
         collect_snapshots(bs, info);
 
         elem = g_new0(ImageInfoList, 1);