qemu-block
[Top][All Lists]
Advanced

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

Re: [PATCH for-5.0 02/31] block: Add BdrvChildRole


From: Kevin Wolf
Subject: Re: [PATCH for-5.0 02/31] block: Add BdrvChildRole
Date: Thu, 28 Nov 2019 15:12:18 +0100
User-agent: Mutt/1.12.1 (2019-06-15)

Am 27.11.2019 um 14:15 hat Max Reitz geschrieben:
> This enum will supplement BdrvChildClass when it comes to what role (or
> combination of roles) a child takes for its parent.
> 
> Because empty enums are not allowed, let us just start with it filled.
> 
> Signed-off-by: Max Reitz <address@hidden>
> ---
>  include/block/block.h | 38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
> 
> diff --git a/include/block/block.h b/include/block/block.h
> index 38963ef203..36817d5689 100644
> --- a/include/block/block.h
> +++ b/include/block/block.h
> @@ -279,6 +279,44 @@ enum {
>      DEFAULT_PERM_UNCHANGED      = BLK_PERM_ALL & ~DEFAULT_PERM_PASSTHROUGH,
>  };
>  
> +typedef enum BdrvChildRole {
> +    /*
> +     * If present, bdrv_replace_node() will not change the node this
> +     * BdrvChild points to.
> +     */
> +    BDRV_CHILD_STAY_AT_NODE = (1 << 0),
> +
> +    /* Child stores data */
> +    BDRV_CHILD_DATA         = (1 << 1),
> +
> +    /* Child stores metadata */
> +    BDRV_CHILD_METADATA     = (1 << 2),
> +
> +    /* Filtered child */
> +    BDRV_CHILD_FILTERED     = (1 << 3),
> +
> +    /* Child to COW from (backing child) */
> +    BDRV_CHILD_COW          = (1 << 4),
> +
> +    /* Child is expected to be a protocol node */
> +    BDRV_CHILD_PROTOCOL     = (1 << 5),
> +
> +    /* Child is expected to be a format node */
> +    BDRV_CHILD_FORMAT       = (1 << 6),

In theory, a node shouldn't care what other nodes it has as its
children. For a parent, protocols and formats look exactly the same.

Of course, we do have BDRV_O_PROTOCOL, but if I'm not mistaken this is
basically only about probing or not probing an image format when a
legacy filename is given rather than BlockdevOptions.

Therefore, unless you have a real reason for this to be here, I'd prefer
if we could keep such legacy flags outside of the core infrastructure if
at all possible.

> +    /*
> +     * The primary child.  For most drivers, this is the child whose
> +     * filename applies best to the parent node.
> +     */
> +    BDRV_CHILD_PRIMARY      = (1 << 7),

If primary is a flag of each BdrvChild, then you could end up having
multiple children that claim that they're the primary child. On the
other hand, if we have a bs->primary_child instead to make sure that we
only have one primary child, we'd have to keep this consistent when
children change.

So maybe just document that this flag must be given to only one
BdrvChild link for each parent.

> +    /* Useful combination of flags */
> +    BDRV_CHILD_IMAGE        = BDRV_CHILD_DATA
> +                              | BDRV_CHILD_METADATA
> +                              | BDRV_CHILD_PROTOCOL
> +                              | BDRV_CHILD_PRIMARY,
> +} BdrvChildRole;
> +
>  char *bdrv_perm_names(uint64_t perm);
>  uint64_t bdrv_qapi_perm_to_blk_perm(BlockPermission qapi_perm);

Kevin




reply via email to

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