Permalink
Browse files

Merge remote-tracking branch 'stefanha/block' into staging

# By Kevin Wolf (22) and Peter Lieven (1)
# Via Stefan Hajnoczi
* stefanha/block: (23 commits)
  block: Fix direct use of protocols as driver for bdrv_open()
  qcow2: Gather clusters in a looping loop
  qcow2: Move cluster gathering to a non-looping loop
  qcow2: Allow requests with multiple l2metas
  qcow2: Use byte granularity in qcow2_alloc_cluster_offset()
  qcow2: Prepare handle_alloc/copied() for byte granularity
  qcow2: handle_copied(): Implement non-zero host_offset
  qcow2: handle_copied(): Get rid of keep_clusters parameter
  qcow2: handle_copied(): Get rid of nb_clusters parameter
  qcow2: Factor out handle_copied()
  qcow2: Clean up handle_alloc()
  qcow2: Finalise interface of handle_alloc()
  qcow2: handle_alloc(): Get rid of keep_clusters parameter
  qcow2: handle_alloc(): Get rid of nb_clusters parameter
  qcow2: Factor out handle_alloc()
  qcow2: Decouple cluster allocation from cluster reuse code
  qcow2: Change handle_dependency to byte granularity
  qcow2: Improve check for overlapping allocations
  qcow2: Handle dependencies earlier
  qcow2: Remove bogus unlock of s->lock
  ...
  • Loading branch information...
2 parents 837df37 + 5d186eb commit fde245ca7ea790495db370cd260259595dbdf874 Anthony Liguori committed Mar 28, 2013
Showing with 553 additions and 176 deletions.
  1. +15 −11 block.c
  2. +360 −149 block/qcow2-cluster.c
  3. +3 −1 block/qcow2-refcount.c
  4. +11 −5 block/qcow2.c
  5. +29 −0 block/qcow2.h
  6. +5 −5 tests/qemu-iotests/038.out
  7. +2 −2 tests/qemu-iotests/044.out
  8. +48 −1 tests/qemu-iotests/046
  9. +76 −0 tests/qemu-iotests/046.out
  10. +2 −0 trace-events
  11. +2 −2 vl.c
View
26 block.c
@@ -680,6 +680,18 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
trace_bdrv_open_common(bs, filename, flags, drv->format_name);
+ if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv)) {
+ return -ENOTSUP;
+ }
+
+ /* bdrv_open() with directly using a protocol as drv. This layer is already
+ * opened, so assign it to bs (while file becomes a closed BlockDriverState)
+ * and return immediately. */
+ if (file != NULL && drv->bdrv_file_open) {
+ bdrv_swap(file, bs);
+ return 0;
+ }
+
bs->open_flags = flags;
bs->buffer_alignment = 512;
@@ -694,10 +706,6 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
bs->filename[0] = '\0';
}
- if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv)) {
- return -ENOTSUP;
- }
-
bs->drv = drv;
bs->opaque = g_malloc0(drv->instance_size);
@@ -708,13 +716,9 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
/* Open the image, either directly or using a protocol */
if (drv->bdrv_file_open) {
- if (file != NULL) {
- bdrv_swap(file, bs);
- ret = 0;
- } else {
- assert(drv->bdrv_parse_filename || filename != NULL);
- ret = drv->bdrv_file_open(bs, filename, options, open_flags);
- }
+ assert(file == NULL);
+ assert(drv->bdrv_parse_filename || filename != NULL);
+ ret = drv->bdrv_file_open(bs, filename, options, open_flags);
} else {
assert(file != NULL);
bs->file = file;
Oops, something went wrong.

0 comments on commit fde245c

Please sign in to comment.