From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49927) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aP9o8-000221-5S for qemu-devel@nongnu.org; Fri, 29 Jan 2016 09:13:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aP9o7-00011L-3R for qemu-devel@nongnu.org; Fri, 29 Jan 2016 09:13:52 -0500 References: <1453917600-2663-1-git-send-email-mreitz@redhat.com> <1453917600-2663-6-git-send-email-mreitz@redhat.com> <20160129124144.GA4356@noname.redhat.com> From: Max Reitz Message-ID: <56AB7396.1090903@redhat.com> Date: Fri, 29 Jan 2016 15:13:42 +0100 MIME-Version: 1.0 In-Reply-To: <20160129124144.GA4356@noname.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="leUvXm7QcO1Kuldbaat05d0jOGbIwPxCB" Subject: Re: [Qemu-devel] [PATCH v8 05/16] virtio-scsi: Catch BDS-BB removal/insertion List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: Alberto Garcia , qemu-block@nongnu.org, qemu-devel@nongnu.org, Paolo Bonzini , Fam Zheng , John Snow This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --leUvXm7QcO1Kuldbaat05d0jOGbIwPxCB Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 29.01.2016 13:41, Kevin Wolf wrote: > Am 27.01.2016 um 18:59 hat Max Reitz geschrieben: >> Make use of the BDS-BB removal and insertion notifiers to remove or se= t >> up, respectively, virtio-scsi's op blockers. >> >> Signed-off-by: Max Reitz >> --- >> hw/scsi/virtio-scsi.c | 55 ++++++++++++++++++++++++++++++++= +++++++++ >> include/hw/virtio/virtio-scsi.h | 10 ++++++++ >> 2 files changed, 65 insertions(+) >> >> diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c >> index 607593c..b508b81 100644 >> --- a/hw/scsi/virtio-scsi.c >> +++ b/hw/scsi/virtio-scsi.c >> @@ -757,6 +757,22 @@ static void virtio_scsi_change(SCSIBus *bus, SCSI= Device *dev, SCSISense sense) >> } >> } >> =20 >> +static void virtio_scsi_blk_insert_notifier(Notifier *n, void *data) >> +{ >> + VirtIOSCSIBlkChangeNotifier *cn =3D DO_UPCAST(VirtIOSCSIBlkChange= Notifier, >> + n, n); >> + assert(cn->sd->conf.blk =3D=3D data); >> + blk_op_block_all(cn->sd->conf.blk, cn->s->blocker); >> +} >> + >> +static void virtio_scsi_blk_remove_notifier(Notifier *n, void *data) >> +{ >> + VirtIOSCSIBlkChangeNotifier *cn =3D DO_UPCAST(VirtIOSCSIBlkChange= Notifier, >> + n, n); >> + assert(cn->sd->conf.blk =3D=3D data); >> + blk_op_unblock_all(cn->sd->conf.blk, cn->s->blocker); >> +} >> + >> static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceSt= ate *dev, >> Error **errp) >> { >> @@ -765,6 +781,22 @@ static void virtio_scsi_hotplug(HotplugHandler *h= otplug_dev, DeviceState *dev, >> SCSIDevice *sd =3D SCSI_DEVICE(dev); >> =20 >> if (s->ctx && !s->dataplane_disabled) { >> + VirtIOSCSIBlkChangeNotifier *insert_notifier, *remove_notifie= r; >> + >> + insert_notifier =3D g_new0(VirtIOSCSIBlkChangeNotifier, 1); >> + insert_notifier->n.notify =3D virtio_scsi_blk_insert_notifier= ; >> + insert_notifier->s =3D s; >> + insert_notifier->sd =3D sd; >> + blk_add_insert_bs_notifier(sd->conf.blk, &insert_notifier->n)= ; >> + QTAILQ_INSERT_TAIL(&s->insert_notifiers, insert_notifier, nex= t); >> + >> + remove_notifier =3D g_new0(VirtIOSCSIBlkChangeNotifier, 1); >> + remove_notifier->n.notify =3D virtio_scsi_blk_remove_notifier= ; >> + remove_notifier->s =3D s; >> + remove_notifier->sd =3D sd; >> + blk_add_remove_bs_notifier(sd->conf.blk, &remove_notifier->n)= ; >> + QTAILQ_INSERT_TAIL(&s->remove_notifiers, remove_notifier, nex= t); >> + >> if (blk_op_is_blocked(sd->conf.blk, BLOCK_OP_TYPE_DATAPLANE, = errp)) { >> return; >> } >=20 > If we take the error path here, won't we have dangling pointers in the > notifier list? Yes, I'll move it below that error path. Max --leUvXm7QcO1Kuldbaat05d0jOGbIwPxCB 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 iQEcBAEBCAAGBQJWq3OWAAoJEDuxQgLoOKytw74IAIDTVlqClJxh9iuNDb8tIjfI Cjm4gBK5lRombBVWRH3Xzr6zHbo9pF0uquSYN01FESu+sW7F2Z4IrG0QSVULhGI1 aABLbtY2rOuvclrJVdqiVcLmsOBKZUgOFm7ZqT8QRHyohc6LdWujpd7rFgHDUMZ+ yUtIZDopBzEcMBd4oJheWtaiarzXeLBoSRblDHe3kdIDisvokBSwJ2Dd9jJW5n+p ewBQqqKZzYmB7CkY4UsjHyyZtRM2zbLjKvrCeEoqWo/RzR3JvvQp5U77Rypejroo PRHbuYCWsmgvY0mHLCpOs0XwjOftiCu0IHyzlJtIYBGpfL+rzlPNOMLO8HOLvP8= =03bj -----END PGP SIGNATURE----- --leUvXm7QcO1Kuldbaat05d0jOGbIwPxCB--