qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, aliguori@us.ibm.com, stefanha@gmail.com,
	Wenchao Xia <xiawenc@linux.vnet.ibm.com>,
	blauwirbel@gmail.com, pbonzini@redhat.com, dietmar@proxmox.com
Subject: [Qemu-devel] [RFC PATCH 1/2] live backup vm, export functions
Date: Sat,  8 Dec 2012 16:24:18 +0800	[thread overview]
Message-ID: <1354955059-14391-2-git-send-email-xiawenc@linux.vnet.ibm.com> (raw)
In-Reply-To: <1354955059-14391-1-git-send-email-xiawenc@linux.vnet.ibm.com>

  This patch moved bdrv_snapshot_find() from savevm.c to block.c,
also exports some function in savevm.c.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
 block.c  |   21 +++++++++++++++++++++
 block.h  |    2 ++
 savevm.c |   37 +++++++++++--------------------------
 sysemu.h |    2 ++
 4 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/block.c b/block.c
index c05875f..155b562 100644
--- a/block.c
+++ b/block.c
@@ -3322,6 +3322,27 @@ char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn)
     return buf;
 }
 
+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;
+}
 /**************************************************************/
 /* async I/Os */
 
diff --git a/block.h b/block.h
index 722c620..0838736 100644
--- a/block.h
+++ b/block.h
@@ -330,6 +330,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 5d04d59..e1bad85 100644
--- a/savevm.c
+++ b/savevm.c
@@ -698,7 +698,7 @@ int qemu_get_byte(QEMUFile *f)
     return result;
 }
 
-static int64_t qemu_ftell(QEMUFile *f)
+int64_t qemu_ftell(QEMUFile *f)
 {
     return f->buf_offset - f->buf_size + f->buf_index;
 }
@@ -2061,32 +2061,10 @@ 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.
  */
-static int del_existing_snapshots(Monitor *mon, const char *name)
+int del_existing_snapshots(Monitor *mon, Error **errp, const char *name)
 {
     BlockDriverState *bs;
     QEMUSnapshotInfo sn1, *snapshot = &sn1;
@@ -2099,9 +2077,16 @@ static int del_existing_snapshots(Monitor *mon, const char *name)
         {
             ret = bdrv_snapshot_delete(bs, name);
             if (ret < 0) {
-                monitor_printf(mon,
+                if (mon != NULL) {
+                    monitor_printf(mon,
                                "Error while deleting snapshot on '%s'\n",
                                bdrv_get_device_name(bs));
+                }
+                if (errp != NULL) {
+                    error_setg(errp,
+                               "Error while deleting snapshot on '%s'\n",
+                               bdrv_get_device_name(bs));
+                }
                 return -1;
             }
         }
@@ -2186,7 +2171,7 @@ void do_savevm(Monitor *mon, const QDict *qdict)
     }
 
     /* Delete old snapshots of the same name */
-    if (name && del_existing_snapshots(mon, name) < 0) {
+    if (name && del_existing_snapshots(mon, NULL, name) < 0) {
         goto the_end;
     }
 
diff --git a/sysemu.h b/sysemu.h
index f5ac664..f44f9ee 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -69,6 +69,8 @@ void do_savevm(Monitor *mon, const QDict *qdict);
 int load_vmstate(const char *name);
 void do_delvm(Monitor *mon, const QDict *qdict);
 void do_info_snapshots(Monitor *mon);
+int del_existing_snapshots(Monitor *mon, Error **errp, const char *name);
+int64_t qemu_ftell(QEMUFile *f);
 
 void qemu_announce_self(void);
 
-- 
1.7.1

  parent reply	other threads:[~2012-12-07  8:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-08  8:24 [Qemu-devel] [RFC PATCH 0/2] live backup vm Wenchao Xia
2012-12-07 10:12 ` Dietmar Maurer
2012-12-09  4:37   ` Wenchao Xia
2012-12-09  7:12     ` Dietmar Maurer
2012-12-10  1:37       ` Wenchao Xia
2012-12-10  6:23         ` Dietmar Maurer
2012-12-11  7:14           ` Wenchao Xia
2012-12-11  7:46             ` Dietmar Maurer
2012-12-12  2:16               ` Wenchao Xia
2012-12-12  8:30               ` Paolo Bonzini
2012-12-12  8:50                 ` Dietmar Maurer
2012-12-12  9:03                 ` Dietmar Maurer
2012-12-12 10:00                   ` Paolo Bonzini
2012-12-08  8:24 ` Wenchao Xia [this message]
2012-12-08  8:24 ` [Qemu-devel] [RFC PATCH 2/2] live backup vm, snapshots all lively Wenchao Xia

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=1354955059-14391-2-git-send-email-xiawenc@linux.vnet.ibm.com \
    --to=xiawenc@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=blauwirbel@gmail.com \
    --cc=dietmar@proxmox.com \
    --cc=kwolf@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).