[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH V8 03/20] block: move bdrv_snapshot_find() to block/
From: |
Wenchao Xia |
Subject: |
[Qemu-devel] [PATCH V8 03/20] block: move bdrv_snapshot_find() to block/snapshot.c |
Date: |
Thu, 7 Mar 2013 14:07:08 +0800 |
This patch also fix small code style error reported by check script.
Signed-off-by: Wenchao Xia <address@hidden>
---
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.
*/
--
1.7.1
- [Qemu-devel] [PATCH V8 00/20] qmp/hmp interfaces for internal snapshot info, Wenchao Xia, 2013/03/07
- [Qemu-devel] [PATCH V8 02/20] build: add block/qapi.c, Wenchao Xia, 2013/03/07
- [Qemu-devel] [PATCH V8 03/20] block: move bdrv_snapshot_find() to block/snapshot.c,
Wenchao Xia <=
- [Qemu-devel] [PATCH V8 04/20] block: distinguish id and name in bdrv_find_snapshot(), Wenchao Xia, 2013/03/07
- [Qemu-devel] [PATCH V8 07/20] block: add snapshot info query function bdrv_query_snapshot_info_list(), Wenchao Xia, 2013/03/07
- [Qemu-devel] [PATCH V8 05/20] qemu-img: remove unused parameter in collect_image_info(), Wenchao Xia, 2013/03/07
- [Qemu-devel] [PATCH V8 06/20] block: move collect_snapshots() and collect_image_info() to block/qapi.c, Wenchao Xia, 2013/03/07