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

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