Received: from eggs.gnu.org ([2001:4830:134:3::10]:44958) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fJFkj-0000dK-GP for qemu-devel@nongnu.org; Thu, 17 May 2018 06:03:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fJFkd-00008b-Ox for qemu-devel@nongnu.org; Thu, 17 May 2018 06:03:17 -0400 References: <20180512012537.22478-1-jsnow@redhat.com> <20180512012537.22478-8-jsnow@redhat.com> <453c0511-0114-49f9-07e1-3eb63c06cf6c@virtuozzo.com> From: Vladimir Sementsov-Ogievskiy Message-ID: <3545c85c-e4fc-bfce-d732-02ed9359c7d0@virtuozzo.com> Date: Thu, 17 May 2018 13:03:05 +0300 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Content-Language: en-US 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: John Snow , qemu-block@nongnu.org, qemu-devel@nongnu.org Cc: Kevin Wolf , Markus Armbruster , Max Reitz 17.05.2018 00:17, John Snow wrote: > > 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; >> mask is unused in this patch >> >>> +=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_AUTO= ,=C2=A0=C2=A0 BITMAP_FLAG_ENUM_AUTO }, >>> +=C2=A0=C2=A0=C2=A0 [BME_FLAG_BIT_EXTRA]=C2=A0 =3D { BME_FLAG_EXTRA, >>> 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(BitmapFlagE= numList, 1); >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (i >=3D BME_FLAG_BIT__BE= GIN && 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 ftm= p->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 ftm= p->value =3D BITMAP_FLAG_ENUM_UNKNOWN; >> so, there may be several "unknown" entries. It's inconsistent with >> "@unknown: This bitmap has unknown or reserved properties.". >> >> Finally, can we export values for unknown flags? It should be more >> informative. >> > I changed my mind -- qemu-img is not a debugging tool and shouldn't get > lost in the weeds trying to enumerate the different kinds of reserved > values that are set. > > It's an error to have them set, or not -- which ones specifically is not > information that an end-user need know or care about, and I don't want > to create an extra structure to contain the value. > > I'm going to rewrite this loop to just only ever have one unknown value > at a maximum. > > --js > Ok, I agree. --=20 Best regards, Vladimir