[PATCH V2 1/4] mount: add a macro to resolve path or device
by Wanlong Gao
Add a macro STRDUP_RESOLVE_DEVICE_OR_PATH to resolve path or device.
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
daemon/daemon.h | 16 ++++++++++++++++
daemon/mount.c | 13 ++-----------
2 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 85eec45..f7d0c75 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -336,6 +336,22 @@ is_zero (const char *buffer, size_t size)
} \
} while (0)
+/* Same as REQUIRE_ROOT_OR_RESOLVE_DEVICE but this strdup's the result. */
+#define STRDUP_RESOLVE_DEVICE_OR_PATH(path,buf,cancel_stmt,fail_stmt) \
+ do { \
+ int is_dev; \
+ is_dev = STREQLEN (path, "/dev/", 5); \
+ buf = is_dev ? strdup (path) \
+ : sysroot_path (path); \
+ if (buf == NULL) { \
+ cancel_stmt; \
+ reply_with_perror ("malloc"); \
+ fail_stmt; \
+ } \
+ if (is_dev) \
+ RESOLVE_DEVICE (buf, cancel_stmt, fail_stmt); \
+ } while (0)
+
/* NB:
* (1) You must match CHROOT_IN and CHROOT_OUT even along error paths.
* (2) You must not change directory! cwd must always be "/", otherwise
diff --git a/daemon/mount.c b/daemon/mount.c
index 0661eb8..1843165 100644
--- a/daemon/mount.c
+++ b/daemon/mount.c
@@ -192,18 +192,9 @@ do_umount (const char *pathordevice)
int r;
char *err;
char *buf;
- int is_dev;
- is_dev = STREQLEN (pathordevice, "/dev/", 5);
- buf = is_dev ? strdup (pathordevice)
- : sysroot_path (pathordevice);
- if (buf == NULL) {
- reply_with_perror ("malloc");
- return -1;
- }
-
- if (is_dev)
- RESOLVE_DEVICE (buf, , { free (buf); return -1; });
+ STRDUP_RESOLVE_DEVICE_OR_PATH (pathordevice, buf, ,
+ { free (buf); return -1;});
r = command (NULL, &err, "umount", buf, NULL);
free (buf);
--
1.7.11.3.287.ge771946
12 years, 3 months
[PATCH 1/5] mount: add a macro to resolve path or device
by Wanlong Gao
Add a macro DUP_RESOLVE_DEVICE_OR_PATH to resolve path or device.
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
daemon/daemon.h | 18 ++++++++++++++++++
daemon/mount.c | 13 ++-----------
po/POTFILES | 8 ++++++++
3 files changed, 28 insertions(+), 11 deletions(-)
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 85eec45..39cc3f3 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -336,6 +336,24 @@ is_zero (const char *buffer, size_t size)
} \
} while (0)
+/* Helper for functions which need either a root(/sysroot) path,
+ * OR a /dev/ device which exists.
+ */
+#define DUP_RESOLVE_DEVICE_OR_PATH(path,buf,cancel_stmt,fail_stmt) \
+ do { \
+ int is_dev; \
+ is_dev = STREQLEN (path, "/dev/", 5); \
+ buf = is_dev ? strdup (path) \
+ : sysroot_path (path); \
+ if (buf == NULL) { \
+ cancel_stmt; \
+ reply_with_perror ("malloc"); \
+ fail_stmt; \
+ } \
+ if (is_dev) \
+ RESOLVE_DEVICE (buf, cancel_stmt, fail_stmt); \
+ } while (0)
+
/* NB:
* (1) You must match CHROOT_IN and CHROOT_OUT even along error paths.
* (2) You must not change directory! cwd must always be "/", otherwise
diff --git a/daemon/mount.c b/daemon/mount.c
index 0661eb8..1bac1a7 100644
--- a/daemon/mount.c
+++ b/daemon/mount.c
@@ -192,18 +192,9 @@ do_umount (const char *pathordevice)
int r;
char *err;
char *buf;
- int is_dev;
- is_dev = STREQLEN (pathordevice, "/dev/", 5);
- buf = is_dev ? strdup (pathordevice)
- : sysroot_path (pathordevice);
- if (buf == NULL) {
- reply_with_perror ("malloc");
- return -1;
- }
-
- if (is_dev)
- RESOLVE_DEVICE (buf, , { free (buf); return -1; });
+ DUP_RESOLVE_DEVICE_OR_PATH (pathordevice, buf, ,
+ { free (buf); return -1;});
r = command (NULL, &err, "umount", buf, NULL);
free (buf);
diff --git a/po/POTFILES b/po/POTFILES
index 60f8d95..69291fa 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -27,6 +27,7 @@ daemon/du.c
daemon/echo-daemon.c
daemon/errnostring-gperf.c
daemon/errnostring.c
+daemon/errnostring_gperf.c
daemon/ext2.c
daemon/fallocate.c
daemon/file.c
@@ -97,6 +98,7 @@ erlang/erl-guestfs.c
fish/alloc.c
fish/cmds-gperf.c
fish/cmds.c
+fish/cmds_gperf.c
fish/completion.c
fish/config.c
fish/copy.c
@@ -135,6 +137,7 @@ format/format.c
fuse/guestmount.c
gobject/src/optargs-add_domain.c
gobject/src/optargs-add_drive.c
+gobject/src/optargs-add_drive_opts.c
gobject/src/optargs-btrfs_filesystem_resize.c
gobject/src/optargs-btrfs_fsck.c
gobject/src/optargs-compress_device_out.c
@@ -150,12 +153,15 @@ gobject/src/optargs-internal_test.c
gobject/src/optargs-md_create.c
gobject/src/optargs-mkfs.c
gobject/src/optargs-mkfs_btrfs.c
+gobject/src/optargs-mkfs_opts.c
gobject/src/optargs-mount_9p.c
gobject/src/optargs-mount_local.c
gobject/src/optargs-ntfsclone_out.c
gobject/src/optargs-ntfsfix.c
gobject/src/optargs-ntfsresize.c
+gobject/src/optargs-ntfsresize_opts.c
gobject/src/optargs-set_e2attrs.c
+gobject/src/optargs-test0.c
gobject/src/optargs-tune2fs.c
gobject/src/optargs-umount_local.c
gobject/src/session.c
@@ -180,6 +186,7 @@ inspector/virt-inspector.c
java/com_redhat_et_libguestfs_GuestFS.c
ocaml/guestfs-c-actions.c
ocaml/guestfs-c.c
+ocaml/guestfs_c_actions.c
perl/Guestfs.c
perl/bindtests.pl
perl/lib/Sys/Guestfs.pm
@@ -197,6 +204,7 @@ src/bindtests.c
src/dbdump.c
src/errnostring-gperf.c
src/errnostring.c
+src/errnostring_gperf.c
src/events.c
src/filearch.c
src/fuse.c
--
1.7.11.2.249.g31c7954
12 years, 3 months
[PATCH] fuse:remove the unused macro when fuse is not available
by Wanlong Gao
Just make gcc happy when fuse is not available.
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
src/fuse.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/fuse.c b/src/fuse.c
index 2bd6787..349a5b9 100644
--- a/src/fuse.c
+++ b/src/fuse.c
@@ -25,6 +25,7 @@
#include <sys/types.h>
#include <sys/wait.h>
+#if HAVE_FUSE
/* See <attr/xattr.h> */
#ifndef ENOATTR
#define ENOATTR ENODATA
@@ -32,7 +33,6 @@
#define FUSE_USE_VERSION 26
-#if HAVE_FUSE
#include <fuse.h>
#include <fuse_lowlevel.h>
#endif
--
1.7.11.2.249.g31c7954
12 years, 3 months
[PATCH V4] NEW API: add new api xfs_info
by Wanlong Gao
Add xfs_info to show the geometry of the xfs filesystem.
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
Hi Rich,
I got an odd error, can you help me with this error
or give me a debug method?
Thanks,
Wanlong Gao
daemon/Makefile.am | 1 +
daemon/xfs.c | 278 +++++++++++++++++++++++++++++++
generator/generator_actions.ml | 8 +
generator/generator_structs.ml | 30 ++++
gobject/Makefile.inc | 2 +
java/Makefile.inc | 1 +
java/com/redhat/et/libguestfs/.gitignore | 1 +
po/POTFILES | 3 +
src/MAX_PROC_NR | 2 +-
9 files changed, 325 insertions(+), 1 deletion(-)
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 0000000..b328d09
--- /dev/null
+++ b/daemon/xfs.c
@@ -0,0 +1,278 @@
+/* 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");
+}
+
+static char *
+split_strdup (char *string)
+{
+ char *end = string;
+ while (*end != ' ' && *end != ',') end++;
+ size_t len = end - string;
+ char *ret = malloc (len + 1);
+ if (!ret) {
+ reply_with_perror ("malloc");
+ return NULL;
+ }
+ strncpy (ret, string, len);
+ ret[len] = '\0';
+ fprintf(stderr, "%s\n", ret);
+ return ret;
+}
+
+static int
+parse_uint32 (uint32_t *ret, const char *str)
+{
+ uint32_t r;
+
+ if (sscanf (str, "%" SCNu32, &r) != 1) {
+ reply_with_error ("cannot parse numeric field from isoinfo: %s", str);
+ return -1;
+ }
+
+ *ret = r;
+ return 0;
+}
+
+static int
+parse_uint64 (uint64_t *ret, const char *str)
+{
+ uint64_t r;
+
+ if (sscanf (str, "%" SCNu64, &r) != 1) {
+ reply_with_error ("cannot parse numeric field from isoinfo: %s", str);
+ return -1;
+ }
+
+ *ret = r;
+ return 0;
+}
+
+static guestfs_int_xfsinfo *
+parse_xfs_info (char **lines)
+{
+ guestfs_int_xfsinfo *ret;
+ char *buf, *p;
+ size_t i;
+
+ ret = calloc (1, sizeof *ret);
+ if (ret == NULL) {
+ reply_with_error ("calloc");
+ return NULL;
+ }
+
+ for (i = 0; lines[i] != NULL; ++i) {
+ if (p = strstr (lines[i], "meta-data=")) {
+ ret->mntpoint = split_strdup (p + 10);
+ if (ret->mntpoint == NULL) goto error;
+ } else if (p = strstr (lines[i], "isize=")) {
+ buf = split_strdup (p + 6);
+ if (buf == NULL) goto error;
+ if (parse_uint32 (&ret->inodesize, buf) == -1)
+ goto error;
+ } else if (p = strstr (lines[i], "agcount=")) {
+ buf = split_strdup (p + 8);
+ if (buf == NULL) goto error;
+ if (parse_uint32 (&ret->agcount, buf) == -1)
+ goto error;
+ } else if (p = strstr (lines[i], "agsize=")) {
+ buf = split_strdup (p + 7);
+ if (buf == NULL) goto error;
+ if (parse_uint32 (&ret->agsize, buf) == -1)
+ goto error;
+ } else if (p = strstr (lines[i], "sectsz=")) {
+ buf = split_strdup (p + 7);
+ if (buf == NULL) goto error;
+ if (i == 1)
+ if (parse_uint32 (&ret->sectsize, buf) == -1)
+ goto error;
+ else if (i == 6)
+ if (parse_uint32 (&ret->logsectsize, buf) == -1)
+ goto error;
+ else goto error;
+ } else if (p = strstr (lines[i], "attr=")) {
+ buf = split_strdup (p + 5);
+ if (buf == NULL) goto error;
+ if (parse_uint32 (&ret->attr, buf) == -1)
+ goto error;
+ } else if (p = strstr (lines[i], "bsize=")) {
+ buf = split_strdup (p + 6);
+ if (buf == NULL) goto error;
+ if (i == 2)
+ if (parse_uint32 (&ret->blocksize, buf) == -1)
+ goto error;
+ else if (i == 4)
+ if (parse_uint32 (&ret->dirblocksize, buf) == -1)
+ goto error;
+ else if (i == 5)
+ if (parse_uint32 (&ret->logblocksize, buf) == -1)
+ goto error;
+ else goto error;
+ } else if (p = strstr (lines[i], "blocks=")) {
+ buf = split_strdup (p + 7);
+ if (buf == NULL) goto error;
+ if (i == 2)
+ if (parse_uint64 (&ret->datablocks, buf) == -1)
+ goto error;
+ else if (i == 5)
+ if (parse_uint32 (&ret->logblocks, buf) == -1)
+ goto error;
+ else if (i == 7)
+ if (parse_uint64 (&ret->rtblocks, buf) == -1)
+ goto error;
+ else goto error;
+ } else if (p = strstr (lines[i], "imaxpct=")) {
+ buf = split_strdup (p + 8);
+ if (buf == NULL) goto error;
+ if (parse_uint32 (&ret->imaxpct, buf) == -1)
+ goto error;
+ } else if (p = strstr (lines[i], "sunit=")) {
+ buf = split_strdup (p + 6);
+ if (buf == NULL) goto error;
+ if (i == 3)
+ if (parse_uint32 (&ret->sunit, buf) == -1)
+ goto error;
+ else if (i == 6)
+ if (parse_uint32 (&ret->logsunit, buf) == -1)
+ goto error;
+ else goto error;
+ } else if (p = strstr (lines[i], "swidth=")) {
+ buf = split_strdup (p + 7);
+ if (buf == NULL) goto error;
+ if (parse_uint32 (&ret->swidth, buf) == -1)
+ goto error;
+ } else if (p = strstr (lines[i], "naming =version ")) {
+ buf = split_strdup (p + 18);
+ if (buf == NULL) goto error;
+ if (parse_uint32 (&ret->dirversion, buf) == -1)
+ goto error;
+ } else if (p = strstr (lines[i], "ascii-ci=")) {
+ buf = split_strdup (p + 9);
+ if (buf == NULL) goto error;
+ if (parse_uint32 (&ret->cimode, buf) == -1)
+ goto error;
+ } else if (p = strstr (lines[i], "log =")) {
+ ret->logname = split_strdup (p + 10);
+ if (ret->logname == NULL) goto error;
+ } else if (p = strstr (lines[i], "version=")) {
+ buf = split_strdup (p + 8);
+ if (buf == NULL) goto error;
+ if (parse_uint32 (&ret->logversion, buf) == -1)
+ goto error;
+ } else if (p = strstr (lines[i], "lazy-count=")) {
+ buf = split_strdup (p + 11);
+ if (buf == NULL) goto error;
+ if (parse_uint32 (&ret->lazycount, buf) == -1)
+ goto error;
+ } else if (p = strstr (lines[i], "realtime =")) {
+ ret->rtname = split_strdup (p + 10);
+ if (ret->rtname == NULL) goto error;
+ } else if (p = strstr (lines[i], "rtextents=")) {
+ buf = split_strdup (p + 10);
+ if (buf == NULL) goto error;
+ if (parse_uint64 (&ret->rtextents, buf) == -1)
+ goto error;
+ }
+
+ free (buf);
+ }
+
+ if (ret->mntpoint == NULL) {
+ ret->mntpoint = strdup ("");
+ if (ret->mntpoint == NULL) goto error;
+ }
+ if (ret->logname == NULL) {
+ ret->logname = strdup ("");
+ if (ret->logname == NULL) goto error;
+ }
+ if (ret->rtname == NULL) {
+ ret->rtname = strdup ("");
+ if (ret->rtname == NULL) goto error;
+ }
+
+ return ret;
+
+error:
+ free (buf);
+ free (ret->mntpoint);
+ free (ret->logname);
+ free (ret->rtname);
+ free (ret);
+ return NULL;
+}
+
+guestfs_int_xfsinfo *
+do_xfs_info (const char *path)
+{
+ int r;
+ char *buf;
+ char *out = NULL, *err = NULL;
+ char **lines = NULL;
+ guestfs_int_xfsinfo *ret = NULL;
+
+ 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);
+ goto error;
+ }
+
+ lines = split_lines (out);
+ if (lines == NULL)
+ goto error;
+
+ ret = parse_xfs_info (lines);
+
+error:
+ free (err);
+ free (out);
+ if (lines)
+ free_strings (lines);
+ return ret;
+}
diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml
index c83bf70..dd9ea03 100644
--- a/generator/generator_actions.ml
+++ b/generator/generator_actions.ml
@@ -8995,6 +8995,14 @@ be returned if you called C<guestfs_list_devices>.
To find out the maximum number of devices that could be added,
call C<guestfs_max_disks>." };
+ { defaults with
+ name = "xfs_info";
+ style = RStruct ("info", "xfsinfo"), [Pathname "path"], [];
+ proc_nr = Some 337;
+ shortdesc = "get geometry of XFS filesystem";
+ longdesc = "\
+This functions can print out the geometry of a mounted XFS filesystem." };
+
]
(* Non-API meta-commands available only in guestfish.
diff --git a/generator/generator_structs.ml b/generator/generator_structs.ml
index 024bb3c..3dded35 100644
--- a/generator/generator_structs.ml
+++ b/generator/generator_structs.ml
@@ -213,6 +213,35 @@ let structs = [
"iso_volume_effective_t", FInt64;
];
+ (* XFS info descriptor. *)
+ "xfsinfo", [
+ "mntpoint", FString;
+ "inodesize", FUInt32;
+ "agcount", FUInt32;
+ "agsize", FUInt32;
+ "sectsize", FUInt32;
+ "attr", FUInt32;
+ "blocksize", FUInt32;
+ "datablocks", FUInt64;
+ "imaxpct", FUInt32;
+ "sunit", FUInt32;
+ "swidth", FUInt32;
+ "dirversion", FUInt32;
+ "dirblocksize", FUInt32;
+ "cimode", FInt32;
+ "logname", FString;
+ "logblocksize", FUInt32;
+ "logblocks", FUInt32;
+ "logversion", FUInt32;
+ "logsectsize", FUInt32;
+ "logsunit", FUInt32;
+ "lazycount", FUInt32;
+ "rtname", FString;
+ "rtextsize", FUInt32;
+ "rtblocks", FUInt64;
+ "rtextents", FUInt64;
+ ];
+
(* /proc/mdstat information. See linux.git/drivers/md/md.c *)
"mdstat", [
"mdstat_device", FString;
@@ -243,6 +272,7 @@ let camel_structs = [
"partition", "Partition";
"application", "Application";
"isoinfo", "ISOInfo";
+ "xfsinfo", "XFSInfo";
"mdstat", "MDStat";
"btrfssubvolume", "BTRFSSubvolume";
]
diff --git a/gobject/Makefile.inc b/gobject/Makefile.inc
index e84236d..d70e106 100644
--- a/gobject/Makefile.inc
+++ b/gobject/Makefile.inc
@@ -36,6 +36,7 @@ guestfs_gobject_headers= \
include/guestfs-gobject/struct-partition.h \
include/guestfs-gobject/struct-application.h \
include/guestfs-gobject/struct-isoinfo.h \
+ include/guestfs-gobject/struct-xfsinfo.h \
include/guestfs-gobject/struct-mdstat.h \
include/guestfs-gobject/struct-btrfssubvolume.h \
include/guestfs-gobject/optargs-internal_test.h \
@@ -80,6 +81,7 @@ guestfs_gobject_sources= \
src/struct-partition.c \
src/struct-application.c \
src/struct-isoinfo.c \
+ src/struct-xfsinfo.c \
src/struct-mdstat.c \
src/struct-btrfssubvolume.c \
src/optargs-internal_test.c \
diff --git a/java/Makefile.inc b/java/Makefile.inc
index efad2a0..da8de49 100644
--- a/java/Makefile.inc
+++ b/java/Makefile.inc
@@ -35,4 +35,5 @@ java_built_sources = \
com/redhat/et/libguestfs/VG.java \
com/redhat/et/libguestfs/Version.java \
com/redhat/et/libguestfs/XAttr.java \
+ com/redhat/et/libguestfs/XFSInfo.java \
com/redhat/et/libguestfs/GuestFS.java
diff --git a/java/com/redhat/et/libguestfs/.gitignore b/java/com/redhat/et/libguestfs/.gitignore
index 9556d81..1034665 100644
--- a/java/com/redhat/et/libguestfs/.gitignore
+++ b/java/com/redhat/et/libguestfs/.gitignore
@@ -13,3 +13,4 @@ StatVFS.java
VG.java
Version.java
XAttr.java
+XFSInfo.java
diff --git a/po/POTFILES b/po/POTFILES
index 6c819d3..017f5bd 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -84,6 +84,7 @@ daemon/upload.c
daemon/utimens.c
daemon/wc.c
daemon/xattr.c
+daemon/xfs.c
daemon/zero.c
daemon/zerofree.c
df/df.c
@@ -155,6 +156,7 @@ gobject/src/optargs-ntfsclone_out.c
gobject/src/optargs-ntfsfix.c
gobject/src/optargs-ntfsresize_opts.c
gobject/src/optargs-set_e2attrs.c
+gobject/src/optargs-test0.c
gobject/src/optargs-tune2fs.c
gobject/src/optargs-umount_local.c
gobject/src/session.c
@@ -173,6 +175,7 @@ gobject/src/struct-stat.c
gobject/src/struct-statvfs.c
gobject/src/struct-version.c
gobject/src/struct-xattr.c
+gobject/src/struct-xfsinfo.c
gobject/src/tristate.c
inspector/virt-inspector.c
java/com_redhat_et_libguestfs_GuestFS.c
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.1.165.g299666c
12 years, 3 months
[PATCH] virt-v2v: Create a libvirt-friendly volume name
by Alex Jia
The $vmdk value is a directory name in ESX.pm, although the later codes
replace '/' with '_', the volume name isn't still friendly, for example,
it looks like this:
# virsh vol-list pool-dir
Name Path
-----------------------------------------
esx4.1-rhel6.2-x86_64_esx4.1-rhel6.2-x86_64 /mnt/esx4.1-rhel6.2-x86_64_esx4.1-rhel6.2-x86_64
With the patch, the volume name is very friendly like guest name:
# virsh vol-list pool-dir
Name Path
-----------------------------------------
esx4.1-rhel6.2-x86_64 /mnt/esx4.1-rhel6.2-x86_64
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
lib/Sys/VirtConvert/Transfer/ESX.pm | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/Sys/VirtConvert/Transfer/ESX.pm b/lib/Sys/VirtConvert/Transfer/ESX.pm
index 23969cd..f29eb31 100644
--- a/lib/Sys/VirtConvert/Transfer/ESX.pm
+++ b/lib/Sys/VirtConvert/Transfer/ESX.pm
@@ -368,8 +368,9 @@ sub new
}
# Create a libvirt-friendly volume name
- $self->{name} = $vmdk;
- $self->{name} =~ s,/,_,g;
+ use File::Basename;
+ my($name, $dir, $suffix) = fileparse($vmdk);
+ $self->{name} = $name;
return $self;
}
--
1.7.10.4
12 years, 3 months
[PATCH] isoinfo: remove the useless goto
by Wanlong Gao
Code cleanup.
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
daemon/isoinfo.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/daemon/isoinfo.c b/daemon/isoinfo.c
index c0ee1c9..fd777bd 100644
--- a/daemon/isoinfo.c
+++ b/daemon/isoinfo.c
@@ -255,8 +255,6 @@ isoinfo (const char *path)
goto done;
ret = parse_isoinfo (lines);
- if (ret == NULL)
- goto done;
done:
free (out);
--
1.7.11.2.249.g31c7954
12 years, 3 months
[PATCH 0/6] Allow non-optargs functions to gain optional arguments.
by Richard W.M. Jones
This rather complex set of patches allow non-optargs functions to gain
optional arguments, while preserving source and binary backwards
compatibility.
The problem is that we cannot add an optional argument to an existing
function. For example, we might want to add flags to the 'lvresize'
API which currently has no optional arguments.
http://libguestfs.org/guestfs.3.html#guestfs_lvresize
The reason this wouldn't be possible is because in C the call is
specified as:
int guestfs_lvresize (guestfs_h *g, const char *device, int mbytes);
which leaves no scope for extra parameters to be added. However in
other languages, it wouldn't be a problem, eg. in Perl you can
overload functions with additional arguments perfectly happily:
$g->lvresize (device, mbytes);
$g->lvresize (device, mbytes, free_percent => 50);
and this is true in most non-C languages.
The way to make this work is to generate C bindings differently. We
would still generate the (backwards-compatible) guestfs_lvresize
function as before, but we would generate an additional function
'guestfs_lvresize_opts' which could take optional arguments.
Additionally, there are three "*-opts" APIs already (add-drive-opts,
mkfs-opts, ntfsresize-opts). By luck, all of these have "non-opts"
variants which take all the same required arguments. Therefore we can
rename these as non-opts functions (add-drive, mkfs, ntfsresize) and
use the same machinery above to generate the "*-opts" variants
automatically. Existing callers will not be affected.
The patches in this series do just this:
1/6, 2/6: Adds a 'once_had_no_optargs' flag to the generator, allowing
functions to be transitioned from non-opts -> opts. This flag must be
set to true when this is done so the corresponding backwards-
compatibility functions can be generated.
3/6: Adds *-opts aliases in non-C languages. This ensures that non-C
bindings won't be broken by this transition. *NB* PHP, Haskell and
GObject bindings *are* broken at the moment; see the notes in the
commit message.
4/6, 5/6, 6/6: Rename add-drive-opts -> add_drive, mkfs-opts -> mkfs,
ntfsresize-opts -> ntfsresize. By setting the once_had_no_optargs
flag we avoid breaking code for callers.
----
At the moment, the GObject bindings don't run at all on Rawhide. I
suspect this is a general bug in Rawhide, since it doesn't happen on
F17. The error is:
JS ERROR: !!! Exception was: Error: Unsupported type void, deriving from fundamental void
JS ERROR: !!! message = '"Unsupported type void, deriving from fundamental void"'
JS ERROR: !!! fileName = '"./bindtests.js"'
JS ERROR: !!! lineNumber = '27'
JS ERROR: !!! stack = '"@./bindtests.js:27
Rich.
12 years, 3 months
[PATCH] NEW API: add new api xfs_info
by Wanlong Gao
Add xfs_info to show the geometry of the xfs filesystem.
Signed-off-by: Wanlong Gao <gaowanlong(a)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 0000000..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 C<guestfs_list_devices>.
To find out the maximum number of devices that could be added,
call C<guestfs_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
12 years, 3 months