[PATCH] perl: tests: reenable set_path tests
by Pino Toscano
guestfs_set_path now does a copy of the passed string, so bindings don't
need to take care of the lifetime of strings parameters for it.
---
perl/t/060-handle-properties.t | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/perl/t/060-handle-properties.t b/perl/t/060-handle-properties.t
index 0057503..6b1ee42 100644
--- a/perl/t/060-handle-properties.t
+++ b/perl/t/060-handle-properties.t
@@ -17,7 +17,7 @@
use strict;
use warnings;
-use Test::More tests => 7;
+use Test::More tests => 9;
use Sys::Guestfs;
@@ -33,13 +33,10 @@ ok ($g->get_autosync () == 1, "autosync not true");
$g->set_autosync (0);
ok ($g->get_autosync () == 0, "autosync not false");
-# This probably doesn't work at the moment because
-# the binding for set_path does not ensure the string
-# remains around for the lifetime of the handle.
-#$g->set_path (".");
-#ok ($g->get_path () eq ".", "path not dot");
-#$g->set_path (undef);
-#ok ($g->get_path () ne "", "path is empty");
+$g->set_path (".");
+ok ($g->get_path () eq ".", "path not dot");
+$g->set_path (undef);
+ok ($g->get_path () ne "", "path is empty");
$g->add_drive ("/dev/null");
ok (1, "add drive");
--
1.9.3
9 years, 9 months
resize: Preserve GPT GUID so we don't break EFI bootloaders (RHBZ#1189284)
by Richard W.M. Jones
virt-resize didn't preserve the per-partition GPT GUID.
Now that guests using UEFI are becoming common (basically it's the
default on aarch64) we need to take into account that sometimes the
partition GUID is used by the bootloader NVRAM variables to identify
the boot partition, so it must be preserved across resize.
This bug caused the 'virt-builder --size' option to fail on aarch64.
Rich.
9 years, 9 months
[PATCH] btrfs: fix parsing of output of 'btrfs qgroup show' (RHBZ#1188553)
by Hu Tao
'btrfs qgroup show' used to output bytes in raw, but in
btrfs-progs v3.18.2 it outputs bytes with suffix KiB, MiB
or like by default, which causes error when parsing the output.
Fix it by adding '--raw' to let 'btrfs qgroup show' output raw numbers
always.
Signed-off-by: Hu Tao <hutao(a)cn.fujitsu.com>
---
daemon/btrfs.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 5cab52a..402b7de 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -1231,6 +1231,7 @@ do_btrfs_qgroup_show (const char *path)
ADD_ARG (argv, i, str_btrfs);
ADD_ARG (argv, i, "qgroup");
ADD_ARG (argv, i, "show");
+ ADD_ARG (argv, i, "--raw");
ADD_ARG (argv, i, path_buf);
ADD_ARG (argv, i, NULL);
@@ -1240,6 +1241,9 @@ do_btrfs_qgroup_show (const char *path)
return NULL;
}
+ if (verbose)
+ fprintf (stderr, "output of 'btrfs qgroup show %s' is:\n%s\n", path_buf, out);
+
lines = split_lines (out);
if (!lines)
return NULL;
--
2.1.0
9 years, 9 months
Re: [Libguestfs] make install ignoring PREFIX for bash_completion
by Richard W.M. Jones
> Date: Tue, 3 Feb 2015 09:36:01 -0800
> Subject: make install ignoring PREFIX for bash_completion
>
> I am trying to install the libguestfs python bindings in my
> virtualenv. Since this cannot be done through PIP,
The PIP problem is https://bugzilla.redhat.com/show_bug.cgi?id=1075594
Unfortunately we are stuck here because the pypi website still has a
license that we cannot live with (it would have the effect of
assigning all work we upload to them). They have said this is not
their intention, but declined to do anything about the actual wording.
> I was trying to do
> the following:
>
> https://github.com/libguestfs/libguestfs/commit/fcbfc4775fa2a440209740735...
>
> To get to building the python dist, I did the following:
>
> git clone https://github.com/libguestfs/libguestfs.git
> git checkout 1.28.5
> ./autogen.sh --disable-php --disable-ruby --disable-gobject
> --disable-golang --disable-erlang --disable-lua
> --prefix=/home/dev/venv
> make
> rm po-docs/podfiles; make -C po-docs update-po
> make
> make -C python sdist
> make install
>
> However at the "make install" step, I get the following error:
>
> make[2]: Entering directory '/home/dev/libguestfs/bash'
> make[2]: Nothing to be done for 'install-exec-am'.
> /bin/mkdir -p /usr/share/bash-completion/completions
> cp -d guestfish guestmount virt-alignment-scan virt-rescue virt-resize
> virt-builder virt-cat virt-df virt-edit virt-filesystems virt-format
> virt-inspector virt-log virt-ls virt-sparsify virt-sysprep
> /usr/share/bash-completion/completions
> cp: cannot create regular file
> '/usr/share/bash-completion/completions/guestfish': Permission denied
> cp: cannot create regular file
> '/usr/share/bash-completion/completions/guestmount': Permission denied
> cp: cannot create regular file
> '/usr/share/bash-completion/completions/virt-alignment-scan':
> Permission denied
> cp: cannot create regular file
> '/usr/share/bash-completion/completions/virt-rescue': Permission
> denied
> cp: cannot create regular file
> '/usr/share/bash-completion/completions/virt-resize': Permission
> denied
> cp: cannot remove
> '/usr/share/bash-completion/completions/virt-builder': Permission
> denied
> cp: cannot remove '/usr/share/bash-completion/completions/virt-cat':
> Permission denied
> cp: cannot remove '/usr/share/bash-completion/completions/virt-df':
> Permission denied
> cp: cannot remove '/usr/share/bash-completion/completions/virt-edit':
> Permission denied
> cp: cannot remove
> '/usr/share/bash-completion/completions/virt-filesystems': Permission
> denied
> cp: cannot remove
> '/usr/share/bash-completion/completions/virt-format': Permission
> denied
> cp: cannot remove
> '/usr/share/bash-completion/completions/virt-inspector': Permission
> denied
> cp: cannot remove '/usr/share/bash-completion/completions/virt-log':
> Permission denied
> cp: cannot remove '/usr/share/bash-completion/completions/virt-ls':
> Permission denied
> cp: cannot remove
> '/usr/share/bash-completion/completions/virt-sparsify': Permission
> denied
> cp: cannot remove
> '/usr/share/bash-completion/completions/virt-sysprep': Permission
> denied
> Makefile:1671: recipe for target 'install-data-local' failed
> make[2]: *** [install-data-local] Error 1
>
>
> Why is the install process trying to copy files in to /usr/share/ and
> not /home/dev/venv/usr/share/? Am I doing something wrong or is there
> a workaround for this?
After trying './configure --prefix=/tmp && make && make install' I see
there's a disturbingly large number of problems/bugs in this area ...
The configure script only uses --prefix so far, but frequently
overrides it. eg: OCaml scripts are always installed in
`ocamlc -where' and in the case above bash-completion scripts are
always installed in `pkg-config --variable=completionsdir bash-completion'.
I guess whether you think this is a bug or a feature depends on your
point of view ...
After using 'python sdist', can't you use the tarball (in python/dist)
in order to create a venv directly?
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
9 years, 9 months
make install ignoring PREFIX for bash_completion
by AP
I am trying to install the libguestfs python bindings in my
virtualenv. Since this cannot be done through PIP, I was trying to do
the following:
https://github.com/libguestfs/libguestfs/commit/fcbfc4775fa2a440209740735...
To get to building the python dist, I did the following:
git clone https://github.com/libguestfs/libguestfs.git
git checkout 1.28.5
./autogen.sh --disable-php --disable-ruby --disable-gobject
--disable-golang --disable-erlang --disable-lua
--prefix=/home/dev/venv
make
rm po-docs/podfiles; make -C po-docs update-po
make
make -C python sdist
make install
However at the "make install" step, I get the following error:
make[2]: Entering directory '/home/dev/libguestfs/bash'
make[2]: Nothing to be done for 'install-exec-am'.
/bin/mkdir -p /usr/share/bash-completion/completions
cp -d guestfish guestmount virt-alignment-scan virt-rescue virt-resize
virt-builder virt-cat virt-df virt-edit virt-filesystems virt-format
virt-inspector virt-log virt-ls virt-sparsify virt-sysprep
/usr/share/bash-completion/completions
cp: cannot create regular file
'/usr/share/bash-completion/completions/guestfish': Permission denied
cp: cannot create regular file
'/usr/share/bash-completion/completions/guestmount': Permission denied
cp: cannot create regular file
'/usr/share/bash-completion/completions/virt-alignment-scan':
Permission denied
cp: cannot create regular file
'/usr/share/bash-completion/completions/virt-rescue': Permission
denied
cp: cannot create regular file
'/usr/share/bash-completion/completions/virt-resize': Permission
denied
cp: cannot remove
'/usr/share/bash-completion/completions/virt-builder': Permission
denied
cp: cannot remove '/usr/share/bash-completion/completions/virt-cat':
Permission denied
cp: cannot remove '/usr/share/bash-completion/completions/virt-df':
Permission denied
cp: cannot remove '/usr/share/bash-completion/completions/virt-edit':
Permission denied
cp: cannot remove
'/usr/share/bash-completion/completions/virt-filesystems': Permission
denied
cp: cannot remove
'/usr/share/bash-completion/completions/virt-format': Permission
denied
cp: cannot remove
'/usr/share/bash-completion/completions/virt-inspector': Permission
denied
cp: cannot remove '/usr/share/bash-completion/completions/virt-log':
Permission denied
cp: cannot remove '/usr/share/bash-completion/completions/virt-ls':
Permission denied
cp: cannot remove
'/usr/share/bash-completion/completions/virt-sparsify': Permission
denied
cp: cannot remove
'/usr/share/bash-completion/completions/virt-sysprep': Permission
denied
Makefile:1671: recipe for target 'install-data-local' failed
make[2]: *** [install-data-local] Error 1
Why is the install process trying to copy files in to /usr/share/ and
not /home/dev/venv/usr/share/? Am I doing something wrong or is there
a workaround for this?
Thanks,
AP
9 years, 9 months
[PATCH v2 0/2] add btrfs_balance_status and btrfs_scrub_status
by Hu Tao
changes in v2:
- add check for the length of lines[]
- the code parsing 'btrfs scrub -R status' output is changed into a loop
Hu Tao (2):
New API: btrfs_balance_status
New API: btfs_scrub_status.
daemon/btrfs.c | 263 +++++++++++++++++++++++++++++++
generator/actions.ml | 26 +++
generator/structs.ml | 34 ++++
gobject/Makefile.inc | 4 +
java/Makefile.inc | 2 +
java/com/redhat/et/libguestfs/.gitignore | 2 +
po/POTFILES | 2 +
src/MAX_PROC_NR | 2 +-
8 files changed, 334 insertions(+), 1 deletion(-)
--
2.1.0
9 years, 9 months
[PATCH 1/2] New API: btrfs_balance_status
by Hu Tao
Signed-off-by: Hu Tao <hutao(a)cn.fujitsu.com>
---
These two patches are refactored to parse the output info structures.
daemon/btrfs.c | 109 +++++++++++++++++++++++++++++++
generator/actions.ml | 10 +++
generator/structs.ml | 12 ++++
gobject/Makefile.inc | 2 +
java/Makefile.inc | 1 +
java/com/redhat/et/libguestfs/.gitignore | 1 +
po/POTFILES | 1 +
src/MAX_PROC_NR | 2 +-
8 files changed, 137 insertions(+), 1 deletion(-)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 796eaff..bb82f32 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -1659,3 +1659,112 @@ do_btrfs_rescue_super_recover (const char *device)
return 0;
}
+
+guestfs_int_btrfsbalance *
+do_btrfs_balance_status (const char *path)
+{
+ const size_t MAX_ARGS = 64;
+ const char *argv[MAX_ARGS];
+ size_t i = 0;
+ CLEANUP_FREE char *path_buf = NULL;
+ CLEANUP_FREE char *err = NULL;
+ char *out;
+ int r;
+ guestfs_int_btrfsbalance *ret;
+ char **lines;
+ const char *errptr;
+ int erroffset;
+#define N_MATCH 2
+ int ovector[N_MATCH * 3];
+ pcre *re = NULL;
+
+ path_buf = sysroot_path (path);
+ if (path_buf == NULL) {
+ reply_with_perror ("malloc");
+ return NULL;
+ }
+
+ ADD_ARG (argv, i, str_btrfs);
+ ADD_ARG (argv, i, "balance");
+ ADD_ARG (argv, i, "status");
+ ADD_ARG (argv, i, path_buf);
+ ADD_ARG (argv, i, NULL);
+
+ r = commandv (&out, &err, argv);
+ if (r == -1) {
+ reply_with_error ("%s: %s", path, err);
+ return NULL;
+ }
+
+ lines = split_lines (out);
+ if (!lines)
+ return NULL;
+
+ ret = malloc(sizeof *ret);
+ if (ret == NULL) {
+ reply_with_perror ("malloc");
+ goto error;
+ }
+ memset (ret, 0, sizeof(*ret));
+
+ /* Output of `btrfs balance status' is like:
+ *
+ * running:
+ *
+ * Balance on '/' is running
+ * 3 out of about 8 chunks balanced (3 considered), 62% left
+ *
+ * paused:
+ *
+ * Balance on '/' is paused
+ * 3 out of about 8 chunks balanced (3 considered), 62% left
+ *
+ * no balance running:
+ *
+ * No Balance found on '/'
+ *
+ */
+ if (strstr (lines[0], "No balance found on")) {
+ ret->btrfsbalance_status = strdup("none");
+ return ret;
+ }
+
+ re = pcre_compile ("Balance on '.*' is (.*)", 0, &errptr, &erroffset, NULL);
+ if (re == NULL) {
+ reply_with_error ("pcre_compile (%i): %s", erroffset, errptr);
+ goto error;
+ }
+ if (pcre_exec (re, NULL, lines[0], strlen (lines[0]), 0, 0,
+ ovector, N_MATCH * 3) < 0) {
+ reply_with_error ("unexpected output from 'btrfs balance status' command: %s", lines[0]);
+ goto error;
+ }
+#undef N_MATCH
+
+ if (STREQ (lines[0] + ovector[2], "running"))
+ ret->btrfsbalance_status = strdup("running");
+ else if (STREQ (lines[0] + ovector[2], "paused"))
+ ret->btrfsbalance_status = strdup("paused");
+ else {
+ reply_with_error ("unexpected output from 'btrfs balance status' command: %s", lines[0]);
+ goto error;
+ }
+
+ if (sscanf (lines[1], "%" SCNu64 " out of about %" SCNu64
+ " chunks balanced (%" SCNu64 " considered), %" SCNu64 "%% left",
+ &ret->btrfsbalance_balanced, &ret->btrfsbalance_total,
+ &ret->btrfsbalance_considered, &ret->btrfsbalance_left) != 4) {
+ reply_with_perror ("sscanf");
+ goto error;
+ }
+
+ pcre_free (re);
+ return ret;
+
+error:
+ free (ret->btrfsbalance_status);
+ free (ret);
+ pcre_free (re);
+
+ return NULL;
+}
diff --git a/generator/actions.ml b/generator/actions.ml
index c0beaae..f943ecb 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12385,6 +12385,16 @@ Recover the chunk tree of btrfs filesystem by scannning the devices one by one."
longdesc = "\
Recover bad superblocks from good copies." };
+{ defaults with
+ name = "btrfs_balance_status";
+ style = RStruct ("status", "btrfsbalance"), [Pathname "path"], [];
+ proc_nr = Some 446;
+ optional = Some "btrfs"; camel_name = "BTRFSBalanceStatus";
+ test_excuse = "test disk isn't large enough that btrfs_balance completes before we can get its status";
+ shortdesc = "show the status of a running or paused balance";
+ longdesc = "\
+Show the status of a running or paused balance on a btrfs filesystem." };
+
]
(* Non-API meta-commands available only in guestfish.
diff --git a/generator/structs.ml b/generator/structs.ml
index 5b466a2..af42529 100644
--- a/generator/structs.ml
+++ b/generator/structs.ml
@@ -340,6 +340,18 @@ let structs = [
];
s_camel_name = "BTRFSQgroup" };
+ (* btrfs balance status output *)
+ { defaults with
+ s_name = "btrfsbalance";
+ s_cols = [
+ "btrfsbalance_status", FString;
+ "btrfsbalance_total", FUInt64;
+ "btrfsbalance_balanced", FUInt64;
+ "btrfsbalance_considered", FUInt64;
+ "btrfsbalance_left", FUInt64;
+ ];
+ s_camel_name = "BTRFSBalance" };
+
(* XFS info descriptor. *)
{ defaults with
s_name = "xfsinfo";
diff --git a/gobject/Makefile.inc b/gobject/Makefile.inc
index e0c0a5f..3ce10f9 100644
--- a/gobject/Makefile.inc
+++ b/gobject/Makefile.inc
@@ -25,6 +25,7 @@ guestfs_gobject_headers= \
include/guestfs-gobject/tristate.h \
include/guestfs-gobject/struct-application.h \
include/guestfs-gobject/struct-application2.h \
+ include/guestfs-gobject/struct-btrfsbalance.h \
include/guestfs-gobject/struct-btrfsqgroup.h \
include/guestfs-gobject/struct-btrfssubvolume.h \
include/guestfs-gobject/struct-dirent.h \
@@ -108,6 +109,7 @@ guestfs_gobject_sources= \
src/tristate.c \
src/struct-application.c \
src/struct-application2.c \
+ src/struct-btrfsbalance.c \
src/struct-btrfsqgroup.c \
src/struct-btrfssubvolume.c \
src/struct-dirent.c \
diff --git a/java/Makefile.inc b/java/Makefile.inc
index 103010f..499d3de 100644
--- a/java/Makefile.inc
+++ b/java/Makefile.inc
@@ -22,6 +22,7 @@
java_built_sources = \
com/redhat/et/libguestfs/Application.java \
com/redhat/et/libguestfs/Application2.java \
+ com/redhat/et/libguestfs/BTRFSBalance.java \
com/redhat/et/libguestfs/BTRFSQgroup.java \
com/redhat/et/libguestfs/BTRFSSubvolume.java \
com/redhat/et/libguestfs/Dirent.java \
diff --git a/java/com/redhat/et/libguestfs/.gitignore b/java/com/redhat/et/libguestfs/.gitignore
index 1d4accc..b2b1b22 100644
--- a/java/com/redhat/et/libguestfs/.gitignore
+++ b/java/com/redhat/et/libguestfs/.gitignore
@@ -1,5 +1,6 @@
Application.java
Application2.java
+BTRFSBalance.java
BTRFSQgroup.java
BTRFSSubvolume.java
Dirent.java
diff --git a/po/POTFILES b/po/POTFILES
index 4194e5f..9330256 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -230,6 +230,7 @@ gobject/src/optargs-xfs_repair.c
gobject/src/session.c
gobject/src/struct-application.c
gobject/src/struct-application2.c
+gobject/src/struct-btrfsbalance.c
gobject/src/struct-btrfsqgroup.c
gobject/src/struct-btrfssubvolume.c
gobject/src/struct-dirent.c
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index e5a135a..0187835 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-445
+446
--
2.1.0
9 years, 9 months
[PATCH 0/7 v2] Make copy_in & copy_out APIs, and use copy_in in customize
by Pino Toscano
Hi,
attached there is the second version of the patch series adding
copy_in and copy_out in the library, mostly moving them from guestfish.
It also adds the copy_in usage in virt-customize, as aid in a new image
building.
Thanks,
Pino Toscano (7):
cmd: add a way to run (and wait) asynchronously commands
cmd: add a child-setup callback
cmd: add the possibility to get a fd to the process stdin
generator: add VPublicNoFish visibility type
New APIs: copy-in and copy-out
fish: use copy-in and copy-out
customize: add copy-in operation (RHBZ#1135585).
builder/cmdline.ml | 2 +-
customize/customize_run.ml | 4 +
fish/copy.c | 279 +--------------------------------------------
generator/actions.ml | 34 +++++-
generator/c.ml | 2 +-
generator/customize.ml | 13 +++
generator/types.ml | 2 +
po/POTFILES | 1 +
src/Makefile.am | 1 +
src/command.c | 119 +++++++++++++++++--
src/copy-in-out.c | 250 ++++++++++++++++++++++++++++++++++++++++
src/guestfs-internal.h | 5 +
12 files changed, 423 insertions(+), 289 deletions(-)
create mode 100644 src/copy-in-out.c
--
1.9.3
9 years, 9 months
[PATCH 1/6] cmd: add a way to run (and wait) asynchronously commands
by Pino Toscano
---
src/command.c | 64 +++++++++++++++++++++++++++++++++++++++++++-------
src/guestfs-internal.h | 3 +++
2 files changed, 58 insertions(+), 9 deletions(-)
diff --git a/src/command.c b/src/command.c
index 4bb469b..e26573d 100644
--- a/src/command.c
+++ b/src/command.c
@@ -360,7 +360,7 @@ debug_command (struct command *cmd)
}
static int
-run_command (struct command *cmd)
+run_command (struct command *cmd, bool get_stdout_fd, bool get_stderr_fd)
{
struct sigaction sa;
int i, fd, max_fd, r;
@@ -368,8 +368,11 @@ run_command (struct command *cmd)
int outfd[2] = { -1, -1 };
char status_string[80];
+ get_stdout_fd = get_stdout_fd || cmd->stdout_callback != NULL;
+ get_stderr_fd = get_stderr_fd || cmd->capture_errors;
+
/* Set up a pipe to capture command output and send it to the error log. */
- if (cmd->capture_errors) {
+ if (get_stderr_fd) {
if (pipe2 (errorfd, O_CLOEXEC) == -1) {
perrorf (cmd->g, "pipe2");
goto error;
@@ -377,7 +380,7 @@ run_command (struct command *cmd)
}
/* Set up a pipe to capture stdout for the callback. */
- if (cmd->stdout_callback) {
+ if (get_stdout_fd) {
if (pipe2 (outfd, O_CLOEXEC) == -1) {
perrorf (cmd->g, "pipe2");
goto error;
@@ -392,14 +395,14 @@ run_command (struct command *cmd)
/* In parent, return to caller. */
if (cmd->pid > 0) {
- if (cmd->capture_errors) {
+ if (get_stderr_fd) {
close (errorfd[1]);
errorfd[1] = -1;
cmd->errorfd = errorfd[0];
errorfd[0] = -1;
}
- if (cmd->stdout_callback) {
+ if (get_stdout_fd) {
close (outfd[1]);
outfd[1] = -1;
cmd->outfd = outfd[0];
@@ -410,15 +413,15 @@ run_command (struct command *cmd)
}
/* Child process. */
- if (cmd->capture_errors) {
+ if (get_stderr_fd) {
close (errorfd[0]);
- if (!cmd->stdout_callback)
+ if (!get_stdout_fd)
dup2 (errorfd[1], 1);
dup2 (errorfd[1], 2);
close (errorfd[1]);
}
- if (cmd->stdout_callback) {
+ if (get_stdout_fd) {
close (outfd[0]);
dup2 (outfd[1], 1);
close (outfd[1]);
@@ -615,7 +618,7 @@ guestfs___cmd_run (struct command *cmd)
if (cmd->g->verbose)
debug_command (cmd);
- if (run_command (cmd) == -1)
+ if (run_command (cmd, false, false) == -1)
return -1;
if (loop (cmd) == -1)
@@ -624,6 +627,49 @@ guestfs___cmd_run (struct command *cmd)
return wait_command (cmd);
}
+/* Fork, run the command, and returns the pid of the command,
+ * and its stdout and stderr file descriptors.
+ *
+ * Returns the exit status. Test it using WIF* macros.
+ *
+ * On error: Calls error(g) and returns -1.
+ */
+int
+guestfs___cmd_run_async (struct command *cmd, pid_t *pid,
+ int *stdout_fd, int *stderr_fd)
+{
+ finish_command (cmd);
+
+ if (cmd->g->verbose)
+ debug_command (cmd);
+
+ if (run_command (cmd, stdout_fd != NULL, stderr_fd != NULL) == -1)
+ return -1;
+
+ if (pid)
+ *pid = cmd->pid;
+ if (stdout_fd)
+ *stdout_fd = cmd->outfd;
+ if (stderr_fd)
+ *stderr_fd = cmd->errorfd;
+
+ return 0;
+}
+
+/* Wait for the command to finish.
+ *
+ * The command MUST have been started with guestfs___cmd_run_async.
+ *
+ * Returns the exit status. Test it using WIF* macros.
+ *
+ * On error: Calls error(g) and returns -1.
+ */
+int
+guestfs___cmd_wait (struct command *cmd)
+{
+ return wait_command (cmd);
+}
+
void
guestfs___cmd_close (struct command *cmd)
{
diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h
index 573c3da..bd5f675 100644
--- a/src/guestfs-internal.h
+++ b/src/guestfs-internal.h
@@ -20,6 +20,7 @@
#define GUESTFS_INTERNAL_H_
#include <stdbool.h>
+#include <sys/types.h>
#include <libintl.h>
@@ -870,6 +871,8 @@ extern void guestfs___cmd_set_stderr_to_stdout (struct command *);
extern void guestfs___cmd_clear_capture_errors (struct command *);
extern void guestfs___cmd_clear_close_files (struct command *);
extern int guestfs___cmd_run (struct command *);
+extern int guestfs___cmd_run_async (struct command *, pid_t *pid, int *stdout_fd, int *stderr_fd);
+extern int guestfs___cmd_wait (struct command *);
extern void guestfs___cmd_close (struct command *);
#ifdef HAVE_ATTRIBUTE_CLEANUP
--
1.9.3
9 years, 9 months