From: Andrew Cooper Date: Sat, 7 Jun 2014 20:32:07 +0000 (+0100) Subject: tools/libxc: x86 common code X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~3341 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a270d09bc06c89cfc660e00a28325d95c540eae0;p=xen.git tools/libxc: x86 common code Save/restore records common to all x86 domain types (HVM, PV). This is only the TSC_INFO record. Signed-off-by: Andrew Cooper Acked-by: Ian Campbell --- diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile index 803db592ae..5e12e9a077 100644 --- a/tools/libxc/Makefile +++ b/tools/libxc/Makefile @@ -55,6 +55,7 @@ GUEST_SRCS-y += xg_private.c xc_suspend.c ifeq ($(CONFIG_MIGRATE),y) GUEST_SRCS-y += xc_domain_restore.c xc_domain_save.c GUEST_SRCS-y += xc_sr_common.c +GUEST_SRCS-$(CONFIG_X86) += xc_sr_common_x86.c GUEST_SRCS-y += xc_sr_restore.c GUEST_SRCS-y += xc_sr_save.c GUEST_SRCS-y += xc_offline_page.c xc_compression.c diff --git a/tools/libxc/xc_sr_common_x86.c b/tools/libxc/xc_sr_common_x86.c new file mode 100644 index 0000000000..98f1cef30f --- /dev/null +++ b/tools/libxc/xc_sr_common_x86.c @@ -0,0 +1,54 @@ +#include "xc_sr_common_x86.h" + +int write_tsc_info(struct xc_sr_context *ctx) +{ + xc_interface *xch = ctx->xch; + struct xc_sr_rec_tsc_info tsc = { 0 }; + struct xc_sr_record rec = + { + .type = REC_TYPE_TSC_INFO, + .length = sizeof(tsc), + .data = &tsc + }; + + if ( xc_domain_get_tsc_info(xch, ctx->domid, &tsc.mode, + &tsc.nsec, &tsc.khz, &tsc.incarnation) < 0 ) + { + PERROR("Unable to obtain TSC information"); + return -1; + } + + return write_record(ctx, &rec); +} + +int handle_tsc_info(struct xc_sr_context *ctx, struct xc_sr_record *rec) +{ + xc_interface *xch = ctx->xch; + struct xc_sr_rec_tsc_info *tsc = rec->data; + + if ( rec->length != sizeof(*tsc) ) + { + ERROR("TSC_INFO record wrong size: length %u, expected %zu", + rec->length, sizeof(*tsc)); + return -1; + } + + if ( xc_domain_set_tsc_info(xch, ctx->domid, tsc->mode, + tsc->nsec, tsc->khz, tsc->incarnation) ) + { + PERROR("Unable to set TSC information"); + return -1; + } + + return 0; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/tools/libxc/xc_sr_common_x86.h b/tools/libxc/xc_sr_common_x86.h new file mode 100644 index 0000000000..1d42da9af2 --- /dev/null +++ b/tools/libxc/xc_sr_common_x86.h @@ -0,0 +1,26 @@ +#ifndef __COMMON_X86__H +#define __COMMON_X86__H + +#include "xc_sr_common.h" + +/* + * Obtains a domains TSC information from Xen and writes a TSC_INFO record + * into the stream. + */ +int write_tsc_info(struct xc_sr_context *ctx); + +/* + * Parses a TSC_INFO record and applies the result to the domain. + */ +int handle_tsc_info(struct xc_sr_context *ctx, struct xc_sr_record *rec); + +#endif +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */