migration/multifd: put IOV initialization into compression method
Different compression methods may require different numbers of IOVs. Based on streaming compression of zlib and zstd, all pages will be compressed to a data block, so two IOVs are needed for packet header and compressed data block. Signed-off-by: Yuan Liu <yuan1.liu@intel.com> Reviewed-by: Nanhai Zou <nanhai.zou@intel.com> Reviewed-by: Fabiano Rosas <farosas@suse.de> Reviewed-by: Peter Xu <peterx@redhat.com> Signed-off-by: Fabiano Rosas <farosas@suse.de>
This commit is contained in:
@@ -52,7 +52,6 @@ static int zstd_send_setup(MultiFDSendParams *p, Error **errp)
|
||||
struct zstd_data *z = g_new0(struct zstd_data, 1);
|
||||
int res;
|
||||
|
||||
p->compress_data = z;
|
||||
z->zcs = ZSTD_createCStream();
|
||||
if (!z->zcs) {
|
||||
g_free(z);
|
||||
@@ -77,6 +76,10 @@ static int zstd_send_setup(MultiFDSendParams *p, Error **errp)
|
||||
error_setg(errp, "multifd %u: out of memory for zbuff", p->id);
|
||||
return -1;
|
||||
}
|
||||
p->compress_data = z;
|
||||
|
||||
/* Needs 2 IOVs, one for packet header and one for compressed data */
|
||||
p->iov = g_new0(struct iovec, 2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -98,6 +101,9 @@ static void zstd_send_cleanup(MultiFDSendParams *p, Error **errp)
|
||||
z->zbuff = NULL;
|
||||
g_free(p->compress_data);
|
||||
p->compress_data = NULL;
|
||||
|
||||
g_free(p->iov);
|
||||
p->iov = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user