thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-multifd-Make-zstd-compression-method-not-use-iovs.patch

0727d3
From ab6262bd4829e3bd6437fe32737209df2af2d141 Mon Sep 17 00:00:00 2001
0727d3
From: Juan Quintela <quintela@redhat.com>
0727d3
Date: Wed, 18 May 2022 02:52:23 -0300
0727d3
Subject: [PATCH 08/37] multifd: Make zstd compression method not use iovs
0727d3
MIME-Version: 1.0
0727d3
Content-Type: text/plain; charset=UTF-8
0727d3
Content-Transfer-Encoding: 8bit
0727d3
0727d3
RH-Author: Leonardo Brás <leobras@redhat.com>
0727d3
RH-MergeRequest: 191: MSG_ZEROCOPY + Multifd @ rhel8.7
0727d3
RH-Commit: [8/26] 010579fa73b5a4c6fd631dc9fbaf6f974974bc99
0727d3
RH-Bugzilla: 2072049
0727d3
RH-Acked-by: Peter Xu <peterx@redhat.com>
0727d3
RH-Acked-by: Daniel P. Berrangé <berrange@redhat.com>
0727d3
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
0727d3
0727d3
Signed-off-by: Juan Quintela <quintela@redhat.com>
0727d3
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
0727d3
(cherry picked from commit f5ff548774c22b34a0c0e2fef85f1be11160d774)
0727d3
Signed-off-by: Leonardo Bras <leobras@redhat.com>
0727d3
---
0727d3
 migration/multifd-zstd.c | 20 ++++++++++----------
0727d3
 1 file changed, 10 insertions(+), 10 deletions(-)
0727d3
0727d3
diff --git a/migration/multifd-zstd.c b/migration/multifd-zstd.c
0727d3
index f0d1105792..d9ed42622b 100644
0727d3
--- a/migration/multifd-zstd.c
0727d3
+++ b/migration/multifd-zstd.c
0727d3
@@ -13,6 +13,7 @@
0727d3
 #include "qemu/osdep.h"
0727d3
 #include <zstd.h>
0727d3
 #include "qemu/rcu.h"
0727d3
+#include "exec/ramblock.h"
0727d3
 #include "exec/target_page.h"
0727d3
 #include "qapi/error.h"
0727d3
 #include "migration.h"
0727d3
@@ -113,8 +114,8 @@ static void zstd_send_cleanup(MultiFDSendParams *p, Error **errp)
0727d3
  */
0727d3
 static int zstd_send_prepare(MultiFDSendParams *p, Error **errp)
0727d3
 {
0727d3
-    struct iovec *iov = p->pages->iov;
0727d3
     struct zstd_data *z = p->data;
0727d3
+    size_t page_size = qemu_target_page_size();
0727d3
     int ret;
0727d3
     uint32_t i;
0727d3
 
0727d3
@@ -128,8 +129,8 @@ static int zstd_send_prepare(MultiFDSendParams *p, Error **errp)
0727d3
         if (i == p->pages->num - 1) {
0727d3
             flush = ZSTD_e_flush;
0727d3
         }
0727d3
-        z->in.src = iov[i].iov_base;
0727d3
-        z->in.size = iov[i].iov_len;
0727d3
+        z->in.src = p->pages->block->host + p->pages->offset[i];
0727d3
+        z->in.size = page_size;
0727d3
         z->in.pos = 0;
0727d3
 
0727d3
         /*
0727d3
@@ -261,7 +262,8 @@ static int zstd_recv_pages(MultiFDRecvParams *p, Error **errp)
0727d3
 {
0727d3
     uint32_t in_size = p->next_packet_size;
0727d3
     uint32_t out_size = 0;
0727d3
-    uint32_t expected_size = p->pages->num * qemu_target_page_size();
0727d3
+    size_t page_size = qemu_target_page_size();
0727d3
+    uint32_t expected_size = p->pages->num * page_size;
0727d3
     uint32_t flags = p->flags & MULTIFD_FLAG_COMPRESSION_MASK;
0727d3
     struct zstd_data *z = p->data;
0727d3
     int ret;
0727d3
@@ -283,10 +285,8 @@ static int zstd_recv_pages(MultiFDRecvParams *p, Error **errp)
0727d3
     z->in.pos = 0;
0727d3
 
0727d3
     for (i = 0; i < p->pages->num; i++) {
0727d3
-        struct iovec *iov = &p->pages->iov[i];
0727d3
-
0727d3
-        z->out.dst = iov->iov_base;
0727d3
-        z->out.size = iov->iov_len;
0727d3
+        z->out.dst = p->pages->block->host + p->pages->offset[i];
0727d3
+        z->out.size = page_size;
0727d3
         z->out.pos = 0;
0727d3
 
0727d3
         /*
0727d3
@@ -300,8 +300,8 @@ static int zstd_recv_pages(MultiFDRecvParams *p, Error **errp)
0727d3
         do {
0727d3
             ret = ZSTD_decompressStream(z->zds, &z->out, &z->in);
0727d3
         } while (ret > 0 && (z->in.size - z->in.pos > 0)
0727d3
-                         && (z->out.pos < iov->iov_len));
0727d3
-        if (ret > 0 && (z->out.pos < iov->iov_len)) {
0727d3
+                         && (z->out.pos < page_size));
0727d3
+        if (ret > 0 && (z->out.pos < page_size)) {
0727d3
             error_setg(errp, "multifd %d: decompressStream buffer too small",
0727d3
                        p->id);
0727d3
             return -1;
0727d3
-- 
0727d3
2.35.3
0727d3