On Wed, 01/20 17:38, Daniel P. Berrange wrote:
> +    /* XXX Should we treat size as being total physical size
> +     * of the image (ie payload + encryption header), or just
> +     * the logical size of the image (ie payload). If the latter
> +     * then we need to extend 'size' to include the header
> +     * size */

The latter. :)

> +    qemu_opt_set_number(opts, BLOCK_OPT_SIZE, size, &error_abort);
> +#define BLOCK_CRYPTO_DRIVER(name, format)                               \
> +    static int block_crypto_probe_ ## name(const uint8_t *buf,          \
> +                                           int buf_size,                \
> +                                           const char *filename) {      \
> +        return block_crypto_probe_generic(format,                       \
> +                                          buf, buf_size, filename);     \
> +    }                                                                   \
> +                                                                        \
> +    static int block_crypto_open_ ## name(BlockDriverState *bs,         \
> +                                          QDict *options,               \
> +                                          int flags,                    \
> +                                          Error **errp)                 \
> +    {                                                                   \
> +        return block_crypto_open_generic(format,                        \
> +                                         &block_crypto_runtime_opts_ ## 
> name, \
> +                                         bs, options, flags, errp);     \
> +    }                                                                   \
> +                                                                        \
> +    static int block_crypto_create_ ## name(const char *filename,       \
> +                                            QemuOpts *opts,             \
> +                                            Error **errp)               \
> +    {                                                                   \
> +        return block_crypto_create_generic(format,                      \
> +                                           filename, opts, errp);       \
> +    }                                                                   \
> +                                                                        \
> +    BlockDriver bdrv_crypto_ ## name = {                                \
> +        .format_name        = #name,                                    \
> +        .instance_size      = sizeof(BlockCrypto),                      \
> +        .bdrv_probe         = block_crypto_probe_ ## name,              \
> +        .bdrv_open          = block_crypto_open_ ## name,               \
> +        .bdrv_close         = block_crypto_close,                       \
> +        .bdrv_create        = block_crypto_create_ ## name,             \
> +        .create_opts        = &block_crypto_create_opts_ ## name,       \
> +                                                                        \
> +        .bdrv_co_readv      = block_crypto_co_readv,                    \
> +        .bdrv_co_writev     = block_crypto_co_writev,                   \
> +        .bdrv_getlength     = block_crypto_getlength,                   \
> +    }
> +
> +BLOCK_CRYPTO_DRIVER(luks, Q_CRYPTO_BLOCK_FORMAT_LUKS);

Personally I really prefer a preprocessed version, for the ease of grep.

Fam

Reply via email to