26ba25
From 2343d566f8dff6f97dfb280fbf409ff20379640c Mon Sep 17 00:00:00 2001
26ba25
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
26ba25
Date: Wed, 1 Aug 2018 12:55:19 +0000
26ba25
Subject: [PATCH 14/21] migration: introduce decompress-error-check
26ba25
26ba25
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
26ba25
Message-id: <20180801135522.11658-16-dgilbert@redhat.com>
26ba25
Patchwork-id: 81575
26ba25
O-Subject: [qemu-kvm RHEL8/virt212 PATCH 15/18] migration: introduce decompress-error-check
26ba25
Bugzilla: 1594384
26ba25
RH-Acked-by: Peter Xu <peterx@redhat.com>
26ba25
RH-Acked-by: John Snow <jsnow@redhat.com>
26ba25
RH-Acked-by: Juan Quintela <quintela@redhat.com>
26ba25
26ba25
From: Xiao Guangrong <xiaoguangrong@tencent.com>
26ba25
26ba25
QEMU 3.0 enables strict check for compression & decompression to
26ba25
make the migration more robust, that depends on the source to fix
26ba25
the internal design which triggers the unexpected error conditions
26ba25
26ba25
To make it work for migrating old version QEMU to 2.13 QEMU, we
26ba25
introduce this parameter to disable the error check on the
26ba25
destination which is the default behavior of the machine type
26ba25
which is older than 2.13, alternately, the strict check can be
26ba25
enabled explicitly as followings:
26ba25
      -M pc-q35-2.11 -global migration.decompress-error-check=true
26ba25
26ba25
Signed-off-by: Xiao Guangrong <xiaoguangrong@tencent.com>
26ba25
Reviewed-by: Juan Quintela <quintela@redhat.com>
26ba25
Signed-off-by: Juan Quintela <quintela@redhat.com>
26ba25
(cherry picked from commit f548222c24342ca74689de7794f9006b43f86a54)
26ba25
  added compat entry to HW_COMPAT_RHEL7_5
26ba25
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
26ba25
  Context conflict in compat.h; 8.0 hasn't got the cirrus change 7.6 has
26ba25
---
26ba25
 hw/arm/virt.c         | 4 ++++
26ba25
 hw/i386/pc_piix.c     | 1 +
26ba25
 hw/i386/pc_q35.c      | 1 +
26ba25
 include/hw/compat.h   | 5 +++++
26ba25
 migration/migration.c | 4 ++++
26ba25
 migration/migration.h | 8 ++++++++
26ba25
 migration/ram.c       | 2 +-
26ba25
 7 files changed, 24 insertions(+), 1 deletion(-)
26ba25
26ba25
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
26ba25
index a4d0f52..751a93c 100644
26ba25
--- a/hw/arm/virt.c
26ba25
+++ b/hw/arm/virt.c
26ba25
@@ -1607,6 +1607,9 @@ static void machvirt_machine_init(void)
26ba25
 }
26ba25
 type_init(machvirt_machine_init);
26ba25
 
26ba25
+#define VIRT_COMPAT_2_12 \
26ba25
+    HW_COMPAT_2_12
26ba25
+
26ba25
 static void virt_2_12_instance_init(Object *obj)
26ba25
 {
26ba25
     VirtMachineState *vms = VIRT_MACHINE(obj);
26ba25
@@ -1669,6 +1672,7 @@ static void virt_2_12_instance_init(Object *obj)
26ba25
 
26ba25
 static void virt_machine_2_12_options(MachineClass *mc)
26ba25
 {
26ba25
+    SET_MACHINE_COMPAT(mc, VIRT_COMPAT_2_12);
26ba25
 }
26ba25
 DEFINE_VIRT_MACHINE_AS_LATEST(2, 12)
26ba25
 
26ba25
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
26ba25
index 60441c1..9d9cee0 100644
26ba25
--- a/hw/i386/pc_piix.c
26ba25
+++ b/hw/i386/pc_piix.c
26ba25
@@ -432,6 +432,7 @@ static void pc_i440fx_2_12_machine_options(MachineClass *m)
26ba25
     pc_i440fx_machine_options(m);
26ba25
     m->alias = "pc";
26ba25
     m->is_default = 1;
26ba25
+    SET_MACHINE_COMPAT(m, PC_COMPAT_2_12);
26ba25
 }
26ba25
 
26ba25
 DEFINE_I440FX_MACHINE(v2_12, "pc-i440fx-2.12", NULL,
26ba25
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
26ba25
index ccdeb11..90f12b1 100644
26ba25
--- a/hw/i386/pc_q35.c
26ba25
+++ b/hw/i386/pc_q35.c
26ba25
@@ -313,6 +313,7 @@ static void pc_q35_2_12_machine_options(MachineClass *m)
26ba25
 {
26ba25
     pc_q35_machine_options(m);
26ba25
     m->alias = "q35";
26ba25
+    SET_MACHINE_COMPAT(m, PC_COMPAT_2_12);
26ba25
 }
26ba25
 
26ba25
 DEFINE_Q35_MACHINE(v2_12, "pc-q35-2.12", NULL,
26ba25
diff --git a/include/hw/compat.h b/include/hw/compat.h
26ba25
index c343e8f..8b59c30 100644
26ba25
--- a/include/hw/compat.h
26ba25
+++ b/include/hw/compat.h
26ba25
@@ -477,6 +477,11 @@
26ba25
         .driver   = "cirrus-vga",\
26ba25
         .property = "vgamem_mb",\
26ba25
         .value    = "16",\
26ba25
+    },{ /* HW_COMPAT_RHEL7_5 */ \
26ba25
+        .driver   = "migration",\
26ba25
+        .property = "decompress-error-check",\
26ba25
+        .value    = "off",\
26ba25
     },
26ba25
 
26ba25
+
26ba25
 #endif /* HW_COMPAT_H */
26ba25
diff --git a/migration/migration.c b/migration/migration.c
26ba25
index 43d8a64..b6294f6 100644
26ba25
--- a/migration/migration.c
26ba25
+++ b/migration/migration.c
26ba25
@@ -2483,6 +2483,8 @@ void migration_global_dump(Monitor *mon)
26ba25
                    ms->send_configuration ? "on" : "off");
26ba25
     monitor_printf(mon, "send-section-footer: %s\n",
26ba25
                    ms->send_section_footer ? "on" : "off");
26ba25
+    monitor_printf(mon, "decompress-error-check: %s\n",
26ba25
+                   ms->decompress_error_check ? "on" : "off");
26ba25
 }
26ba25
 
26ba25
 #define DEFINE_PROP_MIG_CAP(name, x)             \
26ba25
@@ -2496,6 +2498,8 @@ static Property migration_properties[] = {
26ba25
                      send_configuration, true),
26ba25
     DEFINE_PROP_BOOL("send-section-footer", MigrationState,
26ba25
                      send_section_footer, true),
26ba25
+    DEFINE_PROP_BOOL("decompress-error-check", MigrationState,
26ba25
+                      decompress_error_check, true),
26ba25
 
26ba25
     /* Migration parameters */
26ba25
     DEFINE_PROP_UINT8("x-compress-level", MigrationState,
26ba25
diff --git a/migration/migration.h b/migration/migration.h
26ba25
index 06833d7..a9c5c7f 100644
26ba25
--- a/migration/migration.h
26ba25
+++ b/migration/migration.h
26ba25
@@ -182,6 +182,14 @@ struct MigrationState
26ba25
     bool send_configuration;
26ba25
     /* Whether we send section footer during migration */
26ba25
     bool send_section_footer;
26ba25
+
26ba25
+    /*
26ba25
+     * Whether we abort the migration if decompression errors are
26ba25
+     * detected at the destination. It is left at false for qemu
26ba25
+     * older than 3.0, since only newer qemu sends streams that
26ba25
+     * do not trigger spurious decompression errors.
26ba25
+     */
26ba25
+    bool decompress_error_check;
26ba25
 };
26ba25
 
26ba25
 void migrate_set_state(int *state, int old_state, int new_state);
26ba25
diff --git a/migration/ram.c b/migration/ram.c
26ba25
index c982201..bd563b5 100644
26ba25
--- a/migration/ram.c
26ba25
+++ b/migration/ram.c
26ba25
@@ -2582,7 +2582,7 @@ static void *do_data_decompress(void *opaque)
26ba25
 
26ba25
             ret = qemu_uncompress_data(¶m->stream, des, pagesize,
26ba25
                                        param->compbuf, len);
26ba25
-            if (ret < 0) {
26ba25
+            if (ret < 0 && migrate_get_current()->decompress_error_check) {
26ba25
                 error_report("decompress data failed");
26ba25
                 qemu_file_set_error(decomp_file, ret);
26ba25
             }
26ba25
-- 
26ba25
1.8.3.1
26ba25