From: Wanlong Gao Date: Thu, 24 Nov 2011 13:06:07 +0000 (+0800) Subject: New API: md-stop for stopping MD devices X-Git-Tag: 1.15.6~12 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=cbd1c45d95c530c8d94103dcc2c521bf5501ef59;p=libguestfs.git New API: md-stop for stopping MD devices 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 --- diff --git a/daemon/md.c b/daemon/md.c index 8e4ff88..43bb64e 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 c0ef261..361df05 100644 --- a/generator/generator_actions.ml +++ b/generator/generator_actions.ml @@ -6527,6 +6527,23 @@ The name of the MD device. =back"); + ("md_stop", (RErr, [Device "md"], []), 302, [Optional "mdadm"], + [], + "stop a Linux md (RAID) device", + "\ +This command deactivates the MD array named C. The +device is stopped, but it is not destroyed or zeroed. + +The parameter is: + +=over 4 + +=item C + +The md (RAID) device which to be deactivated. + +=back"); + ] let all_functions = non_daemon_functions @ daemon_functions diff --git a/regressions/test-mdadm.sh b/regressions/test-mdadm.sh index e9b0db5..7314ca5 100755 --- a/regressions/test-mdadm.sh +++ b/regressions/test-mdadm.sh @@ -150,4 +150,17 @@ 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 md-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