From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48884) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3Zxv-000744-Uk for qemu-devel@nongnu.org; Mon, 30 Nov 2015 20:42:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a3Zxu-00019L-LS for qemu-devel@nongnu.org; Mon, 30 Nov 2015 20:42:47 -0500 Date: Tue, 1 Dec 2015 11:57:54 +1100 From: David Gibson Message-ID: <20151201005754.GD31343@voom.redhat.com> References: <1448024079-20808-1-git-send-email-bharata@linux.vnet.ibm.com> <1448024079-20808-6-git-send-email-bharata@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="T7mxYSe680VjQnyC" Content-Disposition: inline In-Reply-To: <1448024079-20808-6-git-send-email-bharata@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH v5 05/10] cpu: Add a sync version of cpu_remove() 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 --T7mxYSe680VjQnyC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Nov 20, 2015 at 06:24:34PM +0530, Bharata B Rao wrote: > This sync API will be used by the CPU hotplug code to wait for the CPU to > completely get removed before flagging the failure to the device_add > command. >=20 > Sync version of this call is needed to correctly recover from CPU > realization failures when ->plug() handler fails. >=20 > Signed-off-by: Bharata B Rao Reviewed-by: David Gibson > --- > cpus.c | 12 ++++++++++++ > include/qom/cpu.h | 8 ++++++++ > 2 files changed, 20 insertions(+) >=20 > diff --git a/cpus.c b/cpus.c > index af2b274..c2444ba 100644 > --- a/cpus.c > +++ b/cpus.c > @@ -1070,6 +1070,8 @@ static void *qemu_kvm_cpu_thread_fn(void *arg) > qemu_kvm_wait_io_event(cpu); > if (cpu->exit && !cpu_can_run(cpu)) { > qemu_kvm_destroy_vcpu(cpu); > + cpu->created =3D false; > + qemu_cond_signal(&qemu_cpu_cond); > qemu_mutex_unlock(&qemu_global_mutex); > return NULL; > } > @@ -1174,6 +1176,8 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) > } > if (remove_cpu) { > qemu_tcg_destroy_vcpu(remove_cpu); > + cpu->created =3D false; > + qemu_cond_signal(&qemu_cpu_cond); > remove_cpu =3D NULL; > } > } > @@ -1339,6 +1343,14 @@ void cpu_remove(CPUState *cpu) > qemu_cpu_kick(cpu); > } > =20 > +void cpu_remove_sync(CPUState *cpu) > +{ > + cpu_remove(cpu); > + while (cpu->created) { > + qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex); > + } > +} > + > /* For temporary buffers for forming a name */ > #define VCPU_THREAD_NAME_SIZE 16 > =20 > diff --git a/include/qom/cpu.h b/include/qom/cpu.h > index 67e05b0..7fc6696 100644 > --- a/include/qom/cpu.h > +++ b/include/qom/cpu.h > @@ -705,6 +705,14 @@ void cpu_resume(CPUState *cpu); > */ > void cpu_remove(CPUState *cpu); > =20 > + /** > + * cpu_remove_sync: > + * @cpu: The CPU to remove. > + * > + * Requests the CPU to be removed and waits till it is removed. > + */ > +void cpu_remove_sync(CPUState *cpu); > + > /** > * qemu_init_vcpu: > * @cpu: The vCPU to initialize. --=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 --T7mxYSe680VjQnyC Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWXPCSAAoJEGw4ysog2bOSdOkP/1gLwaWjdH1fKOOYaAhn8AYF HhakB5U0y02ciXAOBL4aEoxn1Z/ozK1YvTMvVis9ojVEL8WYtGqJLsAH/rD32s9r Id9xEapscRMSSYQUiOyfvI4CpP1vaaJ0Mj49yaYb6bcPMKY+u2tNIbAl9aeA0oII A/S12oOLWoHsWshir3bzyKWP2VQwhpzd1WFmOGDEYiJYLfv3S4cWVQqjdrKmUwRp sPDY0sDIXE91D2HF29GNDsjGp7SJdtzANk5uTwANd++I7ODm2QVSBdvZzsHgQ3Dd RR8XAxuXe0pJa4IRP6Vm+23vG/DVhQyC7Ii4v2GvxlpKcPeGEfxywOBzHBbCHOPV p50pRKXpBsGKIZwwmVsevni/u5/rxILku/JDzE61JJ68XQ4gZKGolIhTzEEo5mAW XF6PHSXZCgImXipoqVG6Un/p3VKUHn4/xU0fi71fi64Nqon/EeKbpBketfGQIY/C dXEgPuHmgQWTshUY0Z9QcI5OrU6mWPjK9ndM0lk/TGBUPeABwigSa33Y9j+tB1jY 7lfy4guTy1X1QPQSJkMbQHp3gstucbM+3rjFi0Eu6ezX1Unyxdx555dTEj1drRo8 zH7CNUzk4nvwnqkkrvFHylGzHTGoqUKmYwy6FBJlV2qS3MJ9acxolGeOiPJ/4Z1Y qFQCo3CYqaU4GLGN9RHf =OG/R -----END PGP SIGNATURE----- --T7mxYSe680VjQnyC--