migration/multifd: Switch to no compression when no hardware support

Send raw packets over if UADK hardware support is not available. This is to
satisfy  Qemu qtest CI which may run on platforms that don't have UADK
hardware support. Subsequent patch will add support for uadk migration
qtest.

Reviewed-by: Fabiano Rosas <farosas@suse.de>
Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
Reviewed-by: Zhangfei Gao <zhangfei.gao@linaro.org>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
This commit is contained in:
Shameer Kolothum 2024-06-07 14:53:09 +01:00 committed by Fabiano Rosas
parent 3c49191a0d
commit c1dfd12168
1 changed files with 53 additions and 39 deletions

View File

@ -17,6 +17,7 @@
#include "migration.h" #include "migration.h"
#include "multifd.h" #include "multifd.h"
#include "options.h" #include "options.h"
#include "qemu/error-report.h"
#include "uadk/wd_comp.h" #include "uadk/wd_comp.h"
#include "uadk/wd_sched.h" #include "uadk/wd_sched.h"
@ -48,12 +49,9 @@ static struct wd_data *multifd_uadk_init_sess(uint32_t count,
uint32_t size = count * page_size; uint32_t size = count * page_size;
struct wd_data *wd; struct wd_data *wd;
if (!uadk_hw_init()) {
error_setg(errp, "multifd: UADK hardware not available");
return NULL;
}
wd = g_new0(struct wd_data, 1); wd = g_new0(struct wd_data, 1);
if (uadk_hw_init()) {
ss.alg_type = WD_ZLIB; ss.alg_type = WD_ZLIB;
if (compress) { if (compress) {
ss.op_type = WD_DIR_COMPRESS; ss.op_type = WD_DIR_COMPRESS;
@ -62,7 +60,6 @@ static struct wd_data *multifd_uadk_init_sess(uint32_t count,
} else { } else {
ss.op_type = WD_DIR_DECOMPRESS; ss.op_type = WD_DIR_DECOMPRESS;
} }
/* We use default level 1 compression and 4K window size */ /* We use default level 1 compression and 4K window size */
param.type = ss.op_type; param.type = ss.op_type;
ss.sched_param = &param; ss.sched_param = &param;
@ -72,6 +69,10 @@ static struct wd_data *multifd_uadk_init_sess(uint32_t count,
error_setg(errp, "multifd: failed wd_comp_alloc_sess"); error_setg(errp, "multifd: failed wd_comp_alloc_sess");
goto out; goto out;
} }
} else {
/* For CI test use */
warn_report_once("UADK hardware not available. Switch to no compression mode");
}
wd->buf = g_try_malloc(size); wd->buf = g_try_malloc(size);
if (!wd->buf) { if (!wd->buf) {
@ -82,7 +83,9 @@ static struct wd_data *multifd_uadk_init_sess(uint32_t count,
return wd; return wd;
out_free_sess: out_free_sess:
if (wd->handle) {
wd_comp_free_sess(wd->handle); wd_comp_free_sess(wd->handle);
}
out: out:
wd_comp_uninit2(); wd_comp_uninit2();
g_free(wd); g_free(wd);
@ -91,7 +94,9 @@ out:
static void multifd_uadk_uninit_sess(struct wd_data *wd) static void multifd_uadk_uninit_sess(struct wd_data *wd)
{ {
if (wd->handle) {
wd_comp_free_sess(wd->handle); wd_comp_free_sess(wd->handle);
}
wd_comp_uninit2(); wd_comp_uninit2();
g_free(wd->buf); g_free(wd->buf);
g_free(wd->buf_hdr); g_free(wd->buf_hdr);
@ -188,6 +193,7 @@ static int multifd_uadk_send_prepare(MultiFDSendParams *p, Error **errp)
.dst_len = p->page_size * 2, .dst_len = p->page_size * 2,
}; };
if (uadk_data->handle) {
ret = wd_do_comp_sync(uadk_data->handle, &creq); ret = wd_do_comp_sync(uadk_data->handle, &creq);
if (ret || creq.status) { if (ret || creq.status) {
error_setg(errp, "multifd %u: failed compression, ret %d status %d", error_setg(errp, "multifd %u: failed compression, ret %d status %d",
@ -198,13 +204,15 @@ static int multifd_uadk_send_prepare(MultiFDSendParams *p, Error **errp)
uadk_data->buf_hdr[i] = cpu_to_be32(creq.dst_len); uadk_data->buf_hdr[i] = cpu_to_be32(creq.dst_len);
prepare_next_iov(p, buf, creq.dst_len); prepare_next_iov(p, buf, creq.dst_len);
buf += creq.dst_len; buf += creq.dst_len;
} else { }
}
/* /*
* Send raw data if compressed out >= page_size. We might be better * Send raw data if no UADK hardware or if compressed out >= page_size.
* off sending raw data if output is slightly less than page_size * We might be better off sending raw data if output is slightly less
* as well because at the receive end we can skip the decompression. * than page_size as well because at the receive end we can skip the
* But it is tricky to find the right number here. * decompression. But it is tricky to find the right number here.
*/ */
if (!uadk_data->handle || creq.dst_len >= p->page_size) {
uadk_data->buf_hdr[i] = cpu_to_be32(p->page_size); uadk_data->buf_hdr[i] = cpu_to_be32(p->page_size);
prepare_next_iov(p, p->pages->block->host + p->pages->offset[i], prepare_next_iov(p, p->pages->block->host + p->pages->offset[i],
p->page_size); p->page_size);
@ -323,6 +331,12 @@ static int multifd_uadk_recv(MultiFDRecvParams *p, Error **errp)
continue; continue;
} }
if (unlikely(!uadk_data->handle)) {
error_setg(errp, "multifd %u: UADK HW not available for decompression",
p->id);
return -1;
}
ret = wd_do_comp_sync(uadk_data->handle, &creq); ret = wd_do_comp_sync(uadk_data->handle, &creq);
if (ret || creq.status) { if (ret || creq.status) {
error_setg(errp, "multifd %u: failed decompression, ret %d status %d", error_setg(errp, "multifd %u: failed decompression, ret %d status %d",