Fwd: hivex: patch for read support of "li"-records from "ri" intermediate
by Richard W.M. Jones
[The bug which this fixes is:
https://bugzilla.redhat.com/show_bug.cgi?id=717583 ]
----- Forwarded message from Peter Fokker <peter(a)berestijn.nl> -----
Date: Thu, 8 Mar 2012 11:37:06 +0100 (CET)
From: Peter Fokker <peter(a)berestijn.nl>
To: rjones(a)redhat.com
Cc: Peter Fokker <peter(a)berestijn.nl>
Subject: hivex: patch for read support of "li"-records from "ri"
intermediate
User-Agent: SquirrelMail/1.4.9a
Richard,
Thank you for creating the hivex-library. Studying your source code helped
me a great deal to better understand the internals of the Windows Registry.
However, while I was browsing a real-world SOFTWARE-hive (XP, SP3) I
could not browse to the '\Classes' key. Instead I got this (debug)-message:
get_children: returning ENOTSUP because ri-record offset does not
point to lf/lh (0x49020)
I tracked this issue down and I discovered that the intermediate
"ri"-record may not only contain offsets to "lf" and "lh" but to
"li"-records too.
Attached is a patch against hivex.c v1.3.3 that recognises
"li"-records referenced from "ri"-records. For me this fixed the issue
with browsing the '\Classes' key.
Note that I have not fixed the related problem of rewriting
"li"-records when inserting a new subkey or deleting an
existing one. This sure would cause problems when I were to
add/delete a subkey to/from '\Classes'.
I would very much appreciate it if would be so kind to take a look at
my patch, allthough I cannot blame you if you immediately dump this
unsollicited message+patch from some random stranger from The Netherlands.
Kind regards,
--Peter Fokker
--
Peter Fokker <peter(a)berestijn.nl>
Ingenieursbureau PSD +31 35 695 29 99 / +31 644 238 568
Stargardlaan 7 1404 BC Bussum, The Netherlands
----- End forwarded message -----
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages. http://libguestfs.org
11 years, 11 months
[PATCH] xfs: add new api xfs-growfs
by Wanlong Gao
New api xfs_growfs for expanding a XFS filesystem.
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
daemon/xfs.c | 119 +++++++++++++++++++++++++++++++++++++++++
generator/generator_actions.ml | 15 ++++++
gobject/Makefile.inc | 6 ++-
po/POTFILES | 1 +
src/MAX_PROC_NR | 2 +-
5 files changed, 140 insertions(+), 3 deletions(-)
diff --git a/daemon/xfs.c b/daemon/xfs.c
index e0f0062..97da3f1 100644
--- a/daemon/xfs.c
+++ b/daemon/xfs.c
@@ -348,3 +348,122 @@ error:
free_strings (lines);
return ret;
}
+
+guestfs_int_xfsinfo *
+do_xfs_growfs (const char *path,
+ int datasec, int logsec, int rtsec,
+ int64_t datasize, int64_t logsize, int64_t rtsize,
+ int64_t rtextsize, int32_t maxpct)
+{
+
+#define MAX_ARGS 64
+
+ int r;
+ char *buf;
+ char *out = NULL, *err = NULL;
+ char **lines = NULL;
+ guestfs_int_xfsinfo *ret = NULL;
+ const char *argv[MAX_ARGS];
+ char datasize_s[64];
+ char logsize_s[64];
+ char rtsize_s[64];
+ char rtextsize_s[64];
+ char maxpct_s[32];
+ size_t i = 0;
+
+ buf = sysroot_path (path);
+ if (buf == NULL) {
+ reply_with_perror ("malloc");
+ return NULL;
+ }
+
+ ADD_ARG (argv, i, "xfs_growfs");
+
+ /* Optional arguments */
+ if (!(optargs_bitmask & GUESTFS_XFS_GROWFS_DATASEC_BITMASK))
+ datasec = 0;
+ if (!(optargs_bitmask & GUESTFS_XFS_GROWFS_LOGSEC_BITMASK))
+ logsec = 0;
+ if (!(optargs_bitmask & GUESTFS_XFS_GROWFS_RTSEC_BITMASK))
+ rtsec = 0;
+
+ if (datasec)
+ ADD_ARG (argv, i, "-d");
+ if (logsec)
+ ADD_ARG (argv, i, "-l");
+ if (rtsec)
+ ADD_ARG (argv, i, "-r");
+
+ if (optargs_bitmask & GUESTFS_XFS_GROWFS_DATASIZE_BITMASK) {
+ if (datasize < 0) {
+ reply_with_error ("datasize must be >= 0");
+ goto error;
+ }
+ snprintf (datasize_s, sizeof datasize_s, "%" PRIi64, datasize);
+ ADD_ARG (argv, i, "-D");
+ ADD_ARG (argv, i, datasize_s);
+ }
+
+ if (optargs_bitmask & GUESTFS_XFS_GROWFS_LOGSIZE_BITMASK) {
+ if (logsize < 0) {
+ reply_with_error ("logsize must be >= 0");
+ goto error;
+ }
+ snprintf(logsize_s, sizeof logsize_s, "%" PRIi64, logsize);
+ ADD_ARG (argv, i, "-L");
+ ADD_ARG (argv, i, logsize_s);
+ }
+
+ if (optargs_bitmask & GUESTFS_XFS_GROWFS_RTSIZE_BITMASK) {
+ if (rtsize < 0) {
+ reply_with_error ("rtsize must be >= 0");
+ goto error;
+ }
+ snprintf(rtsize_s, sizeof rtsize_s, "%" PRIi64, rtsize);
+ ADD_ARG (argv, i, "-R");
+ ADD_ARG (argv, i, rtsize_s);
+ }
+
+ if (optargs_bitmask & GUESTFS_XFS_GROWFS_RTEXTSIZE_BITMASK) {
+ if (rtextsize < 0) {
+ reply_with_error ("rtextsize must be >= 0");
+ goto error;
+ }
+ snprintf(rtextsize_s, sizeof rtextsize_s, "%" PRIi64, rtextsize);
+ ADD_ARG (argv, i, "-e");
+ ADD_ARG (argv, i, rtextsize_s);
+ }
+
+ if (optargs_bitmask & GUESTFS_XFS_GROWFS_MAXPCT_BITMASK) {
+ if (maxpct < 0) {
+ reply_with_error ("maxpct must be >= 0");
+ goto error;
+ }
+ snprintf(maxpct_s, sizeof maxpct_s, "%" PRIi32, maxpct);
+ ADD_ARG (argv, i, "-m");
+ ADD_ARG (argv, i, maxpct_s);
+ }
+
+ ADD_ARG (argv, i, buf);
+ ADD_ARG (argv, i, NULL);
+
+ r = commandv (&out, &err, argv);
+ free (buf);
+ if (r == -1) {
+ reply_with_error ("%s: %s", path, err);
+ goto error;
+ }
+
+ lines = split_lines (out);
+ if (lines == NULL)
+ goto error;
+
+ ret = parse_xfs_info (lines);
+
+error:
+ if (buf) free (buf);
+ if (err) free (err);
+ if (out) free (out);
+ if (lines) free_strings (lines);
+ return ret;
+}
diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml
index e4956f7..4d650aa 100644
--- a/generator/generator_actions.ml
+++ b/generator/generator_actions.ml
@@ -9051,6 +9051,21 @@ This returns the kernel version of the appliance, where this is
available. This information is only useful for debugging. Nothing
in the returned structure is defined by the API." };
+ { defaults with
+ name = "xfs_growfs";
+ style = RStruct ("info", "xfsinfo"), [Pathname "path"], [OBool "datasec"; OBool "logsec"; OBool "rtsec"; OInt64 "datasize"; OInt64 "logsize"; OInt64 "rtsize"; OInt64 "rtextsize"; OInt "maxpct"];
+ proc_nr = Some 343;
+ optional = Some "xfs";
+ tests = [];
+ shortdesc = "expand a existing XFS filesystem";
+ longdesc = "\
+The C<path> argument is the pathname of the directory where
+the filesystem is mounted. The filesystem must be mounted to be grown.
+
+The returned struct contains geometry information. Missing
+fields are returned as C<-1> (for numeric fields) or empty
+string." };
+
]
(* Non-API meta-commands available only in guestfish.
diff --git a/gobject/Makefile.inc b/gobject/Makefile.inc
index 7a60933..3129275 100644
--- a/gobject/Makefile.inc
+++ b/gobject/Makefile.inc
@@ -65,7 +65,8 @@ guestfs_gobject_headers= \
include/guestfs-gobject/optargs-mkfs_btrfs.h \
include/guestfs-gobject/optargs-set_e2attrs.h \
include/guestfs-gobject/optargs-btrfs_fsck.h \
- include/guestfs-gobject/optargs-fstrim.h
+ include/guestfs-gobject/optargs-fstrim.h \
+ include/guestfs-gobject/optargs-xfs_growfs.h
guestfs_gobject_sources= \
src/session.c \
@@ -112,4 +113,5 @@ guestfs_gobject_sources= \
src/optargs-mkfs_btrfs.c \
src/optargs-set_e2attrs.c \
src/optargs-btrfs_fsck.c \
- src/optargs-fstrim.c
+ src/optargs-fstrim.c \
+ src/optargs-xfs_growfs.c
diff --git a/po/POTFILES b/po/POTFILES
index cdb873e..ada0da8 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -160,6 +160,7 @@ gobject/src/optargs-set_e2attrs.c
gobject/src/optargs-tune2fs.c
gobject/src/optargs-umount.c
gobject/src/optargs-umount_local.c
+gobject/src/optargs-xfs_growfs.c
gobject/src/session.c
gobject/src/struct-application.c
gobject/src/struct-btrfssubvolume.c
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index c9693eb..fe2cd8b 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-342
+343
--
1.7.12.rc1
12 years, 1 month
[PATCH] fish: Use minimal permissions when initially creating history file
by Matthew Booth
---
fish/fish.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fish/fish.c b/fish/fish.c
index ded80ec..9bb8c90 100644
--- a/fish/fish.c
+++ b/fish/fish.c
@@ -1455,7 +1455,7 @@ cleanup_readline (void)
int fd;
if (histfile[0] != '\0') {
- fd = open (histfile, O_WRONLY|O_CREAT|O_NOCTTY|O_CLOEXEC, 0644);
+ fd = open (histfile, O_WRONLY|O_CREAT|O_NOCTTY|O_CLOEXEC, 0600);
if (fd == -1) {
perror (histfile);
return;
--
1.7.10.4
12 years, 1 month
qemu:could not load kernel
by Giuseppe Calarco
Hi,
I have a problem when i run java examples of libguestfs. It needs root
privileges. This is the output of libguestfs-test-tool:
<libguestfs(a)redhat.com>===== Test starts here =====
LIBGUESTFS_DEBUG=1
TMPDIR=(not set)
libguestfs: new guestfs handle 0x9871c80
library version: 1.14.10
guestfs_get_append: (null)
guestfs_get_attach_method: appliance
guestfs_get_autosync: 1
guestfs_get_direct: 0
guestfs_get_memsize: 500
guestfs_get_network: 0
guestfs_get_path: /usr/local/lib/guestfs
guestfs_get_pgroup: 0
guestfs_get_qemu: /usr/bin/kvm
guestfs_get_recovery_proc: 1
guestfs_get_selinux: 0
guestfs_get_smp: 1
guestfs_get_trace: 0
guestfs_get_verbose: 1
host_cpu: i686
Launching appliance, timeout set to 600 seconds.
libguestfs: [00000ms] febootstrap-supermin-helper --verbose -f checksum
'/usr/local/lib/guestfs/supermin.d' i686
supermin helper [00000ms] whitelist = (not specified), host_cpu = i686,
kernel = (null), initrd = (null), appliance = (null)
supermin helper [00000ms] inputs[0] = /usr/local/lib/guestfs/supermin.d
checking modpath /lib/modules/3.2.0-23-generic-pae is a directory
picked vmlinuz-3.2.0-23-generic-pae because modpath
/lib/modules/3.2.0-23-generic-pae exists
checking modpath /lib/modules/3.2.0-24-generic-pae is a directory
picked vmlinuz-3.2.0-24-generic-pae because modpath
/lib/modules/3.2.0-24-generic-pae exists
checking modpath /lib/modules/3.2.0-26-generic-pae is a directory
picked vmlinuz-3.2.0-26-generic-pae because modpath
/lib/modules/3.2.0-26-generic-pae exists
supermin helper [00000ms] finished creating kernel
supermin helper [00000ms] visiting /usr/local/lib/guestfs/supermin.d
supermin helper [00000ms] visiting
/usr/local/lib/guestfs/supermin.d/base.img
supermin helper [00000ms] visiting
/usr/local/lib/guestfs/supermin.d/daemon.img
supermin helper [00000ms] visiting
/usr/local/lib/guestfs/supermin.d/hostfiles
supermin helper [00022ms] visiting
/usr/local/lib/guestfs/supermin.d/init.img
supermin helper [00022ms] adding kernel modules
supermin helper [00198ms] finished creating appliance
libguestfs: [00200ms] begin testing qemu features
libguestfs: [00229ms] finished testing qemu features
libguestfs: accept_from_daemon: 0x9871c80 g->state = 1
[00234ms] /usr/bin/kvm \
-global virtio-blk-pci.scsi=off \
-drive
file=/tmp/libguestfs-test-tool-sda-AGg9Vg,cache=off,format=raw,if=virtio \
-nodefconfig \
-machine accel=kvm:tcg \
-nodefaults \
-nographic \
-m 500 \
-no-reboot \
-no-hpet \
-device virtio-serial \
-serial stdio \
-chardev socket,path=/tmp/libguestfsZJquQh/guestfsd.sock,id=channel0 \
-device virtserialport,chardev=channel0,name=org.libguestfs.channel.0 \
-kernel /var/tmp/.guestfs-1000/kernel.9392 \
-initrd /var/tmp/.guestfs-1000/initrd.9392 \
-append 'panic=1 console=ttyS0 udevtimeout=300 no_timer_check acpi=off
printk.time=1 cgroup_disable=memory selinux=0 guestfs_verbose=1 TERM=xterm
' \
-drive
file=/var/tmp/.guestfs-1000/root.9392,snapshot=on,if=virtio,cache=unsafeCould
not access KVM kernel module: No such file or directory
failed to initialize KVM: No such file or directory
Back to tcg accelerator.
qemu: could not load kernel '/var/tmp/.guestfs-1000/kernel.9392':
Permission denied
libguestfs: error: unexpected end of file when reading from daemon.
See earlier debug messages.
Or you can run 'libguestfs-test-tool' and post the complete output into
a bug report or message to the libguestfs mailing list.
libguestfs: child_cleanup: 0x9871c80: child process died
libguestfs-test-tool: failed to launch appliance
libguestfs: closing guestfs handle 0x9871c80 (state 0)
I hope that help me. Thanks in advance.
Giuseppe
12 years, 1 month
[PATCH 1/2] sysprep: remove the auto generated abrt data
by Wanlong Gao
remove the automatically generated abrt data.
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
po/POTFILES-ml | 1 +
sysprep/Makefile.am | 2 ++
sysprep/sysprep_operation_abrt_data.ml | 47 ++++++++++++++++++++++++++++++++++
3 files changed, 50 insertions(+)
create mode 100644 sysprep/sysprep_operation_abrt_data.ml
diff --git a/po/POTFILES-ml b/po/POTFILES-ml
index 0adfb8e..1622bf2 100644
--- a/po/POTFILES-ml
+++ b/po/POTFILES-ml
@@ -10,6 +10,7 @@ sparsify/utils.ml
sysprep/main.ml
sysprep/sysprep_gettext.ml
sysprep/sysprep_operation.ml
+sysprep/sysprep_operation_abrt_data.ml
sysprep/sysprep_operation_bash_history.ml
sysprep/sysprep_operation_blkid_tab.ml
sysprep/sysprep_operation_ca_certificates.ml
diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am
index 8c4081a..c82e4f8 100644
--- a/sysprep/Makefile.am
+++ b/sysprep/Makefile.am
@@ -43,6 +43,7 @@ SOURCES = \
sysprep_gettext.ml \
sysprep_operation.ml \
sysprep_operation.mli \
+ sysprep_operation_abrt_data.ml \
sysprep_operation_bash_history.ml \
sysprep_operation_blkid_tab.ml \
sysprep_operation_ca_certificates.ml \
@@ -81,6 +82,7 @@ OBJECTS = \
sysprep_gettext.cmx \
utils.cmx \
sysprep_operation.cmx \
+ sysprep_operation_abrt_data.cmx \
sysprep_operation_bash_history.cmx \
sysprep_operation_blkid_tab.cmx \
sysprep_operation_ca_certificates.cmx \
diff --git a/sysprep/sysprep_operation_abrt_data.ml b/sysprep/sysprep_operation_abrt_data.ml
new file mode 100644
index 0000000..f3fe0e9
--- /dev/null
+++ b/sysprep/sysprep_operation_abrt_data.ml
@@ -0,0 +1,47 @@
+(* virt-sysprep
+ * 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.
+ *)
+
+open Sysprep_operation
+open Sysprep_gettext.Gettext
+
+module G = Guestfs
+
+let abrt_data_perform g root =
+ let typ = g#inspect_get_type root in
+ if typ <> "windows" then (
+ let paths = g#glob_expand "/var/spool/abrt/*" in
+ Array.iter (
+ fun path -> g#rm_rf path;
+ ) paths;
+ g#rm_rf "/root/.ssh";
+ []
+ )
+ else []
+
+let abrt_data_op = {
+ name = "abrt-data";
+ enabled_by_default = true;
+ heading = s_"Remove the crash data generated by ABRT";
+ pod_description = Some (s_"\
+Remove the automatically generated crash data in /var/spool/abrt/
+by ABRT.");
+ extra_args = [];
+ perform = abrt_data_perform;
+}
+
+let () = register_operation abrt_data_op
--
1.7.12.rc0
12 years, 1 month
[PATCH 01/12] configure: Add -nographic command line option to qemu.
by Masami HIRATA
Without this option, configure will fail when there is no display.
Signed-off-by: Masami HIRATA <msmhrt(a)gmail.com>
---
configure.ac | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/configure.ac b/configure.ac
index de8a064..61d6f69 100644
--- a/configure.ac
+++ b/configure.ac
@@ -593,16 +593,16 @@ working.
AC_MSG_FAILURE([$QEMU version must be >= 1.0.])
fi
- AC_MSG_CHECKING([that $QEMU -machine accel=kvm:tcg -device ? works])
- if $QEMU -machine accel=kvm:tcg -device \? >&AS_MESSAGE_LOG_FD 2>&1; then
+ AC_MSG_CHECKING([that $QEMU -nographic -machine accel=kvm:tcg -device ? works])
+ if $QEMU -nographic -machine accel=kvm:tcg -device \? >&AS_MESSAGE_LOG_FD 2>&1; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
- AC_MSG_FAILURE([$QEMU -machine accel=kvm:tcg -device ? doesn't work.])
+ AC_MSG_FAILURE([$QEMU -nographic -machine accel=kvm:tcg -device ? doesn't work.])
fi
AC_MSG_CHECKING([for virtio-serial support in $QEMU])
- if $QEMU $QEMU_OPTIONS -machine accel=kvm:tcg -device \? 2>&1 | grep -sq virtio-serial; then
+ if $QEMU $QEMU_OPTIONS -nographic -machine accel=kvm:tcg -device \? 2>&1 | grep -sq virtio-serial; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
--
1.7.11.1
12 years, 1 month
[PATCH V4 1/3] umount: add force umount and lazy umount
by Wanlong Gao
Add the option force and lazy for force and lazy umount.
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
daemon/mount.c | 25 +++++++++++++++++++++++--
generator/generator_actions.ml | 23 ++++++++++++-----------
gobject/Makefile.inc | 2 ++
po/POTFILES | 1 +
4 files changed, 38 insertions(+), 13 deletions(-)
diff --git a/daemon/mount.c b/daemon/mount.c
index 0661eb8..1ad99fa 100644
--- a/daemon/mount.c
+++ b/daemon/mount.c
@@ -29,6 +29,8 @@
#include "daemon.h"
#include "actions.h"
+#define MAX_ARGS 64
+
/* You must mount something on "/" first before many operations.
* Hence we have an internal function which can test if something is
* mounted on *or under* the sysroot directory. (It has to be *or
@@ -187,12 +189,16 @@ do_mount_options (const char *options, const char *device,
* is kept updated.
*/
int
-do_umount (const char *pathordevice)
+do_umount (const char *pathordevice,
+ int force, int lazyunmount)
{
int r;
char *err;
char *buf;
int is_dev;
+ char prog[] = "umount";
+ const char *argv[MAX_ARGS];
+ size_t i = 0;
is_dev = STREQLEN (pathordevice, "/dev/", 5);
buf = is_dev ? strdup (pathordevice)
@@ -205,7 +211,22 @@ do_umount (const char *pathordevice)
if (is_dev)
RESOLVE_DEVICE (buf, , { free (buf); return -1; });
- r = command (NULL, &err, "umount", buf, NULL);
+ if (!(optargs_bitmask & GUESTFS_UMOUNT_FORCE_BITMASK))
+ force = 0;
+ if (!(optargs_bitmask & GUESTFS_UMOUNT_LAZYUNMOUNT_BITMASK))
+ lazyunmount = 0;
+
+ ADD_ARG (argv, i, prog);
+
+ if (force)
+ ADD_ARG (argv, i, "-f");
+ if (lazyunmount)
+ ADD_ARG (argv, i, "-l");
+
+ ADD_ARG (argv, i, buf);
+ ADD_ARG (argv, i, NULL);
+
+ r = commandv (NULL, &err, argv);
free (buf);
if (r == -1) {
diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml
index 70fd6e3..d512d7c 100644
--- a/generator/generator_actions.ml
+++ b/generator/generator_actions.ml
@@ -2772,9 +2772,10 @@ characters does I<not> work, even if the length is specified." };
{ defaults with
name = "umount";
- style = RErr, [String "pathordevice"], [];
+ style = RErr, [String "pathordevice"], [OBool "force"; OBool "lazyunmount"];
proc_nr = Some 45;
fish_alias = ["unmount"];
+ once_had_no_optargs = true;
tests = [
InitEmpty, Always, TestOutputListOfDevices (
[["part_disk"; "/dev/sda"; "mbr"];
@@ -2785,7 +2786,7 @@ characters does I<not> work, even if the length is specified." };
[["part_disk"; "/dev/sda"; "mbr"];
["mkfs"; "ext2"; "/dev/sda1"; ""; "NOARG"; ""; ""];
["mount_options"; ""; "/dev/sda1"; "/"];
- ["umount"; "/"];
+ ["umount"; "/"; "false"; "false"];
["mounts"]], [])
];
shortdesc = "unmount a filesystem";
@@ -3467,12 +3468,12 @@ To download an uncompressed tarball, use C<guestfs_tar_out>." };
proc_nr = Some 73;
tests = [
InitBasicFS, Always, TestLastFail (
- [["umount"; "/"];
+ [["umount"; "/"; "false"; "false"];
["mount_ro"; "/dev/sda1"; "/"];
["touch"; "/new"]]);
InitBasicFS, Always, TestOutput (
[["write"; "/new"; "data"];
- ["umount"; "/"];
+ ["umount"; "/"; "false"; "false"];
["mount_ro"; "/dev/sda1"; "/"];
["cat"; "/new"]], "data")
];
@@ -3715,10 +3716,10 @@ C<device>." };
fish_output = Some FishOutputHexadecimal;
tests = [
InitBasicFS, Always, TestOutputInt (
- [["umount"; "/dev/sda1"];
+ [["umount"; "/dev/sda1"; "false"; "false"];
["fsck"; "ext2"; "/dev/sda1"]], 0);
InitBasicFS, Always, TestOutputInt (
- [["umount"; "/dev/sda1"];
+ [["umount"; "/dev/sda1"; "false"; "false"];
["zero"; "/dev/sda1"];
["fsck"; "ext2"; "/dev/sda1"]], 8)
];
@@ -3759,7 +3760,7 @@ This command is entirely equivalent to running C<fsck -a -t fstype device>." };
progress = true;
tests = [
InitBasicFS, Always, TestRun (
- [["umount"; "/dev/sda1"];
+ [["umount"; "/dev/sda1"; "false"; "false"];
["zero"; "/dev/sda1"]])
];
shortdesc = "write zeroes to the device";
@@ -4081,7 +4082,7 @@ the human-readable, canonical hex dump of the file." };
["mkfs"; "ext3"; "/dev/sda1"; ""; "NOARG"; ""; ""];
["mount_options"; ""; "/dev/sda1"; "/"];
["write"; "/new"; "test file"];
- ["umount"; "/dev/sda1"];
+ ["umount"; "/dev/sda1"; "false"; "false"];
["zerofree"; "/dev/sda1"];
["mount_options"; ""; "/dev/sda1"; "/"];
["cat"; "/new"]], "test file")
@@ -4205,7 +4206,7 @@ are activated or deactivated." };
["mkfs"; "ext2"; "/dev/VG/LV"; ""; "NOARG"; ""; ""];
["mount_options"; ""; "/dev/VG/LV"; "/"];
["write"; "/new"; "test content"];
- ["umount"; "/"];
+ ["umount"; "/"; "false"; "false"];
["lvresize"; "/dev/VG/LV"; "20"];
["e2fsck_f"; "/dev/VG/LV"];
["e2fsck"; "/dev/VG/LV"; "true"; "false"];
@@ -6564,7 +6565,7 @@ Rename a logical volume C<logvol> with the new name C<newlogvol>." };
proc_nr = Some 220;
tests = [
InitBasicFSonLVM, Always, TestOutputList (
- [["umount"; "/"];
+ [["umount"; "/"; "false"; "false"];
["vg_activate"; "false"; "VG"];
["vgrename"; "VG"; "VG2"];
["vg_activate"; "true"; "VG2"];
@@ -7685,7 +7686,7 @@ it contains all zero bytes." };
proc_nr = Some 284;
tests = [
InitBasicFS, Always, TestOutputTrue (
- [["umount"; "/dev/sda1"];
+ [["umount"; "/dev/sda1"; "false"; "false"];
["zero_device"; "/dev/sda1"];
["is_zero_device"; "/dev/sda1"]]);
InitBasicFS, Always, TestOutputFalse (
diff --git a/gobject/Makefile.inc b/gobject/Makefile.inc
index c73e5df..230d114 100644
--- a/gobject/Makefile.inc
+++ b/gobject/Makefile.inc
@@ -45,6 +45,7 @@ guestfs_gobject_headers= \
include/guestfs-gobject/optargs-inspect_get_icon.h \
include/guestfs-gobject/optargs-mount_local.h \
include/guestfs-gobject/optargs-umount_local.h \
+ include/guestfs-gobject/optargs-umount.h \
include/guestfs-gobject/optargs-mkfs.h \
include/guestfs-gobject/optargs-mount_9p.h \
include/guestfs-gobject/optargs-ntfsresize.h \
@@ -90,6 +91,7 @@ guestfs_gobject_sources= \
src/optargs-inspect_get_icon.c \
src/optargs-mount_local.c \
src/optargs-umount_local.c \
+ src/optargs-umount.c \
src/optargs-mkfs.c \
src/optargs-mount_9p.c \
src/optargs-ntfsresize.c \
diff --git a/po/POTFILES b/po/POTFILES
index ad00cd4..228aa39 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -157,6 +157,7 @@ gobject/src/optargs-ntfsfix.c
gobject/src/optargs-ntfsresize.c
gobject/src/optargs-set_e2attrs.c
gobject/src/optargs-tune2fs.c
+gobject/src/optargs-umount.c
gobject/src/optargs-umount_local.c
gobject/src/session.c
gobject/src/struct-application.c
--
1.7.12.rc0
12 years, 1 month
[PATCH V3 1/2] umount: add force umount and lazy umount
by Wanlong Gao
Add the option force and lazy for force and lazy umount.
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
daemon/mount.c | 25 +++++++++++++++++++++++--
generator/generator_actions.ml | 23 ++++++++++++-----------
gobject/Makefile.inc | 2 ++
po/POTFILES | 1 +
4 files changed, 38 insertions(+), 13 deletions(-)
diff --git a/daemon/mount.c b/daemon/mount.c
index 0661eb8..1ad99fa 100644
--- a/daemon/mount.c
+++ b/daemon/mount.c
@@ -29,6 +29,8 @@
#include "daemon.h"
#include "actions.h"
+#define MAX_ARGS 64
+
/* You must mount something on "/" first before many operations.
* Hence we have an internal function which can test if something is
* mounted on *or under* the sysroot directory. (It has to be *or
@@ -187,12 +189,16 @@ do_mount_options (const char *options, const char *device,
* is kept updated.
*/
int
-do_umount (const char *pathordevice)
+do_umount (const char *pathordevice,
+ int force, int lazyunmount)
{
int r;
char *err;
char *buf;
int is_dev;
+ char prog[] = "umount";
+ const char *argv[MAX_ARGS];
+ size_t i = 0;
is_dev = STREQLEN (pathordevice, "/dev/", 5);
buf = is_dev ? strdup (pathordevice)
@@ -205,7 +211,22 @@ do_umount (const char *pathordevice)
if (is_dev)
RESOLVE_DEVICE (buf, , { free (buf); return -1; });
- r = command (NULL, &err, "umount", buf, NULL);
+ if (!(optargs_bitmask & GUESTFS_UMOUNT_FORCE_BITMASK))
+ force = 0;
+ if (!(optargs_bitmask & GUESTFS_UMOUNT_LAZYUNMOUNT_BITMASK))
+ lazyunmount = 0;
+
+ ADD_ARG (argv, i, prog);
+
+ if (force)
+ ADD_ARG (argv, i, "-f");
+ if (lazyunmount)
+ ADD_ARG (argv, i, "-l");
+
+ ADD_ARG (argv, i, buf);
+ ADD_ARG (argv, i, NULL);
+
+ r = commandv (NULL, &err, argv);
free (buf);
if (r == -1) {
diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml
index 74f76bb..1a89b0e 100644
--- a/generator/generator_actions.ml
+++ b/generator/generator_actions.ml
@@ -2749,9 +2749,10 @@ characters does I<not> work, even if the length is specified." };
{ defaults with
name = "umount";
- style = RErr, [String "pathordevice"], [];
+ style = RErr, [String "pathordevice"], [OBool "force"; OBool "lazyunmount"];
proc_nr = Some 45;
fish_alias = ["unmount"];
+ once_had_no_optargs = true;
tests = [
InitEmpty, Always, TestOutputListOfDevices (
[["part_disk"; "/dev/sda"; "mbr"];
@@ -2762,7 +2763,7 @@ characters does I<not> work, even if the length is specified." };
[["part_disk"; "/dev/sda"; "mbr"];
["mkfs"; "ext2"; "/dev/sda1"; ""; "NOARG"; ""; ""];
["mount_options"; ""; "/dev/sda1"; "/"];
- ["umount"; "/"];
+ ["umount"; "/"; "false"; "false"];
["mounts"]], [])
];
shortdesc = "unmount a filesystem";
@@ -3444,12 +3445,12 @@ To download an uncompressed tarball, use C<guestfs_tar_out>." };
proc_nr = Some 73;
tests = [
InitBasicFS, Always, TestLastFail (
- [["umount"; "/"];
+ [["umount"; "/"; "false"; "false"];
["mount_ro"; "/dev/sda1"; "/"];
["touch"; "/new"]]);
InitBasicFS, Always, TestOutput (
[["write"; "/new"; "data"];
- ["umount"; "/"];
+ ["umount"; "/"; "false"; "false"];
["mount_ro"; "/dev/sda1"; "/"];
["cat"; "/new"]], "data")
];
@@ -3692,10 +3693,10 @@ C<device>." };
fish_output = Some FishOutputHexadecimal;
tests = [
InitBasicFS, Always, TestOutputInt (
- [["umount"; "/dev/sda1"];
+ [["umount"; "/dev/sda1"; "false"; "false"];
["fsck"; "ext2"; "/dev/sda1"]], 0);
InitBasicFS, Always, TestOutputInt (
- [["umount"; "/dev/sda1"];
+ [["umount"; "/dev/sda1"; "false"; "false"];
["zero"; "/dev/sda1"];
["fsck"; "ext2"; "/dev/sda1"]], 8)
];
@@ -3736,7 +3737,7 @@ This command is entirely equivalent to running C<fsck -a -t fstype device>." };
progress = true;
tests = [
InitBasicFS, Always, TestRun (
- [["umount"; "/dev/sda1"];
+ [["umount"; "/dev/sda1"; "false"; "false"];
["zero"; "/dev/sda1"]])
];
shortdesc = "write zeroes to the device";
@@ -4058,7 +4059,7 @@ the human-readable, canonical hex dump of the file." };
["mkfs"; "ext3"; "/dev/sda1"; ""; "NOARG"; ""; ""];
["mount_options"; ""; "/dev/sda1"; "/"];
["write"; "/new"; "test file"];
- ["umount"; "/dev/sda1"];
+ ["umount"; "/dev/sda1"; "false"; "false"];
["zerofree"; "/dev/sda1"];
["mount_options"; ""; "/dev/sda1"; "/"];
["cat"; "/new"]], "test file")
@@ -4182,7 +4183,7 @@ are activated or deactivated." };
["mkfs"; "ext2"; "/dev/VG/LV"; ""; "NOARG"; ""; ""];
["mount_options"; ""; "/dev/VG/LV"; "/"];
["write"; "/new"; "test content"];
- ["umount"; "/"];
+ ["umount"; "/"; "false"; "false"];
["lvresize"; "/dev/VG/LV"; "20"];
["e2fsck_f"; "/dev/VG/LV"];
["e2fsck"; "/dev/VG/LV"; "true"; "false"];
@@ -6541,7 +6542,7 @@ Rename a logical volume C<logvol> with the new name C<newlogvol>." };
proc_nr = Some 220;
tests = [
InitBasicFSonLVM, Always, TestOutputList (
- [["umount"; "/"];
+ [["umount"; "/"; "false"; "false"];
["vg_activate"; "false"; "VG"];
["vgrename"; "VG"; "VG2"];
["vg_activate"; "true"; "VG2"];
@@ -7662,7 +7663,7 @@ it contains all zero bytes." };
proc_nr = Some 284;
tests = [
InitBasicFS, Always, TestOutputTrue (
- [["umount"; "/dev/sda1"];
+ [["umount"; "/dev/sda1"; "false"; "false"];
["zero_device"; "/dev/sda1"];
["is_zero_device"; "/dev/sda1"]]);
InitBasicFS, Always, TestOutputFalse (
diff --git a/gobject/Makefile.inc b/gobject/Makefile.inc
index c73e5df..230d114 100644
--- a/gobject/Makefile.inc
+++ b/gobject/Makefile.inc
@@ -45,6 +45,7 @@ guestfs_gobject_headers= \
include/guestfs-gobject/optargs-inspect_get_icon.h \
include/guestfs-gobject/optargs-mount_local.h \
include/guestfs-gobject/optargs-umount_local.h \
+ include/guestfs-gobject/optargs-umount.h \
include/guestfs-gobject/optargs-mkfs.h \
include/guestfs-gobject/optargs-mount_9p.h \
include/guestfs-gobject/optargs-ntfsresize.h \
@@ -90,6 +91,7 @@ guestfs_gobject_sources= \
src/optargs-inspect_get_icon.c \
src/optargs-mount_local.c \
src/optargs-umount_local.c \
+ src/optargs-umount.c \
src/optargs-mkfs.c \
src/optargs-mount_9p.c \
src/optargs-ntfsresize.c \
diff --git a/po/POTFILES b/po/POTFILES
index ad00cd4..228aa39 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -157,6 +157,7 @@ gobject/src/optargs-ntfsfix.c
gobject/src/optargs-ntfsresize.c
gobject/src/optargs-set_e2attrs.c
gobject/src/optargs-tune2fs.c
+gobject/src/optargs-umount.c
gobject/src/optargs-umount_local.c
gobject/src/session.c
gobject/src/struct-application.c
--
1.7.11.3.287.ge771946
12 years, 1 month
[PATCH libguestfs 0/4] Add a libvirt backend to libguestfs.
by Richard W.M. Jones
This preliminary patch series adds a libvirt backend to libguestfs.
It's for review only because although it launches the guest OK, there
are some missing features that need to be implemented.
The meat of the patch is in part 4/4.
To save you the trouble of interpreting libxml2 fragments, an example
of the generated XML and the corresponding qemu command line are
attached below. Note the hack required to work around lack of support
for '-drive [...]snapshot=on'
Some questions:
- I've tried to use the minimum set of XML possible to create the
guest, leaving libvirt to fill out as much as possible. How does
this XML look?
- The <name> is mandatory, and I generate one randomly. Is this a
good idea? I notice that my $HOME/.libvirt directory fills up with
random files. Really I'd like libvirt to generate a random name and
just deal with the logfiles.
- How do we query libvirt to find out if qemu supports virtio-scsi?
- Will <source file> work if the source is a host device?
- Since when has <memory unit> attribute been available? For example,
is it available in RHEL 6?
- I'm using type="kvm" and I've only tested this on baremetal, but I
don't want to force KVM. If only software emulation is available,
I'd like to use it.
- Is there an easy way to get -cpu host? Although I have the libvirt
capabilities, I'd prefer not to have to parse it if I can avoid
that, since libxml2 from C is so arcane.
Comments:
- <source mode> attribute is undocumented.
Rich.
----------------------------------------------------------------------
<?xml version="1.0"?>
<domain type="kvm" xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0">
<name>1dhdpe3sb9ub2vxd</name>
<memory unit="MiB">500</memory>
<currentMemory unit="MiB">500</currentMemory>
<vcpu>1</vcpu>
<clock offset="utc"/>
<os>
<type>hvm</type>
<kernel>/home/rjones/d/libguestfs/.guestfs-500/kernel.3198</kernel>
<initrd>/home/rjones/d/libguestfs/.guestfs-500/initrd.3198</initrd>
<cmdline>panic=1 console=ttyS0 udevtimeout=600 no_timer_check acpi=off printk.time=1 cgroup_disable=memory root=/dev/sdb selinux=0 guestfs_verbose=1 TERM=xterm </cmdline>
</os>
<devices>
<controller type="scsi" index="0" model="virtio-scsi"/>
<disk type="file" device="disk">
<source file="/home/rjones/d/libguestfs/test1.img"/>
<target dev="sda" bus="scsi"/>
<driver name="qemu" format="raw" cache="none"/>
<address type="drive" controller="0" bus="0" target="0" unit="0"/>
</disk>
<disk type="file" device="disk">
<source file="/home/rjones/d/libguestfs/.guestfs-500/root.3198"/>
<target dev="sdb" bus="scsi"/>
<driver name="qemu" format="raw" cache="unsafe"/>
<address type="drive" controller="0" bus="0" target="1" unit="0"/>
</disk>
<channel type="unix">
<source mode="bind" path="/home/rjones/d/libguestfs/libguestfsSSg3Kl/guestfsd.sock"/>
<target type="virtio" name="org.libguestfs.channel.0"/>
</channel>
</devices>
<qemu:commandline>
<qemu:arg value="-set"/>
<qemu:arg value="drive.drive-scsi0-0-1-0.snapshot=on"/>
</qemu:commandline>
</domain>
/usr/bin/qemu-kvm -S -M pc-1.1 -enable-kvm -m 500 -smp 1,sockets=1,cores=1,threads=1 -name 1dhdpe3sb9ub2vxd -uuid efcc8ab8-7193-da14-a72c-acbb82a1b975 -nographic -nodefconfig -nodefaults -chardev socket,id=charmonitor,path=/home/rjones/.libvirt/qemu/lib/1dhdpe3sb9ub2vxd.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -no-acpi -kernel /home/rjones/d/libguestfs/.guestfs-500/kernel.3198 -initrd /home/rjones/d/libguestfs/.guestfs-500/initrd.3198 -append panic=1 console=ttyS0 udevtimeout=600 no_timer_check acpi=off printk.time=1 cgroup_disable=memory root=/dev/sdb selinux=0 guestfs_verbose=1 TERM=xterm -device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x4 -drive file=/home/rjones/d/libguestfs/test1.img,if=none,id=drive-scsi0-0-0-0,format=raw,cache=none -device scsi-disk,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=driv!
e-scsi0-0-0-0,id=scsi0-0-0-0,bootindex=1 -drive file=/home/rjones/d/libguestfs/.guestfs-500/root.3198,if=none,id=drive-scsi0-0-1-0,format=raw,cache=unsafe -device scsi-disk,bus=scsi0.0,channel=0,scsi-id=1,lun=0,drive=drive-scsi0-0-1-0,id=scsi0-0-1-0 -chardev socket,id=charchannel0,path=/home/rjones/d/libguestfs/libguestfsSSg3Kl/guestfsd.sock,server,nowait -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=org.libguestfs.channel.0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 -set drive.drive-scsi0-0-1-0.snapshot=on
12 years, 1 month