From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=42587 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OMibr-0003Wx-8x for qemu-devel@nongnu.org; Thu, 10 Jun 2010 10:19:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OMibp-0006m3-SD for qemu-devel@nongnu.org; Thu, 10 Jun 2010 10:19:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2018) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OMibp-0006lq-K8 for qemu-devel@nongnu.org; Thu, 10 Jun 2010 10:19:53 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5AEJqgr027605 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 10 Jun 2010 10:19:52 -0400 Message-ID: <4C10F478.6040905@redhat.com> Date: Thu, 10 Jun 2010 16:19:36 +0200 From: Kevin Wolf MIME-Version: 1.0 References: <1275497729-13120-1-git-send-email-armbru@redhat.com> <1275497729-13120-8-git-send-email-armbru@redhat.com> In-Reply-To: <1275497729-13120-8-git-send-email-armbru@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 07/13] blockdev: Means to destroy blockdev only if made with drive_init() List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org, kraxel@redhat.com Am 02.06.2010 18:55, schrieb Markus Armbruster: > All drives are still made that way. They get destroyed along with > their device. That's inappropriate for the alternative way to make > blockdevs that will appear later in this series. These won't have a > DriveInfo. > > blockdev_detach() destroys the blockdev only if it has a DriveInfo. > > blockdev_attach() does nothing for now. It'll be fleshed out later. > > Signed-off-by: Markus Armbruster > --- > blockdev.c | 35 +++++++++++++++++++++++++++++++++++ > blockdev.h | 7 +++++++ > 2 files changed, 42 insertions(+), 0 deletions(-) > > diff --git a/blockdev.c b/blockdev.c > index ace74e4..f90d4fc 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -1,8 +1,12 @@ > /* > * QEMU host block devices > * > + * Copyright (C) 2010 Red Hat Inc. > * Copyright (c) 2003-2008 Fabrice Bellard > * > + * Authors: > + * Markus Armbruster , > + * > * This work is licensed under the terms of the GNU GPL, version 2 or > * later. See the COPYING file in the top-level directory. > */ > @@ -17,6 +21,37 @@ > > static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives); > > +static int blockdev_del_dinfo(BlockDriverState *bs) > +{ > + DriveInfo *dinfo, *next_dinfo; > + int res = 0; > + > + QTAILQ_FOREACH_SAFE(dinfo, &drives, next, next_dinfo) { > + if (dinfo->bdrv == bs) { > + qemu_opts_del(dinfo->opts); > + QTAILQ_REMOVE(&drives, dinfo, next); > + qemu_free(dinfo); > + res = 1; > + } > + } > + > + return res; Can it happen that a BlockDriverState belongs to multiple DriveInfos? If no, why not returning in the loop? Wouldn't need a FOREACH_SAFE then, too. It's not worth respinning because of this one, but there were more comments and I think you'll send a v2 for the actual -blockdev option anyway once we have decided how to do it. I have applied patches 1 to 6 now, and I think I could safely go on until patch 9 if the minor improvements that were mentioned in comments are made. I'd ignore patch 10 to 13 for now. Is this what you would have expected or should I handle anything in a different way? Kevin