qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block: bdrv_append() fixes
@ 2012-03-27 20:30 Jeff Cody
  2012-04-03 11:24 ` Kevin Wolf
  0 siblings, 1 reply; 2+ messages in thread
From: Jeff Cody @ 2012-03-27 20:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, pbonzini, armbru

A few fixups for bdrv_append():

The new bs (bs_new) passed into bdrv_append() should be anonymous.  Rather
than call bdrv_make_anon() to enforce this, use an assert to catch when a caller
is passing in a bs_new that is not anonymous.

Also, the new top layer should have its backing_format reflect the original
top's format.

And last, after the swap of bs contents, the device_name will have been copied
down. This needs to be cleared to reflect the anonymity of the bs that was
pushed down.

Signed-off-by: Jeff Cody <jcody@redhat.com>
---
 block.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/block.c b/block.c
index b88ee90..c971e28 100644
--- a/block.c
+++ b/block.c
@@ -889,14 +889,16 @@ void bdrv_make_anon(BlockDriverState *bs)
  * This will modify the BlockDriverState fields, and swap contents
  * between bs_new and bs_top. Both bs_new and bs_top are modified.
  *
+ * bs_new is required to be anonymous.
+ *
  * This function does not create any image files.
  */
 void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top)
 {
     BlockDriverState tmp;
 
-    /* the new bs must not be in bdrv_states */
-    bdrv_make_anon(bs_new);
+    /* bs_new must be anonymous */
+    assert(bs_new->device_name[0] == '\0');
 
     tmp = *bs_new;
 
@@ -941,11 +943,18 @@ void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top)
      * swapping bs_new and bs_top contents. */
     tmp.backing_hd = bs_new;
     pstrcpy(tmp.backing_file, sizeof(tmp.backing_file), bs_top->filename);
+    bdrv_get_format(bs_top, tmp.backing_format, sizeof(tmp.backing_format));
 
     /* swap contents of the fixed new bs and the current top */
     *bs_new = *bs_top;
     *bs_top = tmp;
 
+    /* device_name[] was carried over from the old bs_top.  bs_new
+     * shouldn't be in bdrv_states, so we need to make device_name[]
+     * reflect the anonymity of bs_new
+     */
+    bs_new->device_name[0] = '\0';
+
     /* clear the copied fields in the new backing file */
     bdrv_detach_dev(bs_new, bs_new->dev);
 
-- 
1.7.9.rc2.1.g69204

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] block: bdrv_append() fixes
  2012-03-27 20:30 [Qemu-devel] [PATCH] block: bdrv_append() fixes Jeff Cody
@ 2012-04-03 11:24 ` Kevin Wolf
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Wolf @ 2012-04-03 11:24 UTC (permalink / raw)
  To: Jeff Cody; +Cc: pbonzini, qemu-devel, armbru

Am 27.03.2012 22:30, schrieb Jeff Cody:
> A few fixups for bdrv_append():
> 
> The new bs (bs_new) passed into bdrv_append() should be anonymous.  Rather
> than call bdrv_make_anon() to enforce this, use an assert to catch when a caller
> is passing in a bs_new that is not anonymous.
> 
> Also, the new top layer should have its backing_format reflect the original
> top's format.
> 
> And last, after the swap of bs contents, the device_name will have been copied
> down. This needs to be cleared to reflect the anonymity of the bs that was
> pushed down.
> 
> Signed-off-by: Jeff Cody <jcody@redhat.com>

Thanks, applied to the block branch.

Kevin

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-04-03 11:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-27 20:30 [Qemu-devel] [PATCH] block: bdrv_append() fixes Jeff Cody
2012-04-03 11:24 ` Kevin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).