|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] libs/guest: Use a single write_exact() in write_headers()
commit dfb11094ae586a1ccc3cfab9e93c7099aed0cede
Author: Frediano Ziglio <freddy77@xxxxxxxxx>
AuthorDate: Fri Jun 19 14:04:49 2026 +0100
Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Wed Jul 8 15:35:45 2026 +0100
libs/guest: Use a single write_exact() in write_headers()
Reduce number of syscalls by coalescing the image and the domain headers.
Signed-off-by: Frediano Ziglio <frediano.ziglio@xxxxxxxxxx>
Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Acked-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
---
tools/libs/guest/xg_sr_save.c | 37 ++++++++++++++++++-------------------
1 file changed, 18 insertions(+), 19 deletions(-)
diff --git a/tools/libs/guest/xg_sr_save.c b/tools/libs/guest/xg_sr_save.c
index fdbceab52e..6f310d6d8c 100644
--- a/tools/libs/guest/xg_sr_save.c
+++ b/tools/libs/guest/xg_sr_save.c
@@ -10,17 +10,22 @@ static int write_headers(struct xc_sr_context *ctx,
uint16_t guest_type)
{
xc_interface *xch = ctx->xch;
int32_t xen_version = xc_version(xch, XENVER_version, NULL);
- struct xc_sr_ihdr ihdr = {
- .marker = IHDR_MARKER,
- .id = htonl(IHDR_ID),
- .version = htonl(3),
- .options = htons(IHDR_OPT_LITTLE_ENDIAN),
- };
- struct xc_sr_dhdr dhdr = {
- .type = guest_type,
- .page_shift = XC_PAGE_SHIFT,
- .xen_major = (xen_version >> 16) & 0xffff,
- .xen_minor = (xen_version) & 0xffff,
+ struct {
+ struct xc_sr_ihdr ihdr;
+ struct xc_sr_dhdr dhdr;
+ } hdrs = {
+ .ihdr = {
+ .marker = IHDR_MARKER,
+ .id = htonl(IHDR_ID),
+ .version = htonl(3),
+ .options = htons(IHDR_OPT_LITTLE_ENDIAN),
+ },
+ .dhdr = {
+ .type = guest_type,
+ .page_shift = XC_PAGE_SHIFT,
+ .xen_major = (xen_version >> 16) & 0xffff,
+ .xen_minor = (xen_version) & 0xffff,
+ },
};
if ( xen_version < 0 )
@@ -29,15 +34,9 @@ static int write_headers(struct xc_sr_context *ctx, uint16_t
guest_type)
return -1;
}
- if ( write_exact(ctx->fd, &ihdr, sizeof(ihdr)) )
- {
- PERROR("Unable to write Image Header to stream");
- return -1;
- }
-
- if ( write_exact(ctx->fd, &dhdr, sizeof(dhdr)) )
+ if ( write_exact(ctx->fd, &hdrs, sizeof(hdrs)) )
{
- PERROR("Unable to write Domain Header to stream");
+ PERROR("Unable to write Image/Domain headers to stream");
return -1;
}
--
generated by git-patchbot for /home/xen/git/xen.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |