-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add automatic snapshot feature for QEMU VMs #775
base: main
Are you sure you want to change the base?
Conversation
- Add automatic snapshots for QEMU VMs every 10 minutes by default - Create QemuSnapshotManager to handle QEMU VM snapshot scheduling - Implement create_snapshot method in AlephQemuInstance using QMP - Keep only one active snapshot at a time, deleting previous ones - Make QEMU confidential VMs also support snapshots - Update pool and execution classes to use appropriate snapshot manager 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
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.
LGTM in general
Shouldnt' we add at least a few additional tests?
""" | ||
try: | ||
logger.debug(f"Creating snapshot {snapshot_name} for VM {self.vm.vm_id}") | ||
self.qmp_client.command("savevm", **{"name": snapshot_name}) |
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.
self.qmp_client.command("savevm", **{"name": snapshot_name}) | |
self.qmp_client.command("savevm", name=snapshot_name) |
""" | ||
try: | ||
logger.debug(f"Deleting snapshot {snapshot_name} for VM {self.vm.vm_id}") | ||
self.qmp_client.command("delvm", **{"name": snapshot_name}) |
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.
self.qmp_client.command("delvm", **{"name": snapshot_name}) | |
self.qmp_client.command("delvm", name=snapshot_name) |
|
||
class QemuSnapshotExecution: | ||
vm_hash: ItemHash | ||
execution: any # AlephQemuInstance |
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.
execution: any # AlephQemuInstance | |
execution: Any # AlephQemuInstance |
This should be Any
from typing, I'm surprised this worked
|
||
async def start(self) -> None: | ||
logger.debug(f"Starting QEMU snapshots for VM {self.vm_hash} every {self.frequency} minutes") | ||
job = self._scheduler.every(self.frequency).minutes.do(run_threaded_snapshot, self.execution) |
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.
job = self._scheduler.every(self.frequency).minutes.do(run_threaded_snapshot, self.execution) | |
self._job = self._scheduler.every(self.frequency).minutes.do(run_threaded_snapshot, self.execution) |
And remove the next line
|
||
async def start(self) -> None: | ||
logger.debug(f"Starting QEMU snapshots for VM {self.vm_hash} every {self.frequency} minutes") | ||
job = self._scheduler.every(self.frequency).minutes.do(run_threaded_snapshot, self.execution) |
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.
job = self._scheduler.every(self.frequency).minutes.do(run_threaded_snapshot, self.execution) | |
self._job = self._scheduler.every(self.frequency).minutes.do(run_threaded_snapshot, self.execution) |
And remove the next line
await snapshot_execution.stop() | ||
|
||
async def stop_all(self) -> None: | ||
await asyncio.gather(*(self.stop_for(vm_hash) for vm_hash in list(self.executions.keys()))) |
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.
Shouldn't this function also do a job_thread.stop()
? I'm no sure
Create automatic Qemu snapshots every 10 minutes
Related ClickUp, GitHub or Jira tickets : ALEPH-XXX
Self proofreading checklist
packaging/Makefile
Changes
🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]
How to test
Check if a snapshot is created every 10 minutes