Blame SOURCES/kvm-migration-introduce-decompress-error-check.patch

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