-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Returns the number of allocated clusters in a Qcow #70
base: 3.2.3-8.3
Are you sure you want to change the base?
Conversation
Last commit: 9207abe "fix(linstor): check if resource is tiebreaker (#62)" Signed-off-by: Ronan Abhamon <[email protected]>
8259021
to
303c6b0
Compare
I will probably put functions into a class and pass the filename during the init(). The init will update a header, L1 table and L2 table. So we won't pass the file and header every time and the Qcow file will be hold only during the init. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: your PR is targeting a 8.2 maintenance branch.
Ok noted 👍 . I took the default branch presented on the github page. But in fact it doesn't matter a lot because we will only took the class to add it to the future qcowutil.py file. So this PR probably won't be merged as is. |
248cbc5
to
7254eea
Compare
7b63087
to
6febcd4
Compare
This script can returns: - the number of allocated clusters in a Qcow file. - the number of newly allocated clusters in a Qcow file compared to a reference one (like the backing file). - it can erase all data and set clusters as unallocated - it can set/unset/get the hidden property. - for now it creates the custom header if not found but it can easily be changed. It also moves the backing file name because when a snapshot is created the hidden custom header is ignored so we need to make space to crate it again. NOTE: This script is a POC to validate that all helpers from vhd util are also doable with qcow file. It will be used in another file. Signed-off-by: Guillaume <[email protected]>
6febcd4
to
881b48a
Compare
with open(self.filename, "rb+") as qcow2_file: | ||
if self.header["version"] == 3: | ||
qcow2_file.seek(100) # 100 is the offset of header_length | ||
header_length = int.from_bytes(qcow2_file.read(4)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we need to add the endianess: header_length = int.from_bytes(qcow2_file.read(4), 'big')
custom_data_offset = 0 | ||
|
||
while True: | ||
ext_type = int.from_bytes(qcow2_file.read(4)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here a below
This script returns the number of allocated clusters in a Qcow file.
We probably won't use it like this but more probably as a library for the next qcow2util implementation.
I opened it because it is easier to discuss on a PR and like that we keep a backup while waiting to see what we do with it...