From patchwork Sat Apr 13 08:56:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 236313 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3CE572C00C5 for ; Sat, 13 Apr 2013 19:02:34 +1000 (EST) Received: from localhost ([::1]:57029 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQwLw-0003W5-FE for incoming@patchwork.ozlabs.org; Sat, 13 Apr 2013 05:02:32 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49503) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQwJd-0008Vx-9y for qemu-devel@nongnu.org; Sat, 13 Apr 2013 05:00:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UQwJb-0000lL-SQ for qemu-devel@nongnu.org; Sat, 13 Apr 2013 05:00:09 -0400 Received: from e23smtp06.au.ibm.com ([202.81.31.148]:38555) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQwJb-0000kW-Bw for qemu-devel@nongnu.org; Sat, 13 Apr 2013 05:00:07 -0400 Received: from /spool/local by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 13 Apr 2013 18:54:17 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sat, 13 Apr 2013 18:54:16 +1000 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [9.190.235.21]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 0FB672CE804D for ; Sat, 13 Apr 2013 18:59:57 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r3D8xpSS10879428 for ; Sat, 13 Apr 2013 18:59:51 +1000 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r3D8xuqV027370 for ; Sat, 13 Apr 2013 18:59:56 +1000 Received: from RH63Wenchao (wenchaox.cn.ibm.com [9.115.122.157]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r3D8u24K020091; Sat, 13 Apr 2013 18:59:54 +1000 From: Wenchao Xia To: qemu-devel@nongnu.org Date: Sat, 13 Apr 2013 16:56:36 +0800 Message-Id: <1365843407-16504-8-git-send-email-xiawenc@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1365843407-16504-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1365843407-16504-1-git-send-email-xiawenc@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13041308-7014-0000-0000-000002D95B2F X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 202.81.31.148 Cc: kwolf@redhat.com, phrdina@redhat.com, stefanha@gmail.com, armbru@redhat.com, lcapitulino@redhat.com, pbonzini@redhat.com, Wenchao Xia Subject: [Qemu-devel] [PATCH V12 07/18] block: change VM snapshot checking logic 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 Original logic is different with load_vmstate(), this patch change it to be exactly the same with load_vmstate(), so any VM snapshot shown in qmp/hmp should succeed in load_vmstate(). Note that, runtime snapshot info maybe different with what is got in "qemu-img info" as static snapshot info, and this patch clearly tips it. Signed-off-by: Wenchao Xia Reviewed-by: Eric Blake --- block/qapi.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index 97c5cd4..49c0eb0 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -46,7 +46,18 @@ static bool snapshot_valid_for_vm(const QEMUSnapshotInfo *sn, take snapshot, for example, readonly ones, will be ignored in load_vmstate(). */ while ((bs1 = bdrv_next(bs1))) { - if (bs1 != bs && bdrv_can_snapshot(bs1)) { + + if (!bdrv_is_inserted(bs1) || bdrv_is_read_only(bs1)) { + continue; + } + + if (!bdrv_can_snapshot(bs1)) { + /* Device is writable but does not support snapshots, will be + rejected by load_vmstate(). */ + return false; + } + + if (bs1 != bs) { ret = bdrv_snapshot_find(bs1, sn_info, sn->id_str, NULL); if (ret < 0) { return false;