[PATCH 0/8] Add MD inspection support to libguestfs
by Matthew Booth
This series fixes inspection in the case that fstab contains references to md
devices. I've made a few changes since the previous posting, which I've
summarised below.
[PATCH 1/8] build: Create an MD variant of the dummy Fedora image
I've double checked that no timestamp is required in the Makefile. The script
will not run a second time to build fedora-md2.img.
[PATCH 2/8] build: Nothing under images/ should be translated
[PATCH 3/8] NFC: Declare and use variables on the same line in
[PATCH 4/8] md: Inspect MD devices
I separated this, as it's potentially independently useful. I've also split out
the NFs as requested.
[PATCH 5/8] NFC: Consolidate the error path in check_fstab in
[PATCH 6/8] NFC: Allow multiple config files in inspect_with_augeas
[PATCH 7/8] inspection: Handle MD devices in fstab
* Split out the NFCs
* Changed warning() to debug() in all cases
* Following the pattern of other code, I have:
* Not called error() when failure is due to the error return of a guestfs api
* Explicitly called g->abort_cb() for malloc failures, consistent with the safe_ functions
There are no other failure paths in the code.
[PATCH 8/8] inspection: Add a test for MD device mapping in fstab
13 years
[PATCH] NFC: Cleanup iteration over fstab entries in inspect_fs_unix.c
by Matthew Booth
Select non-comment labels using an augeas path to return the correct nodes in
the first instance, rather than applying a regular expression to all results.
Iterate over returned matches using a char** iterator.
Use asprintf() to ensure the path string buffer is the correct size.
---
src/inspect_fs_unix.c | 50 +++++++++++++++++++++---------------------------
1 files changed, 22 insertions(+), 28 deletions(-)
diff --git a/src/inspect_fs_unix.c b/src/inspect_fs_unix.c
index 0fa3e83..34d218f 100644
--- a/src/inspect_fs_unix.c
+++ b/src/inspect_fs_unix.c
@@ -110,7 +110,6 @@ compile_regexps (void)
COMPILE (re_scientific_linux_no_minor,
"Scientific Linux.*release (\\d+)", 0);
COMPILE (re_major_minor, "(\\d+)\\.(\\d+)", 0);
- COMPILE (re_aug_seq, "/\\d+$", 0);
COMPILE (re_xdev, "^/dev/(h|s|v|xv)d([a-z]+)(\\d*)$", 0);
COMPILE (re_cciss, "^/dev/(cciss/c\\d+d\\d+)(?:p(\\d+))?$", 0);
COMPILE (re_mdN, "^(/dev/md\\d+)$", 0);
@@ -132,7 +131,6 @@ free_regexps (void)
pcre_free (re_scientific_linux);
pcre_free (re_scientific_linux_no_minor);
pcre_free (re_major_minor);
- pcre_free (re_aug_seq);
pcre_free (re_xdev);
pcre_free (re_cciss);
pcre_free (re_mdN);
@@ -725,47 +723,43 @@ check_fstab (guestfs_h *g, struct inspect_fs *fs)
Hash_table *md_map;
if (!map_md_devices (g, &md_map)) return -1;
- char **lines = guestfs_aug_ls (g, "/files/etc/fstab");
- if (lines == NULL) goto error;
+ char *augpath = NULL;
+ char **entries = guestfs_aug_match (g, "/files/etc/fstab/*"
+ "[label() != '#comment']");
+ if (entries == NULL) goto error;
- if (lines[0] == NULL) {
+ if (entries[0] == NULL) {
error (g, _("could not parse /etc/fstab or empty file"));
goto error;
}
- size_t i;
- char augpath[256];
- for (i = 0; lines[i] != NULL; ++i) {
- /* Ignore comments. Only care about sequence lines which
- * match m{/\d+$}.
- */
- if (match (g, lines[i], re_aug_seq)) {
- snprintf (augpath, sizeof augpath, "%s/spec", lines[i]);
- char *spec = guestfs_aug_get (g, augpath);
- if (spec == NULL) goto error;
-
- snprintf (augpath, sizeof augpath, "%s/file", lines[i]);
- char *mp = guestfs_aug_get (g, augpath);
- if (mp == NULL) {
- free (spec);
- goto error;
- }
+ for (char **entry = entries; *entry != NULL; entry++) {
+ if (asprintf (&augpath, "%s/spec", *entry) == -1) g->abort_cb();
+ char *spec = guestfs_aug_get (g, augpath);
+ if (spec == NULL) goto error;
- int r = add_fstab_entry (g, fs, spec, mp, md_map);
+ if (asprintf (&augpath, "%s/file", *entry) == -1) g->abort_cb();
+ char *mp = guestfs_aug_get (g, augpath);
+ if (mp == NULL) {
free (spec);
- free (mp);
-
- if (r == -1) goto error;
+ goto error;
}
+
+ int r = add_fstab_entry (g, fs, spec, mp, md_map);
+ free (spec);
+ free (mp);
+
+ if (r == -1) goto error;
}
hash_free (md_map);
- guestfs___free_string_list (lines);
+ guestfs___free_string_list (entries);
return 0;
error:
hash_free (md_map);
- if (lines) guestfs___free_string_list (lines);
+ if (entries) guestfs___free_string_list (entries);
+ free(augpath);
return -1;
}
--
1.7.7.3
13 years
mdadm / Ubuntu 10.04 error
by Richard W.M. Jones
md_create: mdadm: boot: mdadm: boot is not a block device. at /home/rjones/d/libguestfs/images/guest-aux/make-fedora-img.pl line 95.
Looking into this, it appears the old version of mdadm shipped in
Ubuntu (mdadm 2.6.7) doesn't support the notion of giving arbitrary
names to devices. Thus you have to do:
mdadm --create /dev/md0 [devices]
We do:
mdadm --create boot [devices]
which it doesn't know how to handle.
I wonder if we are assuming so many features of mdadm >= 3 that we
should simply test for this in the optional group "mdadm" test, and
disable if mdadm < 3. (We would also have to change the test so it is
skipped if mdadm is not present, but that's a real bug in the test
suite anyway). Alternately we could look into this more deeply for
RHEL 5 / Ubuntu 10.04.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top
13 years
[PATCH] Rename mdadm_ apis to md_
by Matthew Booth
This change renames the following 2 apis:
* mdadm_create -> md_create
* mdadm_detail -> md_detail
This is more consistent with list_md_devices, and removes a reference to an
implementation detail from the api.
---
daemon/md.c | 24 ++++++++++++------------
generator/generator_actions.ml | 4 ++--
regressions/test-list-filesystems.sh | 2 +-
regressions/test-list-md-devices.sh | 2 +-
regressions/test-mdadm.sh | 26 +++++++++++++-------------
src/inspect_fs_unix.c | 4 ++--
6 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/daemon/md.c b/daemon/md.c
index 82ddb82..8e4ff88 100644
--- a/daemon/md.c
+++ b/daemon/md.c
@@ -50,9 +50,9 @@ count_bits (uint64_t bitmap)
/* Takes optional arguments, consult optargs_bitmask. */
int
-do_mdadm_create (const char *name, char *const *devices,
- int64_t missingbitmap, int nrdevices, int spare,
- int64_t chunk, const char *level)
+do_md_create (const char *name, char *const *devices,
+ int64_t missingbitmap, int nrdevices, int spare,
+ int64_t chunk, const char *level)
{
char nrdevices_s[32];
char spare_s[32];
@@ -63,10 +63,10 @@ do_mdadm_create (const char *name, char *const *devices,
uint64_t umissingbitmap = (uint64_t) missingbitmap;
/* Check the optional parameters and set defaults where appropriate. */
- if (!(optargs_bitmask & GUESTFS_MDADM_CREATE_MISSINGBITMAP_BITMASK))
+ if (!(optargs_bitmask & GUESTFS_MD_CREATE_MISSINGBITMAP_BITMASK))
umissingbitmap = 0;
- if (optargs_bitmask & GUESTFS_MDADM_CREATE_SPARE_BITMASK) {
+ if (optargs_bitmask & GUESTFS_MD_CREATE_SPARE_BITMASK) {
if (spare < 0) {
reply_with_error ("spare must not be negative");
return -1;
@@ -75,7 +75,7 @@ do_mdadm_create (const char *name, char *const *devices,
else
spare = 0;
- if (optargs_bitmask & GUESTFS_MDADM_CREATE_NRDEVICES_BITMASK) {
+ if (optargs_bitmask & GUESTFS_MD_CREATE_NRDEVICES_BITMASK) {
if (nrdevices < 2) {
reply_with_error ("nrdevices is less than 2");
return -1;
@@ -84,7 +84,7 @@ do_mdadm_create (const char *name, char *const *devices,
else
nrdevices = count_strings (devices) + count_bits (umissingbitmap);
- if (optargs_bitmask & GUESTFS_MDADM_CREATE_LEVEL_BITMASK) {
+ if (optargs_bitmask & GUESTFS_MD_CREATE_LEVEL_BITMASK) {
if (STRNEQ (level, "linear") && STRNEQ (level, "raid0") &&
STRNEQ (level, "0") && STRNEQ (level, "stripe") &&
STRNEQ (level, "raid1") && STRNEQ (level, "1") &&
@@ -100,7 +100,7 @@ do_mdadm_create (const char *name, char *const *devices,
else
level = "raid1";
- if (optargs_bitmask & GUESTFS_MDADM_CREATE_CHUNK_BITMASK) {
+ if (optargs_bitmask & GUESTFS_MD_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");
@@ -131,12 +131,12 @@ do_mdadm_create (const char *name, char *const *devices,
ADD_ARG (argv, i, "--raid-devices");
snprintf (nrdevices_s, sizeof nrdevices_s, "%d", nrdevices);
ADD_ARG (argv, i, nrdevices_s);
- if (optargs_bitmask & GUESTFS_MDADM_CREATE_SPARE_BITMASK) {
+ if (optargs_bitmask & GUESTFS_MD_CREATE_SPARE_BITMASK) {
ADD_ARG (argv, i, "--spare-devices");
snprintf (spare_s, sizeof spare_s, "%d", spare);
ADD_ARG (argv, i, spare_s);
}
- if (optargs_bitmask & GUESTFS_MDADM_CREATE_CHUNK_BITMASK) {
+ if (optargs_bitmask & GUESTFS_MD_CREATE_CHUNK_BITMASK) {
ADD_ARG (argv, i, "--chunk");
snprintf (chunk_s, sizeof chunk_s, "%" PRIi64, chunk / 1024);
ADD_ARG (argv, i, chunk_s);
@@ -233,7 +233,7 @@ error:
}
char **
-do_mdadm_detail(const char *md)
+do_md_detail(const char *md)
{
int r;
@@ -290,7 +290,7 @@ do_mdadm_detail(const char *md)
} else {
/* Ignore lines with no equals sign (shouldn't happen). Log to stderr so
* it will show up in LIBGUESTFS_DEBUG. */
- fprintf(stderr, "mdadm-detail: unexpected output ignored: %s", line);
+ fprintf(stderr, "md-detail: unexpected mdadm output ignored: %s", line);
}
}
diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml
index 925640f..c0ef261 100644
--- a/generator/generator_actions.ml
+++ b/generator/generator_actions.ml
@@ -6432,7 +6432,7 @@ To get the current values of filesystem parameters, see
C<guestfs_tune2fs_l>. For precise details of how tune2fs
works, see the L<tune2fs(8)> man page.");
- ("mdadm_create", (RErr, [String "name"; DeviceList "devices"], [Int64 "missingbitmap"; Int "nrdevices"; Int "spare"; Int64 "chunk"; String "level"]), 299, [Optional "mdadm"],
+ ("md_create", (RErr, [String "name"; DeviceList "devices"], [Int64 "missingbitmap"; Int "nrdevices"; Int "spare"; Int64 "chunk"; String "level"]), 299, [Optional "mdadm"],
[],
"create a Linux md (RAID) device",
"\
@@ -6496,7 +6496,7 @@ If not set, this defaults to C<raid1>.
"\
List all Linux md devices.");
- ("mdadm_detail", (RHashtable "info", [Device "md"], []), 301, [Optional "mdadm"],
+ ("md_detail", (RHashtable "info", [Device "md"], []), 301, [Optional "mdadm"],
[],
"obtain metadata for an MD device",
"\
diff --git a/regressions/test-list-filesystems.sh b/regressions/test-list-filesystems.sh
index 1144286..353cdd0 100755
--- a/regressions/test-list-filesystems.sh
+++ b/regressions/test-list-filesystems.sh
@@ -50,7 +50,7 @@ vgcreate vg0 /dev/sdb1
lvcreate lv0 vg0 16
# Create an md device from sda2 and sdb2
-mdadm-create test "/dev/sda2 /dev/sdb2" level:raid1
+md-create test "/dev/sda2 /dev/sdb2" level:raid1
# Create filesystems
mkfs ext3 /dev/sda1
diff --git a/regressions/test-list-md-devices.sh b/regressions/test-list-md-devices.sh
index cd12d80..0216ca9 100755
--- a/regressions/test-list-md-devices.sh
+++ b/regressions/test-list-md-devices.sh
@@ -31,7 +31,7 @@ run
list-md-devices
# Create a raid1 based on the 2 disks
-mdadm-create test "/dev/sda /dev/sdb" level:raid1
+md-create test "/dev/sda /dev/sdb" level:raid1
EOF
)
diff --git a/regressions/test-mdadm.sh b/regressions/test-mdadm.sh
index 8119561..e9b0db5 100755
--- a/regressions/test-mdadm.sh
+++ b/regressions/test-mdadm.sh
@@ -16,7 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-# Test guestfish mdadm-create command.
+# Test guestfish md-create and md-detail commands.
set -e
@@ -53,16 +53,16 @@ part-add /dev/sdd p 12288 16383
part-add /dev/sdd p 16384 20479
# RAID 1.
-mdadm-create r1t1 "/dev/sda1 /dev/sdb1"
-mdadm-create r1t2 "/dev/sdc1 /dev/sdd1" chunk:65536
+md-create r1t1 "/dev/sda1 /dev/sdb1"
+md-create r1t2 "/dev/sdc1 /dev/sdd1" chunk:65536
# RAID 5.
-mdadm-create r5t1 "/dev/sda2 /dev/sdb2 /dev/sdc2 /dev/sdd2" \
+md-create r5t1 "/dev/sda2 /dev/sdb2 /dev/sdc2 /dev/sdd2" \
missingbitmap:0x10 nrdevices:4 spare:1 level:5
-mdadm-create r5t2 "/dev/sda3 /dev/sdb3" missingbitmap:0x1 level:5
+md-create r5t2 "/dev/sda3 /dev/sdb3" missingbitmap:0x1 level:5
-mdadm-create r5t3 "/dev/sdc3 /dev/sdd3" \
+md-create r5t3 "/dev/sdc3 /dev/sdd3" \
missingbitmap:0x6 nrdevices:2 spare:2 level:5
# Make some filesystems and put some content on the
@@ -100,11 +100,11 @@ eval `../fish/guestfish --listen`
../fish/guestfish --remote run
for md in `../fish/guestfish --remote list-md-devices`; do
- ../fish/guestfish --remote mdadm-detail "${md}" > mdadm-detail.out
+ ../fish/guestfish --remote md-detail "${md}" > md-detail.out
- sed 's/:\s*/=/' mdadm-detail.out > mdadm-detail.out.sh
- . mdadm-detail.out.sh
- rm -f mdadm-detail.out.sh
+ sed 's/:\s*/=/' md-detail.out > md-detail.out.sh
+ . md-detail.out.sh
+ rm -f md-detail.out.sh
error=0
case "$name" in
@@ -141,8 +141,8 @@ for md in `../fish/guestfish --remote list-md-devices`; do
[ ! -z "$metadata" ] || error=1
if [ "$error" == "1" ]; then
- echo "$0: Unexpected output from mdadm-detail for device $md"
- cat mdadm-detail.out
+ echo "$0: Unexpected output from md-detail for device $md"
+ cat md-detail.out
../fish/guestfish --remote exit
exit 1
fi
@@ -150,4 +150,4 @@ done
../fish/guestfish --remote exit
-rm -f mdadm-detail.out md-test1.img md-test2.img md-test3.img md-test4.img
+rm -f md-detail.out md-test1.img md-test2.img md-test3.img md-test4.img
diff --git a/src/inspect_fs_unix.c b/src/inspect_fs_unix.c
index 3be49d5..0fa3e83 100644
--- a/src/inspect_fs_unix.c
+++ b/src/inspect_fs_unix.c
@@ -930,7 +930,7 @@ map_app_md_devices (guestfs_h *g, Hash_table **map)
if (mds == NULL) goto error;
for (char **md = mds; *md != NULL; md++) {
- char **detail = guestfs_mdadm_detail(g, *md);
+ char **detail = guestfs_md_detail(g, *md);
if (detail == NULL) goto error;
/* Iterate over keys until we find uuid */
@@ -949,7 +949,7 @@ map_app_md_devices (guestfs_h *g, Hash_table **map)
if (!parse_uuid(*i, entry->uuid)) {
/* Invalid UUID is weird, but not fatal. */
- debug(g, "inspect-os: guestfs_mdadm_detail returned invalid "
+ debug(g, "inspect-os: guestfs_md_detail returned invalid "
"uuid for %s: %s", *md, *i);
guestfs___free_string_list(detail);
md_uuid_free(entry);
--
1.7.7.3
13 years
[PATCH] New API: md-stop for stopping MD devices
by 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(a)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
--
1.7.8.rc3
13 years
[PATCH] run script: Don't overwrite LD_LIBRARY_PATH and PERL5LIB
by Matthew Booth
This change allows the run scripts of virt-v2v and libguestfs to be chained.
---
run.in | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/run.in b/run.in
index 9388398..7cef715 100755
--- a/run.in
+++ b/run.in
@@ -37,9 +37,19 @@ b=@abs_builddir@
export TMPDIR="$b"
# Set local environment relative to this script.
-export LD_LIBRARY_PATH="$b/src/.libs"
-export LIBGUESTFS_PATH="$b/appliance"
-export PERL5LIB="$b/perl/blib/lib:$b/perl/blib/arch"
+if [ -z "$LD_LIBRARY_PATH" ]; then
+ LD_LIBRARY_PATH="$b/src/.libs"
+else
+ LD_LIBRARY_PATH="$b/src/.libs:$LD_LIBRARY_PATH"
+fi
+if [ -z "$PERL5LIB" ]; then
+ PERL5LIB="$b/perl/blib/lib:$b/perl/blib/arch"
+else
+ PERL5LIB="$b/perl/blib/lib:$b/perl/blib/arch:$PERL5LIB"
+fi
+LIBGUESTFS_PATH="$b/appliance"
+
+export LD_LIBRARY_PATH PERL5LIB LIBGUESTFS_PATH
# Do we have libtool? If we have it then we can use it to make
# running valgrind simpler. However don't depend on it.
--
1.7.6.4
13 years
[PATCH] New API: mdadm-stop for stopping MD devices.
by 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(a)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
13 years
[PATCH] New API: mdadm-stop for stopping MD devices.
by 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(a)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
13 years
Re: [Libguestfs] Virtio-win RPM?
by Greg Scott
Thanks Matt.
What would happen if I installed that RHEL6 libguestfs-winsupport RPM
with nodeps on my Fedora conversion server?
- Greg
-----Original Message-----
From: Matthew Booth [mailto:mbooth@redhat.com]
Sent: Tuesday, November 22, 2011 5:12 AM
To: Greg Scott
Cc: libguestfs(a)redhat.com
Subject: Re: [Libguestfs] Virtio-win RPM?
On 22/11/11 10:03, Matthew Booth wrote:
> On 22/11/11 05:33, Greg Scott wrote:
>> Also, how do I turn on that TRACE info with virt-p2v-server in case
>> I
> need it? Those lines Matt said to uncomment do not exist in the copy
> from yum install virt-v2v.
>
> Sorry about that, those lines from from upstream v2v. I was just about
> to do a new build with this code in, but I noticed we still have a
> libguestfs dependency issue to resolve. We should be able to get
> something testable out in a couple of days.
Please try this build:
http://koji.fedoraproject.org/koji/taskinfo?taskID=3531688
It's a scratch build, so it'll only be available for a few days before
it's automatically deleted. You will also require libguestfs from
updates-testing. You can download it manually from here:
https://admin.fedoraproject.org/updates/FEDORA-2011-16166/libguestfs-1.1
4.2-1.fc16
The v2v package doesn't have any dependency which will require you to
install the new libguestfs, but if you don't install it libguestfs will
fail to launch immediately after the data transfer completes.
Disclaimer: I don't have a system here I can easily test the above v2v
package on, and it has received no testing whatsoever! It's also not
really 0.8.4-1, which is why I've put a suffix on it. That said, I don't
anticipate a problem.
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
13 years