Score:1

Is it possible to pipe qemu-img into SSH target?

cn flag

I tried the following command, but only an empty file is created on the target and the command stays open

qemu-img convert -f raw -O vmdk /dev/sda1 - | ssh foo@bar "cat > /home/foo/foobar.vmdk"

Note: sshfs is not available.

vskubriev avatar
pk flag
Sorry, but it is impossible. See comments in the answer comments. Gerald Schneider is a right.
Score:2
in flag

You want to use tee instead of cat.

tee - read from standard input and write to standard output and files

qemu-img convert -f raw -O vmdk /dev/sda1 - | ssh foo@bar "tee /home/foo/foobar.vmdk > /dev/null"
cn flag
I've tried it locally, but the file stays empty `qemu-img convert -f raw -O vmdk /dev/sda1 - | tee "/home/foo/foobar.vmdk" > /dev/null`
in flag
Did you check if a file called `-` was created? Using `-` for stdout is a convention, but it's not available in every tool. I found [this old mailing list entry](https://linux.debian.bugs.dist.narkive.com/PGRdZGYQ/bug-513451-qemu-img-add-stdin-stdout-support) where it is stated that `This is technically not possible. Given the formats involved, the file is not read/written linearly, which render the use of stdin/stdout impossible`. If that hasn't changed since It might simply not be possible to pipe the result of qemu-img to stdout.
thomas avatar
ca flag
Couldn't down vote because of missing points but this answer is wrong. Using cat is totally fine and using tee with piping stdout to dev null shouldn't help at all here.
thomas avatar
ca flag
Though the comment regarding using `-` for `/dev/stdout` explains what happend. `qemu-img` just wrote the output into a file called `-`. If you 180° your answer to reflect that you can have my upvote.
Score:2
ru flag

Unfortunately it is not possible to write the qemu-img output to a pipe due to the fact that the output files need to be seekable

Ref: https://www.mail-archive.com/[email protected]/msg05176.html

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.