From patchwork Thu Mar 7 06:07:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 225730 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 024572C0385 for ; Thu, 7 Mar 2013 17:10:23 +1100 (EST) Received: from localhost ([::1]:38100 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDU20-0006xX-UI for incoming@patchwork.ozlabs.org; Thu, 07 Mar 2013 01:10:20 -0500 Received: from eggs.gnu.org ([208.118.235.92]:50988) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDU1S-0006t6-9y for qemu-devel@nongnu.org; Thu, 07 Mar 2013 01:09:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UDU1Q-0003wB-18 for qemu-devel@nongnu.org; Thu, 07 Mar 2013 01:09:46 -0500 Received: from e28smtp04.in.ibm.com ([122.248.162.4]:36404) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDU1P-0003vl-7S for qemu-devel@nongnu.org; Thu, 07 Mar 2013 01:09:43 -0500 Received: from /spool/local by e28smtp04.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 7 Mar 2013 11:36:45 +0530 Received: from d28dlp03.in.ibm.com (9.184.220.128) by e28smtp04.in.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 7 Mar 2013 11:36:43 +0530 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by d28dlp03.in.ibm.com (Postfix) with ESMTP id AF9E0125804E for ; Thu, 7 Mar 2013 11:40:36 +0530 (IST) Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r2769ZDd17891454 for ; Thu, 7 Mar 2013 11:39:35 +0530 Received: from d28av03.in.ibm.com (loopback [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r2769aPp028997 for ; Thu, 7 Mar 2013 17:09:37 +1100 Received: from RH63Wenchao (wenchaox.cn.ibm.com [9.115.122.208]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r2767TJi021188; Thu, 7 Mar 2013 17:09:34 +1100 From: Wenchao Xia To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2013 14:07:08 +0800 Message-Id: <1362636445-7188-4-git-send-email-xiawenc@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1362636445-7188-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1362636445-7188-1-git-send-email-xiawenc@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13030706-5564-0000-0000-000006EA5748 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.4 Cc: kwolf@redhat.com, aliguori@us.ibm.com, capitulino@redhat.com, stefanha@gmail.com, armbru@redhat.com, pbonzini@redhat.com, Wenchao Xia Subject: [Qemu-devel] [PATCH V8 03/20] block: move bdrv_snapshot_find() to block/snapshot.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 This patch also fix small code style error reported by check script. Signed-off-by: Wenchao Xia --- block/snapshot.c | 23 +++++++++++++++++++++++ include/block/snapshot.h | 9 +++++++++ savevm.c | 23 +---------------------- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/block/snapshot.c b/block/snapshot.c index c65519b..8de73b4 100644 --- a/block/snapshot.c +++ b/block/snapshot.c @@ -12,3 +12,26 @@ */ #include "block/snapshot.h" + +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; +} diff --git a/include/block/snapshot.h b/include/block/snapshot.h index 278e064..369e047 100644 --- a/include/block/snapshot.h +++ b/include/block/snapshot.h @@ -1,4 +1,13 @@ #ifndef SNAPSHOT_H #define SNAPSHOT_H +#include "qemu-common.h" +/* + * block.h is needed for QEMUSnapshotInfo, it can be removed when define is + * moved here. + */ +#include "block.h" + +int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info, + const char *name); #endif diff --git a/savevm.c b/savevm.c index a8a53ef..95f19ca 100644 --- a/savevm.c +++ b/savevm.c @@ -39,6 +39,7 @@ #include "qmp-commands.h" #include "trace.h" #include "qemu/bitops.h" +#include "block/snapshot.h" #define SELF_ANNOUNCE_ROUNDS 5 @@ -2060,28 +2061,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. */