From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tso01-0006jK-72 for qemu-devel@nongnu.org; Wed, 09 Jan 2013 00:14:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tso00-0008Ow-3J for qemu-devel@nongnu.org; Wed, 09 Jan 2013 00:14:49 -0500 Received: from e28smtp07.in.ibm.com ([122.248.162.7]:35719) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tsnzz-0008On-Eu for qemu-devel@nongnu.org; Wed, 09 Jan 2013 00:14:48 -0500 Received: from /spool/local by e28smtp07.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 9 Jan 2013 10:43:24 +0530 Received: from d28relay02.in.ibm.com (d28relay02.in.ibm.com [9.184.220.59]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id 68F59394004F for ; Wed, 9 Jan 2013 10:44:44 +0530 (IST) Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay02.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r095EgPi49676428 for ; Wed, 9 Jan 2013 10:44:42 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r095EhBa020288 for ; Wed, 9 Jan 2013 16:14:43 +1100 From: Wenchao Xia Date: Wed, 9 Jan 2013 13:12:26 +0800 Message-Id: <1357708350-9917-8-git-send-email-xiawenc@linux.vnet.ibm.com> In-Reply-To: <1357708350-9917-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1357708350-9917-1-git-send-email-xiawenc@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH V2 07/11] block: export function bdrv_find_snapshot() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, phrdina@redhat.com, stefanha@gmail.com, armbru@redhat.com, lcapitulino@redhat.com, pbonzini@redhat.com, Wenchao Xia This patch move it from savevm.c to block.c and export it. Signed-off-by: Wenchao Xia --- block.c | 23 +++++++++++++++++++++++ include/block/block.h | 2 ++ savevm.c | 22 ---------------------- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/block.c b/block.c index 8192d8e..b7d2f03 100644 --- a/block.c +++ b/block.c @@ -3351,6 +3351,29 @@ 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 5ce817a..c473be5 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -340,6 +340,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 021420f..9af2605 100644 --- a/savevm.c +++ b/savevm.c @@ -2036,28 +2036,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. */ -- 1.7.1