From: Andrew Cooper Subject: Re: "X86_PV_VCPU_MSRS record truncated" during domain restore Date: Thu, 21 Jul 2016 01:10:18 +0100 Message-ID: References: <20160720113752.GT1161@mail-itl> <345d27df-0424-c7bd-a099-d933b0a45c18@gmail.com> <20160720232009.GA24847@mail-itl> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0143669778511797059==" Return-path: In-Reply-To: <20160720232009.GA24847@mail-itl> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: =?UTF-8?Q?Marek_Marczykowski-G=c3=b3recki?= , Massimo Colombi Cc: xen-devel List-Id: xen-devel@lists.xenproject.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --===============0143669778511797059== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="J5cOI4TdgWV7nuTtMPGR2aH3kea6l06m2" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --J5cOI4TdgWV7nuTtMPGR2aH3kea6l06m2 Content-Type: multipart/mixed; boundary="EGvfA56dcWOvJpuug18cdhwb7tm93jUhL" From: Andrew Cooper To: =?UTF-8?Q?Marek_Marczykowski-G=c3=b3recki?= , Massimo Colombi Cc: xen-devel Message-ID: Subject: Re: [Xen-devel] "X86_PV_VCPU_MSRS record truncated" during domain restore References: <20160720113752.GT1161@mail-itl> <345d27df-0424-c7bd-a099-d933b0a45c18@gmail.com> <20160720232009.GA24847@mail-itl> In-Reply-To: <20160720232009.GA24847@mail-itl> --EGvfA56dcWOvJpuug18cdhwb7tm93jUhL Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 21/07/2016 00:20, Marek Marczykowski-G=C3=B3recki wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > > On Wed, Jul 20, 2016 at 02:33:20PM +0200, Massimo Colombi wrote: >> I retried (it's not the first time) to regenerate new savefile, but Di= spVM >> doesn't work. >> I attach the results. > For me it looks like a bug in savefile handling. Moving to xen-devel. A= ny > idea? > Background info: it's about restoring a domain through libvirt->libxl > (virsh restore equivalent). Xen 4.6.1. Full error: > >> 2016-07-20 14:23:01 CEST xc: error: X86_PV_VCPU_MSRS record truncated:= length 8, min 9: Internal error >> 2016-07-20 14:23:01 CEST xc: error: Restore failed (0 =3D Success): In= ternal error [EDIT] While writing the explanation below, I have spotted the bug. The restore side found a record in the stream of type X86_PV_VCPU_MSRS and 8 bytes long. The X86_PV_VCPU_MSRS record is an 8 byte header, followed by 1 or more bytes which are treated as an opaque blob, and handed back to Xen. As such, 8 bytes is insufficient to contain a nonzero sized payload. Is it possible to do an `xl save` equivalent on the domain, and run tools/python/scripts/verify-stream-v2 against the resulting file? That should identify whether it is a malformed X86_PV_VCPU_MSRS record but otherwise intact stream, or whether the stream becomes corrupted elsewher= e? If not, another line if inquiry would be to instrument tools/libxc/xc_sr_save_x86_pv.c write_one_vcpu_msrs() to identify what XEN_DOMCTL_get_vcpu_msrs is returning on the source side (although this function does deliberately check for a zero-sized payload and omit the record). The hypervisor side implementation is in xen/arch/x86/domctl.c at the XEN_DOMCTL_get_vcpu_msrs case label. Re-reading the write_one_vcpu_msrs(), there is an error. We first query Xen for the maximum number of MSRs it might potentially give to us, which will return 4 on this hardware. We then actually ask for the MSR content, but Xen only writes non-zero MSRs into payload. A domain which isn't using Debug Extensions will return 4 for the first query (maximum number of MSRs), then 0 for the second query (actual MSR content), and write a X86_PV_VCPU_MSRS record with 0 payload into the stream, which the receiving side is objecting to. I will make a patch series tomorrow to address this issue. I think there are similar issues for other records as well. ~Andrew --EGvfA56dcWOvJpuug18cdhwb7tm93jUhL-- --J5cOI4TdgWV7nuTtMPGR2aH3kea6l06m2 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (MingW32) iQIcBAEBAgAGBQJXkBL3AAoJEGXD+Qal15+gGNkQAK+Pjlt/RECZ58dHgbewdk4Y EQTMLz25cTz9hB65VdymFVsB8RmA5Mkx5wDaRxu0IMM0FdmxX6Zp4fRVqO7UyC+o j+QQHVrD+H4opCOH1dGgiZ2rHfEcUd7j+HAu6waz62bZq+XpEJRf6nQAf+ZH6qrN TbBKCMrphw0rNWiRbwt5FW2GQfYxAQ6Vt+kqn8G4SN8JXqDsCXn/Am7jk/ONjlqT ZgSHRYn8NYu4nmCrpEEayOVJSdmisPbqKxJjNn5rQDjxxE5ClCP0xltD944XBlaR HLTbmAw7/LoLqFNs4B8D6bM2a+ApifGTTB+VIlgadha0d/qpALJNNSvdl9cnoY3k ab3Nhquh+kXwVhUlJsqWatUxhLPtqXR8aIDbhjw0/qiHR8CpgFR+zGAL+GYfwRwQ Wsr5+nuytb3MY/x6vkiWHBZ4KZ6ulsUaQMDJIcYhSjSC2Vj1u2U5f/6sfHM08bpZ IE+kufvOlTxdEdFJ90kyh4X7LIYMnKvNkS/TXN13e4ErWFETEOavDJMwizGF5GRg bDvOiZHMh9gi14MqbUswEyUbHOKnUbmWv0iyZLuNUw3h47DmxTEjiRHLImqQmEJ9 GvEOgTwkiO63R22oVNfoRIYHdgRvc9/p3z9GH2uv3x9bWPmLCgEVko6HCyx2ZtRB 6H5a1DrEJwoL2Y8ZbGK6 =wsmD -----END PGP SIGNATURE----- --J5cOI4TdgWV7nuTtMPGR2aH3kea6l06m2-- --===============0143669778511797059== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwczovL2xpc3RzLnhlbi5v cmcveGVuLWRldmVsCg== --===============0143669778511797059==--