Patchwork block: use correct filename

login
register
mail settings
Submitter dunrong huang
Date Oct. 2, 2013, 5:31 p.m.
Message ID <1380735087-16406-1-git-send-email-riegamaths@gmail.com>
Download mbox | patch
Permalink /patch/280124/
State New
Headers show

Comments

dunrong huang - Oct. 2, 2013, 5:31 p.m.
The content filename point to may be erased by qemu_opts_absorb_qdict()
in raw_open_common() in drv->bdrv_file_open()

So it's better to use bs->filename.

Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
---
 block.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Max Reitz - Oct. 4, 2013, 7:35 a.m.
On 2013-10-02 19:31, Dunrong Huang wrote:
> The content filename point to may be erased by qemu_opts_absorb_qdict()
> in raw_open_common() in drv->bdrv_file_open()
>
> So it's better to use bs->filename.
>
> Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
> ---
>   block.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Max Reitz <mreitz@redhat.com>
Stefan Hajnoczi - Oct. 7, 2013, 8:51 a.m.
On Thu, Oct 03, 2013 at 01:31:27AM +0800, Dunrong Huang wrote:
> The content filename point to may be erased by qemu_opts_absorb_qdict()
> in raw_open_common() in drv->bdrv_file_open()
> 
> So it's better to use bs->filename.
> 
> Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
> ---
>  block.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan

Patch

diff --git a/block.c b/block.c
index 93e113a..469d842 100644
--- a/block.c
+++ b/block.c
@@ -824,8 +824,8 @@  static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
 
 #ifndef _WIN32
     if (bs->is_temporary) {
-        assert(filename != NULL);
-        unlink(filename);
+        assert(bs->filename[0] != '\0');
+        unlink(bs->filename);
     }
 #endif
     return 0;