From mboxrd@z Thu Jan 1 00:00:00 1970 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 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 From: Wenchao Xia Date: Sat, 13 Apr 2013 16:56:36 +0800 Message-Id: <1365843407-16504-8-git-send-email-xiawenc@linux.vnet.ibm.com> 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> Subject: [Qemu-devel] [PATCH V12 07/18] block: change VM snapshot checking logic List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, phrdina@redhat.com, stefanha@gmail.com, armbru@redhat.com, lcapitulino@redhat.com, pbonzini@redhat.com, Wenchao Xia 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 --- 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; -- 1.7.1