diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2011-03-18 17:17:30 +0000 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2011-03-18 17:56:45 +0000 |
commit | 33b638109ed66ea360b53b80b1f407b3a5f5ec39 (patch) | |
tree | c1e04200129b5152428c089698642296b17421dc /regressions | |
parent | c7368ce167d6dbfd3e69ba208301c5af3f17a8a1 (diff) | |
download | libguestfs-33b638109ed66ea360b53b80b1f407b3a5f5ec39.tar.gz libguestfs-33b638109ed66ea360b53b80b1f407b3a5f5ec39.tar.xz libguestfs-33b638109ed66ea360b53b80b1f407b3a5f5ec39.zip |
proto: Fix FileIn ops that abort during the chunk upload stage.
As a previous, incorrect attempt to fix RHBZ#576879 we tried to
prevent the daemon from sending an error reply if the daemon had
cancelled the transfer. This is wrong: the daemon should send an
error reply in these cases.
A simple test case is this:
guestfish -N fs -m /dev/sda1 upload big-file /
(This fails because the target "/" is a directory, not a file.)
Prior to this commit, libguestfs would hang instead of printing an
error. With this commit, libguestfs prints an error.
What is happening is:
(1) Library is uploading
a file (2) In the middle of the long
upload, daemon detects an error.
Daemon cancels.
(3) Library detects cancel,
sends cancel chunk, then waits
for the error reply from the
daemon. (4) Daemon is supposed to send
an error reply message.
Because step (4) wasn't happening, uploads that failed like this would
hang in the library (waiting for the error message, while the daemon
was waiting for the next request).
This also adds a regression test.
This temporarily breaks the "both ends cancel" case (RHBZ#576879c5).
Therefore the test for that is disabled, and this is fixed in the next
patch in the series.
This partially reverts commit dc706a639eec16084c0618baf7bfde00c6565f63.
Diffstat (limited to 'regressions')
-rw-r--r-- | regressions/Makefile.am | 7 | ||||
-rwxr-xr-x | regressions/rhbz576879.sh (renamed from regressions/rhbz576879c0.sh) | 2 | ||||
-rwxr-xr-x | regressions/test-both-ends-cancel.sh (renamed from regressions/rhbz576879c5.sh) | 0 | ||||
-rwxr-xr-x | regressions/test-upload-to-dir.sh | 39 |
4 files changed, 44 insertions, 4 deletions
diff --git a/regressions/Makefile.am b/regressions/Makefile.am index a64d2728..6527e063 100644 --- a/regressions/Makefile.am +++ b/regressions/Makefile.am @@ -29,8 +29,7 @@ TESTS = \ rhbz503169c10.sh \ rhbz503169c13.sh \ rhbz557655.sh \ - rhbz576879c0.sh \ - rhbz576879c5.sh \ + rhbz576879.sh \ rhbz578407.sh \ rhbz580246.sh \ test-add-domain.sh \ @@ -53,12 +52,14 @@ TESTS = \ test-read_file.sh \ test-remote.sh \ test-reopen.sh \ - test-stringlist.sh + test-stringlist.sh \ + test-upload-to-dir.sh SKIPPED_TESTS = \ test-bootbootboot.sh FAILING_TESTS = \ + test-both-ends-cancel.sh \ test-qemudie-launchfail.sh random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null) diff --git a/regressions/rhbz576879c0.sh b/regressions/rhbz576879.sh index f0604966..d3db55bc 100755 --- a/regressions/rhbz576879c0.sh +++ b/regressions/rhbz576879.sh @@ -25,7 +25,7 @@ set -e rm -f test1.img ../fish/guestfish -N disk <<EOF --upload $srcdir/rhbz576879c0.sh /test.sh +-upload $srcdir/rhbz576879.sh /test.sh # Shouldn't lose synchronization, so next command should work: ping-daemon EOF diff --git a/regressions/rhbz576879c5.sh b/regressions/test-both-ends-cancel.sh index 817e0987..817e0987 100755 --- a/regressions/rhbz576879c5.sh +++ b/regressions/test-both-ends-cancel.sh diff --git a/regressions/test-upload-to-dir.sh b/regressions/test-upload-to-dir.sh new file mode 100755 index 00000000..03cce5b5 --- /dev/null +++ b/regressions/test-upload-to-dir.sh @@ -0,0 +1,39 @@ +#!/bin/bash - +# libguestfs +# Copyright (C) 2011 Red Hat Inc. +# +# 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., 675 Mass Ave, Cambridge, MA 02139, USA. + +# If you used the guestfish command 'upload' and accidentally set the +# target to a directory instead of the full filename, then previously +# libguestfs would hang. It should return an error instead. + +set -e + +rm -f test1.img test.out + +if ../fish/guestfish -N fs -m /dev/sda1 upload ../images/test.iso / 2>test.out +then + echo "$0: expecting guestfish to return an error" + exit 1 +fi + +if ! grep -q "upload: /: Is a directory" test.out; then + echo "$0: unexpected error message from guestfish" + cat test.out + exit 1 +fi + +rm -f test1.img test.out |