Received: from eggs.gnu.org ([2001:4830:134:3::10]:38142) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2Yfl-00005L-Fw for qemu-devel@nongnu.org; Thu, 03 Jul 2014 00:31:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X2Yfh-0006TH-1z for qemu-devel@nongnu.org; Thu, 03 Jul 2014 00:31:01 -0400 Received: from soto.provo.novell.com ([137.65.250.214]:55365) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2Yfg-0006T6-RR for qemu-devel@nongnu.org; Thu, 03 Jul 2014 00:30:56 -0400 Message-Id: <53B54CF602000066000434BA@soto.provo.novell.com> Date: Wed, 02 Jul 2014 22:30:46 -0600 From: "Chun Yan Liu" References: <1404294640-16360-1-git-send-email-cyliu@suse.com> <53B4031E.3030400@redhat.com> In-Reply-To: <53B4031E.3030400@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Subject: Re: [Qemu-devel] [PATCH] qemu-img info: show nocow info List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Eric Blake , stefanha@redhat.com >>> On 7/2/2014 at 09:03 PM, in message <53B4031E.3030400@redhat.com>, = Eric Blake wrote:=20 > On 07/02/2014 03:50 AM, Chunyan Liu wrote:=20 > > Add nocow info in 'qemu-img info' output to show whether the file=20 > > currently has NOCOW flag set or not.=20 > > =20 > > Signed-off-by: Chunyan Liu =20 > > ---=20 > > block/qapi.c | 25 +++++++++++++++++++++++++=20 > > qapi/block-core.json | 3 ++-=20 > > 2 files changed, 27 insertions(+), 1 deletion(-)=20 > > =20 > =20 > > +=20 > > + /* get NOCOW info */=20 > > + fd =3D qemu_open(bs->filename, O_RDONLY | O_NONBLOCK);=20 > > + if (fd >=3D 0) {=20 > > + if (ioctl(fd, FS_IOC_GETFLAGS, &attr) =3D=3D 0 && (attr & = FS_NOCOW_FL)) {=20 > > + info->has_nocow =3D true;=20 > > + info->nocow =3D true;=20 > =20 > Better is:=20 > =20 > if (ioctl... =3D=3D 0) {=20 > info->has_nocow =3D true;=20 > info->nocow =3D !!(attr & FS_NOCOW_FL)=20 > }=20 > =20 It won't work. FS_IOC_GETFLAGS is a common ioctl to all file systems, it = only gets flags info that the file is currently set. Output 'attr' contains the = flags info. Even the filesystem doesn't support NOCOW, that ioctl could return 0. > to explicitly document the cases where we know nocow works but is not=20 > set (and omitting it in cases where nocow doesn't exist because of the = fs)=20 > =20 > =20 > > +++ b/qapi/block-core.json=20 > > @@ -126,7 +126,8 @@=20 > > '*backing-filename': 'str', '*full-backing-filename': = 'str',=20 > > '*backing-filename-format': 'str', '*snapshots': =20 > ['SnapshotInfo'],=20 > > '*backing-image': 'ImageInfo',=20 > > - '*format-specific': 'ImageInfoSpecific' } }=20 > > + '*format-specific': 'ImageInfoSpecific',=20 > > + '*nocow': 'bool' } }=20 > =20 > Missing documentation. When adding that, remember to add '(since = 2.2)'=20 > (or even since 2.1 if you think this is a bug fix that should go in=20 > during hard freeze)=20 OK. Thanks. -Chunyan > =20 > -- =20 > Eric Blake eblake redhat com +1-919-301-3266=20 > Libvirt virtualization library http://libvirt.org=20 > =20 > =20