From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48944) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3Zxy-00074I-Kl for qemu-devel@nongnu.org; Mon, 30 Nov 2015 20:42:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a3Zxu-000190-J3 for qemu-devel@nongnu.org; Mon, 30 Nov 2015 20:42:50 -0500 Date: Tue, 1 Dec 2015 11:46:58 +1100 From: David Gibson Message-ID: <20151201004658.GB31343@voom.redhat.com> References: <1448024079-20808-1-git-send-email-bharata@linux.vnet.ibm.com> <1448024079-20808-4-git-send-email-bharata@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="7ZAtKRhVyVSsbBD2" Content-Disposition: inline In-Reply-To: <1448024079-20808-4-git-send-email-bharata@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH v5 03/10] exec: Do vmstate unregistration from cpu_exec_exit() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bharata B Rao Cc: mdroth@linux.vnet.ibm.com, aik@ozlabs.ru, agraf@suse.de, qemu-devel@nongnu.org, pbonzini@redhat.com, qemu-ppc@nongnu.org, tyreld@linux.vnet.ibm.com, nfont@linux.vnet.ibm.com, imammedo@redhat.com, afaerber@suse.de --7ZAtKRhVyVSsbBD2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Nov 20, 2015 at 06:24:32PM +0530, Bharata B Rao wrote: > cpu_exec_init() does vmstate_register and register_savevm for the CPU dev= ice. > These need to be undone from cpu_exec_exit(). These changes are needed to > support CPU hot removal and also to correctly fail hotplug attempts > beyond max_cpus. >=20 > Signed-off-by: Bharata B Rao Reviewed-by: David Gibson > --- > exec.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) >=20 > diff --git a/exec.c b/exec.c > index fbac85b..47f03c0 100644 > --- a/exec.c > +++ b/exec.c > @@ -588,6 +588,8 @@ static int cpu_get_free_index(Error **errp) > =20 > void cpu_exec_exit(CPUState *cpu) > { > + CPUClass *cc =3D CPU_GET_CLASS(cpu); > + > if (cpu->cpu_index =3D=3D -1) { > /* cpu_index was never allocated by this @cpu or was already fre= ed. */ > return; > @@ -596,6 +598,15 @@ void cpu_exec_exit(CPUState *cpu) > QTAILQ_REMOVE(&cpus, cpu, node); > bitmap_clear(cpu_index_map, cpu->cpu_index, 1); > cpu->cpu_index =3D -1; > + if (cc->vmsd !=3D NULL) { > + vmstate_unregister(NULL, cc->vmsd, cpu); > + } > +#if defined(CPU_SAVE_VERSION) > + unregister_savevm(NULL, "cpu", cpu->env_ptr); > +#endif > + if (qdev_get_vmsd(DEVICE(cpu)) =3D=3D NULL) { > + vmstate_unregister(NULL, &vmstate_cpu_common, cpu); > + } > } > #else > =20 > @@ -612,6 +623,8 @@ static int cpu_get_free_index(Error **errp) > =20 > void cpu_exec_exit(CPUState *cpu) > { > + CPUClass *cc =3D CPU_GET_CLASS(cpu); > + > cpu_list_lock(); > if (cpu->cpu_index =3D=3D -1) { > cpu_list_unlock(); > @@ -621,6 +634,13 @@ void cpu_exec_exit(CPUState *cpu) > QTAILQ_REMOVE(&cpus, cpu, node); > cpu->cpu_index =3D -1; > cpu_list_unlock(); > + > + if (cc->vmsd !=3D NULL) { > + vmstate_unregister(NULL, cc->vmsd, cpu); > + } > + if (qdev_get_vmsd(DEVICE(cpu)) =3D=3D NULL) { > + vmstate_unregister(NULL, &vmstate_cpu_common, cpu); > + } > } > #endif > =20 --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --7ZAtKRhVyVSsbBD2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWXO4CAAoJEGw4ysog2bOSbjAP/iqKBRqRNOdo3MIKItiwuIUM CtSVNOV36d+jqlMQ4HJ3pHmaLk7UhYiD2J4Q3u5QslsexR9YBKOfAGBNMNXFVoWF l06tvBq4s5Skf7uNjZgfsssHxpv8NpAkkXSlyjbgTxWhXORgtKR1DwEr56V7hmII 8dNBk2D/lsF2yl80YGa4Z9hwXfsi6t1HwPQaktzDaW9oSZn64pS/+RsBxeuEbsKN 3AGNIM6VoK2EXrhx/K/S4YpvEFIM7jtIMqTyr6JWkltLXTG+5mGg2GRxAuwuaSoG G7iolucSfkmlUuLwXHVHYJXc09JS8ZP8rp5xIO7Uq+mf+Lil6/33O3bIB2gkpExS Gv3+r4NCHPv/2nsJyQKyE6N4XQgzLBEXBYJ0Pb5BhIhIXD8I51nxRDpktAQ+2mU5 NBlI0vS84rYge72sc8CzY/8fR8ViaKGOBuHjuifGh9HAXtDz6DL1Rtz5QMUpO7l2 Hbz4n/gxRQ+/ixth2OjgSy93W4jxBK9Uo+jFSJ/2STu4FI9BojUO3jM/fFEQrFk1 W88eB3hBiBkI/N/g3cTwYhM2YIPo1KR9VZvlunaLxjXK1nG+qYGwZ11g1DvNw/bL gQraww8VSTyq4GphSyBwt24hFYo1a5TFP6X8Uup/YFP7GLe8Mb13zfhjU+nw+bsh ZHPK1YETt4qfH+H+orqm =wHkU -----END PGP SIGNATURE----- --7ZAtKRhVyVSsbBD2--