From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pekka Enberg Subject: Re: [PATCH] kvm tools: Add read-only support for QCOW2 images Date: Wed, 20 Apr 2011 18:57:23 +0300 (EEST) Message-ID: References: <1303247249-11037-1-git-send-email-penberg@kernel.org> Mime-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="8323329-324490087-1303315044=:5088" Cc: kvm@vger.kernel.org, Asias He , Cyrill Gorcunov , Sasha Levin , Ingo Molnar To: Prasad Joshi Return-path: Received: from filtteri6.pp.htv.fi ([213.243.153.189]:55883 "EHLO filtteri6.pp.htv.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750818Ab1DTP50 (ORCPT ); Wed, 20 Apr 2011 11:57:26 -0400 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-324490087-1303315044=:5088 Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8BIT On Tue, 19 Apr 2011, Prasad Joshi wrote: > On Tue, Apr 19, 2011 at 10:07 PM, Pekka Enberg wrote: > This patch extends the QCOW1 format to also support QCOW2 images as specified > by the following document: > >  http://people.gnome.org/~markmc/qcow-image-format.html > > Cc: Asias He > Cc: Cyrill Gorcunov > Cc: Prasad Joshi > Cc: Sasha Levin > Cc: Ingo Molnar > Signed-off-by: Pekka Enberg > --- >  tools/kvm/include/kvm/qcow.h |   42 ++++++++++- >  tools/kvm/qcow.c             |  177 +++++++++++++++++++++++++++++++++--------- >  2 files changed, 181 insertions(+), 38 deletions(-) > > diff --git a/tools/kvm/include/kvm/qcow.h b/tools/kvm/include/kvm/qcow.h > index 4be2597..afd776d 100644 > --- a/tools/kvm/include/kvm/qcow.h > +++ b/tools/kvm/include/kvm/qcow.h > @@ -4,9 +4,17 @@ >  #include > >  #define QCOW_MAGIC             (('Q' << 24) | ('F' << 16) | ('I' << 8) | 0xfb) > + >  #define QCOW1_VERSION          1 > +#define QCOW2_VERSION          2 > + > +#define QCOW1_OFLAG_COMPRESSED (1LL << 63) > + > +#define QCOW1_OFLAG_MASK       QCOW1_OFLAG_COMPRESSED > > -#define QCOW_OFLAG_COMPRESSED  (1LL << 63) > +#define QCOW2_OFLAG_COPIED     (1LL << 63) > +#define QCOW2_OFLAG_COMPRESSED (1LL << 62) > +#define QCOW2_OFLAG_MASK       (QCOW2_OFLAG_COPIED|QCOW2_OFLAG_COMPRESSED) > >  struct qcow_table { >        u32                     table_size; > @@ -19,7 +27,16 @@ struct qcow { >        int                     fd; >  }; > > -struct qcow1_header { > +struct qcow_header { > +       u64                     size; /* in bytes */ > +       u64                     l1_table_offset; > +       u32                     l1_size; > +       u8                      cluster_bits; > +       u8                      l2_bits; > +       uint64_t                oflag_mask; > +}; > + > +struct qcow1_header_disk { >        u32                     magic; >        u32                     version; > > @@ -36,6 +53,27 @@ struct qcow1_header { >        u64                     l1_table_offset; >  }; > > +struct qcow2_header_disk { > +       u32                     magic; > +       u32                     version; > + > +       u64                     backing_file_offset; > +       u32                     backing_file_size; > + > +       u32                     cluster_bits; > +       u64                     size; /* in bytes */ > +       u32                     crypt_method; > + > +       u32                     l1_size; > +       u64                     l1_table_offset; > + > +       u64                     refcount_table_offset; > +       u32                     refcount_table_clusters; > + > +       u32                     nb_snapshots; > +       u64                     snapshots_offset; > +}; > > IMHO, as we start adding other features of QCOW, the two structures qcow2_header_disk and qcow_header might eventually become the same.  No, the point of 'struct qcow2_header_disk' is to map to the on-disk representation. 'struct qcow_header' is the in-memory version of the data. > +       disk_image = disk_image__new(fd, h->size, &qcow1_disk_ops); > > > qcow1_disk_ops can be changed to qcow_disk_ops. Sure, there's more qcow1 prefixes that need fixing now as well. --8323329-324490087-1303315044=:5088--