Skip to content

Type hints, optional sparse output, stdin as input#7

Open
elonen wants to merge 2 commits intojancc:masterfrom
elonen:master
Open

Type hints, optional sparse output, stdin as input#7
elonen wants to merge 2 commits intojancc:masterfrom
elonen:master

Conversation

@elonen
Copy link
Copy Markdown

@elonen elonen commented Aug 12, 2024

This PR implements several improvements:

  • Add Python type hints
  • Remove seeking of input, making it possible to use /dev/stdin (e.g. zstdcat pipe) as an input (fixes FR. Using stdin as input #3)
  • Optionally write output as sparse files instead of filling explicitly with zeros. Zero-fill is default, however, as I've recently encoutered some odd integrity issues with sparse VMA extracts on CephFS

It has so far always produced identical output to the original PVE vma command, but it's really hard to be 100% sure as the VMA format unfortunately doesn't have checksums for the device image contents, only the file headers.

@rainerjung
Copy link
Copy Markdown

rainerjung commented Jun 4, 2025

Great, both sparseness and supporting pipes are very welcome additions. Worked for me.
You might want to support "-" in addition to "/dev/stdin" as a special case abbreviation to /dev/stdin. That is used by most *nix commandline tools.

Something as simple as:

--- vma.py	2025-06-04 12:50:10.260232538 +0200
+++ vma.py	2025-06-04 13:03:25.770753855 +0200
@@ -340,6 +340,9 @@
             help='write sparse files')
     args = parser.parse_args()
 
+    if(args.filename == '-'):
+        args.filename = '/dev/stdin'
+
     if(not os.path.exists(args.filename)):
         print('Error! Source file does not exist!')
         return 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FR. Using stdin as input

2 participants