yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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