qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/6] libqblock public type defines


From: Blue Swirl
Subject: Re: [Qemu-devel] [PATCH 2/6] libqblock public type defines
Date: Mon, 3 Sep 2012 19:31:20 +0000

On Mon, Sep 3, 2012 at 9:18 AM, Wenchao Xia <address@hidden> wrote:
>   This patch contains public type and defines used in APIs.
>
> Signed-off-by: Wenchao Xia <address@hidden>
> ---
>  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 <stdio.h>
> +#include <stdint.h>
> +#include <stdlib.h>
> +#include <stdbool.h>
> +
> +/* 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'

> +};
> +
> +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
>
>
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]