From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8nQQ-00010d-R5 for qemu-devel@nongnu.org; Tue, 04 Sep 2012 03:20:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T8nQM-0007By-4y for qemu-devel@nongnu.org; Tue, 04 Sep 2012 03:19:54 -0400 Received: from e28smtp01.in.ibm.com ([122.248.162.1]:58074) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8nQL-0007BQ-7Z for qemu-devel@nongnu.org; Tue, 04 Sep 2012 03:19:50 -0400 Received: from /spool/local by e28smtp01.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 4 Sep 2012 12:49:45 +0530 Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay04.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q847JRL17405894 for ; Tue, 4 Sep 2012 12:49:28 +0530 Received: from d28av03.in.ibm.com (loopback [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q847JPXB004189 for ; Tue, 4 Sep 2012 17:19:26 +1000 Message-ID: <5045AB77.1010602@linux.vnet.ibm.com> Date: Tue, 04 Sep 2012 15:19:19 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1346663926-20188-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1346663926-20188-3-git-send-email-xiawenc@linux.vnet.ibm.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/6] libqblock public type defines List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: kwolf@redhat.com, aliguori@us.ibm.com, stefanha@gmail.com, qemu-devel@nongnu.org, pbonzini@redhat.com, eblake@redhat.com > On Mon, Sep 3, 2012 at 9:18 AM, Wenchao Xia wrote: >> This patch contains public type and defines used in APIs. >> >> Signed-off-by: Wenchao Xia >> --- >> libqblock/libqblock-types.h | 228 +++++++++++++++++++++++++++++++++++++++++++ >> 1 files changed, 228 insertions(+), 0 deletions(-) >> create mode 100644 libqblock/libqblock-types.h >> >> diff --git a/libqblock/libqblock-types.h b/libqblock/libqblock-types.h >> new file mode 100644 >> index 0000000..3389bda >> --- /dev/null >> +++ b/libqblock/libqblock-types.h >> @@ -0,0 +1,228 @@ >> +#ifndef LIBQBLOCK_TYPES_H >> +#define LIBQBLOCK_TYPES_H >> + >> +#include >> +#include >> +#include >> +#include >> + >> +/* this library is designed around this core struct. */ >> +struct QBlockState; >> + >> +/* every thread would have a broker. */ >> +struct QBroker; >> + >> +/* flag used in open and create */ >> +#define LIBQBLOCK_O_RDWR 0x0002 >> +/* do not use the host page cache */ >> +#define LIBQBLOCK_O_NOCACHE 0x0020 >> +/* use write-back caching */ >> +#define LIBQBLOCK_O_CACHE_WB 0x0040 >> +/* don't open the backing file */ >> +#define LIBQBLOCK_O_NO_BACKING 0x0100 >> +/* disable flushing on this disk */ >> +#define LIBQBLOCK_O_NO_FLUSH 0x0200 >> + >> +#define LIBQBLOCK_O_CACHE_MASK \ >> + (LIBQBLOCK_O_NOCACHE | LIBQBLOCK_O_CACHE_WB | LIBQBLOCK_O_NO_FLUSH) >> + >> +#define LIBQBLOCK_O_VALID_MASK \ >> + (LIBQBLOCK_O_RDWR | LIBQBLOCK_O_NOCACHE | LIBQBLOCK_O_CACHE_WB | \ >> + LIBQBLOCK_O_NO_BACKING | LIBQBLOCK_O_NO_FLUSH) >> + >> +enum QBlockProtocol { >> + QB_PROTO_NONE = 0, >> + QB_PROTO_FILE, >> + QB_PROTO_MAX >> +}; >> + >> +enum QBlockFormat { >> + QB_FMT_NONE = 0, >> + QB_FMT_COW, >> + QB_FMT_QED, >> + QB_FMT_QCOW, >> + QB_FMT_QCOW2, >> + QB_FMT_RAW, >> + QB_FMT_RBD, >> + QB_FMT_SHEEPDOG, >> + QB_FMT_VDI, >> + QB_FMT_VMDK, >> + QB_FMT_VPC, >> + QB_FMT_MAX >> +}; >> + >> +struct QBlockOption_prot_file { > > QBlockOptionProtFile > >> + char *filename; > > 'const' > There is a problem, this member would be used in information retrieving, so it will be set to a pointer to a string allocated at runtime, and later be freed. I am not sure if const fits for this situation, let me check. >> +}; >> + >> +union QBlockOption_prot { > > QBlockOptionProt > >> + struct QBlockOption_prot_file o_file; >> +}; >> + >> +/** >> + * struct QBlockOptionLoc: contains information about how to find the image >> + * >> + * @prot_type: protocol type, now only support FILE. >> + * @prot_op: protocol related options. >> + */ >> +struct QBlockOptionLoc { >> + enum QBlockProtocol prot_type; >> + union QBlockOption_prot prot_op; >> + uint8_t reserved[512]; >> +}; >> + >> +/* format related options */ >> +struct QBlockOption_fmt_cow { > > QBlockOptionFmtCOW > >> + size_t virt_size; >> + struct QBlockOptionLoc backing_loc; >> +}; >> + >> +struct QBlockOption_fmt_qed { > > QBlockOptionFmtQED > > etc. for the rest. Don't mix CamelCase with underscore style, struct > names must use CamelCase. > >> + size_t virt_size; >> + struct QBlockOptionLoc backing_loc; >> + enum QBlockFormat backing_fmt; >> + size_t cluster_size; /* unit is bytes */ >> + size_t table_size; /* unit is clusters */ >> +}; >> + >> +struct QBlockOption_fmt_qcow { >> + size_t virt_size; >> + struct QBlockOptionLoc backing_loc; >> + bool encrypt; >> +}; >> + >> +/* "Compatibility level (0.10 or 1.1)" */ >> +enum QBlockOption_fmt_qcow2_cpt { >> + QBO_FMT_QCOW2_CPT_NONE = 0, >> + QBO_FMT_QCOW2_CPT_V010, >> + QBO_FMT_QCOW2_CPT_V110, >> +}; >> + >> +/* off or metadata */ >> +enum QBlockOption_fmt_qcow2_prealloc { >> + QBO_FMT_QCOW2_PREALLOC_NONE = 0, >> + QBO_FMT_QCOW2_PREALLOC_OFF, >> + QBO_FMT_QCOW2_PREALLOC_METADATA, >> +}; >> + >> +struct QBlockOption_fmt_qcow2 { >> + size_t virt_size; >> + struct QBlockOptionLoc backing_loc; >> + enum QBlockFormat backing_fmt; >> + bool encrypt; >> + size_t cluster_size; /* unit is bytes */ >> + enum QBlockOption_fmt_qcow2_cpt cpt_lv; >> + enum QBlockOption_fmt_qcow2_prealloc pre_mode; >> +}; >> + >> +struct QBlockOption_fmt_raw { >> + size_t virt_size; >> +}; >> + >> +struct QBlockOption_fmt_rbd { >> + size_t virt_size; >> + size_t cluster_size; >> +}; >> + >> +/* off or full */ >> +enum QBlockOption_fmt_sheepdog_prealloc { >> + QBO_FMT_SD_PREALLOC_NONE = 0, >> + QBO_FMT_SD_PREALLOC_OFF, >> + QBO_FMT_SD_PREALLOC_FULL, >> +}; >> + >> +struct QBlockOption_fmt_sheepdog { >> + size_t virt_size; >> + struct QBlockOptionLoc backing_loc; >> + enum QBlockOption_fmt_sheepdog_prealloc pre_mode; >> +}; >> + >> +enum QBlockOption_fmt_vdi_prealloc { >> + QBO_FMT_VDI_PREALLOC_NONE = 0, >> + QBO_FMT_VDI_PREALLOC_FALSE, >> + QBO_FMT_VDI_PREALLOC_TRUE, >> +}; >> + >> +struct QBlockOption_fmt_vdi { >> + size_t virt_size; >> + size_t cluster_size; >> + enum QBlockOption_fmt_vdi_prealloc pre_mode; >> +}; >> + >> +/* whether compact to vmdk verion 6 */ >> +enum QBlockOption_fmt_vmdk_cpt { >> + QBO_FMT_VMDK_CPT_NONE = 0, >> + QBO_FMT_VMDK_CPT_VMDKV6_FALSE, >> + QBO_FMT_VMDK_CPT_VMDKV6_TRUE, >> +}; >> + >> +/* vmdk flat extent format, values: >> +"{monolithicSparse (default) | monolithicFlat | twoGbMaxExtentSparse | >> +twoGbMaxExtentFlat | streamOptimized} */ >> +enum QBlockOption_fmt_vmdk_subfmt { >> + QBO_FMT_VMDK_SUBFMT_MONOLITHIC_NONE = 0, >> + QBO_FMT_VMDK_SUBFMT_MONOLITHIC_SPARSE, >> + QBO_FMT_VMDK_SUBFMT_MONOLITHIC_FLAT, >> + QBO_FMT_VMDK_SUBFMT_TWOGBMAX_EXTENT_SPARSE, >> + QBO_FMT_VMDK_SUBFMT_TWOGBMAX_EXTENT_FLAT, >> + QBO_FMT_VMDK_SUBFMT_STREAM_OPTIMIZED, >> +}; >> + >> +struct QBlockOption_fmt_vmdk { >> + size_t virt_size; >> + struct QBlockOptionLoc backing_loc; >> + enum QBlockOption_fmt_vmdk_cpt cpt_lv; >> + enum QBlockOption_fmt_vmdk_subfmt subfmt; >> +}; >> + >> +/* "{dynamic (default) | fixed} " */ >> +enum QBlockOption_fmt_vpc_subfmt { >> + QBO_FMT_VPC_SUBFMT_NONE = 0, >> + QBO_FMT_VPC_SUBFMT_DYNAMIC, >> + QBO_FMT_VPC_SUBFMT_FIXED, >> +}; >> + >> +struct QBlockOption_fmt_vpc { >> + size_t virt_size; >> + enum QBlockOption_fmt_vpc_subfmt subfmt; >> +}; >> + >> +union QBlockOption_fmt { >> + struct QBlockOption_fmt_cow o_cow; >> + struct QBlockOption_fmt_qed o_qed; >> + struct QBlockOption_fmt_qcow o_qcow; >> + struct QBlockOption_fmt_qcow2 o_qcow2; >> + struct QBlockOption_fmt_raw o_raw; >> + struct QBlockOption_fmt_rbd o_rbd; >> + struct QBlockOption_fmt_sheepdog o_sheepdog; >> + struct QBlockOption_fmt_vdi o_vdi; >> + struct QBlockOption_fmt_vmdk o_vmdk; >> + struct QBlockOption_fmt_vpc o_vpc; >> +}; >> + >> +struct QBlockOptionFormat { >> + enum QBlockFormat fmt_type; >> + union QBlockOption_fmt fmt_op; >> + uint8_t reserved[512]; >> +}; >> + >> +/** >> + * QBlockInfoImageStatic: information about the block image. >> + * >> + * @loc: location info. >> + * @fmt_type: format type. >> + * @virt_size: virtual size in bytes. >> + * @backing_loc: backing file location, its type is QB_PROT_NONE if not exist. >> + * @allocated_size: allocated size in bytes, negative if not available. >> + * @encrypt: encrypt flag. >> + */ >> +struct QBlockInfoImageStatic { >> + struct QBlockOptionLoc loc; >> + enum QBlockFormat fmt_type; >> + size_t virt_size; >> + /* advance info */ >> + struct QBlockOptionLoc backing_loc; >> + size_t allocated_size; >> + bool encrypt; >> +}; >> +#endif >> -- >> 1.7.1 >> >> >> > -- Best Regards Wenchao Xia