aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Straub <lukasstraub2@web.de>2023-04-20 11:48:35 +0200
committerJuan Quintela <quintela@redhat.com>2023-05-08 15:25:26 +0200
commit52623f23b0d114837a0d6278180b3e3ae8947117 (patch)
tree775b79717ee907041eacd6715c4e69f16bdc9cb2
parent4024cc8506139a8f04f3f99ba478880410af10f5 (diff)
downloadqemu-52623f23b0d114837a0d6278180b3e3ae8947117.zip
qemu-52623f23b0d114837a0d6278180b3e3ae8947117.tar.gz
qemu-52623f23b0d114837a0d6278180b3e3ae8947117.tar.bz2
ram-compress.c: Make target independent
Make ram-compress.c target independent. Signed-off-by: Lukas Straub <lukasstraub2@web.de> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
-rw-r--r--migration/meson.build3
-rw-r--r--migration/ram-compress.c17
2 files changed, 12 insertions, 8 deletions
diff --git a/migration/meson.build b/migration/meson.build
index 2090af8..75de868 100644
--- a/migration/meson.build
+++ b/migration/meson.build
@@ -23,6 +23,8 @@ softmmu_ss.add(files(
'migration.c',
'multifd.c',
'multifd-zlib.c',
+ 'multifd-zlib.c',
+ 'ram-compress.c',
'options.c',
'postcopy-ram.c',
'savevm.c',
@@ -40,5 +42,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 3d2a4a6..06254d8 100644
--- a/migration/ram-compress.c
+++ b/migration/ram-compress.c
@@ -35,7 +35,8 @@
#include "migration.h"
#include "options.h"
#include "io/channel-null.h"
-#include "exec/ram_addr.h"
+#include "exec/target_page.h"
+#include "exec/ramblock.h"
CompressionStats compression_counters;
@@ -156,7 +157,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;
}
@@ -192,11 +193,12 @@ static CompressResult do_compress_ram_page(QEMUFile *f, z_stream *stream,
uint8_t *source_buf)
{
uint8_t *p = block->host + offset;
+ size_t page_size = qemu_target_page_size();
int ret;
assert(qemu_file_buffer_empty(f));
- if (buffer_is_zero(p, TARGET_PAGE_SIZE)) {
+ if (buffer_is_zero(p, page_size)) {
return RES_ZEROPAGE;
}
@@ -205,8 +207,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, page_size);
+ ret = qemu_put_compression_data(f, stream, source_buf, page_size);
if (ret < 0) {
qemu_file_set_error(migrate_get_current()->to_dst_file, ret);
error_report("compressed data failed!");
@@ -336,7 +338,7 @@ static void *do_data_decompress(void *opaque)
param->des = 0;
qemu_mutex_unlock(&param->mutex);
- pagesize = TARGET_PAGE_SIZE;
+ pagesize = qemu_target_page_size();
ret = qemu_uncompress_data(&param->stream, des, pagesize,
param->compbuf, len);
@@ -439,7 +441,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;