summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--daemon/guestfsd.c30
-rw-r--r--libguestfs.spec.in10
-rw-r--r--perl/Guestfs.xs2
-rwxr-xr-xsrc/generator.ml2
-rw-r--r--src/guestfs.c39
6 files changed, 53 insertions, 32 deletions
diff --git a/configure.ac b/configure.ac
index a71fff8b..e3b4e2ed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-AC_INIT([libguestfs],[1.0.19])
+AC_INIT([libguestfs],[1.0.20])
AM_INIT_AUTOMAKE
AC_CONFIG_MACRO_DIR([m4])
diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c
index 99055a92..eeb84bd1 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -446,6 +446,7 @@ commandrv (char **stdoutput, char **stderror, char * const* const argv)
int pid, r, quit, i;
fd_set rset, rset2;
char buf[256];
+ char *p;
if (stdoutput) *stdoutput = NULL;
if (stderror) *stderror = NULL;
@@ -500,6 +501,9 @@ commandrv (char **stdoutput, char **stderror, char * const* const argv)
r = select (MAX (so_fd[0], se_fd[0]) + 1, &rset2, NULL, NULL, NULL);
if (r == -1) {
perror ("select");
+ quit:
+ if (stdoutput) free (*stdoutput);
+ if (stderror) free (*stderror);
close (so_fd[0]);
close (se_fd[0]);
waitpid (pid, NULL, 0);
@@ -510,21 +514,18 @@ commandrv (char **stdoutput, char **stderror, char * const* const argv)
r = read (so_fd[0], buf, sizeof buf);
if (r == -1) {
perror ("read");
- close (so_fd[0]);
- close (se_fd[0]);
- waitpid (pid, NULL, 0);
- return -1;
+ goto quit;
}
if (r == 0) { FD_CLR (so_fd[0], &rset); quit++; }
if (r > 0 && stdoutput) {
so_size += r;
- *stdoutput = realloc (*stdoutput, so_size);
- if (*stdoutput == NULL) {
+ p = realloc (*stdoutput, so_size);
+ if (p == NULL) {
perror ("realloc");
- *stdoutput = NULL;
- continue;
+ goto quit;
}
+ *stdoutput = p;
memcpy (*stdoutput + so_size - r, buf, r);
}
}
@@ -533,21 +534,18 @@ commandrv (char **stdoutput, char **stderror, char * const* const argv)
r = read (se_fd[0], buf, sizeof buf);
if (r == -1) {
perror ("read");
- close (so_fd[0]);
- close (se_fd[0]);
- waitpid (pid, NULL, 0);
- return -1;
+ goto quit;
}
if (r == 0) { FD_CLR (se_fd[0], &rset); quit++; }
if (r > 0 && stderror) {
se_size += r;
- *stderror = realloc (*stderror, se_size);
- if (*stderror == NULL) {
+ p = realloc (*stderror, se_size);
+ if (p == NULL) {
perror ("realloc");
- *stderror = NULL;
- continue;
+ goto quit;
}
+ *stderror = p;
memcpy (*stderror + se_size - r, buf, r);
}
}
diff --git a/libguestfs.spec.in b/libguestfs.spec.in
index c7d36ba6..a0a55e1c 100644
--- a/libguestfs.spec.in
+++ b/libguestfs.spec.in
@@ -238,6 +238,8 @@ Requires: jpackage-utils
%prep
%setup -q
+mkdir -p daemon/m4
+
%build
%if %{buildnonet}
@@ -427,9 +429,15 @@ rm -rf $RPM_BUILD_ROOT
%changelog
-* Tue Apr 28 2009 Richard Jones <rjones@redhat.com> - @VERSION@-1
+* Thu May 7 2009 Richard Jones <rjones@redhat.com> - @VERSION@-1
- New upstream version @VERSION@.
+* Thu May 7 2009 Richard Jones <rjones@redhat.com> - 1.0.20-1
+- New upstream version 1.0.20.
+
+* Thu May 7 2009 Richard Jones <rjones@redhat.com> - 1.0.19-1
+- New upstream version 1.0.19.
+
* Tue Apr 28 2009 Richard Jones <rjones@redhat.com> - 1.0.15-1
- New upstream version 1.0.15.
diff --git a/perl/Guestfs.xs b/perl/Guestfs.xs
index d29d5a08..e95b2746 100644
--- a/perl/Guestfs.xs
+++ b/perl/Guestfs.xs
@@ -88,6 +88,8 @@ XS_unpack_charPtrPtr (SV *arg) {
MODULE = Sys::Guestfs PACKAGE = Sys::Guestfs
+PROTOTYPES: ENABLE
+
guestfs_h *
_create ()
CODE:
diff --git a/src/generator.ml b/src/generator.ml
index 089ed29e..ef8b3aa0 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -4826,6 +4826,8 @@ XS_unpack_charPtrPtr (SV *arg) {
MODULE = Sys::Guestfs PACKAGE = Sys::Guestfs
+PROTOTYPES: ENABLE
+
guestfs_h *
_create ()
CODE:
diff --git a/src/guestfs.c b/src/guestfs.c
index 395bc97c..9060c111 100644
--- a/src/guestfs.c
+++ b/src/guestfs.c
@@ -441,8 +441,11 @@ xread (int fd, void *buf, size_t len)
while (len > 0) {
r = read (fd, buf, len);
- if (r == -1)
+ if (r == -1) {
+ if (errno == EINTR || errno == EAGAIN)
+ continue;
return -1;
+ }
buf += r;
len -= r;
@@ -599,7 +602,7 @@ guestfs_config (guestfs_h *g,
int
guestfs_add_drive (guestfs_h *g, const char *filename)
{
- int len = strlen (filename) + 64;
+ size_t len = strlen (filename) + 64;
char buf[len];
if (strchr (filename, ',') != NULL) {
@@ -637,7 +640,8 @@ int
guestfs_launch (guestfs_h *g)
{
static const char *dir_template = "/tmp/libguestfsXXXXXX";
- int r, i, len, pmore, memsize;
+ int r, i, pmore, memsize;
+ size_t len;
int wfd[2], rfd[2];
int tries;
const char *kernel_name = "vmlinuz." REPO "." host_cpu;
@@ -784,7 +788,7 @@ guestfs_launch (guestfs_h *g)
/* Linux kernel command line. */
snprintf (append, sizeof append,
- "console=ttyS0 guestfs=%s:%d%s",
+ "panic=1 console=ttyS0 guestfs=%s:%d%s",
VMCHANNEL_ADDR, VMCHANNEL_PORT,
g->verbose ? " guestfs_verbose=1" : "");
@@ -795,6 +799,7 @@ guestfs_launch (guestfs_h *g)
#if 0
add_cmdline (g, "-no-kqemu"); /* Avoids a warning. */
#endif
+ add_cmdline (g, "-no-reboot"); /* Force exit instead of reboot on panic */
add_cmdline (g, "-kernel");
add_cmdline (g, (char *) kernel);
add_cmdline (g, "-initrd");
@@ -1201,7 +1206,7 @@ stdout_event (struct guestfs_main_loop *ml, guestfs_h *g, void *data,
}
if (n == -1) {
- if (errno != EAGAIN)
+ if (errno != EINTR && errno != EAGAIN)
perrorf (g, "read");
return;
}
@@ -1223,7 +1228,7 @@ sock_read_event (struct guestfs_main_loop *ml, guestfs_h *g, void *data,
int watch, int fd, int events)
{
XDR xdr;
- unsigned len;
+ u_int32_t len;
int n;
if (g->verbose)
@@ -1249,7 +1254,7 @@ sock_read_event (struct guestfs_main_loop *ml, guestfs_h *g, void *data,
return;
if (n == -1) {
- if (errno != EAGAIN)
+ if (errno != EINTR && errno != EAGAIN)
perrorf (g, "read");
return;
}
@@ -1543,7 +1548,7 @@ guestfs__send_sync (guestfs_h *g, int proc_nr,
{
struct guestfs_message_header hdr;
XDR xdr;
- unsigned len;
+ u_int32_t len;
int serial = g->msg_next_serial++;
int sent;
guestfs_main_loop *ml = guestfs_get_main_loop (g);
@@ -1656,7 +1661,11 @@ guestfs__send_file_sync (guestfs_h *g, const char *filename)
}
/* Send file in chunked encoding. */
- while (!cancel && (r = read (fd, buf, sizeof buf)) > 0) {
+ while (!cancel) {
+ r = read (fd, buf, sizeof buf);
+ if (r == -1 && (errno == EINTR || errno == EAGAIN))
+ continue;
+ if (r <= 0) break;
err = send_file_data_sync (g, buf, r);
if (err < 0) {
if (err == -2) /* daemon sent cancellation */
@@ -1718,7 +1727,7 @@ static int check_for_daemon_cancellation (guestfs_h *g);
static int
send_file_chunk_sync (guestfs_h *g, int cancel, const char *buf, size_t buflen)
{
- unsigned len;
+ u_int32_t len;
int sent;
guestfs_chunk chunk;
XDR xdr;
@@ -1843,13 +1852,14 @@ check_for_daemon_cancellation (guestfs_h *g)
/* Synchronously receive a file. */
/* Returns -1 = error, 0 = EOF, 1 = more data */
-static int receive_file_data_sync (guestfs_h *g, void **buf, int *len);
+static int receive_file_data_sync (guestfs_h *g, void **buf, size_t *len);
int
guestfs__receive_file_sync (guestfs_h *g, const char *filename)
{
void *buf;
- int fd, r, len;
+ int fd, r;
+ size_t len;
fd = open (filename, O_WRONLY|O_CREAT|O_TRUNC|O_NOCTTY, 0666);
if (fd == -1) {
@@ -1957,11 +1967,12 @@ receive_file_cb (guestfs_h *g, void *data, XDR *xdr)
/* Receive a chunk of file data. */
/* Returns -1 = error, 0 = EOF, 1 = more data */
static int
-receive_file_data_sync (guestfs_h *g, void **buf, int *len_r)
+receive_file_data_sync (guestfs_h *g, void **buf, size_t *len_r)
{
struct receive_file_ctx ctx;
guestfs_main_loop *ml = guestfs_get_main_loop (g);
- int i, len;
+ int i;
+ size_t len;
ctx.count = 0;
ctx.chunks = NULL;