|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v2 5/7] xenguest: Use a single write_exact in write_headers
From: Frediano Ziglio <frediano.ziglio@xxxxxxxxxx>
Reduce number of syscalls.
Signed-off-by: Frediano Ziglio <frediano.ziglio@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 62a39dfecc7a..8c4e760f8d0a 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 = {
+ {
+ .marker = IHDR_MARKER,
+ .id = htonl(IHDR_ID),
+ .version = htonl(3),
+ .options = htons(IHDR_OPT_LITTLE_ENDIAN),
+ },
+ {
+ .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 Headers to stream");
return -1;
}
--
2.53.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |