[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 8/9] tools/xl: mark LZ4 migration streams with a mandatory header flag
- To: Marcus Granado <marcus.granado@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
- From: Teddy Astie <teddy.astie@xxxxxxxxxx>
- Date: Thu, 29 Oct 2026 12:39:30 +0100
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=vates.tech header.i="@vates.tech" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:In-Reply-To:References:Feedback-ID"
- Autocrypt: addr=teddy.astie@xxxxxxxxxx; keydata= xsDNBGn5sK8BDACuzSrrTjpVf4ay06OYB6yY0J1PqKffihoNMtrQRZjAHxoAPC7LTBVHV/XO Zw5HJc+9R71z1JV+iYg6z3jPziGKzX8Fj3ZXlzJPmpf1PuETH3KdbvtJT4ny+OGntnJntUoR KRPhTirr6yNeBk/637O3CQXjtqFUPZnko8OI/o1yawIBhJJAWicutjkkUgd28Bh6HV9EIumH tCBgn5/1A/fpm9624MMgYLsA8qjC4XsoovQvFCaO8HEhvfzrrTZHjn/nPeB9SigxIxXW8YaT VqMdqul07o72m3eA2mf+LMu9a04FX/d4wbxBLtELm+1jIrbtyaFZEMOLv/haSiS/Lj3btJH/ EoucejoZ5SH49ksmVAmKOLktOaTQ8b2gEvP7iaKiIiszCCtOSRohr+2GvDsDeLvVZnlR3I+S PhHar7TPKjFz0G3DPNolyjXywNqOAMpomSPi8lSwjAFsxOtQbcck/qRGRSNk4DAmH70pA+89 MXfQXZ3qt1Q01B1+sU0I8xsAEQEAAc0kVGVkZHkgQXN0aWUgPHRlZGR5LmFzdGllQHZhdGVz LnRlY2g+wsENBBMBCAA3FiEEGAIew9LzHY3pdrqtZg+p0QLLz9AFAmn5sK8FCQWjmoACGwME CwkIBwUVCAkKCwUWAgMBAAAKCRBmD6nRAsvP0ID6DACGOktArFbLKHNzuyOVCskwfUZPla6Z pd3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A CgkQZg+p0QLLz9DncQwAg76IehTemLIfrB8T9WIBZrI4kUV7G7a4rjiVoUiHYN5QwhnbZnsa JDlt+Ezoqy/510eo2bCSzvW5xXYPgyjcuOPwgQo1Qp764QxyX6rld2f2RcWkDuBHun55ZWXj by8o21ginPRwruBVYY5rVf3DV1iBu4NurUeHtyFk/dS0XTOQi2wVUb17sW/+ybCEokdVacZG zOqP/OmwHrF8ylXlXnhQq6e3r+J+T8fuoGJelm/CJiMwyP6cEWE8sxVqX/iqwjwUYkuOCpE+ lOWSvdNHgoEkWR0RXBPQjnGmLKbfTl/QDXLk6NP2/r9uxm2HL6Ei3QJKSEdrp+XZaVnk/Off O485NOTKwGOxyWb006cTMh53xPkAJFQu4Tvdj+odsHz88jqw5wfPG0BYWx0I/FspYj7N9kZR 8ULR9nX0LvpzJ/kB4NgHIUt8YtIL6ZSfM2dbF7fKzvx1UqFfvozJZwFzfEieJLXa4nlGgR6D x9fhaZEsniw8/bYgC3igkk5YJiOa
- Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Frediano Ziglio <freddy77@xxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
- Delivery-date: Thu, 29 Oct 2026 11:39:43 +0000
- Feedback-id: default:8631fc262581453bbf619ec5b2062170:Sweego
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
Le 20/10/2026 à 22:06, Marcus Granado a écrit :
A receiver which cannot decompress LZ4 rejects the first compressed
PAGE_DATA record. That is late: the receiver has already created the
domain, precopy has started, and an older libxenguest's error says
nothing about compression.
xl can fail earlier. Its save file header carries mandatory_flags, and
create_domain() rejects unknown bits before it calls
libxl_domain_create_restore(). Similar to commit e72ce244dc91
("tools/xl: Mandatory flag indicating the format of the migration
stream"), claim bit 2 for LZ4 and set it for "xl migrate --compress".
An older xl then reports mandatory flag 0x4 as unsupported and creates
no domain.
This is defence in depth, for xl-to-xl migration only. An xl which
knows the flag but whose libxenguest lacks liblz4 still accepts the
header and fails late, at the first compressed PAGE_DATA record, though
with an error that names LZ4. The header is written before any record,
so a stream in which no record ends up compressed still carries the
flag and needs an LZ4-aware xl.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Marcus Granado <marcus.granado@xxxxxxxxxx>
---
I think it would be preferable to check for libxenguest lz4 support as
well, so that libxenguest without lz4 would fail the same way as
libxenguest prior to this patch.
Notes:
Changes in v2:
- New, after an off-list question from Ross Lagerwall: an older xl
now refuses a compressed stream before it creates the domain.
tools/xl/xl.h | 7 +++++--
tools/xl/xl_migrate.c | 8 ++++----
tools/xl/xl_saverestore.c | 7 +++++--
3 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/tools/xl/xl.h b/tools/xl/xl.h
index 7b75f9a493..009cbd1c3c 100644
--- a/tools/xl/xl.h
+++ b/tools/xl/xl.h
@@ -77,8 +77,10 @@ static const char migrate_report[]=
#define XL_MANDATORY_FLAG_JSON (1U << 0) /* config data is in JSON format */
#define XL_MANDATORY_FLAG_STREAMv2 (1U << 1) /* stream is v2 */
+#define XL_MANDATORY_FLAG_COMPRESS_LZ4 (1U << 2) /* PAGE_DATA may use LZ4 */
#define XL_MANDATORY_FLAG_ALL (XL_MANDATORY_FLAG_JSON | \
- XL_MANDATORY_FLAG_STREAMv2)
+ XL_MANDATORY_FLAG_STREAMv2 | \
+ XL_MANDATORY_FLAG_COMPRESS_LZ4)
struct save_file_header {
char magic[32]; /* savefileheader_magic */
@@ -102,7 +104,8 @@ void save_domain_core_begin(uint32_t domid,
uint8_t **config_data_r,
int *config_len_r);
void save_domain_core_writeconfig(int fd, const char *source,
- const uint8_t *config_data, int config_len);
+ const uint8_t *config_data, int config_len,
+ int compress_lz4);
/*
* The xl process should always return either EXIT_SUCCESS or
diff --git a/tools/xl/xl_migrate.c b/tools/xl/xl_migrate.c
index 31a8cb4f32..230aac1b71 100644
--- a/tools/xl/xl_migrate.c
+++ b/tools/xl/xl_migrate.c
@@ -153,7 +153,7 @@ static void migration_child_report(int recv_fd) {
static void migrate_do_preamble(int send_fd, int recv_fd, pid_t child,
uint8_t *config_data, int config_len,
- const char *rune)
+ const char *rune, int compress_lz4)
{
int rc = 0;
@@ -172,7 +172,7 @@ static void migrate_do_preamble(int send_fd, int recv_fd, pid_t child,
}
save_domain_core_writeconfig(send_fd, "migration stream",
- config_data, config_len);
+ config_data, config_len, compress_lz4);
}
@@ -200,7 +200,7 @@ static void migrate_domain(uint32_t domid, int preserve_domid,
child = create_migration_child(rune, &send_fd, &recv_fd);
migrate_do_preamble(send_fd, recv_fd, child, config_data, config_len,
- rune);
+ rune, compress_lz4);
xtl_stdiostream_adjust_flags(logger, XTL_STDIOSTREAM_HIDE_PROGRESS, 0);
@@ -740,7 +740,7 @@ int main_remus(int argc, char **argv)
child = create_migration_child(rune, &send_fd, &recv_fd);
migrate_do_preamble(send_fd, recv_fd, child, config_data, config_len,
- rune);
+ rune, 0);
if (ssh_command[0])
free(rune);
diff --git a/tools/xl/xl_saverestore.c b/tools/xl/xl_saverestore.c
index 747094ec7b..5151c8a130 100644
--- a/tools/xl/xl_saverestore.c
+++ b/tools/xl/xl_saverestore.c
@@ -79,7 +79,8 @@ void save_domain_core_begin(uint32_t domid,
}
void save_domain_core_writeconfig(int fd, const char *source,
- const uint8_t *config_data, int config_len)
+ const uint8_t *config_data, int config_len,
+ int compress_lz4)
{
struct save_file_header hdr;
uint8_t *optdata_begin;
@@ -89,6 +90,8 @@ void save_domain_core_writeconfig(int fd, const char *source,
memcpy(hdr.magic, savefileheader_magic, sizeof(hdr.magic));
hdr.byteorder = SAVEFILE_BYTEORDER_VALUE;
hdr.mandatory_flags = XL_MANDATORY_FLAG_STREAMv2;
+ if (compress_lz4)
+ hdr.mandatory_flags |= XL_MANDATORY_FLAG_COMPRESS_LZ4;
optdata_begin= 0;
@@ -144,7 +147,7 @@ static int save_domain(uint32_t domid, int preserve_domid,
exit(EXIT_FAILURE);
}
- save_domain_core_writeconfig(fd, filename, config_data, config_len);
+ save_domain_core_writeconfig(fd, filename, config_data, config_len, 0);
int rc = libxl_domain_suspend(ctx, domid, fd, 0, NULL);
close(fd);
Attachment:
OpenPGP_signature.asc
Description: OpenPGP digital signature
|