[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 13/14] ram-compress.c: Make target independent
From: |
Lukas Straub |
Subject: |
[PATCH 13/14] ram-compress.c: Make target independent |
Date: |
Sun, 2 Apr 2023 17:56:45 +0000 |
Make ram-compress.c target independent.
Signed-off-by: Lukas Straub <lukasstraub2@web.de>
---
migration/meson.build | 2 +-
migration/ram-compress.c | 16 +++++++++-------
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/migration/meson.build b/migration/meson.build
index 262e3c9754..16f642031c 100644
--- a/migration/meson.build
+++ b/migration/meson.build
@@ -22,6 +22,7 @@ softmmu_ss.add(files(
'migration.c',
'multifd.c',
'multifd-zlib.c',
+ 'ram-compress.c',
'postcopy-ram.c',
'savevm.c',
'socket.c',
@@ -38,5 +39,4 @@ softmmu_ss.add(when: zstd, if_true: files('multifd-zstd.c'))
specific_ss.add(when: 'CONFIG_SOFTMMU',
if_true: files('dirtyrate.c',
'ram.c',
- 'ram-compress.c',
'target.c'))
diff --git a/migration/ram-compress.c b/migration/ram-compress.c
index b75a9d2b9a..a75c6e0573 100644
--- a/migration/ram-compress.c
+++ b/migration/ram-compress.c
@@ -34,7 +34,8 @@
#include "qemu/error-report.h"
#include "migration.h"
#include "io/channel-null.h"
-#include "exec/ram_addr.h"
+#include "exec/target_page.h"
+#include "exec/ramblock.h"
CompressionStats compression_counters;
@@ -155,7 +156,7 @@ int compress_threads_save_setup(void)
qemu_cond_init(&comp_done_cond);
qemu_mutex_init(&comp_done_lock);
for (i = 0; i < thread_count; i++) {
- comp_param[i].originbuf = g_try_malloc(TARGET_PAGE_SIZE);
+ comp_param[i].originbuf = g_try_malloc(qemu_target_page_size());
if (!comp_param[i].originbuf) {
goto exit;
}
@@ -195,7 +196,7 @@ static CompressResult do_compress_ram_page(QEMUFile *f,
z_stream *stream,
assert(qemu_file_buffer_empty(f));
- if (buffer_is_zero(p, TARGET_PAGE_SIZE)) {
+ if (buffer_is_zero(p, qemu_target_page_size())) {
return RES_ZEROPAGE;
}
@@ -204,8 +205,8 @@ static CompressResult do_compress_ram_page(QEMUFile *f,
z_stream *stream,
* so that we can catch up the error during compression and
* decompression
*/
- memcpy(source_buf, p, TARGET_PAGE_SIZE);
- ret = qemu_put_compression_data(f, stream, source_buf, TARGET_PAGE_SIZE);
+ memcpy(source_buf, p, qemu_target_page_size());
+ ret = qemu_put_compression_data(f, stream, source_buf,
qemu_target_page_size());
if (ret < 0) {
qemu_file_set_error(migrate_get_current()->to_dst_file, ret);
error_report("compressed data failed!");
@@ -335,7 +336,7 @@ static void *do_data_decompress(void *opaque)
param->des = 0;
qemu_mutex_unlock(¶m->mutex);
- pagesize = TARGET_PAGE_SIZE;
+ pagesize = qemu_target_page_size();
ret = qemu_uncompress_data(¶m->stream, des, pagesize,
param->compbuf, len);
@@ -438,7 +439,8 @@ int compress_threads_load_setup(QEMUFile *f)
goto exit;
}
- decomp_param[i].compbuf = g_malloc0(compressBound(TARGET_PAGE_SIZE));
+ size_t compbuf_size = compressBound(qemu_target_page_size());
+ decomp_param[i].compbuf = g_malloc0(compbuf_size);
qemu_mutex_init(&decomp_param[i].mutex);
qemu_cond_init(&decomp_param[i].cond);
decomp_param[i].done = true;
--
2.30.2
pgpDJ0jZ66Yho.pgp
Description: OpenPGP digital signature
- [PATCH 05/14] ram.c: Call update_compress_thread_counts from compress_send_queued_data, (continued)
- [PATCH 05/14] ram.c: Call update_compress_thread_counts from compress_send_queued_data, Lukas Straub, 2023/04/02
- [PATCH 06/14] ram.c: Remove last ram.c dependency from the core compress code, Lukas Straub, 2023/04/02
- [PATCH 07/14] ram.c: Introduce whitespace (squash with next patch), Lukas Straub, 2023/04/02
- [PATCH 08/14] ram.c: Move core compression code into its own file, Lukas Straub, 2023/04/02
- [PATCH 09/14] ram.c: Remove whitespace (squash with previous patch), Lukas Straub, 2023/04/02
- [PATCH 10/14] ram.c: Move core decompression code into its own file, Lukas Straub, 2023/04/02
- [PATCH 11/14] ram compress: Assert that the file buffer matches the result, Lukas Straub, 2023/04/02
- [PATCH 12/14] ram.c: Remove unused include after moving out code, Lukas Straub, 2023/04/02
- [PATCH 13/14] ram-compress.c: Make target independent,
Lukas Straub <=
- [PATCH 14/14] migration: Initialize and cleanup decompression in migration.c, Lukas Straub, 2023/04/02
- RE: [PATCH 00/14] migration/ram.c: Refactor compress code, Zhang, Chen, 2023/04/02
- Re: [PATCH 00/14] migration/ram.c: Refactor compress code, Lukas Straub, 2023/04/05