jancc / vma-extractor

Extraction tool for the VMA backup format used by Proxmox
https://janw.name/tools.html
zlib License
72 stars 18 forks source link

FR. Using stdin as input #3

Open VasoVV opened 2 years ago

VasoVV commented 2 years ago

This is really the best solution to handle a *.vma outside of ProxMox.

But typically we face with compressed *.vma.gz format, so we have to write a BIG file twice: .vma.gz --> .vma .vma --> .raw

Actually we need a triple free disk space (vma.gz + vma + raw) at a time.

It would be perfect if the script has the ability to use stdin as input (as origin vma has), so we can use it in such a way:

zcat big.vma.gz | vma.py - /tmp/big-vma-extracted

Unfortunately named pipe doesn't work:

$ mkfifo blackhole
$ zcat big.vma.gz > blackhole &
$ vma.py blackhole /tmp/big-vma-extracted
[1]  + 237676 broken pipe  zcat big.vma.gz > blackhole
Traceback (most recent call last):
  File "vma.py", line 357, in <module>
    sys.exit(main())
  File "vma.py", line 352, in main
    extract(fo, args)
  File "vma.py", line 239, in extract
    fo.seek(0, os.SEEK_END)
io.UnsupportedOperation: File or stream is not seekable.

Thank you for your work!

jancc commented 2 years ago

Sounds like a good idea. Especially getting named pipes to work shouldn't require too much thought. As far as I remember random seeking is only required for the output size anyways.

And I have no idea why I did the wierd seek, tell and seek thingy to get the filesize ahead of time, when I could just run the loop until EOF... 😅