Maxim Perevedentsev
2015-Oct-24 09:59 UTC
[Libguestfs] [PATCH] Added xfs support for vfs_min_size.
--- daemon/daemon.h | 1 + daemon/fs-min-size.c | 7 +++++++ daemon/xfs.c | 12 ++++++++++++ generator/actions.ml | 6 +++++- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/daemon/daemon.h b/daemon/daemon.h index 4a969dd..1f0cd30 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -269,6 +269,7 @@ extern int copy_xattrs (const char *src, const char *dest); extern int xfs_set_uuid (const char *device, const char *uuid); extern int xfs_set_uuid_random (const char *device); extern int xfs_set_label (const char *device, const char *label); +extern int64_t xfs_minimum_size (const char *path); /*-- debug-bmap.c --*/ extern char *debug_bmap (const char *subcmd, size_t argc, char *const *const argv); diff --git a/daemon/fs-min-size.c b/daemon/fs-min-size.c index e43237b..432e04f 100644 --- a/daemon/fs-min-size.c +++ b/daemon/fs-min-size.c @@ -64,6 +64,13 @@ do_vfs_minimum_size (const mountable_t *mountable) r = btrfs_minimum_size (path); } + else if (STREQ (vfs_type, "xfs")) { + CLEANUP_FREE char *path = get_mount_point (mountable->device); + if (path == NULL) + return -1; + r = xfs_minimum_size (path); + } + else NOT_SUPPORTED (-1, "don't know how to get minimum size of '%s' filesystems", vfs_type); diff --git a/daemon/xfs.c b/daemon/xfs.c index f748902..c4533bf 100644 --- a/daemon/xfs.c +++ b/daemon/xfs.c @@ -660,3 +660,15 @@ do_xfs_repair (const char *device, return r; } + +int64_t +xfs_minimum_size (const char *path) +{ + CLEANUP_FREE guestfs_int_xfsinfo *info = do_xfs_info (path); + + if (info == NULL) + return -1; + + // XFS does not support shrinking. + return info->xfs_blocksize * info->xfs_datablocks; +} diff --git a/generator/actions.ml b/generator/actions.ml index 8832410..d8af08d 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -12765,6 +12765,10 @@ To read the UUID on a filesystem, call C<guestfs_vfs_uuid>." }; [["mkfs"; "btrfs"; "/dev/sda1"; ""; "NOARG"; ""; ""; "NOARG"]; ["mount"; "/dev/sda1"; "/"]; ["vfs_minimum_size"; "/dev/sda1"]]), []; + InitPartition, Always, TestRun ( + [["mkfs"; "xfs"; "/dev/sda1"; ""; "NOARG"; ""; ""; "NOARG"]; + ["mount"; "/dev/sda1"; "/"]; + ["vfs_minimum_size"; "/dev/sda1"]]), []; ]; shortdesc = "get minimum filesystem size"; longdesc = "\ @@ -12774,7 +12778,7 @@ This is the minimum possible size for filesystem shrinking. If getting minimum size of specified filesystem is not supported, this will fail and set errno as ENOTSUP. -See also L<ntfsresize(8)>, L<resize2fs(8)>, L<btrfs(8)>." }; +See also L<ntfsresize(8)>, L<resize2fs(8)>, L<btrfs(8)>, L<xfs_info(8)>." }; ] -- 1.8.3.1
Richard W.M. Jones
2015-Oct-27 13:19 UTC
Re: [Libguestfs] [PATCH] Added xfs support for vfs_min_size.
On Sat, Oct 24, 2015 at 12:59:14PM +0300, Maxim Perevedentsev wrote:> --- > daemon/daemon.h | 1 + > daemon/fs-min-size.c | 7 +++++++ > daemon/xfs.c | 12 ++++++++++++ > generator/actions.ml | 6 +++++- > 4 files changed, 25 insertions(+), 1 deletion(-)Could you repost the patch rebased on current head? This one doesn't apply to my tree. Thanks, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html
Richard W.M. Jones
2015-Oct-27 13:19 UTC
Re: [Libguestfs] [PATCH] Added xfs support for vfs_min_size.
Oh wait, ignore the previous message. I see the earlier patch. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
Richard W.M. Jones
2015-Oct-27 13:28 UTC
Re: [Libguestfs] [PATCH] Added xfs support for vfs_min_size.
On Sat, Oct 24, 2015 at 12:59:14PM +0300, Maxim Perevedentsev wrote:> +int64_t > +xfs_minimum_size (const char *path) > +{ > + CLEANUP_FREE guestfs_int_xfsinfo *info = do_xfs_info (path); > + > + if (info == NULL) > + return -1; > + > + // XFS does not support shrinking. > + return info->xfs_blocksize * info->xfs_datablocks; > +}My spidey sense says .. what happens if this multiplication overflows? Maybe nothing bad. Nevertheless, both of these numbers are under end-user control. Rest of the patch looks fine to me. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW