Conversation
a6ebb86 to
5d8cefd
Compare
Add vm_compact.py for reducing XVA sizes to replace win-diskclone.sh Remove scripts that are no longer used Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
5d8cefd to
31ee78e
Compare
| from lib.vbd import VBD | ||
| from lib.vm import VM | ||
|
|
||
| # Tool to compact Windows VMs and create test XVAs |
There was a problem hiding this comment.
| # Tool to compact Windows VMs and create test XVAs | |
| # Tool to compress Windows VMs and create test XVAs |
|
|
||
| with tempfile.TemporaryDirectory() as mountpoint: | ||
| for vm_uuid in args.vm: | ||
| logging.info(f"Compacting VM {vm_uuid}") |
There was a problem hiding this comment.
| logging.info(f"Compacting VM {vm_uuid}") | |
| logging.info(f"Compressing VM {vm_uuid}") |
I am nitpicking: compact can be used but unsure it is used as widely as compress.
There was a problem hiding this comment.
The script compacts the affected VMs, not just compressing it (due to the ntfsclone step, which omits free clusters from the destination VDI)
| assert os.path.exists(orig_device_path) | ||
|
|
||
| logging.info(f"Cloning VDI {orig_vdi.name()}") | ||
| compact_vdi = orig_vdi.sr.create_vdi(f"{orig_vdi.name()}-compacted", orig_vdi.get_virtual_size()) |
There was a problem hiding this comment.
| compact_vdi = orig_vdi.sr.create_vdi(f"{orig_vdi.name()}-compacted", orig_vdi.get_virtual_size()) | |
| compact_vdi = orig_vdi.sr.create_vdi(f"{orig_vdi.name()}-compressed", orig_vdi.get_virtual_size()) |
| subprocess.run(["mount", orig_part, mountpoint], check=True) | ||
| try: | ||
| mountpath = pathlib.Path(mountpoint) | ||
| (mountpath / "pagefile.sys").unlink(missing_ok=True) |
There was a problem hiding this comment.
will those files be created again ? if not i will just size to zero or replace empty contents
There was a problem hiding this comment.
These are Windows temp files that will be automatically created again.
| else: | ||
| logging.info(f"Cloning {orig_part} -> {compact_part}") | ||
| subprocess.run( | ||
| ["dd", f"if={orig_part}", f"of={compact_part}", "bs=1M", "status=progress"], check=True |
There was a problem hiding this comment.
do we need to set bs ? I think even a cat would work and the system figure out cache, it could save a bit of performance (or not)
There was a problem hiding this comment.
Not really, I just used dd to print the cloning progress (compared to cat which is silent)
| ) | ||
|
|
||
| logging.info("Finalizing cloned VDI") | ||
| subprocess.run("sync", check=True) |
There was a problem hiding this comment.
Usually i used to call sync serveral time, but I don't remember the reason
Add vm_compact.py for reducing XVA sizes to replace win-diskclone.sh
Remove scripts that are no longer used
vm_compact.py is a reimplementation of win-diskclone.sh that also manages the new VDI.
Since the image generation pipeline has changed, the install-autotest and unattend files are no longer used. They're not actively updated in this repo anyway.