From patchwork Tue Feb 26 10:40:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 223205 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 71C8B2C0294 for ; Tue, 26 Feb 2013 22:26:44 +1100 (EST) Received: from localhost ([::1]:39554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAI1J-0006h8-DE for incoming@patchwork.ozlabs.org; Tue, 26 Feb 2013 05:44:25 -0500 Received: from eggs.gnu.org ([208.118.235.92]:54955) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAI0L-00055R-To for qemu-devel@nongnu.org; Tue, 26 Feb 2013 05:43:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UAI0E-0003p1-Vr for qemu-devel@nongnu.org; Tue, 26 Feb 2013 05:43:25 -0500 Received: from e23smtp03.au.ibm.com ([202.81.31.145]:49628) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAI0E-0003np-6q for qemu-devel@nongnu.org; Tue, 26 Feb 2013 05:43:18 -0500 Received: from /spool/local by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 26 Feb 2013 20:37:06 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp03.au.ibm.com (202.81.31.209) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 26 Feb 2013 20:37:05 +1000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [9.190.235.152]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 639553578051 for ; Tue, 26 Feb 2013 21:43:14 +1100 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r1QAUceJ6291952 for ; Tue, 26 Feb 2013 21:30:38 +1100 Received: from d23av01.au.ibm.com (loopback [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r1QAhDpL016222 for ; Tue, 26 Feb 2013 21:43:13 +1100 Received: from RH63Wenchao (wenchaox.cn.ibm.com [9.115.122.152]) by d23av01.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r1QAeKOE012693; Tue, 26 Feb 2013 21:43:11 +1100 From: Wenchao Xia To: qemu-devel@nongnu.org Date: Tue, 26 Feb 2013 18:40:23 +0800 Message-Id: <1361875228-15769-10-git-send-email-xiawenc@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1361875228-15769-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1361875228-15769-1-git-send-email-xiawenc@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13022610-6102-0000-0000-0000030FF4A8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 202.81.31.145 Cc: kwolf@redhat.com, aliguori@us.ibm.com, stefanha@gmail.com, armbru@redhat.com, lcapitulino@redhat.com, pbonzini@redhat.com, Wenchao Xia Subject: [Qemu-devel] [PATCH V7 09/14] block: move bdrv_snapshot_find() to block.c 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 Signed-off-by: Wenchao Xia Reviewed-by: Eric Blake --- block.c | 24 ++++++++++++++++++++++++ include/block/block.h | 2 ++ savevm.c | 22 ---------------------- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/block.c b/block.c index 3976167..a97c7ec 100644 --- a/block.c +++ b/block.c @@ -3421,6 +3421,30 @@ int bdrv_snapshot_load_tmp(BlockDriverState *bs, return -ENOTSUP; } +int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info, + const char *name) +{ + QEMUSnapshotInfo *sn_tab, *sn; + int nb_sns, i, ret; + + ret = -ENOENT; + nb_sns = bdrv_snapshot_list(bs, &sn_tab); + if (nb_sns < 0) { + return ret; + } + + for (i = 0; i < nb_sns; i++) { + sn = &sn_tab[i]; + if (!strcmp(sn->id_str, name) || !strcmp(sn->name, name)) { + *sn_info = *sn; + ret = 0; + break; + } + } + g_free(sn_tab); + return ret; +} + /* backing_file can either be relative, or absolute, or a protocol. If it is * relative, it must be relative to the chain. So, passing in bs->filename * from a BDS as backing_file should not be done, as that may be relative to diff --git a/include/block/block.h b/include/block/block.h index a820184..d2b8bd1 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -343,6 +343,8 @@ int bdrv_snapshot_list(BlockDriverState *bs, int bdrv_snapshot_load_tmp(BlockDriverState *bs, const char *snapshot_name); char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn); +int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info, + const char *name); char *get_human_readable_size(char *buf, int buf_size, int64_t size); int path_is_absolute(const char *path); diff --git a/savevm.c b/savevm.c index a8a53ef..f73ac32 100644 --- a/savevm.c +++ b/savevm.c @@ -2060,28 +2060,6 @@ out: return ret; } -static int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info, - const char *name) -{ - QEMUSnapshotInfo *sn_tab, *sn; - int nb_sns, i, ret; - - ret = -ENOENT; - nb_sns = bdrv_snapshot_list(bs, &sn_tab); - if (nb_sns < 0) - return ret; - for(i = 0; i < nb_sns; i++) { - sn = &sn_tab[i]; - if (!strcmp(sn->id_str, name) || !strcmp(sn->name, name)) { - *sn_info = *sn; - ret = 0; - break; - } - } - g_free(sn_tab); - return ret; -} - /* * Deletes snapshots of a given name in all opened images. */