Received: from eggs.gnu.org ([2001:4830:134:3::10]:32812) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fT48s-0006cb-QG for qemu-devel@nongnu.org; Wed, 13 Jun 2018 07:40:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fT48r-0001c9-Rz for qemu-devel@nongnu.org; Wed, 13 Jun 2018 07:40:46 -0400 From: Markus Armbruster References: <1516366207-109842-1-git-send-email-anton.nefedov@virtuozzo.com> <1516366207-109842-9-git-send-email-anton.nefedov@virtuozzo.com> <87tvuyf4it.fsf@dusky.pond.sub.org> <959271ee-c39e-09ab-9f9a-90d97d34f4f5@virtuozzo.com> <87wovar5tl.fsf@dusky.pond.sub.org> <02f27bf7-e371-c396-eaec-1f9e3e24611e@redhat.com> <87a7s5q20q.fsf@dusky.pond.sub.org> Date: Wed, 13 Jun 2018 13:40:38 +0200 In-Reply-To: (Anton Nefedov's message of "Wed, 13 Jun 2018 13:36:05 +0300") Message-ID: <87wov2kj7t.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 8/8] qapi: query-blockstat: add driver specific file-posix stats List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anton Nefedov Cc: Markus Armbruster , Eric Blake , kwolf@redhat.com, den@virtuozzo.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, mreitz@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Anton Nefedov writes: > On 8/6/2018 8:29 AM, Markus Armbruster wrote: >> Eric Blake writes: >> >>> On 06/07/2018 10:23 AM, Anton Nefedov wrote: >>>>>> If we introduce BlockdevDriver as a discriminator as Markus suggests >>>>>> above, we need some way to define its value. >>>>>> I guess one would be to check blk->bs->drv->format_name but it won't >>>>>> always work; often it's even blk->bs =3D=3D NULL. >>>>> >>>>> There is no blk->bs, at least not if blk is a BlockBackend *. >>>>> >>>>> I figure the problem you're trying to describe is query-blockstats >>>>> running into BlockBackends that aren't associated with a >>>>> BlockDriverState (blk->root is null), and thus aren't associated with= a >>>>> BlockDriver.=C2=A0 Correct? >>>>> >>>> >>>> Sorry, yes, exactly >>> >>> Okay, that sounds like the driver stats have to be optional, present >>> only when blk->bs is non-NULL. >>> >>>> >>>>>> I guess we could add a default ('unspecified'?) to BlockdevDriver en= um? >>>>> >>>>> This part I understand, but... >>>>> >>>>>> But I'd rather leave an optional BlockDriverStats union (but make it >>>>>> flat). Only the drivers that provide these stats will need to set >>>>>> BlockdevDriver field. What do you think? >>>>> >>>>> I'm not sure I got this part.=C2=A0 Care to sketch the QAPI schema sn= ippet? >>>>> >>>> >>>> You earlier proposed: >>>> >>>> >>> You're adding a union of driver-specific stats to a struct of ge= neric >>>> >>> stats.=C2=A0 That's unnecessarily complicated.=C2=A0 Instead, tu= rn the struct of >>>> >>> generic stats into a flat union, like this: >>>> >>> >>>> >>> { 'union': 'BlockStats', >>>> >>>=C2=A0=C2=A0=C2=A0=C2=A0 'base': { ... the generic stats, i.e. th= e members of BlockStats >>>> >>>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 before this patch ... >>>> >>>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 'driver': 'BlockdevDriver' } >>>> >>>=C2=A0=C2=A0=C2=A0=C2=A0 'discriminator': 'driver', >>>> >>>=C2=A0=C2=A0=C2=A0=C2=A0 'data': { >>>> >>>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 'file': 'BlockDr= iverStatsFile', >>>> >>>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ... } } >>> >>> That would require 'driver' to always resolve to something, even when >>> there is no driver (unless we create a superset enum that adds 'none' >>> beyond what 'BlockdevDriver' supports). >>> >>>> >>>> But I meant to leave it as: >>>> >>>> + { 'union': 'BlockDriverStats': >>>> +=C2=A0=C2=A0=C2=A0=C2=A0 'base': { 'driver': 'BlockdevDriver' }, >>>> +=C2=A0=C2=A0=C2=A0=C2=A0 'discriminator': 'driver', >>>> +=C2=A0=C2=A0=C2=A0=C2=A0 'data': { >>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 'file': 'BlockDriver= StatsFile' } } >>>> >>>> >>>> =C2=A0 { 'struct': 'BlockStats', >>>> =C2=A0=C2=A0=C2=A0 'data': {'*device': 'str', '*node-name': 'str', >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 'stats': 'BlockDeviceStats', >>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 '*= driver-stats': 'BlockDriverStats', >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 '*parent': 'BlockStats', >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 '*backing': 'BlockStats'} } >>>> >>>> so those block backends which do not provide driver stats do not need = to >>>> set BlockdevDriver field. >>> >>> This makes the most sense to me - we're stuck with a layer of nesting, >>> but that's because driver-stats truly is optional (we don't always >>> have access to a driver). >> >> Agree. >> >> Now we have to name the thing. You propose @driver-stats. Servicable, >> but let's review how existing driver-specific things are named. >> >> BlockdevOptions and BlockdevCreateOptions have them inline, thus no >> name. >> >> ImageInfo has '*format-specific': 'ImageInfoSpecific'. >> >> If we follow ImageInfo precedence, we get '*driver-specific': >> 'BlockStatsSpecific'. driver-specific I like well enough. >> BlockStatsSpecific less so. BlockStatsDriverSpecific feels better, but >> perhaps a bit long. >> > > following it further we will have BlockStatsDriverSpecificFile which is > even longer. > > Personally, both > '*driver-specific': 'BlockDriverStats'; 'BlockDriverStatsFile' > '*driver-specific': 'BlockStatsSpecific'; 'BlockStatsSpecificFile' > look right to me. > > Function signatures look ok too except that BlockDriverStats is easy to > confuse with BlockDriverState > > BlockDriverStats *bdrv_get_stats(BlockDriverState *bs); > BlockStatsSpecific *bdrv_get_specific_stats(BlockDriverState *bs); > > so maybe BlockStatsSpecific indeed? Works for me, but block maintainers have veto powers :)