]> git.proxmox.com Git - pve-qemu-kvm.git/blobdiff - debian/patches/0006-add-vm-state-to-backups.patch
set default cpu model to kvm64
[pve-qemu-kvm.git] / debian / patches / 0006-add-vm-state-to-backups.patch
index 9bf11a411d36a6f5a3c00d11d574768fffb066d2..dfed9151fc096af112f53b0a44205aaa3d499b45 100644 (file)
@@ -1,30 +1,30 @@
-From ea2827e070e10b515be9b05628e372d281fcf868 Mon Sep 17 00:00:00 2001
+From aa580be154923056a52fdeec429f7e80f04b456e Mon Sep 17 00:00:00 2001
 From: Dietmar Maurer <dietmar@proxmox.com>
 Date: Thu, 29 Nov 2012 10:46:49 +0100
-Subject: [PATCH v3 6/6] add vm state to backups
+Subject: [PATCH v5 6/6] add vm state to backups
 
 
 Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
 ---
  blockdev.c       |  196 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
- hmp.c            |    5 +-
- qapi-schema.json |    6 +-
- 3 files changed, 201 insertions(+), 6 deletions(-)
+ hmp.c            |    3 +-
+ qapi-schema.json |    5 +-
+ 3 files changed, 200 insertions(+), 4 deletions(-)
 
 diff --git a/blockdev.c b/blockdev.c
-index e16091f..a5e2058 100644
+index 683f7da..dd20631 100644
 --- a/blockdev.c
 +++ b/blockdev.c
 @@ -22,6 +22,8 @@
- #include "arch_init.h"
+ #include "sysemu/arch_init.h"
  #include "backup.h"
  #include "vma.h"
-+#include "qemu-file.h"
-+#include "migration.h"
++#include "migration/qemu-file.h"
++#include "migration/migration.h"
  
  static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives);
  
-@@ -1338,6 +1340,10 @@ static struct GenericBackupState {
+@@ -1355,6 +1357,10 @@ static struct GenericBackupState {
      size_t total;
      size_t transferred;
      size_t zero_bytes;
@@ -35,8 +35,8 @@ index e16091f..a5e2058 100644
  } backup_state;
  
  typedef struct BackupCB {
-@@ -1469,10 +1475,170 @@ static void backup_start_jobs(void)
-     }
+@@ -1510,10 +1516,170 @@ static void backup_start_jobs(void)
+     backup_run_next_job();
  }
  
 +static int backup_state_close(void *opaque)
@@ -50,7 +50,7 @@ index e16091f..a5e2058 100644
 +        memset(backup_state.buf + backup_state.buf_index, 0,
 +               BACKUP_CLUSTER_SIZE - backup_state.buf_index);
 +    }
-+    int bytes = backup_state.driver->dump_cb(
++    int bytes = backup_state.driver->dump(
 +        backup_state.writer, backup_state.vmstate_dev_id,
 +        backup_state.buf_cluster_num,
 +        backup_state.buf, &zero_bytes);
@@ -64,7 +64,7 @@ index e16091f..a5e2058 100644
 +{
 +    assert(backup_state.driver);
 +    assert(backup_state.writer);
-+    assert(backup_state.driver->dump_cb);
++    assert(backup_state.driver->dump);
 +
 +    /* Note: our backup driver expects to get whole clusters (64KB) */
 +
@@ -79,7 +79,7 @@ index e16091f..a5e2058 100644
 +        size -= l;
 +        if (backup_state.buf_index == BACKUP_CLUSTER_SIZE) {
 +            size_t zero_bytes = 0;
-+            int bytes = backup_state.driver->dump_cb(
++            int bytes = backup_state.driver->dump(
 +                backup_state.writer, backup_state.vmstate_dev_id,
 +                backup_state.buf_cluster_num++,
 +                backup_state.buf, &zero_bytes);
@@ -162,12 +162,12 @@ index e16091f..a5e2058 100644
 +                               "backup_start_savevm: qemu_fclose failed");
 +                    goto abort;
 +                }
-+                if (backup_state.driver->complete_cb(backup_state.writer,
++                if (backup_state.driver->complete(backup_state.writer,
 +                    backup_state.vmstate_dev_id, 0) < 0) {
-+                    err = g_strdup("backup_start_savevm: complete_cb failed");
++                    err = g_strdup("backup_start_savevm: complete failed");
 +                    goto abort;
 +                }
-+                backup_start_jobs();
++                backup_run_next_job();
 +                goto out;
 +            }
 +        }
@@ -183,7 +183,7 @@ index e16091f..a5e2058 100644
 +    backup_state.end_time = time(NULL);
 +
 +    Error *local_err = NULL;
-+    backup_state.driver->close_cb(backup_state.writer, &local_err);
++    backup_state.driver->close(backup_state.writer, &local_err);
 +    backup_state.writer = NULL;
 +
 +    error_propagate(&backup_state.error, local_err);
@@ -198,8 +198,8 @@ index e16091f..a5e2058 100644
 +    goto out;
 +}
 +
- char *qmp_backup(const char *backupfile, bool has_format, BackupFormat format,
-                  bool has_config_filename, const char *config_filename,
+ char *qmp_backup(const char *backup_file, bool has_format, BackupFormat format,
+                  bool has_config_file, const char *config_file,
                   bool has_devlist, const char *devlist,
 -                 bool has_speed, int64_t speed, Error **errp)
 +                 bool has_speed, int64_t speed,
@@ -207,16 +207,16 @@ index e16091f..a5e2058 100644
  {
      BlockDriverState *bs;
      Error *local_err = NULL;
-@@ -1481,6 +1647,8 @@ char *qmp_backup(const char *backupfile, bool has_format, BackupFormat format,
-     gchar **devs = NULL;
-     GList *bcblist = NULL;
+@@ -1528,6 +1694,8 @@ char *qmp_backup(const char *backup_file, bool has_format, BackupFormat format,
+         return NULL;
+     }
  
 +    bool save_state = has_state ? state : false;
 +
      /* Todo: try to auto-detect format based on file name */
      format = has_format ? format : BACKUP_FORMAT_VMA;
  
-@@ -1561,6 +1729,22 @@ char *qmp_backup(const char *backupfile, bool has_format, BackupFormat format,
+@@ -1608,6 +1776,22 @@ char *qmp_backup(const char *backup_file, bool has_format, BackupFormat format,
      size_t total = 0;
  
      /* register all devices for vma writer */
@@ -229,7 +229,7 @@ index e16091f..a5e2058 100644
 +         * not know that size in advance).
 +         */
 +        size_t ramsize = ram_bytes_total();
-+        vmstate_dev_id = driver->register_stream_cb(writer, "vmstate", ramsize);
++        vmstate_dev_id = driver->register_stream(writer, "vmstate", ramsize);
 +        if (vmstate_dev_id <= 0) {
 +            error_setg(errp, "register vmstate stream failed");
 +            goto err;
@@ -239,7 +239,7 @@ index e16091f..a5e2058 100644
      l = bcblist;
      while (l) {
          BackupCB *bcb = l->data;
-@@ -1624,8 +1808,16 @@ char *qmp_backup(const char *backupfile, bool has_format, BackupFormat format,
+@@ -1675,6 +1859,9 @@ char *qmp_backup(const char *backup_file, bool has_format, BackupFormat format,
      backup_state.total = total;
      backup_state.transferred = 0;
      backup_state.zero_bytes = 0;
@@ -247,6 +247,12 @@ index e16091f..a5e2058 100644
 +    backup_state.buf_cluster_num = 0;
 +    backup_state.vmstate_dev_id = vmstate_dev_id;
  
+     /* Grab a reference so hotplug does not delete the
+      * BlockDriverState from underneath us.
+@@ -1686,7 +1873,12 @@ char *qmp_backup(const char *backup_file, bool has_format, BackupFormat format,
+         drive_get_ref(drive_get_by_blockdev(bcb->bs));
+     }
 -    backup_start_jobs();
 +    if (save_state) {
 +        Coroutine *co = qemu_coroutine_create(backup_start_savevm);
@@ -258,40 +264,39 @@ index e16091f..a5e2058 100644
      return g_strdup(backup_state.uuid_str);
  
 diff --git a/hmp.c b/hmp.c
-index 77076fa..61ba5c3 100644
+index b2c1f23..370cdf8 100644
 --- a/hmp.c
 +++ b/hmp.c
-@@ -1031,8 +1031,9 @@ void hmp_backup(Monitor *mon, const QDict *qdict)
+@@ -1052,7 +1052,8 @@ void hmp_backup(Monitor *mon, const QDict *qdict)
      Error *errp = NULL;
  
-     qmp_backup(backupfile, true, BACKUP_FORMAT_VMA, false, NULL, !!devlist, 
--             devlist, qdict_haskey(qdict, "speed"), speed, &errp);
--
-+               devlist, qdict_haskey(qdict, "speed"), speed, false, false, 
+     qmp_backup(backup_file, true, BACKUP_FORMAT_VMA, false, NULL, !!devlist,
+-               devlist, qdict_haskey(qdict, "speed"), speed, &errp);
++               devlist, qdict_haskey(qdict, "speed"), speed, false, false,
 +               &errp);
-+    
      if (error_is_set(&errp)) {
          monitor_printf(mon, "%s\n", error_get_pretty(errp));
-         error_free(errp);
 diff --git a/qapi-schema.json b/qapi-schema.json
-index 2d3699b..3f4889e 100644
+index 09ca8ef..1fabb67 100644
 --- a/qapi-schema.json
 +++ b/qapi-schema.json
-@@ -1822,13 +1822,15 @@
- #
- # @speed: #optional the maximum speed, in bytes per second
+@@ -1885,6 +1885,8 @@
+ # @devlist: #optional list of block device names (separated by ',', ';'
+ # or ':'). By default the backup includes all writable block devices.
  #
 +# @state: #optional flag to include vm state
 +#
  # Returns: the uuid of the backup job
  #
- # Since: 1.4.0
- ##
- { 'command': 'backup', 'data': { 'backupfile': 'str', '*format': 'BackupFormat',
--                                 '*config-filename': 'str',
+ # Since: 1.5.0
+@@ -1892,7 +1894,8 @@
+ { 'command': 'backup', 'data': { 'backup-file': 'str',
+                                  '*format': 'BackupFormat',
+                                  '*config-file': 'str',
 -                                 '*devlist': 'str', '*speed': 'int' },
-+                                 '*config-filename': 'str', '*devlist': 'str',
-+                                 '*speed': 'int', '*state': 'bool' },
++                                 '*devlist': 'str', '*speed': 'int',
++                                 '*state': 'bool' },
    'returns': 'str' }
  
  ##