[Libguestfs] [PATCH] New API: md-stop for stopping MD devices

Wanlong Gao wanlong.gao at gmail.com
Thu Nov 24 12:43:52 UTC 2011


Hi Ric:

Sorry for missing your comments, I'll fix and resend this.

Thanks
-Wanlong Gao

> This API is used to stop a md device.
> When we want to move a device to another md array, we should
> stop the md device which contained this device first.
> 
> Signed-off-by: Wanlong Gao <gaowanlong at cn.fujitsu.com>
> ---
>  daemon/md.c                    |   16 ++++++++++++++++
>  generator/generator_actions.ml |    9 +++++++++
>  regressions/test-mdadm.sh      |   14 ++++++++++++++
>  src/MAX_PROC_NR                |    2 +-
>  4 files changed, 40 insertions(+), 1 deletions(-)
> 
> diff --git a/daemon/md.c b/daemon/md.c
> index 82ddb82..e613db7 100644
> --- a/daemon/md.c
> +++ b/daemon/md.c
> @@ -310,3 +310,19 @@ error:
>  
>    return NULL;
>  }
> +
> +int
> +do_md_stop(const char *md)
> +{
> +  int r;
> +  char *err = NULL;
> +
> +  const char *mdadm[] = { "mdadm", "--stop", md, NULL};
> +  r = commandv(NULL, &err, mdadm);
> +  if (r == -1) {
> +    reply_with_error("%s", err);
> +    free(err);
> +    return -1;
> +  }
> +  return 0;
> +}
> diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml
> index 925640f..76b8d72 100644
> --- a/generator/generator_actions.ml
> +++ b/generator/generator_actions.ml
> @@ -6527,6 +6527,15 @@ The name of the MD device.
>  
>  =back");
>  
> +  ("md_stop", (RErr, [Device "md"], []), 302, [],
> +   [],
> +   "stop a Linux md (RAID) device",
> +   "\
> +This command is a wrap of 'mdadm --stop md'.
> +Use this command to stop a created Linux md (RAID) device.
> +
> +NOTE: This just stop the md device but not remove or zeroed it.");
> +
>  ]
>  
>  let all_functions = non_daemon_functions @ daemon_functions
> diff --git a/regressions/test-mdadm.sh b/regressions/test-mdadm.sh
> index 8119561..66d3a9d 100755
> --- a/regressions/test-mdadm.sh
> +++ b/regressions/test-mdadm.sh
> @@ -150,4 +150,18 @@ done
>  
>  ../fish/guestfish --remote exit
>  
> +eval `../fish/guestfish --listen`
> +../fish/guestfish --remote add-ro md-test1.img
> +../fish/guestfish --remote add-ro md-test2.img
> +../fish/guestfish --remote add-ro md-test3.img
> +../fish/guestfish --remote add-ro md-test4.img
> +../fish/guestfish --remote run
> +
> +for md in `../fish/guestfish --remote list-md-devices`; do
> +  ../fish/guestfish --remote md-stop "${md}"
> +done
> +
> +../fish/guestfish --remote exit
> +
> +
>  rm -f mdadm-detail.out md-test1.img md-test2.img md-test3.img md-test4.img
> diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
> index d8fc48a..274f714 100644
> --- a/src/MAX_PROC_NR
> +++ b/src/MAX_PROC_NR
> @@ -1 +1 @@
> -301
> +302





More information about the Libguestfs mailing list