Received: from eggs.gnu.org ([2001:4830:134:3::10]:40266) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ai4LW-00071X-OW for qemu-devel@nongnu.org; Mon, 21 Mar 2016 14:14:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ai4LR-00067i-QB for qemu-devel@nongnu.org; Mon, 21 Mar 2016 14:14:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52766) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ai4LR-00067d-L9 for qemu-devel@nongnu.org; Mon, 21 Mar 2016 14:14:25 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 4AAE346208 for ; Mon, 21 Mar 2016 18:14:25 +0000 (UTC) From: Markus Armbruster References: <1456151945-11225-1-git-send-email-pbonzini@redhat.com> <1456151945-11225-4-git-send-email-pbonzini@redhat.com> <87k2kvzu0z.fsf@blackfin.pond.sub.org> <56F01F8A.2090902@redhat.com> <87shzj68n2.fsf@blackfin.pond.sub.org> <56F030B3.3070709@redhat.com> Date: Mon, 21 Mar 2016 19:14:22 +0100 In-Reply-To: <56F030B3.3070709@redhat.com> (Paolo Bonzini's message of "Mon, 21 Mar 2016 18:34:43 +0100") Message-ID: <87fuvj1ywx.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 3/3] block: remove legacy_dinfo at blk_detach_dev time List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Paolo Bonzini writes: > On 21/03/2016 18:30, Markus Armbruster wrote: >> However, I've now tested my expectation, and it turned out to be wrong. >> I'm inclined to call that a bug. > > --verbose, what is wrong and what was your expectation? x-blockdev-del should refuse to touch anything not created with blockdev-add. >> > In other words, you said "This looks like DriveInfo now owns a reference >> > to BlockBackend, even though the pointer still goes in the other >> > direction". I say, "I thought this was the idea all along"... >> >> For me, the DriveInfo doesn't own anything, but a BlockBackend may have >> a DriveInfo. Evidence: >> >> * The pointer goes from the BlockBackend to the DriveInfo >> >> * To go back, you search the blk_backends for the one that has the >> DriveInfo. See blk_by_legacy_dinfo(). >> >> * There is no list of DriveInfo. If you want to find one, you search >> blk_backends. See drive_get() & friends. > > That's from the point of view of the code. But from the point of view > of the user, he specifies a drive=... and the device converts that under > the hood to a BlockBackend; and when he calls drive_del on an unassigned > drive, the BlockBackend is destroyed. > > There is no action on a BlockBackend that destroys the > DriveInfo---except auto-deletion on unplug, but even then the user in > the first place had provided a DriveInfo. So from the point of view of > the user it's always been the DriveInfo that owned a BlockBackend. The > lack of a list of DriveInfo is just an implementation detail. >From the user's point of view, neither BlockBackend nor DriveInfo are visible :) A BlockBackend may have a DriveInfo. If it has one, then destroying the BlockBackend also destroys its DriveInfo. DriveInfo exists only to capture a -drive in a more convenient form than its QemuOpts. We use it for creating a BlockBackend. It lives on after that only because -drive mixes up front- and backend matter. Keeping DriveInfo around hanging off BlockBackend lets us keep frontend matter out of BlockBackend: if need to access mixed up frontend matter for back-compat, we find it in the BlockBackend's DriveInfo. Imagine a future where we drop -drive / drive_add, or at least its mixed up aspects (doesn't have to be practical for imagining it). In that future, we'd also drop DriveInfo.