From nobody Sun Apr 28 20:20:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1579114526; cv=none; d=zohomail.com; s=zohoarc; b=kOqemLFSvBiLagSODJoPZcHLTehWAT7SihKmbkSdhEG8F4UcARYdNFtZyuYsGYE0AekcCncSpe4SKZTgZW6mPHxqB3rVcyS5noZimNVfW71BvvT9Uq2ATcWqMonVLSfBj0XsIpMJolXDTriFSp8cjMvQFpF+6SCgxHWOjMeUXw8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579114526; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KLD/PYpXQVdoxb0Td7HsoCYtbXJ2LmqQdPx0hxHiqMc=; b=Jd0gh7B9YygZJ6t0sbaunMIiEpNcVrW2RLb8r2w/W4midDWhm3XnQiZtBj1Mo4Qyc/OaiWkDrsloTyWmKwJegkpd/YZAmpHcSlCbE/PMRCTYfG9LMTzvoSw4GP8YvsciHd1iAIG5fWY32fxWHkRcmbm7OUu0FdgONNZEJMgbapE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1579114526473797.0910743962252; Wed, 15 Jan 2020 10:55:26 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1irno0-0002Sw-EL; Wed, 15 Jan 2020 18:54:16 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1irnnz-0002Sr-Kz for xen-devel@lists.xenproject.org; Wed, 15 Jan 2020 18:54:15 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 663c5832-37c8-11ea-b89f-bc764e2007e4; Wed, 15 Jan 2020 18:54:04 +0000 (UTC) X-Inumbo-ID: 663c5832-37c8-11ea-b89f-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1579114444; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=qibFpxQeKPGuuHTezrsBY6/zvkJa9qX2HTmoeRfMxc0=; b=ax835efPO5nPaOrSx8VNQ18rvrEe/JMqwpivWrBT2+kGXoeiusaAJlad JANKbTOsekyS8EnbgMUlNc1Bh0D56OLae+xQJa22sXCxp8a1k5wOk2//o ysSJaDUGbni/Xyp7fNWbHu4Tm7ZG0FV3B6GgEb4qxfjxlPFOgOwhWOds/ A=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: WZ/nsVNfpkCeQAoT3lNg/EUQfvuZUjkh3cSk7y9myLzhJpxt9r5UcomoOm2+o7JrhEWVquWeQW JN5DLxjPtLjyyeGRvwq9QMxv7V/WD5lsk5NwPe4b5uflqXllCsdh1rG0sMVkOBVi0IOKvAC2EO DCza01DKhZPZw5yOyZNkihN1WFr9ytv4OrBoLDLtGiHho25IAWBnqk3WkTbQbQBQ2dpnkIVy/f yJCQNy+JAqfzOY0u6zkPMM8pGgwxDk55RO6dTaLgFJItUpRJ3nkk7SLlQaFxTPggaZKK02wk75 v00= X-SBRS: 2.7 X-MesageID: 11132227 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,323,1574139600"; d="scan'208";a="11132227" From: Andrew Cooper To: Xen-devel Date: Wed, 15 Jan 2020 18:53:47 +0000 Message-ID: <20200115185347.26079-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191224151932.6304-1-andrew.cooper3@citrix.com> References: <20191224151932.6304-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 0.5/12] tools/migration: Formatting and style cleanup X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Ian Jackson Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The code has devating from the prevailing style in many ways. Adjust spaci= ng, indentation, position of operators, layout of multiline comments, removal of superfluous comments, constness, trailing commas, and use of unqualified 'unsigned'. No functional change. Signed-off-by: Andrew Cooper Acked-by: Ian Jackson --- CC: Ian Jackson CC: Wei Liu --- tools/libxc/include/xenguest.h | 35 ++++---- tools/libxc/xc_sr_common.c | 9 +-- tools/libxc/xc_sr_common.h | 10 +-- tools/libxc/xc_sr_common_x86.c | 5 +- tools/libxc/xc_sr_common_x86_pv.c | 12 +-- tools/libxc/xc_sr_restore.c | 39 ++++----- tools/libxc/xc_sr_restore_x86_pv.c | 21 ++--- tools/libxc/xc_sr_save.c | 74 ++++++++--------- tools/libxc/xc_sr_save_x86_hvm.c | 7 +- tools/libxc/xc_sr_save_x86_pv.c | 101 +++++++++-------------- tools/python/scripts/convert-legacy-stream | 20 ++--- tools/python/xen/migration/libxc.py | 124 +++++++++++++++----------= ---- tools/python/xen/migration/libxl.py | 39 ++++----- 13 files changed, 235 insertions(+), 261 deletions(-) diff --git a/tools/libxc/include/xenguest.h b/tools/libxc/include/xenguest.h index 237603373c..19d828a7f2 100644 --- a/tools/libxc/include/xenguest.h +++ b/tools/libxc/include/xenguest.h @@ -52,10 +52,11 @@ typedef int (*precopy_policy_t)(struct precopy_stats, v= oid *); =20 /* callbacks provided by xc_domain_save */ struct save_callbacks { - /* Called after expiration of checkpoint interval, + /* + * Called after expiration of checkpoint interval, * to suspend the guest. */ - int (*suspend)(void* data); + int (*suspend)(void *data); =20 /* * Called before and after every batch of page data sent during @@ -79,7 +80,7 @@ struct save_callbacks { * xc_domain_save then flushes the output buffer, while the * guest continues to run. */ - int (*postcopy)(void* data); + int (*postcopy)(void *data); =20 /* * Called after the memory checkpoint has been flushed @@ -94,7 +95,7 @@ struct save_callbacks { * 0: terminate checkpointing gracefully * 1: take another checkpoint */ - int (*checkpoint)(void* data); + int (*checkpoint)(void *data); =20 /* * Called after the checkpoint callback. @@ -103,13 +104,13 @@ struct save_callbacks { * 0: terminate checkpointing gracefully * 1: take another checkpoint */ - int (*wait_checkpoint)(void* data); + int (*wait_checkpoint)(void *data); =20 /* Enable qemu-dm logging dirty pages to xen */ int (*switch_qemu_logdirty)(uint32_t domid, unsigned enable, void *dat= a); /* HVM only */ =20 /* to be provided as the last argument to each callback function */ - void* data; + void *data; }; =20 /* Type of stream. Plain, or using a continuous replication protocol? */ @@ -138,22 +139,24 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint= 32_t dom, =20 /* callbacks provided by xc_domain_restore */ struct restore_callbacks { - /* Called after a new checkpoint to suspend the guest. - */ - int (*suspend)(void* data); + /* Called after a new checkpoint to suspend the guest. */ + int (*suspend)(void *data); =20 - /* Called after the secondary vm is ready to resume. + /* + * Called after the secondary vm is ready to resume. * Callback function resumes the guest & the device model, * returns to xc_domain_restore. */ - int (*postcopy)(void* data); + int (*postcopy)(void *data); =20 - /* A checkpoint record has been found in the stream. - * returns: */ + /* + * A checkpoint record has been found in the stream. + * returns: + */ #define XGR_CHECKPOINT_ERROR 0 /* Terminate processing */ #define XGR_CHECKPOINT_SUCCESS 1 /* Continue reading more data from the s= tream */ #define XGR_CHECKPOINT_FAILOVER 2 /* Failover and resume VM */ - int (*checkpoint)(void* data); + int (*checkpoint)(void *data); =20 /* * Called after the checkpoint callback. @@ -162,7 +165,7 @@ struct restore_callbacks { * 0: terminate checkpointing gracefully * 1: take another checkpoint */ - int (*wait_checkpoint)(void* data); + int (*wait_checkpoint)(void *data); =20 /* * callback to send store gfn and console gfn to xl @@ -173,7 +176,7 @@ struct restore_callbacks { void *data); =20 /* to be provided as the last argument to each callback function */ - void* data; + void *data; }; =20 /** diff --git a/tools/libxc/xc_sr_common.c b/tools/libxc/xc_sr_common.c index 46fd928de2..dd9a11b4b5 100644 --- a/tools/libxc/xc_sr_common.c +++ b/tools/libxc/xc_sr_common.c @@ -4,7 +4,7 @@ =20 #include =20 -static const char *dhdr_types[] =3D +static const char *const dhdr_types[] =3D { [DHDR_TYPE_X86_PV] =3D "x86 PV", [DHDR_TYPE_X86_HVM] =3D "x86 HVM", @@ -18,7 +18,7 @@ const char *dhdr_type_to_str(uint32_t type) return "Reserved"; } =20 -static const char *mandatory_rec_types[] =3D +static const char *const mandatory_rec_types[] =3D { [REC_TYPE_END] =3D "End", [REC_TYPE_PAGE_DATA] =3D "Page data", @@ -58,13 +58,12 @@ int write_split_record(struct xc_sr_context *ctx, struc= t xc_sr_record *rec, xc_interface *xch =3D ctx->xch; typeof(rec->length) combined_length =3D rec->length + sz; size_t record_length =3D ROUNDUP(combined_length, REC_ALIGN_ORDER); - struct iovec parts[] =3D - { + struct iovec parts[] =3D { { &rec->type, sizeof(rec->type) }, { &combined_length, sizeof(combined_length) }, { rec->data, rec->length }, { buf, sz }, - { (void*)zeroes, record_length - combined_length }, + { (void *)zeroes, record_length - combined_length }, }; =20 if ( record_length > REC_LENGTH_MAX ) diff --git a/tools/libxc/xc_sr_common.h b/tools/libxc/xc_sr_common.h index b923ad5c10..e43b858a0a 100644 --- a/tools/libxc/xc_sr_common.h +++ b/tools/libxc/xc_sr_common.h @@ -228,7 +228,7 @@ struct xc_sr_context struct precopy_stats stats; =20 xen_pfn_t *batch_pfns; - unsigned nr_batch_pfns; + unsigned int nr_batch_pfns; unsigned long *deferred_pages; unsigned long nr_deferred_pages; xc_hypercall_buffer_t dirty_bitmap_hbuf; @@ -262,8 +262,8 @@ struct xc_sr_context */ #define DEFAULT_BUF_RECORDS 1024 struct xc_sr_record *buffered_records; - unsigned allocated_rec_num; - unsigned buffered_rec_num; + unsigned int allocated_rec_num; + unsigned int buffered_rec_num; =20 /* * Xenstore and Console parameters. @@ -333,7 +333,7 @@ struct xc_sr_context { struct xc_sr_blob basic, extd, xsave, msr; } *vcpus; - unsigned nr_vcpus; + unsigned int nr_vcpus; } restore; }; } x86_pv; @@ -418,7 +418,7 @@ int read_record(struct xc_sr_context *ctx, int fd, stru= ct xc_sr_record *rec); * x86_pv_localise_page() if we receive pagetables frames ahead of the * contents of the frames they point at. */ -int populate_pfns(struct xc_sr_context *ctx, unsigned count, +int populate_pfns(struct xc_sr_context *ctx, unsigned int count, const xen_pfn_t *original_pfns, const uint32_t *types); =20 #endif diff --git a/tools/libxc/xc_sr_common_x86.c b/tools/libxc/xc_sr_common_x86.c index 1dee840a03..011684df97 100644 --- a/tools/libxc/xc_sr_common_x86.c +++ b/tools/libxc/xc_sr_common_x86.c @@ -4,11 +4,10 @@ int write_x86_tsc_info(struct xc_sr_context *ctx) { xc_interface *xch =3D ctx->xch; struct xc_sr_rec_x86_tsc_info tsc =3D {}; - struct xc_sr_record rec =3D - { + struct xc_sr_record rec =3D { .type =3D REC_TYPE_X86_TSC_INFO, .length =3D sizeof(tsc), - .data =3D &tsc + .data =3D &tsc, }; =20 if ( xc_domain_get_tsc_info(xch, ctx->domid, &tsc.mode, diff --git a/tools/libxc/xc_sr_common_x86_pv.c b/tools/libxc/xc_sr_common_x= 86_pv.c index f233c8799e..ec433fad70 100644 --- a/tools/libxc/xc_sr_common_x86_pv.c +++ b/tools/libxc/xc_sr_common_x86_pv.c @@ -10,10 +10,10 @@ xen_pfn_t mfn_to_pfn(struct xc_sr_context *ctx, xen_pfn= _t mfn) =20 bool mfn_in_pseudophysmap(struct xc_sr_context *ctx, xen_pfn_t mfn) { - return ( (mfn <=3D ctx->x86_pv.max_mfn) && - (mfn_to_pfn(ctx, mfn) <=3D ctx->x86_pv.max_pfn) && - (xc_pfn_to_mfn(mfn_to_pfn(ctx, mfn), ctx->x86_pv.p2m, - ctx->x86_pv.width) =3D=3D mfn) ); + return ((mfn <=3D ctx->x86_pv.max_mfn) && + (mfn_to_pfn(ctx, mfn) <=3D ctx->x86_pv.max_pfn) && + (xc_pfn_to_mfn(mfn_to_pfn(ctx, mfn), ctx->x86_pv.p2m, + ctx->x86_pv.width) =3D=3D mfn)); } =20 void dump_bad_pseudophysmap_entry(struct xc_sr_context *ctx, xen_pfn_t mfn) @@ -157,7 +157,7 @@ int x86_pv_map_m2p(struct xc_sr_context *ctx) { struct xen_machphys_mfn_list xmml =3D { .max_extents =3D 1, - .extent_start =3D { &ctx->x86_pv.compat_m2p_mfn0 } + .extent_start =3D { &ctx->x86_pv.compat_m2p_mfn0 }, }; =20 rc =3D do_memory_op(xch, XENMEM_machphys_compat_mfn_list, @@ -175,7 +175,7 @@ int x86_pv_map_m2p(struct xc_sr_context *ctx) rc =3D 0; DPRINTF("max_mfn %#lx", ctx->x86_pv.max_mfn); =20 -err: + err: free(entries); free(extents_start); =20 diff --git a/tools/libxc/xc_sr_restore.c b/tools/libxc/xc_sr_restore.c index d9bf6fb5a1..5e31908ca8 100644 --- a/tools/libxc/xc_sr_restore.c +++ b/tools/libxc/xc_sr_restore.c @@ -134,13 +134,13 @@ static int pfn_set_populated(struct xc_sr_context *ct= x, xen_pfn_t pfn) * unpopulated subset. If types is NULL, no page type checking is perform= ed * and all unpopulated pfns are populated. */ -int populate_pfns(struct xc_sr_context *ctx, unsigned count, +int populate_pfns(struct xc_sr_context *ctx, unsigned int count, const xen_pfn_t *original_pfns, const uint32_t *types) { xc_interface *xch =3D ctx->xch; xen_pfn_t *mfns =3D malloc(count * sizeof(*mfns)), *pfns =3D malloc(count * sizeof(*pfns)); - unsigned i, nr_pfns =3D 0; + unsigned int i, nr_pfns =3D 0; int rc =3D -1; =20 if ( !mfns || !pfns ) @@ -202,7 +202,7 @@ int populate_pfns(struct xc_sr_context *ctx, unsigned c= ount, * stream, populate and record their types, map the relevant subset and co= py * the data into the guest. */ -static int process_page_data(struct xc_sr_context *ctx, unsigned count, +static int process_page_data(struct xc_sr_context *ctx, unsigned int count, xen_pfn_t *pfns, uint32_t *types, void *page_= data) { xc_interface *xch =3D ctx->xch; @@ -210,8 +210,8 @@ static int process_page_data(struct xc_sr_context *ctx,= unsigned count, int *map_errs =3D malloc(count * sizeof(*map_errs)); int rc; void *mapping =3D NULL, *guest_page =3D NULL; - unsigned i, /* i indexes the pfns from the record. */ - j, /* j indexes the subset of pfns we decide to map. */ + unsigned int i, /* i indexes the pfns from the record. */ + j, /* j indexes the subset of pfns we decide to map. */ nr_pages =3D 0; =20 if ( !mfns || !map_errs ) @@ -258,8 +258,8 @@ static int process_page_data(struct xc_sr_context *ctx,= unsigned count, if ( nr_pages =3D=3D 0 ) goto done; =20 - mapping =3D guest_page =3D xenforeignmemory_map(xch->fmem, - ctx->domid, PROT_READ | PROT_WRITE, + mapping =3D guest_page =3D xenforeignmemory_map( + xch->fmem, ctx->domid, PROT_READ | PROT_WRITE, nr_pages, mfns, map_errs); if ( !mapping ) { @@ -336,7 +336,7 @@ static int handle_page_data(struct xc_sr_context *ctx, = struct xc_sr_record *rec) { xc_interface *xch =3D ctx->xch; struct xc_sr_rec_page_data_header *pages =3D rec->data; - unsigned i, pages_of_data =3D 0; + unsigned int i, pages_of_data =3D 0; int rc =3D -1; =20 xen_pfn_t *pfns =3D NULL, pfn; @@ -424,12 +424,11 @@ static int send_checkpoint_dirty_pfn_list(struct xc_s= r_context *ctx) { xc_interface *xch =3D ctx->xch; int rc =3D -1; - unsigned count, written; + unsigned int count, written; uint64_t i, *pfns =3D NULL; struct iovec *iov =3D NULL; xc_shadow_op_stats_t stats =3D { 0, ctx->restore.p2m_size }; - struct xc_sr_record rec =3D - { + struct xc_sr_record rec =3D { .type =3D REC_TYPE_CHECKPOINT_DIRTY_PFN_LIST, }; DECLARE_HYPERCALL_BUFFER_SHADOW(unsigned long, dirty_bitmap, @@ -510,7 +509,7 @@ static int handle_checkpoint(struct xc_sr_context *ctx) { xc_interface *xch =3D ctx->xch; int rc =3D 0, ret; - unsigned i; + unsigned int i; =20 if ( ctx->stream_type =3D=3D XC_STREAM_PLAIN ) { @@ -587,7 +586,7 @@ static int handle_checkpoint(struct xc_sr_context *ctx) =20 /* Wait for a new checkpoint */ ret =3D ctx->restore.callbacks->wait_checkpoint( - ctx->restore.callbacks->da= ta); + ctx->restore.callbacks->data); HANDLE_CALLBACK_RETURN_VALUE(ret); =20 /* suspend secondary vm */ @@ -608,7 +607,7 @@ static int handle_checkpoint(struct xc_sr_context *ctx) static int buffer_record(struct xc_sr_context *ctx, struct xc_sr_record *r= ec) { xc_interface *xch =3D ctx->xch; - unsigned new_alloc_num; + unsigned int new_alloc_num; struct xc_sr_record *p; =20 if ( ctx->restore.buffered_rec_num >=3D ctx->restore.allocated_rec_num= ) @@ -675,8 +674,8 @@ static int setup(struct xc_sr_context *ctx) =20 if ( ctx->stream_type =3D=3D XC_STREAM_COLO ) { - dirty_bitmap =3D xc_hypercall_buffer_alloc_pages(xch, dirty_bitmap, - NRPAGES(bitmap_size(ctx->restore.p2m_size)= )); + dirty_bitmap =3D xc_hypercall_buffer_alloc_pages( + xch, dirty_bitmap, NRPAGES(bitmap_size(ctx->restore.p2m_size))= ); =20 if ( !dirty_bitmap ) { @@ -717,7 +716,7 @@ static int setup(struct xc_sr_context *ctx) static void cleanup(struct xc_sr_context *ctx) { xc_interface *xch =3D ctx->xch; - unsigned i; + unsigned int i; DECLARE_HYPERCALL_BUFFER_SHADOW(unsigned long, dirty_bitmap, &ctx->restore.dirty_bitmap_hbuf); =20 @@ -725,10 +724,12 @@ static void cleanup(struct xc_sr_context *ctx) free(ctx->restore.buffered_records[i].data); =20 if ( ctx->stream_type =3D=3D XC_STREAM_COLO ) - xc_hypercall_buffer_free_pages(xch, dirty_bitmap, - NRPAGES(bitmap_size(ctx->restore.p2m_si= ze))); + xc_hypercall_buffer_free_pages( + xch, dirty_bitmap, NRPAGES(bitmap_size(ctx->restore.p2m_size))= ); + free(ctx->restore.buffered_records); free(ctx->restore.populated_pfns); + if ( ctx->restore.ops.cleanup(ctx) ) PERROR("Failed to clean up"); } diff --git a/tools/libxc/xc_sr_restore_x86_pv.c b/tools/libxc/xc_sr_restore= _x86_pv.c index dcc2a7f8c5..9299861236 100644 --- a/tools/libxc/xc_sr_restore_x86_pv.c +++ b/tools/libxc/xc_sr_restore_x86_pv.c @@ -222,7 +222,7 @@ static int process_start_info(struct xc_sr_context *ctx, =20 rc =3D 0; =20 -err: + err: if ( guest_start_info ) munmap(guest_start_info, PAGE_SIZE); =20 @@ -238,7 +238,7 @@ static int process_vcpu_basic(struct xc_sr_context *ctx, xc_interface *xch =3D ctx->xch; vcpu_guest_context_any_t *vcpu =3D ctx->x86_pv.restore.vcpus[vcpuid].b= asic.ptr; xen_pfn_t pfn, mfn; - unsigned i, gdt_count; + unsigned int i, gdt_count; int rc =3D -1; =20 /* Vcpu 0 is special: Convert the suspend record to an mfn. */ @@ -474,7 +474,7 @@ static int update_vcpu_context(struct xc_sr_context *ct= x) { xc_interface *xch =3D ctx->xch; struct xc_sr_x86_pv_restore_vcpu *vcpu; - unsigned i; + unsigned int i; int rc =3D 0; =20 for ( i =3D 0; i < ctx->x86_pv.restore.nr_vcpus; ++i ) @@ -527,7 +527,7 @@ static int update_guest_p2m(struct xc_sr_context *ctx) { xc_interface *xch =3D ctx->xch; xen_pfn_t mfn, pfn, *guest_p2m =3D NULL; - unsigned i; + unsigned int i; int rc =3D -1; =20 for ( i =3D 0; i < ctx->x86_pv.p2m_frames; ++i ) @@ -562,7 +562,7 @@ static int update_guest_p2m(struct xc_sr_context *ctx) =20 guest_p2m =3D xc_map_foreign_pages(xch, ctx->domid, PROT_WRITE, ctx->x86_pv.p2m_pfns, - ctx->x86_pv.p2m_frames ); + ctx->x86_pv.p2m_frames); if ( !guest_p2m ) { PERROR("Failed to map p2m frames"); @@ -572,6 +572,7 @@ static int update_guest_p2m(struct xc_sr_context *ctx) memcpy(guest_p2m, ctx->x86_pv.p2m, (ctx->x86_pv.max_pfn + 1) * ctx->x86_pv.width); rc =3D 0; + err: if ( guest_p2m ) munmap(guest_p2m, ctx->x86_pv.p2m_frames * PAGE_SIZE); @@ -675,7 +676,7 @@ static int handle_x86_pv_p2m_frames(struct xc_sr_contex= t *ctx, { xc_interface *xch =3D ctx->xch; struct xc_sr_rec_x86_pv_p2m_frames *data =3D rec->data; - unsigned start, end, x, fpp =3D PAGE_SIZE / ctx->x86_pv.width; + unsigned int start, end, x, fpp =3D PAGE_SIZE / ctx->x86_pv.width; int rc; =20 if ( !ctx->x86_pv.restore.seen_pv_info ) @@ -862,7 +863,7 @@ static int handle_shared_info(struct xc_sr_context *ctx, struct xc_sr_record *rec) { xc_interface *xch =3D ctx->xch; - unsigned i; + unsigned int i; int rc =3D -1; shared_info_any_t *guest_shinfo =3D NULL; const shared_info_any_t *old_shinfo =3D rec->data; @@ -904,8 +905,8 @@ static int handle_shared_info(struct xc_sr_context *ctx, MEMSET_ARRAY_FIELD(guest_shinfo, evtchn_mask, 0xff, ctx->x86_pv.width); =20 rc =3D 0; - err: =20 + err: if ( guest_shinfo ) munmap(guest_shinfo, PAGE_SIZE); =20 @@ -952,7 +953,7 @@ static int x86_pv_localise_page(struct xc_sr_context *c= tx, xc_interface *xch =3D ctx->xch; uint64_t *table =3D page; uint64_t pte; - unsigned i, to_populate; + unsigned int i, to_populate; xen_pfn_t pfns[(PAGE_SIZE / sizeof(uint64_t))]; =20 type &=3D XEN_DOMCTL_PFINFO_LTABTYPE_MASK; @@ -1134,7 +1135,7 @@ static int x86_pv_cleanup(struct xc_sr_context *ctx) =20 if ( ctx->x86_pv.restore.vcpus ) { - unsigned i; + unsigned int i; =20 for ( i =3D 0; i < ctx->x86_pv.restore.nr_vcpus; ++i ) { diff --git a/tools/libxc/xc_sr_save.c b/tools/libxc/xc_sr_save.c index 0651fa92bc..fa736a311f 100644 --- a/tools/libxc/xc_sr_save.c +++ b/tools/libxc/xc_sr_save.c @@ -10,20 +10,18 @@ static int write_headers(struct xc_sr_context *ctx, uin= t16_t guest_type) { xc_interface *xch =3D ctx->xch; int32_t xen_version =3D xc_version(xch, XENVER_version, NULL); - struct xc_sr_ihdr ihdr =3D - { - .marker =3D IHDR_MARKER, - .id =3D htonl(IHDR_ID), - .version =3D htonl(IHDR_VERSION), - .options =3D htons(IHDR_OPT_LITTLE_ENDIAN), - }; - struct xc_sr_dhdr dhdr =3D - { - .type =3D guest_type, - .page_shift =3D XC_PAGE_SHIFT, - .xen_major =3D (xen_version >> 16) & 0xffff, - .xen_minor =3D (xen_version) & 0xffff, - }; + struct xc_sr_ihdr ihdr =3D { + .marker =3D IHDR_MARKER, + .id =3D htonl(IHDR_ID), + .version =3D htonl(IHDR_VERSION), + .options =3D htons(IHDR_OPT_LITTLE_ENDIAN), + }; + struct xc_sr_dhdr dhdr =3D { + .type =3D guest_type, + .page_shift =3D XC_PAGE_SHIFT, + .xen_major =3D (xen_version >> 16) & 0xffff, + .xen_minor =3D (xen_version) & 0xffff, + }; =20 if ( xen_version < 0 ) { @@ -51,7 +49,7 @@ static int write_headers(struct xc_sr_context *ctx, uint1= 6_t guest_type) */ static int write_end_record(struct xc_sr_context *ctx) { - struct xc_sr_record end =3D { REC_TYPE_END, 0, NULL }; + struct xc_sr_record end =3D { .type =3D REC_TYPE_END }; =20 return write_record(ctx, &end); } @@ -61,7 +59,7 @@ static int write_end_record(struct xc_sr_context *ctx) */ static int write_checkpoint_record(struct xc_sr_context *ctx) { - struct xc_sr_record checkpoint =3D { REC_TYPE_CHECKPOINT, 0, NULL }; + struct xc_sr_record checkpoint =3D { .type =3D REC_TYPE_CHECKPOINT }; =20 return write_record(ctx, &checkpoint); } @@ -84,14 +82,13 @@ static int write_batch(struct xc_sr_context *ctx) void **guest_data =3D NULL; void **local_pages =3D NULL; int *errors =3D NULL, rc =3D -1; - unsigned i, p, nr_pages =3D 0, nr_pages_mapped =3D 0; - unsigned nr_pfns =3D ctx->save.nr_batch_pfns; + unsigned int i, p, nr_pages =3D 0, nr_pages_mapped =3D 0; + unsigned int nr_pfns =3D ctx->save.nr_batch_pfns; void *page, *orig_page; uint64_t *rec_pfns =3D NULL; struct iovec *iov =3D NULL; int iovcnt =3D 0; struct xc_sr_rec_page_data_header hdr =3D { 0 }; - struct xc_sr_record rec =3D - { + struct xc_sr_record rec =3D { .type =3D REC_TYPE_PAGE_DATA, }; =20 @@ -153,8 +150,8 @@ static int write_batch(struct xc_sr_context *ctx) =20 if ( nr_pages > 0 ) { - guest_mapping =3D xenforeignmemory_map(xch->fmem, - ctx->domid, PROT_READ, nr_pages, mfns, errors); + guest_mapping =3D xenforeignmemory_map( + xch->fmem, ctx->domid, PROT_READ, nr_pages, mfns, errors); if ( !guest_mapping ) { PERROR("Failed to map guest pages"); @@ -481,7 +478,7 @@ static int update_progress_string(struct xc_sr_context = *ctx, char **str) static int simple_precopy_policy(struct precopy_stats stats, void *user) { return ((stats.dirty_count >=3D 0 && - stats.dirty_count < SPP_TARGET_DIRTY_COUNT) || + stats.dirty_count < SPP_TARGET_DIRTY_COUNT) || stats.iteration >=3D SPP_MAX_ITERATIONS) ? XGS_POLICY_STOP_AND_COPY : XGS_POLICY_CONTINUE_PRECOPY; @@ -511,12 +508,13 @@ static int send_memory_live(struct xc_sr_context *ctx) if ( rc ) goto out; =20 - ctx->save.stats =3D (struct precopy_stats) - { .dirty_count =3D ctx->save.p2m_size }; + ctx->save.stats =3D (struct precopy_stats){ + .dirty_count =3D ctx->save.p2m_size, + }; policy_stats =3D &ctx->save.stats; =20 if ( precopy_policy =3D=3D NULL ) - precopy_policy =3D simple_precopy_policy; + precopy_policy =3D simple_precopy_policy; =20 bitmap_set(dirty_bitmap, ctx->save.p2m_size); =20 @@ -546,7 +544,7 @@ static int send_memory_live(struct xc_sr_context *ctx) policy_decision =3D precopy_policy(*policy_stats, data); =20 if ( policy_decision !=3D XGS_POLICY_CONTINUE_PRECOPY ) - break; + break; =20 if ( xc_shadow_control( xch, ctx->domid, XEN_DOMCTL_SHADOW_OP_CLEAN, @@ -571,10 +569,10 @@ static int send_memory_live(struct xc_sr_context *ctx) static int colo_merge_secondary_dirty_bitmap(struct xc_sr_context *ctx) { xc_interface *xch =3D ctx->xch; - struct xc_sr_record rec =3D { 0, 0, NULL }; + struct xc_sr_record rec; uint64_t *pfns =3D NULL; uint64_t pfn; - unsigned count, i; + unsigned int count, i; int rc; DECLARE_HYPERCALL_BUFFER_SHADOW(unsigned long, dirty_bitmap, &ctx->save.dirty_bitmap_hbuf); @@ -585,14 +583,14 @@ static int colo_merge_secondary_dirty_bitmap(struct x= c_sr_context *ctx) =20 if ( rec.type !=3D REC_TYPE_CHECKPOINT_DIRTY_PFN_LIST ) { - PERROR("Expect dirty bitmap record, but received %u", rec.type ); + PERROR("Expect dirty bitmap record, but received %u", rec.type); rc =3D -1; goto err; } =20 if ( rec.length % sizeof(*pfns) ) { - PERROR("Invalid dirty pfn list record length %u", rec.length ); + PERROR("Invalid dirty pfn list record length %u", rec.length); rc =3D -1; goto err; } @@ -603,7 +601,7 @@ static int colo_merge_secondary_dirty_bitmap(struct xc_= sr_context *ctx) for ( i =3D 0; i < count; i++ ) { pfn =3D pfns[i]; - if (pfn > ctx->save.p2m_size) + if ( pfn > ctx->save.p2m_size ) { PERROR("Invalid pfn 0x%" PRIx64, pfn); rc =3D -1; @@ -688,11 +686,7 @@ static int verify_frames(struct xc_sr_context *ctx) xc_interface *xch =3D ctx->xch; xc_shadow_op_stats_t stats =3D { 0, ctx->save.p2m_size }; int rc; - struct xc_sr_record rec =3D - { - .type =3D REC_TYPE_VERIFY, - .length =3D 0, - }; + struct xc_sr_record rec =3D { .type =3D REC_TYPE_VERIFY }; =20 DPRINTF("Enabling verify mode"); =20 @@ -748,7 +742,7 @@ static int send_domain_memory_live(struct xc_sr_context= *ctx) goto out; } =20 - out: + out: return rc; } =20 @@ -795,7 +789,7 @@ static int setup(struct xc_sr_context *ctx) goto err; =20 dirty_bitmap =3D xc_hypercall_buffer_alloc_pages( - xch, dirty_bitmap, NRPAGES(bitmap_size(ctx->save.p2m_si= ze))); + xch, dirty_bitmap, NRPAGES(bitmap_size(ctx->save.p2m_size))); ctx->save.batch_pfns =3D malloc(MAX_BATCH_SIZE * sizeof(*ctx->save.batch_pfns)); ctx->save.deferred_pages =3D calloc(1, bitmap_size(ctx->save.p2m_size)= ); @@ -966,7 +960,7 @@ static int save(struct xc_sr_context *ctx, uint16_t gue= st_type) }; =20 int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, - uint32_t flags, struct save_callbacks* callbacks, + uint32_t flags, struct save_callbacks *callbacks, xc_stream_type_t stream_type, int recv_fd) { struct xc_sr_context ctx =3D { diff --git a/tools/libxc/xc_sr_save_x86_hvm.c b/tools/libxc/xc_sr_save_x86_= hvm.c index 90ff35a439..3d86cb0600 100644 --- a/tools/libxc/xc_sr_save_x86_hvm.c +++ b/tools/libxc/xc_sr_save_x86_hvm.c @@ -11,8 +11,7 @@ static int write_hvm_context(struct xc_sr_context *ctx) { xc_interface *xch =3D ctx->xch; int rc, hvm_buf_size; - struct xc_sr_record hvm_rec =3D - { + struct xc_sr_record hvm_rec =3D { .type =3D REC_TYPE_HVM_CONTEXT, }; =20 @@ -134,7 +133,6 @@ static xen_pfn_t x86_hvm_pfn_to_gfn(const struct xc_sr_= context *ctx, static int x86_hvm_normalise_page(struct xc_sr_context *ctx, xen_pfn_t type, void **page) { - /* no-op */ return 0; } =20 @@ -174,19 +172,16 @@ static int x86_hvm_setup(struct xc_sr_context *ctx) =20 static int x86_hvm_start_of_stream(struct xc_sr_context *ctx) { - /* no-op */ return 0; } =20 static int x86_hvm_start_of_checkpoint(struct xc_sr_context *ctx) { - /* no-op */ return 0; } =20 static int x86_hvm_check_vm_state(struct xc_sr_context *ctx) { - /* no-op */ return 0; } =20 diff --git a/tools/libxc/xc_sr_save_x86_pv.c b/tools/libxc/xc_sr_save_x86_p= v.c index 09b6efeee3..3ebc5a2bf8 100644 --- a/tools/libxc/xc_sr_save_x86_pv.c +++ b/tools/libxc/xc_sr_save_x86_pv.c @@ -80,7 +80,7 @@ static int map_p2m_leaves(struct xc_sr_context *ctx, xen_= pfn_t *mfns, size_t n_mfns) { xc_interface *xch =3D ctx->xch; - unsigned x; + unsigned int x; =20 ctx->x86_pv.p2m =3D xc_map_foreign_pages(xch, ctx->domid, PROT_READ, mfns, n_mfns); @@ -133,7 +133,7 @@ static int map_p2m_tree(struct xc_sr_context *ctx) */ xc_interface *xch =3D ctx->xch; int rc =3D -1; - unsigned x, saved_x, fpp, fll_entries, fl_entries; + unsigned int x, saved_x, fpp, fll_entries, fl_entries; xen_pfn_t fll_mfn, saved_mfn, max_pfn; =20 xen_pfn_t *local_fll =3D NULL; @@ -260,8 +260,7 @@ static int map_p2m_tree(struct xc_sr_context *ctx) /* Map the p2m leaves themselves. */ rc =3D map_p2m_leaves(ctx, local_fl, fl_entries); =20 -err: - + err: free(local_fl); if ( guest_fl ) munmap(guest_fl, fll_entries * PAGE_SIZE); @@ -318,7 +317,7 @@ static int map_p2m_list(struct xc_sr_context *ctx, uint= 64_t p2m_cr3) xen_pfn_t p2m_mfn, mfn, saved_mfn, max_pfn; uint64_t *ptes =3D NULL; xen_pfn_t *mfns =3D NULL; - unsigned fpp, n_pages, level, shift, idx_start, idx_end, idx, saved_id= x; + unsigned int fpp, n_pages, level, shift, idx_start, idx_end, idx, save= d_idx; int rc =3D -1; =20 p2m_mfn =3D cr3_to_mfn(ctx, p2m_cr3); @@ -450,7 +449,7 @@ static int map_p2m_list(struct xc_sr_context *ctx, uint= 64_t p2m_cr3) /* Map the p2m leaves themselves. */ rc =3D map_p2m_leaves(ctx, mfns, idx_end - idx_start + 1); =20 -err: + err: free(mfns); if ( ptes ) munmap(ptes, n_pages * PAGE_SIZE); @@ -483,15 +482,13 @@ static int write_one_vcpu_basic(struct xc_sr_context = *ctx, uint32_t id) { xc_interface *xch =3D ctx->xch; xen_pfn_t mfn, pfn; - unsigned i, gdt_count; + unsigned int i, gdt_count; int rc =3D -1; vcpu_guest_context_any_t vcpu; - struct xc_sr_rec_x86_pv_vcpu_hdr vhdr =3D - { + struct xc_sr_rec_x86_pv_vcpu_hdr vhdr =3D { .vcpu_id =3D id, }; - struct xc_sr_record rec =3D - { + struct xc_sr_record rec =3D { .type =3D REC_TYPE_X86_PV_VCPU_BASIC, .length =3D sizeof(vhdr), .data =3D &vhdr, @@ -586,18 +583,15 @@ static int write_one_vcpu_basic(struct xc_sr_context = *ctx, uint32_t id) static int write_one_vcpu_extended(struct xc_sr_context *ctx, uint32_t id) { xc_interface *xch =3D ctx->xch; - struct xc_sr_rec_x86_pv_vcpu_hdr vhdr =3D - { + struct xc_sr_rec_x86_pv_vcpu_hdr vhdr =3D { .vcpu_id =3D id, }; - struct xc_sr_record rec =3D - { + struct xc_sr_record rec =3D { .type =3D REC_TYPE_X86_PV_VCPU_EXTENDED, .length =3D sizeof(vhdr), .data =3D &vhdr, }; - struct xen_domctl domctl =3D - { + struct xen_domctl domctl =3D { .cmd =3D XEN_DOMCTL_get_ext_vcpucontext, .domain =3D ctx->domid, .u.ext_vcpucontext.vcpu =3D id, @@ -626,18 +620,15 @@ static int write_one_vcpu_xsave(struct xc_sr_context = *ctx, uint32_t id) xc_interface *xch =3D ctx->xch; int rc =3D -1; DECLARE_HYPERCALL_BUFFER(void, buffer); - struct xc_sr_rec_x86_pv_vcpu_hdr vhdr =3D - { + struct xc_sr_rec_x86_pv_vcpu_hdr vhdr =3D { .vcpu_id =3D id, }; - struct xc_sr_record rec =3D - { + struct xc_sr_record rec =3D { .type =3D REC_TYPE_X86_PV_VCPU_XSAVE, .length =3D sizeof(vhdr), .data =3D &vhdr, }; - struct xen_domctl domctl =3D - { + struct xen_domctl domctl =3D { .cmd =3D XEN_DOMCTL_getvcpuextstate, .domain =3D ctx->domid, .u.vcpuextstate.vcpu =3D id, @@ -695,18 +686,15 @@ static int write_one_vcpu_msrs(struct xc_sr_context *= ctx, uint32_t id) int rc =3D -1; size_t buffersz; DECLARE_HYPERCALL_BUFFER(void, buffer); - struct xc_sr_rec_x86_pv_vcpu_hdr vhdr =3D - { + struct xc_sr_rec_x86_pv_vcpu_hdr vhdr =3D { .vcpu_id =3D id, }; - struct xc_sr_record rec =3D - { + struct xc_sr_record rec =3D { .type =3D REC_TYPE_X86_PV_VCPU_MSRS, .length =3D sizeof(vhdr), .data =3D &vhdr, }; - struct xen_domctl domctl =3D - { + struct xen_domctl domctl =3D { .cmd =3D XEN_DOMCTL_get_vcpu_msrs, .domain =3D ctx->domid, .u.vcpu_msrs.vcpu =3D id, @@ -805,17 +793,15 @@ static int write_all_vcpu_information(struct xc_sr_co= ntext *ctx) */ static int write_x86_pv_info(struct xc_sr_context *ctx) { - struct xc_sr_rec_x86_pv_info info =3D - { - .guest_width =3D ctx->x86_pv.width, - .pt_levels =3D ctx->x86_pv.levels, - }; - struct xc_sr_record rec =3D - { - .type =3D REC_TYPE_X86_PV_INFO, - .length =3D sizeof(info), - .data =3D &info - }; + struct xc_sr_rec_x86_pv_info info =3D { + .guest_width =3D ctx->x86_pv.width, + .pt_levels =3D ctx->x86_pv.levels, + }; + struct xc_sr_record rec =3D { + .type =3D REC_TYPE_X86_PV_INFO, + .length =3D sizeof(info), + .data =3D &info, + }; =20 return write_record(ctx, &rec); } @@ -827,20 +813,17 @@ static int write_x86_pv_info(struct xc_sr_context *ct= x) static int write_x86_pv_p2m_frames(struct xc_sr_context *ctx) { xc_interface *xch =3D ctx->xch; - int rc; unsigned i; + int rc; unsigned int i; size_t datasz =3D ctx->x86_pv.p2m_frames * sizeof(uint64_t); uint64_t *data =3D NULL; - struct xc_sr_rec_x86_pv_p2m_frames hdr =3D - { - .start_pfn =3D 0, - .end_pfn =3D ctx->x86_pv.max_pfn, - }; - struct xc_sr_record rec =3D - { - .type =3D REC_TYPE_X86_PV_P2M_FRAMES, - .length =3D sizeof(hdr), - .data =3D &hdr, - }; + struct xc_sr_rec_x86_pv_p2m_frames hdr =3D { + .end_pfn =3D ctx->x86_pv.max_pfn, + }; + struct xc_sr_record rec =3D { + .type =3D REC_TYPE_X86_PV_P2M_FRAMES, + .length =3D sizeof(hdr), + .data =3D &hdr, + }; =20 /* No need to translate if sizeof(uint64_t) =3D=3D sizeof(xen_pfn_t). = */ if ( sizeof(uint64_t) !=3D sizeof(*ctx->x86_pv.p2m_pfns) ) @@ -871,8 +854,7 @@ static int write_x86_pv_p2m_frames(struct xc_sr_context= *ctx) */ static int write_shared_info(struct xc_sr_context *ctx) { - struct xc_sr_record rec =3D - { + struct xc_sr_record rec =3D { .type =3D REC_TYPE_SHARED_INFO, .length =3D PAGE_SIZE, .data =3D ctx->x86_pv.shinfo, @@ -890,7 +872,7 @@ static int normalise_pagetable(struct xc_sr_context *ct= x, const uint64_t *src, { xc_interface *xch =3D ctx->xch; uint64_t pte; - unsigned i, xen_first =3D -1, xen_last =3D -1; /* Indices of Xen mappi= ngs. */ + unsigned int i, xen_first =3D -1, xen_last =3D -1; /* Indices of Xen m= appings. */ =20 type &=3D XEN_DOMCTL_PFINFO_LTABTYPE_MASK; =20 @@ -1004,7 +986,6 @@ static int normalise_pagetable(struct xc_sr_context *c= tx, const uint64_t *src, return 0; } =20 -/* save_ops function. */ static xen_pfn_t x86_pv_pfn_to_gfn(const struct xc_sr_context *ctx, xen_pfn_t pfn) { @@ -1040,7 +1021,7 @@ static int x86_pv_normalise_page(struct xc_sr_context= *ctx, xen_pfn_t type, rc =3D normalise_pagetable(ctx, *page, local_page, type); *page =3D local_page; =20 - out: + out: return rc; } =20 @@ -1071,9 +1052,6 @@ static int x86_pv_setup(struct xc_sr_context *ctx) return 0; } =20 -/* - * save_ops function. Writes PV header records into the stream. - */ static int x86_pv_start_of_stream(struct xc_sr_context *ctx) { int rc; @@ -1127,9 +1105,6 @@ static int x86_pv_check_vm_state(struct xc_sr_context= *ctx) return x86_pv_check_vm_state_p2m_list(ctx); } =20 -/* - * save_ops function. Cleanup. - */ static int x86_pv_cleanup(struct xc_sr_context *ctx) { free(ctx->x86_pv.p2m_pfns); diff --git a/tools/python/scripts/convert-legacy-stream b/tools/python/scri= pts/convert-legacy-stream index a5da30b1ce..2922fb3185 100755 --- a/tools/python/scripts/convert-legacy-stream +++ b/tools/python/scripts/convert-legacy-stream @@ -257,8 +257,8 @@ def read_pv_extended_info(vm): =20 =20 if so_far !=3D total_length: - raise StreamError("Overshot Extended Info size by %d bytes" - % (so_far - total_length,)) + raise StreamError("Overshot Extended Info size by %d bytes" % + (so_far - total_length, )) =20 def read_pv_p2m_frames(vm): fpp =3D 4096 / vm.width @@ -375,8 +375,8 @@ def read_chunks(vm): elif marker > 0: =20 if marker > legacy.MAX_BATCH: - raise StreamError("Page batch (%d) exceeded MAX_BATCH (%d)" - % (marker, legacy.MAX_BATCH)) + raise StreamError("Page batch (%d) exceeded MAX_BATCH (%d)= " % + (marker, legacy.MAX_BATCH)) pfns =3D unpack_ulongs(marker) =20 # xc_domain_save() leaves many XEN_DOMCTL_PFINFO_XTAB records = for @@ -398,8 +398,8 @@ def read_chunks(vm): max_id, =3D unpack_exact("i") =20 if max_id > legacy.MAX_VCPU_ID: - raise StreamError("Vcpu max_id out of range: %d > %d" - % (max_id, legacy.MAX_VCPU_ID)) + raise StreamError("Vcpu max_id out of range: %d > %d" % + (max_id, legacy.MAX_VCPU_ID)) =20 vm.max_vcpu_id =3D max_id bitmap =3D unpack_exact("Q" * ((max_id/64) + 1)) @@ -414,8 +414,8 @@ def read_chunks(vm): bit_idx +=3D 1 word >>=3D 1 =20 - info(" Vcpu info: max_id %d, online map %s" - % (vm.max_vcpu_id, vm.online_vcpu_map)) + info(" Vcpu info: max_id %d, online map %s" % + (vm.max_vcpu_id, vm.online_vcpu_map)) =20 elif marker =3D=3D legacy.CHUNK_hvm_ident_pt: _, ident_pt =3D unpack_exact("=3DIQ") @@ -512,7 +512,7 @@ def read_chunks(vm): [public.HVM_PARAM_NR_IOREQ_SERVER_PAGES, nr_pages]) =20 else: - raise StreamError("Unrecognised chunk %d" % (marker,)) + raise StreamError("Unrecognised chunk %d" % (marker, )) =20 def read_hvm_tail(vm): =20 @@ -579,7 +579,7 @@ def read_legacy_stream(vm): =20 try: vm.p2m_size, =3D unpack_ulongs(1) - info("P2M Size: 0x%x" % (vm.p2m_size,)) + info("P2M Size: 0x%x" % (vm.p2m_size, )) =20 if vm.libxl: write_libxl_hdr() diff --git a/tools/python/xen/migration/libxc.py b/tools/python/xen/migrati= on/libxc.py index 432750c9fa..8a800df980 100644 --- a/tools/python/xen/migration/libxc.py +++ b/tools/python/xen/migration/libxc.py @@ -74,7 +74,7 @@ REC_TYPE_x86_pv_vcpu_msrs : "x86 PV vcpu msrs", REC_TYPE_verify : "Verify", REC_TYPE_checkpoint : "Checkpoint", - REC_TYPE_checkpoint_dirty_pfn_list : "Checkpoint dirty pfn list" + REC_TYPE_checkpoint_dirty_pfn_list : "Checkpoint dirty pfn list", } =20 # page_data @@ -137,24 +137,25 @@ def verify_ihdr(self): self.unpack_exact(IHDR_FORMAT) =20 if marker !=3D IHDR_MARKER: - raise StreamError("Bad image marker: Expected 0x%x, got 0x%x" - % (IHDR_MARKER, marker)) + raise StreamError("Bad image marker: Expected 0x%x, got 0x%x" % + (IHDR_MARKER, marker)) =20 if ident !=3D IHDR_IDENT: - raise StreamError("Bad image id: Expected 0x%x, got 0x%x" - % (IHDR_IDENT, ident)) + raise StreamError("Bad image id: Expected 0x%x, got 0x%x" % + (IHDR_IDENT, ident)) =20 if version !=3D IHDR_VERSION: - raise StreamError("Unknown image version: Expected %d, got %d" - % (IHDR_VERSION, version)) + raise StreamError("Unknown image version: Expected %d, got %d"= % + (IHDR_VERSION, version)) =20 if options & IHDR_OPT_RESZ_MASK: - raise StreamError("Reserved bits set in image options field: 0= x%x" - % (options & IHDR_OPT_RESZ_MASK)) + raise StreamError("Reserved bits set in image options field: 0= x%x" % + (options & IHDR_OPT_RESZ_MASK)) =20 if res1 !=3D 0 or res2 !=3D 0: - raise StreamError("Reserved bits set in image header: 0x%04x:0= x%08x" - % (res1, res2)) + raise StreamError( + "Reserved bits set in image header: 0x%04x:0x%08x" % + (res1, res2)) =20 if ( (sys.byteorder =3D=3D "little") and ((options & IHDR_OPT_BIT_ENDIAN) !=3D IHDR_OPT_LE) ): @@ -175,19 +176,19 @@ def verify_dhdr(self): raise StreamError("Unrecognised domain type 0x%x" % (gtype, )) =20 if res1 !=3D 0: - raise StreamError("Reserved bits set in domain header 0x%04x" - % (res1, )) + raise StreamError("Reserved bits set in domain header 0x%04x" % + (res1, )) =20 if page_shift !=3D 12: - raise StreamError("Page shift expected to be 12. Got %d" - % (page_shift, )) + raise StreamError("Page shift expected to be 12. Got %d" % + (page_shift, )) =20 if major =3D=3D 0: - self.info("Domain Header: legacy converted %s" - % (dhdr_type_to_str[gtype], )) + self.info("Domain Header: legacy converted %s" % + (dhdr_type_to_str[gtype], )) else: - self.info("Domain Header: %s from Xen %d.%d" - % (dhdr_type_to_str[gtype], major, minor)) + self.info("Domain Header: %s from Xen %d.%d" % + (dhdr_type_to_str[gtype], major, minor)) =20 =20 def verify_record(self): @@ -204,12 +205,12 @@ def verify_record(self): if rtype !=3D REC_TYPE_page_data: =20 if self.squashed_pagedata_records > 0: - self.info("Squashed %d Page Data records together" - % (self.squashed_pagedata_records, )) + self.info("Squashed %d Page Data records together" % + (self.squashed_pagedata_records, )) self.squashed_pagedata_records =3D 0 =20 - self.info("Libxc Record: %s, length %d" - % (rec_type_to_str[rtype], length)) + self.info("Libxc Record: %s, length %d" % + (rec_type_to_str[rtype], length)) =20 else: self.squashed_pagedata_records +=3D 1 @@ -219,8 +220,9 @@ def verify_record(self): raise StreamError("Padding containing non0 bytes found") =20 if rtype not in record_verifiers: - raise RuntimeError("No verification function for libxc record = '%s'" - % rec_type_to_str[rtype]) + raise RuntimeError( + "No verification function for libxc record '%s'" % + rec_type_to_str[rtype]) else: record_verifiers[rtype](self, content[:length]) =20 @@ -239,32 +241,32 @@ def verify_record_page_data(self, content): minsz =3D calcsize(PAGE_DATA_FORMAT) =20 if len(content) <=3D minsz: - raise RecordError("PAGE_DATA record must be at least %d bytes = long" - % (minsz, )) + raise RecordError( + "PAGE_DATA record must be at least %d bytes long" % (minsz= , )) =20 count, res1 =3D unpack(PAGE_DATA_FORMAT, content[:minsz]) =20 if res1 !=3D 0: - raise StreamError("Reserved bits set in PAGE_DATA record 0x%04= x" - % (res1, )) + raise StreamError( + "Reserved bits set in PAGE_DATA record 0x%04x" % (res1, )) =20 pfnsz =3D count * 8 if (len(content) - minsz) < pfnsz: - raise RecordError("PAGE_DATA record must contain a pfn record = for " - "each count") + raise RecordError( + "PAGE_DATA record must contain a pfn record for each count= ") =20 - pfns =3D list(unpack("=3D%dQ" % (count,), content[minsz:minsz + pf= nsz])) + pfns =3D list(unpack("=3D%dQ" % (count, ), content[minsz:minsz + p= fnsz])) =20 nr_pages =3D 0 for idx, pfn in enumerate(pfns): =20 if pfn & PAGE_DATA_PFN_RESZ_MASK: - raise RecordError("Reserved bits set in pfn[%d]: 0x%016x", - idx, pfn & PAGE_DATA_PFN_RESZ_MASK) + raise RecordError("Reserved bits set in pfn[%d]: 0x%016x" % + (idx, pfn & PAGE_DATA_PFN_RESZ_MASK)) =20 if pfn >> PAGE_DATA_TYPE_SHIFT in (5, 6, 7, 8): - raise RecordError("Invalid type value in pfn[%d]: 0x%016x", - idx, pfn & PAGE_DATA_TYPE_LTAB_MASK) + raise RecordError("Invalid type value in pfn[%d]: 0x%016x"= % + (idx, pfn & PAGE_DATA_TYPE_LTAB_MASK)) =20 # We expect page data for each normal page or pagetable if PAGE_DATA_TYPE_NOTAB <=3D (pfn & PAGE_DATA_TYPE_LTABTYPE_MA= SK) \ @@ -273,8 +275,8 @@ def verify_record_page_data(self, content): =20 pagesz =3D nr_pages * 4096 if len(content) !=3D minsz + pfnsz + pagesz: - raise RecordError("Expected %u + %u + %u, got %u" - % (minsz, pfnsz, pagesz, len(content))) + raise RecordError("Expected %u + %u + %u, got %u" % + (minsz, pfnsz, pagesz, len(content))) =20 =20 def verify_record_x86_pv_info(self, content): @@ -282,8 +284,8 @@ def verify_record_x86_pv_info(self, content): =20 expectedsz =3D calcsize(X86_PV_INFO_FORMAT) if len(content) !=3D expectedsz: - raise RecordError("x86_pv_info: expected length of %d, got %d" - % (expectedsz, len(content))) + raise RecordError("x86_pv_info: expected length of %d, got %d"= % + (expectedsz, len(content))) =20 width, levels, res1, res2 =3D unpack(X86_PV_INFO_FORMAT, content) =20 @@ -294,8 +296,9 @@ def verify_record_x86_pv_info(self, content): raise RecordError("Expected levels of 3 or 4, got %d" % (level= s, )) =20 if res1 !=3D 0 or res2 !=3D 0: - raise StreamError("Reserved bits set in X86_PV_INFO: 0x%04x 0x= %08x" - % (res1, res2)) + raise StreamError( + "Reserved bits set in X86_PV_INFO: 0x%04x 0x%08x" % + (res1, res2)) =20 bitness =3D {4:32, 8:64}[width] self.info(" %sbit guest, %d levels of pagetables" % (bitness, lev= els)) @@ -309,8 +312,8 @@ def verify_record_x86_pv_p2m_frames(self, content): " least 8 bytes long") =20 if len(content) % 8 !=3D 0: - raise RecordError("Length expected to be a multiple of 8, not = %d" - % (len(content), )) + raise RecordError("Length expected to be a multiple of 8, not = %d" % + (len(content), )) =20 start, end =3D unpack("=3DII", content[:8]) self.info(" Start pfn 0x%x, End 0x%x" % (start, end)) @@ -321,30 +324,32 @@ def verify_record_x86_pv_vcpu_generic(self, content, = name): minsz =3D calcsize(X86_PV_VCPU_HDR_FORMAT) =20 if len(content) < minsz: - raise RecordError("X86_PV_VCPU_%s record length must be at lea= st %d" - " bytes long" % (name, minsz)) + raise RecordError( + "X86_PV_VCPU_%s record length must be at least %d bytes lo= ng" % + (name, minsz)) =20 if len(content) =3D=3D minsz: - self.info("Warning: X86_PV_VCPU_%s record with zero content" - % (name, )) + self.info("Warning: X86_PV_VCPU_%s record with zero content" % + (name, )) =20 vcpuid, res1 =3D unpack(X86_PV_VCPU_HDR_FORMAT, content[:minsz]) =20 if res1 !=3D 0: raise StreamError( - "Reserved bits set in x86_pv_vcpu_%s record 0x%04x" - % (name, res1)) + "Reserved bits set in x86_pv_vcpu_%s record 0x%04x" % + (name, res1)) =20 - self.info(" vcpu%d %s context, %d bytes" - % (vcpuid, name, len(content) - minsz)) + self.info(" vcpu%d %s context, %d bytes" % + (vcpuid, name, len(content) - minsz)) =20 =20 def verify_record_shared_info(self, content): """ shared info record """ =20 - if len(content) !=3D 4096: - raise RecordError("Length expected to be 4906 bytes, not %d" - % (len(content), )) + contentsz =3D len(content) + if contentsz !=3D 4096: + raise RecordError("Length expected to be 4906 bytes, not %d" % + (contentsz, )) =20 =20 def verify_record_tsc_info(self, content): @@ -358,11 +363,11 @@ def verify_record_tsc_info(self, content): mode, khz, nsec, incarn, res1 =3D unpack(X86_TSC_INFO_FORMAT, cont= ent) =20 if res1 !=3D 0: - raise StreamError("Reserved bits set in X86_TSC_INFO: 0x%08x" - % (res1, )) + raise StreamError("Reserved bits set in X86_TSC_INFO: 0x%08x" % + (res1, )) =20 - self.info(" Mode %u, %u kHz, %u ns, incarnation %d" - % (mode, khz, nsec, incarn)) + self.info(" Mode %u, %u kHz, %u ns, incarnation %d" % + (mode, khz, nsec, incarn)) =20 =20 def verify_record_hvm_context(self, content): @@ -412,6 +417,7 @@ def verify_record_checkpoint(self, content): if len(content) !=3D 0: raise RecordError("Checkpoint record with non-zero length") =20 + def verify_record_checkpoint_dirty_pfn_list(self, content): """ checkpoint dirty pfn list """ raise RecordError("Found checkpoint dirty pfn list record in strea= m") diff --git a/tools/python/xen/migration/libxl.py b/tools/python/xen/migrati= on/libxl.py index 79f4024e72..5c4d4fe063 100644 --- a/tools/python/xen/migration/libxl.py +++ b/tools/python/xen/migration/libxl.py @@ -45,7 +45,7 @@ REC_TYPE_emulator_xenstore_data : "Emulator xenstore data", REC_TYPE_emulator_context : "Emulator context", REC_TYPE_checkpoint_end : "Checkpoint end", - REC_TYPE_checkpoint_state : "Checkpoint state" + REC_TYPE_checkpoint_state : "Checkpoint state", } =20 # emulator_* header @@ -90,16 +90,16 @@ def verify_hdr(self): ident, version, options =3D self.unpack_exact(HDR_FORMAT) =20 if ident !=3D HDR_IDENT: - raise StreamError("Bad image id: Expected 0x%x, got 0x%x" - % (HDR_IDENT, ident)) + raise StreamError("Bad image id: Expected 0x%x, got 0x%x" % + (HDR_IDENT, ident)) =20 if version !=3D HDR_VERSION: - raise StreamError("Unknown image version: Expected %d, got %d" - % (HDR_VERSION, version)) + raise StreamError("Unknown image version: Expected %d, got %d"= % + (HDR_VERSION, version)) =20 if options & HDR_OPT_RESZ_MASK: - raise StreamError("Reserved bits set in image options field: 0= x%x" - % (options & HDR_OPT_RESZ_MASK)) + raise StreamError("Reserved bits set in image options field: 0= x%x" % + (options & HDR_OPT_RESZ_MASK)) =20 if ( (sys.byteorder =3D=3D "little") and ((options & HDR_OPT_BIT_ENDIAN) !=3D HDR_OPT_LE) ): @@ -121,8 +121,8 @@ def verify_record(self): if rtype not in rec_type_to_str: raise StreamError("Unrecognised record type %x" % (rtype, )) =20 - self.info("Libxl Record: %s, length %d" - % (rec_type_to_str[rtype], length)) + self.info("Libxl Record: %s, length %d" % + (rec_type_to_str[rtype], length)) =20 contentsz =3D (length + 7) & ~7 content =3D self.rdexact(contentsz) @@ -132,8 +132,9 @@ def verify_record(self): raise StreamError("Padding containing non0 bytes found") =20 if rtype not in record_verifiers: - raise RuntimeError("No verification function for libxl record = '%s'" - % rec_type_to_str[rtype]) + raise RuntimeError( + "No verification function for libxl record '%s'" % + rec_type_to_str[rtype]) else: record_verifiers[rtype](self, content[:length]) =20 @@ -162,16 +163,16 @@ def verify_record_emulator_xenstore_data(self, conten= t): minsz =3D calcsize(EMULATOR_HEADER_FORMAT) =20 if len(content) < minsz: - raise RecordError("Length must be at least %d bytes, got %d" - % (minsz, len(content))) + raise RecordError("Length must be at least %d bytes, got %d" % + (minsz, len(content))) =20 emu_id, emu_idx =3D unpack(EMULATOR_HEADER_FORMAT, content[:minsz]) =20 if emu_id not in emulator_id_to_str: raise RecordError("Unrecognised emulator id 0x%x" % (emu_id, )) =20 - self.info("Emulator Xenstore Data (%s, idx %d)" - % (emulator_id_to_str[emu_id], emu_idx)) + self.info("Emulator Xenstore Data (%s, idx %d)" % + (emulator_id_to_str[emu_id], emu_idx)) =20 # Chop off the emulator header content =3D content[minsz:] @@ -185,8 +186,8 @@ def verify_record_emulator_xenstore_data(self, content): parts =3D content[:-1].split("\x00") =20 if (len(parts) % 2) !=3D 0: - raise RecordError("Expected an even number of strings, got= %d" - % (len(parts), )) + raise RecordError("Expected an even number of strings, got= %d" % + (len(parts), )) =20 for key, val in zip(parts[0::2], parts[1::2]): self.info(" '%s' =3D '%s'" % (key, val)) @@ -197,8 +198,8 @@ def verify_record_emulator_context(self, content): minsz =3D calcsize(EMULATOR_HEADER_FORMAT) =20 if len(content) < minsz: - raise RecordError("Length must be at least %d bytes, got %d" - % (minsz, len(content))) + raise RecordError("Length must be at least %d bytes, got %d" % + (minsz, len(content))) =20 emu_id, emu_idx =3D unpack(EMULATOR_HEADER_FORMAT, content[:minsz]) =20 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel