[PATCH] New API: mdadm-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 <gaowanlong@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..9004a6f 100644 --- a/daemon/md.c +++ b/daemon/md.c @@ -310,3 +310,19 @@ error: return NULL; } + +int +do_mdadm_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..938a543 100644 --- a/generator/generator_actions.ml +++ b/generator/generator_actions.ml @@ -6527,6 +6527,15 @@ The name of the MD device. =back"); + ("mdadm_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..017341a 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 mdadm-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 -- 1.7.8.rc3
On 23/11/11 14:43, Wanlong Gao wrote:
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.
I'm not convinced we should extend the md api in libguestfs to active manipulation. I wasn't convinced that mdadm-create was worthwhile either, but it made a test case ever so slightly tidier. To me, MD devices are the domain of physical machines. We need to be able to *read* them (for P2V apart from anything else), but I think manipulation is opening an unnecessary can of worms. Matt -- Matthew Booth, RHCA, RHCSS Red Hat Engineering, Virtualisation Team GPG ID: D33C3490 GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
Hi Matt:
On 23/11/11 14:43, Wanlong Gao wrote:
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.
I'm not convinced we should extend the md api in libguestfs to active manipulation. I wasn't convinced that mdadm-create was worthwhile either, but it made a test case ever so slightly tidier. To me, MD devices are the domain of physical machines. We need to be able to *read* them (for P2V apart from anything else), but I think manipulation is opening an unnecessary can of worms.
Matt
Yeah, you are right. But soft raid is also manipulated by real machine, so this need discussing furthermore. Thanks a lot -Wanlong Gao
On Wed, Nov 23, 2011 at 03:02:19PM +0000, Matthew Booth wrote:
On 23/11/11 14:43, Wanlong Gao wrote:
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.
I'm not convinced we should extend the md api in libguestfs to active manipulation. I wasn't convinced that mdadm-create was worthwhile either, but it made a test case ever so slightly tidier. To me, MD devices are the domain of physical machines. We need to be able to *read* them (for P2V apart from anything else), but I think manipulation is opening an unnecessary can of worms.
But is there any penalty to carrying this? I was inclined to accept this patch, although I will tidy up the documentation. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
On 23/11/11 16:22, Richard W.M. Jones wrote:
On Wed, Nov 23, 2011 at 03:02:19PM +0000, Matthew Booth wrote:
On 23/11/11 14:43, Wanlong Gao wrote:
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.
I'm not convinced we should extend the md api in libguestfs to active manipulation. I wasn't convinced that mdadm-create was worthwhile either, but it made a test case ever so slightly tidier. To me, MD devices are the domain of physical machines. We need to be able to *read* them (for P2V apart from anything else), but I think manipulation is opening an unnecessary can of worms.
But is there any penalty to carrying this?
I can think of 2: 1. Maintenance: I know you think this is free, but some day mdadm --stop might change behaviour, and then the api will break. 2. A false sense of expectation: Having an incomplete md api can only lead to frustration. Implementing a complete md api would require a large amount of effort for something which we don't have a convincing use case for (i.e. nobody's ever going to use it anyway). Matt -- Matthew Booth, RHCA, RHCSS Red Hat Engineering, Virtualisation Team GPG ID: D33C3490 GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
On 23/11/11 17:11, Matthew Booth wrote:
On 23/11/11 16:22, Richard W.M. Jones wrote:
On Wed, Nov 23, 2011 at 03:02:19PM +0000, Matthew Booth wrote:
On 23/11/11 14:43, Wanlong Gao wrote:
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.
I'm not convinced we should extend the md api in libguestfs to active manipulation. I wasn't convinced that mdadm-create was worthwhile either, but it made a test case ever so slightly tidier. To me, MD devices are the domain of physical machines. We need to be able to *read* them (for P2V apart from anything else), but I think manipulation is opening an unnecessary can of worms.
But is there any penalty to carrying this?
I can think of 2:
1. Maintenance: I know you think this is free, but some day mdadm --stop might change behaviour, and then the api will break.
2. A false sense of expectation: Having an incomplete md api can only lead to frustration. Implementing a complete md api would require a large amount of effort for something which we don't have a convincing use case for (i.e. nobody's ever going to use it anyway).
There's another good one, actually: Testing. mdadm-create has already created a testing problem, because test-mdadm.sh fails mysteriously on my machine, but didn't before and doesn't for you or Wanlong. Especially for something like MD, which has a complex subsystem underlying it which we don't fully understand in our team, adding and adequately testing a new API is an expensive operation. Matt -- Matthew Booth, RHCA, RHCSS Red Hat Engineering, Virtualisation Team GPG ID: D33C3490 GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
On 11/24/2011 01:17 AM, Matthew Booth wrote:
On 23/11/11 17:11, Matthew Booth wrote:
On 23/11/11 16:22, Richard W.M. Jones wrote:
On Wed, Nov 23, 2011 at 03:02:19PM +0000, Matthew Booth wrote:
On 23/11/11 14:43, Wanlong Gao wrote:
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.
I'm not convinced we should extend the md api in libguestfs to active manipulation. I wasn't convinced that mdadm-create was worthwhile either, but it made a test case ever so slightly tidier. To me, MD devices are the domain of physical machines. We need to be able to *read* them (for P2V apart from anything else), but I think manipulation is opening an unnecessary can of worms.
But is there any penalty to carrying this?
I can think of 2:
1. Maintenance: I know you think this is free, but some day mdadm --stop might change behaviour, and then the api will break.
2. A false sense of expectation: Having an incomplete md api can only lead to frustration. Implementing a complete md api would require a large amount of effort for something which we don't have a convincing use case for (i.e. nobody's ever going to use it anyway).
There's another good one, actually: Testing. mdadm-create has already created a testing problem, because test-mdadm.sh fails mysteriously on my machine, but didn't before and doesn't for you or Wanlong. Especially
Yeah, we need more test and fix before this go to stable.
for something like MD, which has a complex subsystem underlying it which we don't fully understand in our team, adding and adequately testing a new API is an expensive operation.
It's not a thing, we can support the simple ones which allow users at least creating and stopping the md. IMO, the basic function is needed. Thanks -Wanlong Gao
Matt
On 11/24/2011 01:11 AM, Matthew Booth wrote:
On 23/11/11 16:22, Richard W.M. Jones wrote:
On Wed, Nov 23, 2011 at 03:02:19PM +0000, Matthew Booth wrote:
On 23/11/11 14:43, Wanlong Gao wrote:
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.
I'm not convinced we should extend the md api in libguestfs to active manipulation. I wasn't convinced that mdadm-create was worthwhile either, but it made a test case ever so slightly tidier. To me, MD devices are the domain of physical machines. We need to be able to *read* them (for P2V apart from anything else), but I think manipulation is opening an unnecessary can of worms.
But is there any penalty to carrying this?
I can think of 2:
1. Maintenance: I know you think this is free, but some day mdadm --stop might change behaviour, and then the api will break.
I think it'll not, but if it does, we can change the internal to fix the behavior.
2. A false sense of expectation: Having an incomplete md api can only lead to frustration. Implementing a complete md api would require a large amount of effort for something which we don't have a convincing use case for (i.e. nobody's ever going to use it anyway).
But IMO, we at least support the create and stop API, along with reading the MD together?
Matt
participants (4)
-
Matthew Booth -
Richard W.M. Jones -
Wanlong Gao -
Wanlong Gao