[Libguestfs] [PATCH 1/3] New API: mdadm-create for creating MD devices.

Wanlong Gao gaowanlong at cn.fujitsu.com
Mon Nov 14 07:29:45 UTC 2011


On 11/11/2011 08:58 PM, Richard W.M. Jones wrote:

> From: "Richard W.M. Jones" <rjones at redhat.com>


Reviewed-by: Wanlong Gao <gaowanlong at cn.fujitsu.com>

Thanks Richard, a comment below:

> 
> ---
>  daemon/Makefile.am             |    1 +
>  daemon/md.c                    |  170 ++++++++++++++++++++++++++++++++++++++++
>  generator/generator_actions.ml |   58 ++++++++++++++
>  po/POTFILES.in                 |    1 +
>  regressions/Makefile.am        |    1 +
>  regressions/test-mdadm.sh      |   95 ++++++++++++++++++++++
>  src/MAX_PROC_NR                |    2 +-
>  7 files changed, 327 insertions(+), 1 deletions(-)
>  create mode 100644 daemon/md.c
>  create mode 100755 regressions/test-mdadm.sh
> 


..


> +
> +  if (optargs_bitmask & GUESTFS_MDADM_CREATE_LEVEL_BITMASK) {
> +    if (STRNEQ (level, "linear") && STRNEQ (level, "raid0") &&
> +        STRNEQ (level, "0") && STRNEQ (level, "stripe") &&
> +        STRNEQ (level, "raid1") && STRNEQ (level, "1") &&
> +        STRNEQ (level, "mirror") &&
> +        STRNEQ (level, "raid4") && STRNEQ (level, "4") &&
> +        STRNEQ (level, "raid5") && STRNEQ (level, "5") &&
> +        STRNEQ (level, "raid6") && STRNEQ (level, "6") &&
> +        STRNEQ (level, "raid10") && STRNEQ (level, "10")) {
> +      reply_with_error ("unknown level parameter: %s", level);
> +      return -1;
> +    }
> +  }
> +  else
> +    level = "raid1";
> +
> +  if (optargs_bitmask & GUESTFS_MDADM_CREATE_CHUNK_BITMASK) {
> +    /* chunk is bytes in the libguestfs API, but K when we pass it to mdadm */
> +    if ((chunk & 1023) != 0) {
> +      reply_with_error ("chunk size must be a multiple of 1024 bytes");


I'd like to make the 1024 to a macro, what do you thinks so?


> +      return -1;
> +    }
> +  }
> +
> +  /* Check invariant. */

<..>

Thanks
-Wanlong Gao




More information about the Libguestfs mailing list