Skip to content

Rewind file pointer and be compatible with 3.13.13#84

Merged
twiggler merged 2 commits into
mainfrom
vmtar-3.13.13
Apr 23, 2026
Merged

Rewind file pointer and be compatible with 3.13.13#84
twiggler merged 2 commits into
mainfrom
vmtar-3.13.13

Conversation

@twiggler
Copy link
Copy Markdown
Contributor

@twiggler twiggler commented Apr 9, 2026

Two fixes:

Problem:
We did not rewind the file pointer for uncompressed vmtar files, skipping the first entry

Problem:
Python3.13.13 bypasses frombuf and directly calls _frombuf

(Found by nightly monorepo ci)

It seems our current CI is still using 3.13.12

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 9, 2026

Codecov Report

❌ Patch coverage is 80.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.89%. Comparing base (cf91787) to head (9ba2be2).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
dissect/hypervisor/util/vmtar.py 80.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #84      +/-   ##
==========================================
+ Coverage   80.84%   80.89%   +0.04%     
==========================================
  Files          26       26              
  Lines        2370     2381      +11     
==========================================
+ Hits         1916     1926      +10     
- Misses        454      455       +1     
Flag Coverage Δ
unittests 80.89% <80.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@twiggler twiggler marked this pull request as draft April 9, 2026 12:50
@twiggler twiggler changed the title fix: reset file position WIP fix: reset file position Apr 9, 2026
@twiggler twiggler changed the title WIP fix: reset file position Rewind file pointer and be compatible with 3.13.13 Apr 10, 2026
@twiggler twiggler marked this pull request as ready for review April 10, 2026 09:04
@twiggler twiggler requested a review from Miauwkeru April 13, 2026 07:02
@classmethod
def frombuf(cls, buf: bytes, encoding: str, errors: str) -> VisorTarInfo:
obj = super().frombuf(buf, encoding, errors)
cls._init_visor_attrs(obj, buf)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it now technically call the _init_visor_attrs twice? as super().frombuf calls cls._frombuf which already initiates _init_visor_attrs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but _init_visor_attrs is idempotent

Comment thread dissect/hypervisor/util/vmtar.py Outdated
fileobj.seek(0)
fileobj = BytesIO(fileobj.read())
if compressed:
# GzipFile/LZMAFile are not seekable, but TarFile requires seek/tell.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But they are? That wasn't the reason I did the read into BytesIO.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, what was the reason?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's was in the comment you removed. Performance reasons for random reads.

Comment thread tests/util/test_vmtar.py
# The test file has no textPgs/fixUpPgs
assert all(member.is_visor for member in members.values())
assert set(members.keys()) == {
"test",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: The directory should also be a member, right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would think it should also be included, and not only the file contents. @Schamper was there a reason it wasn't included?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably oversight because I didn't rewind the file pointer :) should be included.

Comment thread dissect/hypervisor/util/vmtar.py Outdated
fileobj.seek(0)
fileobj = BytesIO(fileobj.read())
if compressed:
# GzipFile/LZMAFile are not seekable, but TarFile requires seek/tell.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, what was the reason?

@classmethod
def frombuf(cls, buf: bytes, encoding: str, errors: str) -> VisorTarInfo:
obj = super().frombuf(buf, encoding, errors)
cls._init_visor_attrs(obj, buf)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but _init_visor_attrs is idempotent

@twiggler twiggler requested review from Miauwkeru and Schamper April 23, 2026 07:53
@twiggler twiggler merged commit 8baa8f6 into main Apr 23, 2026
22 of 23 checks passed
@twiggler twiggler deleted the vmtar-3.13.13 branch April 23, 2026 15:11
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.

3 participants