[PATCH v1 5/6] tools/libs/guest: opt in to LZ4 save-side compression via XCFLAGS_COMPRESS_LZ4
Marcus Granado <[email protected]>
| Newsgroups | org.xenproject.lists.xen-devel |
|---|---|
| Message-ID | <[email protected]> |
This patch introduces a new public flag XCFLAGS_COMPRESS_LZ4 (bit 2) that can be used to enable the LZ4 migration compression. xc_domain_save() now starts with ctx.compression = XC_SR_COMPRESS_NONE and only switches to XC_SR_COMPRESS_LZ4 when the caller sets the flag. When this flag is clear, libxenguest emits the legacy REC_TYPE_PAGE_DATA records just as it did before this series. Signed-off-by: Marcus Granado <[email protected]> --- tools/include/xenguest.h | 5 +++-- tools/libs/guest/xg_sr_save.c | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/include/xenguest.h b/tools/include/xenguest.h index 2a277cb7cd..332c95f45b 100644 --- a/tools/include/xenguest.h +++ b/tools/include/xenguest.h @@ -24,8 +24,9 @@ #define XC_NUMA_NO_NODE (~0U) -#define XCFLAGS_LIVE (1 << 0) -#define XCFLAGS_DEBUG (1 << 1) +#define XCFLAGS_LIVE (1 << 0) +#define XCFLAGS_DEBUG (1 << 1) +#define XCFLAGS_COMPRESS_LZ4 (1 << 2) /* Compress PAGE_DATA with LZ4 on save */ #define X86_64_B_SIZE 64 #define X86_32_B_SIZE 32 diff --git a/tools/libs/guest/xg_sr_save.c b/tools/libs/guest/xg_sr_save.c index dbbcddf6fd..6eae9894d3 100644 --- a/tools/libs/guest/xg_sr_save.c +++ b/tools/libs/guest/xg_sr_save.c @@ -1317,6 +1317,17 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, bool hvm; ctx.compression = XC_SR_COMPRESS_NONE; + if ( flags & XCFLAGS_COMPRESS_LZ4 ) + { +#ifdef HAVE_LZ4 + ctx.compression = XC_SR_COMPRESS_LZ4; +#else + ERROR("XCFLAGS_COMPRESS_LZ4 requested but libxenguest was built " + "without liblz4 support"); + errno = EOPNOTSUPP; + return -1; +#endif + } /* GCC 4.4 (of CentOS 6.x vintage) can' t initialise anonymous unions. */ ctx.save.callbacks = callbacks; -- 2.43.0