From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57342) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIh6K-0001dI-Hn for qemu-devel@nongnu.org; Tue, 15 May 2018 17:03:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIh6J-0007vr-Jp for qemu-devel@nongnu.org; Tue, 15 May 2018 17:03:16 -0400 References: <20180512012537.22478-1-jsnow@redhat.com> <20180512012537.22478-8-jsnow@redhat.com> <453c0511-0114-49f9-07e1-3eb63c06cf6c@virtuozzo.com> From: John Snow Message-ID: <47383ab6-b2a6-c9fb-43d6-814422bcd0c2@redhat.com> Date: Tue, 15 May 2018 17:03:09 -0400 MIME-Version: 1.0 In-Reply-To: <453c0511-0114-49f9-07e1-3eb63c06cf6c@virtuozzo.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC PATCH 07/12] qcow2-bitmap: add basic bitmaps info List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladimir Sementsov-Ogievskiy , qemu-block@nongnu.org, qemu-devel@nongnu.org Cc: Kevin Wolf , Markus Armbruster , Max Reitz On 05/14/2018 11:12 AM, Vladimir Sementsov-Ogievskiy wrote: > 12.05.2018 04:25, John Snow wrote: >> Add functions for querying the basic information inside of bitmaps. >> Restructure the bitmaps flags masks to facilitate providing a list of >> flags belonging to the bitmap(s) being queried. >> >> Signed-off-by: John Snow >> --- >> =C2=A0 block/qcow2-bitmap.c | 81 >> ++++++++++++++++++++++++++++++++++++++++++++++++++-- >> =C2=A0 block/qcow2.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0= 7 +++++ >> =C2=A0 block/qcow2.h=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0= 1 + >> =C2=A0 3 files changed, 87 insertions(+), 2 deletions(-) >> >> diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c >> index 60e01abfd7..811b82743a 100644 >> --- a/block/qcow2-bitmap.c >> +++ b/block/qcow2-bitmap.c >> @@ -49,8 +49,28 @@ >> =C2=A0 =C2=A0 /* Bitmap directory entry flags */ >> =C2=A0 #define BME_RESERVED_FLAGS 0xfffffffcU >> -#define BME_FLAG_IN_USE (1U << 0) >> -#define BME_FLAG_AUTO=C2=A0=C2=A0 (1U << 1) >> + >> +enum BME_FLAG_BITS { >> +=C2=A0=C2=A0=C2=A0 BME_FLAG_BIT__BEGIN =3D 0, >> +=C2=A0=C2=A0=C2=A0 BME_FLAG_BIT_IN_USE =3D BME_FLAG_BIT__BEGIN, >> +=C2=A0=C2=A0=C2=A0 BME_FLAG_BIT_AUTO=C2=A0=C2=A0 =3D 1, >> +=C2=A0=C2=A0=C2=A0 BME_FLAG_BIT_EXTRA=C2=A0 =3D 2, >> +=C2=A0=C2=A0=C2=A0 BME_FLAG_BIT__MAX, >> +}; >> + >> +#define BME_FLAG_IN_USE (1U << BME_FLAG_BIT_IN_USE) >> +#define BME_FLAG_AUTO=C2=A0=C2=A0 (1U << BME_FLAG_BIT_AUTO) >> +#define BME_FLAG_EXTRA=C2=A0 (1U << BME_FLAG_BIT_EXTRA) >> + >> +/* Correlate canonical spec values to autogenerated QAPI values */ >> +struct { >> +=C2=A0=C2=A0=C2=A0 uint32_t mask; >=20 > mask is unused in this patch >=20 It sure is! I'll remove it. It's an artifact from an earlier revision. >> +=C2=A0=C2=A0=C2=A0 int qapi_value; >> +} BMEFlagMap[BME_FLAG_BIT__MAX] =3D { >> +=C2=A0=C2=A0=C2=A0 [BME_FLAG_BIT_IN_USE] =3D { BME_FLAG_IN_USE, >> BITMAP_FLAG_ENUM_IN_USE }, >> +=C2=A0=C2=A0=C2=A0 [BME_FLAG_BIT_AUTO]=C2=A0=C2=A0 =3D { BME_FLAG_AUT= O,=C2=A0=C2=A0 BITMAP_FLAG_ENUM_AUTO }, >> +=C2=A0=C2=A0=C2=A0 [BME_FLAG_BIT_EXTRA]=C2=A0 =3D { BME_FLAG_EXTRA,=C2= =A0 >> BITMAP_FLAG_ENUM_EXTRA_DATA_COMPATIBLE }, >> +}; >> =C2=A0 =C2=A0 /* bits [1, 8] U [56, 63] are reserved */ >> =C2=A0 #define BME_TABLE_ENTRY_RESERVED_MASK 0xff000000000001feULL >> @@ -663,6 +683,63 @@ static void del_bitmap_list(BlockDriverState *bs) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> =C2=A0 } >> =C2=A0 +static BitmapFlagEnumList *get_bitmap_flags(uint32_t flags) >> +{ >> +=C2=A0=C2=A0=C2=A0 int i; >> +=C2=A0=C2=A0=C2=A0 BitmapFlagEnumList *flist =3D NULL; >> +=C2=A0=C2=A0=C2=A0 BitmapFlagEnumList *ftmp; >> + >> +=C2=A0=C2=A0=C2=A0 while (flags) { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 i =3D ctz32(flags); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ftmp =3D g_new0(BitmapFlag= EnumList, 1); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (i >=3D BME_FLAG_BIT__B= EGIN && i < BME_FLAG_BIT__MAX) { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ft= mp->value =3D BMEFlagMap[i].qapi_value; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } else { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ft= mp->value =3D BITMAP_FLAG_ENUM_UNKNOWN; >=20 > so, there may be several "unknown" entries. It's inconsistent with > "@unknown: This bitmap has unknown or reserved properties.". >=20 Based on your feedback from the previous patch I'll probably just call this @reserved for any unrecognized flag. > Finally, can we export values for unknown flags? It should be more > informative. >=20 I'll see what I can do -- I hate losing this information too.