Bug 1153702 - Using "upload - XXX" doesn't work with remote
Summary: Using "upload - XXX" doesn't work with remote
Keywords:
Status: NEW
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libguestfs
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Richard W.M. Jones
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-10-16 15:14 UTC by Vincent Bernat
Modified: 2025-10-17 12:52 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2025-10-17 00:10:15 UTC
Embargoed:


Attachments (Terms of Use)

Description Vincent Bernat 2014-10-16 15:14:10 UTC
Description of problem:

cat <<EOF | guestfish --remote upload - /tmp/somefile
hello
EOF

Instead of uploading "hello" to /tmp/somefile, it just hangs when executed in a script. If I do the same interactively, I get "libguestfs: error: read: /dev/stdin: Input/output error". Looking a bit with strace, I see that the guestfish server process is trying to read from stdin which is the running terminal:

accept4(4, 0, NULL, SOCK_CLOEXEC)       = 5
recvmsg(5, {msg_name(0)=NULL, msg_iov(1)=[{"\0", 1}], msg_controllen=24, {cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, {6}}, msg_flags=0}, 0) = 1
dup2(6, 1)                              = 1
close(6)                                = 0
fcntl(5, F_GETFL)                       = 0x2 (flags O_RDWR)
fstat(5, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ffc57828000
lseek(5, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
read(5, "\0\0\0\0061.26.9\0\0\0\0\0\6upload\0\0\0\0\0\2\0\0\0\1"..., 4096) = 84
stat("/dev/stdin", {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 9), ...}) = 0
mmap(NULL, 4198400, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ffc50a78000
mremap(0x7ffc50a78000, 4198400, 4096, MREMAP_MAYMOVE) = 0x7ffc50a78000
poll([{fd=8, events=POLLIN}], 1, 0)     = 0 (Timeout)
poll([{fd=8, events=POLLOUT}, {fd=7, events=POLLIN}], 2, 4294967295) = 1 ([{fd=8, revents=POLLOUT}])
write(8, "\0\0\0T \0\365\365\0\0\0\4\0\0\0B\0\0\0\0\0\0224\1\0\0\0\0\0\0\0\0"..., 88) = 88
munmap(0x7ffc50a78000, 4096)            = 0
open("/dev/stdin", O_RDONLY|O_CLOEXEC)  = 6
fadvise64(6, 0, 0, POSIX_FADV_SEQUENTIAL) = 0
read(6,

So, it doesn't read from the right spot.

Version-Release number of selected component (if applicable):

1.26.9-3 (from Debian unstable)

Comment 1 Richard W.M. Jones 2014-10-24 13:54:54 UTC
The guestfish --listen/--remote options just send commands over
a Unix domain socket.

Since everything is on the same machine, you can just write what
you want to upload to a temporary file, and then send the temporary
filename over the socket.

ie this should work instead:

f=`mktemp`
cat > $f <<EOF
hello
EOF
guestfish --remote upload $f /tmp/somefile

It would be possible to implement the same thing behind the scenes,
by modifying fish/fish.c:file_in() and probably not a huge amount of
work.

Comment 2 Red Hat Bugzilla 2025-10-17 00:10:15 UTC
This product has been discontinued or is no longer tracked in Red Hat Bugzilla.

Comment 3 Alasdair Kergon 2025-10-17 12:52:13 UTC
Reopening because Virtualization Tools has not been discontinued.


Note You need to log in before you can comment on or make changes to this bug.