parallels: split check for parallels format in parallels_open

and rework error path a bit. There is no difference at the moment, but
the code will be definitely shorter when additional processing will
be required for WithouFreSpacExt

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Jeff Cody <jcody@redhat.com>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Denis V. Lunev 2014-07-28 20:23:54 +04:00 committed by Stefan Hajnoczi
parent f08e2f8465
commit 418a7adb77
1 changed files with 8 additions and 5 deletions

View File

@ -85,11 +85,11 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
goto fail;
}
if (memcmp(ph.magic, HEADER_MAGIC, 16) ||
(le32_to_cpu(ph.version) != HEADER_VERSION)) {
error_setg(errp, "Image not in Parallels format");
ret = -EINVAL;
goto fail;
if (le32_to_cpu(ph.version) != HEADER_VERSION) {
goto fail_format;
}
if (memcmp(ph.magic, HEADER_MAGIC, 16)) {
goto fail_format;
}
bs->total_sectors = 0xffffffff & le64_to_cpu(ph.nb_sectors);
@ -124,6 +124,9 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
qemu_co_mutex_init(&s->lock);
return 0;
fail_format:
error_setg(errp, "Image not in Parallels format");
ret = -EINVAL;
fail:
g_free(s->catalog_bitmap);
return ret;