diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2012-05-08 16:51:49 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2012-05-10 10:32:12 +0200 |
commit | 6405875cdd10e531ad3dedaad86ae1ccc4b14f20 (patch) | |
tree | 15a21b4e50d37599e212c1c218560bb6e01676d0 | |
parent | 947995c09ebd35a752837a5573985ba5a9942ec1 (diff) | |
download | qemu-6405875cdd10e531ad3dedaad86ae1ccc4b14f20.zip qemu-6405875cdd10e531ad3dedaad86ae1ccc4b14f20.tar.gz qemu-6405875cdd10e531ad3dedaad86ae1ccc4b14f20.tar.bz2 |
block: move field reset from bdrv_open_common to bdrv_close
bdrv_close should leave fields in the same state as bdrv_new. It is
not up to bdrv_open_common to fix the mess.
Also, backing_format was not being re-initialized.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r-- | block.c | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -610,16 +610,11 @@ static int bdrv_open_common(BlockDriverState *bs, const char *filename, int ret, open_flags; assert(drv != NULL); + assert(bs->file == NULL); trace_bdrv_open_common(bs, filename, flags, drv->format_name); - bs->file = NULL; - bs->total_sectors = 0; - bs->encrypted = 0; - bs->valid_key = 0; - bs->sg = 0; bs->open_flags = flags; - bs->growable = 0; bs->buffer_alignment = 512; assert(bs->copy_on_read == 0); /* bdrv_new() and bdrv_close() make it so */ @@ -628,7 +623,6 @@ static int bdrv_open_common(BlockDriverState *bs, const char *filename, } pstrcpy(bs->filename, sizeof(bs->filename), filename); - bs->backing_file[0] = '\0'; if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv)) { return -ENOTSUP; @@ -878,6 +872,11 @@ void bdrv_close(BlockDriverState *bs) bs->copy_on_read = 0; bs->backing_file[0] = '\0'; bs->backing_format[0] = '\0'; + bs->total_sectors = 0; + bs->encrypted = 0; + bs->valid_key = 0; + bs->sg = 0; + bs->growable = 0; if (bs->file != NULL) { bdrv_delete(bs->file); |