From: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, stefanha@gmail.com, armbru@redhat.com,
lcapitulino@redhat.com, pbonzini@redhat.com,
Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH V9 01/14] block: move bdrv_snapshot_find() to block/snapshot.c
Date: Mon, 11 Mar 2013 19:23:03 +0800 [thread overview]
Message-ID: <1363000996-13221-2-git-send-email-xiawenc@linux.vnet.ibm.com> (raw)
In-Reply-To: <1363000996-13221-1-git-send-email-xiawenc@linux.vnet.ibm.com>
This patch adds block/snapshot.c and then moves the function
there. It also fixes small code style errors reported by check script.
Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
block/Makefile.objs | 1 +
block/snapshot.c | 37 +++++++++++++++++++++++++++++++++++++
include/block/snapshot.h | 26 ++++++++++++++++++++++++++
savevm.c | 23 +----------------------
4 files changed, 65 insertions(+), 22 deletions(-)
create mode 100644 block/snapshot.c
create mode 100644 include/block/snapshot.h
diff --git a/block/Makefile.objs b/block/Makefile.objs
index c067f38..60a4cd2 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -3,6 +3,7 @@ block-obj-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o qcow2-c
block-obj-y += qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-cluster.o
block-obj-y += qed-check.o
block-obj-y += parallels.o blkdebug.o blkverify.o
+block-obj-y += snapshot.o
block-obj-$(CONFIG_WIN32) += raw-win32.o win32-aio.o
block-obj-$(CONFIG_POSIX) += raw-posix.o
block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
diff --git a/block/snapshot.c b/block/snapshot.c
new file mode 100644
index 0000000..8de73b4
--- /dev/null
+++ b/block/snapshot.c
@@ -0,0 +1,37 @@
+/*
+ * Snapshot related functions.
+ *
+ * Copyright IBM, Corp. 2013
+ *
+ * Authors:
+ * Wenchao Xia <xiawenc@linux.vnet.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2 or later.
+ * See the COPYING.LIB file in the top-level directory.
+ *
+ */
+
+#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
new file mode 100644
index 0000000..86891d1
--- /dev/null
+++ b/include/block/snapshot.h
@@ -0,0 +1,26 @@
+/*
+ * Snapshot related functions.
+ *
+ * Copyright IBM, Corp. 2013
+ *
+ * Authors:
+ * Wenchao Xia <xiawenc@linux.vnet.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2 or later.
+ * See the COPYING.LIB file in the top-level directory.
+ *
+ */
+
+#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
next prev parent reply other threads:[~2013-03-11 11:25 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-11 11:23 [Qemu-devel] [PATCH V9 00/14] qmp/hmp interfaces for internal snapshot info Wenchao Xia
2013-03-11 11:23 ` Wenchao Xia [this message]
2013-03-11 17:49 ` [Qemu-devel] [PATCH V9 01/14] block: move bdrv_snapshot_find() to block/snapshot.c Eric Blake
2013-03-12 5:01 ` Wenchao Xia
2013-03-12 16:15 ` Eric Blake
2013-03-12 16:22 ` Eric Blake
2013-03-13 1:57 ` Wenchao Xia
2013-03-13 12:41 ` Kevin Wolf
2013-03-13 18:19 ` Markus Armbruster
2013-03-13 20:28 ` Eric Blake
2013-03-14 9:01 ` Kevin Wolf
2013-03-14 12:10 ` Markus Armbruster
2013-03-14 12:53 ` Kevin Wolf
2013-03-15 6:23 ` Wenchao Xia
2013-03-15 8:00 ` Kevin Wolf
2013-03-13 18:08 ` Markus Armbruster
2013-03-11 11:23 ` [Qemu-devel] [PATCH V9 02/14] block: distinguish id and name in bdrv_find_snapshot() Wenchao Xia
2013-03-11 11:23 ` [Qemu-devel] [PATCH V9 03/14] qemu-img: remove unused parameter in collect_image_info() Wenchao Xia
2013-03-11 11:23 ` [Qemu-devel] [PATCH V9 04/14] block: move collect_snapshots() and collect_image_info() to block/qapi.c Wenchao Xia
2013-03-12 19:41 ` Eric Blake
2013-03-13 20:34 ` Eric Blake
2013-03-11 11:23 ` [Qemu-devel] [PATCH V9 05/14] block: add snapshot info query function bdrv_query_snapshot_info_list() Wenchao Xia
2013-03-11 11:23 ` [Qemu-devel] [PATCH V9 06/14] block: add check for VM snapshot in bdrv_query_snapshot_info_list() Wenchao Xia
2013-03-12 19:45 ` Eric Blake
2013-03-11 11:23 ` [Qemu-devel] [PATCH V9 07/14] block: add image info query function bdrv_query_image_info() Wenchao Xia
2013-03-11 11:23 ` [Qemu-devel] [PATCH V9 08/14] qmp: add interface query-snapshots Wenchao Xia
2013-03-12 21:12 ` Eric Blake
2013-03-11 11:23 ` [Qemu-devel] [PATCH V9 09/14] qmp: add interface query-images Wenchao Xia
2013-03-12 21:24 ` Eric Blake
2013-03-11 11:23 ` [Qemu-devel] [PATCH V9 10/14] hmp: add function hmp_info_snapshots() Wenchao Xia
2013-03-11 11:23 ` [Qemu-devel] [PATCH V9 11/14] hmp: switch snapshot info function to qmp based one Wenchao Xia
2013-03-11 11:23 ` [Qemu-devel] [PATCH V9 12/14] block: move dump_human_image_info() to block/qapi.c Wenchao Xia
2013-03-13 20:38 ` Eric Blake
2013-03-11 11:23 ` [Qemu-devel] [PATCH V9 13/14] block: dump to buffer for bdrv_image_info_dump() Wenchao Xia
2013-03-11 11:23 ` [Qemu-devel] [PATCH V9 14/14] hmp: add command info images Wenchao Xia
2013-03-12 10:07 ` [Qemu-devel] [PATCH V9 00/14] qmp/hmp interfaces for internal snapshot info Stefan Hajnoczi
2013-03-12 16:16 ` Eric Blake
2013-03-13 2:54 ` Wenchao Xia
2013-03-13 11:34 ` Stefan Hajnoczi
2013-03-13 12:29 ` Eric Blake
2013-03-13 12:35 ` Kevin Wolf
2013-03-13 12:40 ` Stefan Hajnoczi
2013-03-15 6:07 ` Wenchao Xia
2013-03-15 8:07 ` Kevin Wolf
2013-03-18 10:30 ` Wenchao Xia
2013-03-18 16:48 ` Kevin Wolf
2013-03-15 8:44 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1363000996-13221-2-git-send-email-xiawenc@linux.vnet.ibm.com \
--to=xiawenc@linux.vnet.ibm.com \
--cc=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).