From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48682) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1cYB-0007cC-7V for qemu-devel@nongnu.org; Wed, 25 Nov 2015 11:04:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a1cYA-00022G-8J for qemu-devel@nongnu.org; Wed, 25 Nov 2015 11:04:07 -0500 Date: Wed, 25 Nov 2015 17:03:56 +0100 From: Kevin Wolf Message-ID: <20151125160356.GF12581@noname.str.redhat.com> References: <1447108773-6836-1-git-send-email-mreitz@redhat.com> <1447108773-6836-14-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1447108773-6836-14-git-send-email-mreitz@redhat.com> Subject: Re: [Qemu-devel] [PATCH v7 13/24] virtio-scsi: Catch BDS-BB removal/insertion List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Alberto Garcia , qemu-block@nongnu.org, John Snow , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi , Paolo Bonzini Am 09.11.2015 um 23:39 hat Max Reitz geschrieben: > Make use of the BDS-BB removal and insertion notifiers to remove or set > up, respectively, virtio-scsi's op blockers. > > Signed-off-by: Max Reitz > @@ -797,6 +830,29 @@ static void virtio_scsi_hotunplug(HotplugHandler *hotplug_dev, DeviceState *dev, > if (s->ctx) { > blk_op_unblock_all(sd->conf.blk, s->blocker); > } > + > + QTAILQ_FOREACH(insert_notifier, &s->insert_notifiers, next) { > + if (insert_notifier->sd == sd) { > + break; > + } > + } > + if (insert_notifier) { > + notifier_remove(&insert_notifier->n); > + QTAILQ_REMOVE(&s->insert_notifiers, insert_notifier, next); > + g_free(insert_notifier); > + } Why a separate if block instead of just doing that inside the loop? > + QTAILQ_FOREACH(remove_notifier, &s->remove_notifiers, next) { > + if (remove_notifier->sd == sd) { > + break; > + } > + } > + if (remove_notifier) { > + notifier_remove(&remove_notifier->n); > + QTAILQ_REMOVE(&s->remove_notifiers, remove_notifier, next); > + g_free(remove_notifier); > + } > + > qdev_simple_device_unplug_cb(hotplug_dev, dev, errp); > } Kevin