From patchwork Tue May 27 14:28:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 352985 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E7CA714007F for ; Wed, 28 May 2014 00:29:48 +1000 (EST) Received: from localhost ([::1]:35681 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpINu-0001i7-Q4 for incoming@patchwork.ozlabs.org; Tue, 27 May 2014 10:29:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59032) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpIND-0000Ld-9B for qemu-devel@nongnu.org; Tue, 27 May 2014 10:29:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WpIN4-00050v-In for qemu-devel@nongnu.org; Tue, 27 May 2014 10:29:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26516) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpIN4-00050l-9D for qemu-devel@nongnu.org; Tue, 27 May 2014 10:28:54 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4RESqgA009537 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 27 May 2014 10:28:52 -0400 Received: from localhost (ovpn-112-29.phx2.redhat.com [10.3.112.29]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s4RESofi025651 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Tue, 27 May 2014 10:28:51 -0400 From: Jeff Cody To: qemu-devel@nongnu.org Date: Tue, 27 May 2014 10:28:33 -0400 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, benoit.canet@irqsave.net, pkrempa@redhat.com, famz@redhat.com, stefanha@redhat.com Subject: [Qemu-devel] [PATCH v2 03/11] block: Add overlay BDS pointer into the BlockDriverState struct X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Now that node-names can reference an individual BlockDriverState without needing to navigate downwards from the 'device' level, in order to find the top-most image (active layer) we need a pointer to the overlay of a BDS. This will allow QMP commands to reference an image solely by its node-name, without also needing to pass in the corresponding 'device' string. Signed-off-by: Jeff Cody Reviewed-by: Eric Blake --- block.c | 5 +++++ include/block/block_int.h | 1 + 2 files changed, 6 insertions(+) diff --git a/block.c b/block.c index cf4b296..b72fe4e 100644 --- a/block.c +++ b/block.c @@ -1114,6 +1114,9 @@ void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd) if (bs->backing_hd) { assert(bs->backing_blocker); bdrv_op_unblock_all(bs->backing_hd, bs->backing_blocker); + if (!backing_hd) { + bs->backing_hd->overlay = NULL; + } } else if (backing_hd) { error_setg(&bs->backing_blocker, "device is used as backing hd of '%s'", @@ -1126,6 +1129,8 @@ void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd) bs->backing_blocker = NULL; goto out; } + backing_hd->overlay = bs; + bs->open_flags &= ~BDRV_O_NO_BACKING; pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_hd->filename); pstrcpy(bs->backing_format, sizeof(bs->backing_format), diff --git a/include/block/block_int.h b/include/block/block_int.h index f2e753f..c0fe90b 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -303,6 +303,7 @@ struct BlockDriverState { char backing_format[16]; /* if non-zero and backing_file exists */ BlockDriverState *backing_hd; + BlockDriverState *overlay; BlockDriverState *file; NotifierList close_notifiers;