[Libguestfs] [PATCH] NEW API: add new api xfs_info
Add xfs_info to show the geometry of the xfs filesystem. Signed-off-by: Wanlong Gao gaowanl...@cn.fujitsu.com --- Hi Rich, This patch add xfs_info, and start the xfs support work. I'd like to add the xfs support, like xfs_growfs, xfs_io, xfs_db, xfs_repair etc. Any thoughts? Thanks, Wanlong Gao daemon/Makefile.am | 1 + daemon/xfs.c | 69 ++ generator/generator_actions.ml | 6 src/MAX_PROC_NR| 2 +- 5 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 daemon/xfs.c diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 9e2a633..afe8874 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -165,6 +165,7 @@ guestfsd_SOURCES = \ utimens.c \ wc.c \ xattr.c \ + xfs.c \ zero.c \ zerofree.c guestfsd_LDADD = \ diff --git a/daemon/xfs.c b/daemon/xfs.c new file mode 100644 index 000..8b60b19 --- /dev/null +++ b/daemon/xfs.c @@ -0,0 +1,69 @@ +/* libguestfs - the guestfsd daemon + * Copyright (C) 2012 Fujitsu Limited. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include config.h + +#include stdio.h +#include stdlib.h +#include inttypes.h +#include string.h +#include unistd.h + +#include guestfs_protocol.h +#include daemon.h +#include c-ctype.h +#include actions.h + +int +optgroup_xfs_available (void) +{ + return prog_exists (mkfs.xfs); +} + +char * +do_xfs_info (const char *path) +{ + int r; + char *buf; + char *out, *err; + + if (do_is_dir (path)) { +buf = sysroot_path (path); +if (!buf) { + reply_with_perror (malloc); + return NULL; +} + } else { +buf = strdup(path); +if (!buf) { + reply_with_perror (strdup); + return NULL; +} + } + + r = command (out, err, xfs_info, buf, NULL); + free (buf); + if (r == -1) { +reply_with_error (%s, err); +free (err); +free (out); +return NULL; + } + + return out; +} diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml index 5baa9b2..ba0b0de 100644 --- a/generator/generator_actions.ml +++ b/generator/generator_actions.ml @@ -7374,6 +7374,12 @@ be returned if you called Cguestfs_list_devices. To find out the maximum number of devices that could be added, call Cguestfs_max_disks.); + (xfs_info, (RString information, [String path], []), 337, [Optional xfs], + [], + print out the geometry of the filesystem, + \ +Thie function can print out the geometry of an mounted XFS filesystem.); + ] let all_functions = non_daemon_functions @ daemon_functions diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR index e64f24d..f59a90f 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -336 +337 -- 1.7.11.rc0 ___ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs
Re: [Libguestfs] [PATCH] NEW API: add new api xfs_info
On 07/09/2012 05:08 PM, Richard W.M. Jones wrote: On Mon, Jul 09, 2012 at 04:37:52PM +0800, Wanlong Gao wrote: Add xfs_info to show the geometry of the xfs filesystem. Signed-off-by: Wanlong Gao gaowanl...@cn.fujitsu.com --- Hi Rich, This patch add xfs_info, and start the xfs support work. I'd like to add the xfs support, like xfs_growfs, xfs_io, xfs_db, xfs_repair etc. Any thoughts? Yes, it's a very good idea. Thanks, Wanlong Gao daemon/Makefile.am | 1 + daemon/xfs.c | 69 ++ generator/generator_actions.ml | 6 src/MAX_PROC_NR| 2 +- 5 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 daemon/xfs.c diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 9e2a633..afe8874 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -165,6 +165,7 @@ guestfsd_SOURCES = \ utimens.c \ wc.c \ xattr.c \ +xfs.c \ zero.c \ zerofree.c guestfsd_LDADD = \ diff --git a/daemon/xfs.c b/daemon/xfs.c new file mode 100644 index 000..8b60b19 --- /dev/null +++ b/daemon/xfs.c @@ -0,0 +1,69 @@ +/* libguestfs - the guestfsd daemon + * Copyright (C) 2012 Fujitsu Limited. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include config.h + +#include stdio.h +#include stdlib.h +#include inttypes.h +#include string.h +#include unistd.h + +#include guestfs_protocol.h +#include daemon.h +#include c-ctype.h +#include actions.h + +int +optgroup_xfs_available (void) +{ + return prog_exists (mkfs.xfs); +} + +char * +do_xfs_info (const char *path) +{ + int r; + char *buf; + char *out, *err; + + if (do_is_dir (path)) { +buf = sysroot_path (path); +if (!buf) { + reply_with_perror (malloc); + return NULL; +} + } else { +buf = strdup(path); +if (!buf) { + reply_with_perror (strdup); + return NULL; +} + } + + r = command (out, err, xfs_info, buf, NULL); + free (buf); + if (r == -1) { +reply_with_error (%s, err); +free (err); +free (out); +return NULL; + } + + return out; xfs_info has structured output: $ virt-rescue --scratch rescue parted /dev/vda mklabel msdos rescue parted -- /dev/vda mkpart primary 32s -32s rescue mkfs.xfs /dev/vda1 rescue file -bsL /dev/vda1 SGI XFS filesystem data (blksz 4096, inosz 256, v2 dirs) rescue mount /dev/vda1 /sysroot [ 136.526415] SGI XFS with ACLs, security attributes, large block/inode numbers, no debug enabled [ 136.539163] XFS (vda1): Mounting Filesystem [ 136.615296] XFS (vda1): Ending clean mount rescue xfs_info /dev/vda1 meta-data=/dev/vda1 isize=256agcount=4, agsize=655358 blks = sectsz=512 attr=2 data = bsize=4096 blocks=2621432, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 It's weird output, but let's parse and return that instead of dumping the problem onto every caller. Sorry, I can't understand what do you mean here, it's the original output of xfs_info. +} diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml index 5baa9b2..ba0b0de 100644 --- a/generator/generator_actions.ml +++ b/generator/generator_actions.ml @@ -7374,6 +7374,12 @@ be returned if you called Cguestfs_list_devices. To find out the maximum number of devices that could be added, call Cguestfs_max_disks.); + (xfs_info, (RString information, [String path], []), 337, [Optional xfs], path isn't a string, it's a filename. And the return type has to be changed to reflect the structure being returned. You mean not a simple string? + [], I think it'd be good to add test(s) here. Ok, will do. + print out the geometry of the filesystem, Only for XFS filesystems, so perhaps a better description is: get geometry of XFS
Re: [Libguestfs] [PATCH] NEW API: add new api xfs_info
On Mon, Jul 09, 2012 at 05:15:47PM +0800, Wanlong Gao wrote: rescue xfs_info /dev/vda1 meta-data=/dev/vda1 isize=256agcount=4, agsize=655358 blks = sectsz=512 attr=2 data = bsize=4096 blocks=2621432, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 It's weird output, but let's parse and return that instead of dumping the problem onto every caller. Sorry, I can't understand what do you mean here, it's the original output of xfs_info. Sure, but what's the caller going to do with this output (assuming the caller is a program)? If it wants to find, eg, the 'bsize' field then it has to parse this, so we're pushing the problem of parsing the output up to every program. BTW we can use augeas to handle parsing, since these useful APIs were added to augeas recently: https://www.redhat.com/archives/augeas-devel/2012-May/msg00035.html Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v ___ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs
Re: [Libguestfs] [PATCH] NEW API: add new api xfs_info
On 07/09/2012 05:28 PM, Richard W.M. Jones wrote: On Mon, Jul 09, 2012 at 05:15:47PM +0800, Wanlong Gao wrote: rescue xfs_info /dev/vda1 meta-data=/dev/vda1 isize=256agcount=4, agsize=655358 blks = sectsz=512 attr=2 data = bsize=4096 blocks=2621432, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 It's weird output, but let's parse and return that instead of dumping the problem onto every caller. Sorry, I can't understand what do you mean here, it's the original output of xfs_info. Sure, but what's the caller going to do with this output (assuming the caller is a program)? If it wants to find, eg, the 'bsize' field then it has to parse this, so we're pushing the problem of parsing the output up to every program. BTW we can use augeas to handle parsing, since these useful APIs were added to augeas recently: https://www.redhat.com/archives/augeas-devel/2012-May/msg00035.html Got it, thank you for explanation. I'll try. Wanlong Gao Rich. ___ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs
[Libguestfs] [PATCH 0/4] Provide guestmount --pid-file and document possible race when unmounting FUSE filesystems.
The full description of this bug is here: https://bugzilla.redhat.com/show_bug.cgi?id=838592 and the effect it has on OpenStack is described here: https://bugzilla.redhat.com/show_bug.cgi?id=835466#c9 Rich. ___ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs
[Libguestfs] [PATCH 1/4] fuse: Document race condition possible with fusermount.
From: Richard W.M. Jones rjo...@redhat.com See also: https://bugzilla.redhat.com/show_bug.cgi?id=835466#c9 --- fuse/guestmount.pod | 16 1 file changed, 16 insertions(+) diff --git a/fuse/guestmount.pod b/fuse/guestmount.pod index a0bc6f1..c37301c 100644 --- a/fuse/guestmount.pod +++ b/fuse/guestmount.pod @@ -106,6 +106,22 @@ namespace using the Linux-specific Lclone(2)/Lunshare(2) flag CCLONE_NEWNS. Unfortunately at the moment this requires root and we would also probably need to add it as a feature to guestmount. +=head2 Race conditions possible when shutting down the connection + +When Cfusermount -u exits, guestmount may still be running and +cleaning up the mountpoint. The disk image will not be fully +finalized. + +This means that scripts like the following have a nasty race +condition: + + guestmount -a disk.img -i /mnt + # copy things into /mnt + fusermount -u /mnt + # immediately try to use 'disk.img' -- UNSAFE + +The solution is to spin waiting for the guestmount process to exit. + =head1 OPTIONS =over 4 -- 1.7.10.4 ___ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs
[Libguestfs] [PATCH 2/4] fuse: Link to mount-local documentation in guestmount man page.
From: Richard W.M. Jones rjo...@redhat.com --- fuse/guestmount.pod |6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fuse/guestmount.pod b/fuse/guestmount.pod index c37301c..d459045 100644 --- a/fuse/guestmount.pod +++ b/fuse/guestmount.pod @@ -122,6 +122,10 @@ condition: The solution is to spin waiting for the guestmount process to exit. +Note that if you use the Cguestfs_mount_local API directly (see +Lguestfs(3)/MOUNT LOCAL) then it is much easier to write a safe, +race-free program. + =head1 OPTIONS =over 4 @@ -354,7 +358,7 @@ Lvirt-inspector(1), Lvirt-cat(1), Lvirt-edit(1), Lvirt-tar(1), -Lguestfs(3), +Lguestfs(3)/MOUNT LOCAL, Lhttp://libguestfs.org/, Lhttp://fuse.sf.net/. -- 1.7.10.4 ___ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs
[Libguestfs] [PATCH] podwrapper.sh: Use date from ChangeLog
--- podwrapper.sh.in |4 1 file changed, 4 insertions(+) diff --git a/podwrapper.sh.in b/podwrapper.sh.in index ec750f1..0a84d13 100755 --- a/podwrapper.sh.in +++ b/podwrapper.sh.in @@ -53,6 +53,9 @@ if [ -z $abs_top_builddir ]; then exit 1 fi +DATE=`awk '/^[0-9]+-[0-9]+-[0-9]+/ { print $1; exit }' \ +$abs_top_srcdir/ChangeLog` + declare -a inserts declare -a pattern declare -a indent @@ -167,6 +170,7 @@ fi # Now generate the final output format(s). if [ -n $man_output ]; then $POD2MAN $POD2_STDERR_OPTION $POD2_UTF8_OPTION \ +--date $DATE \ --section $section -c Virtualization Support --name $name \ --release $PACKAGE_NAME-$PACKAGE_VERSION \ $tmpdir/full.pod $man_output.tmp -- 1.7.10.4 ___ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs
[Libguestfs] Use predictable date in POD-generated manpages
This is a minor issue that may break co-installability of i386/amd64 Debian packages: If the date in otherwise identical manpages differs across architectures, dpkg will refuse to install the two versions of the package together. See: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=680885 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=680886 This patch makes for reproducible outcomes. Cheers, -Hilko ___ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs