From patchwork Sat Jan 30 05:17:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 575921 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 6B970140BB1 for ; Sat, 30 Jan 2016 16:18:23 +1100 (AEDT) Received: from localhost ([::1]:37622 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPNvR-0005VH-Fy for incoming@patchwork.ozlabs.org; Sat, 30 Jan 2016 00:18:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33357) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPNv4-0004ry-Hg for qemu-devel@nongnu.org; Sat, 30 Jan 2016 00:17:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aPNv3-0001dx-HA for qemu-devel@nongnu.org; Sat, 30 Jan 2016 00:17:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38876) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPNv0-0001dA-CP; Sat, 30 Jan 2016 00:17:54 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 03CA33CB28F; Sat, 30 Jan 2016 05:17:54 +0000 (UTC) Received: from localhost (ovpn-112-43.phx2.redhat.com [10.3.112.43]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0U5HqtV010817 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Sat, 30 Jan 2016 00:17:53 -0500 From: Jeff Cody To: qemu-devel@nongnu.org Date: Sat, 30 Jan 2016 00:17:48 -0500 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-stable@nongnu.org, qemu-block@nongnu.org Subject: [Qemu-devel] [PATCH 1/2] block: change parent backing link when *tqe_prev == NULL 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 In change_parent_backing_link(), we only inserted the new BlockDriverState entry into the device_list if the tqe_prev pointer was NULL. However, we must also allow insertion when the BDS pointed to by the tqe_prev pointer is NULL as well. This fixes a bug with external snapshots, and live active layer commits. After a live snapshot occurs, the active layer and the base layer both have a non-NULL tqe_prev field in the device_list, although the base node's tqe_prev field points to a NULL entry. Once the active commit is finished, bdrv_replace_in_backing_chain() is called to set the base node as the new active node, and remove the node that was the prior active layer from the device_list. If we only check against the tqe_prev pointer field and not the entity it is pointing to, then we fail to insert base image into the device list. The previous active layer is still removed from the device_list, leaving an empty device_list queue. With an empty device_list queue, odd behavior occurs - such as not allowing any more live snapshots. This commit fixes this issue, by checking for a NULL tqe_prev entity in the devices_list. Signed-off-by: Jeff Cody --- block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block.c b/block.c index 5709d3d..0b8526b 100644 --- a/block.c +++ b/block.c @@ -2272,7 +2272,7 @@ static void change_parent_backing_link(BlockDriverState *from, } if (from->blk) { blk_set_bs(from->blk, to); - if (!to->device_list.tqe_prev) { + if (!to->device_list.tqe_prev || !*to->device_list.tqe_prev) { QTAILQ_INSERT_BEFORE(from, to, device_list); } QTAILQ_REMOVE(&bdrv_states, from, device_list);