-
Notifications
You must be signed in to change notification settings - Fork 1
Qemu capabilities #49
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
Changes from all commits
ccac7d7
f536cd2
09af36c
6b7dabd
3afbd74
6bbb7a7
c998b64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,8 @@ package qemu | |
| import ( | ||
| "context" | ||
| "fmt" | ||
| "os" | ||
| "path/filepath" | ||
| "time" | ||
|
|
||
| "github.com/digitalocean/go-qemu/qemu" | ||
|
|
@@ -36,8 +38,8 @@ var _ hypervisor.Hypervisor = (*QEMU)(nil) | |
| // Capabilities returns the features supported by QEMU. | ||
| func (q *QEMU) Capabilities() hypervisor.Capabilities { | ||
| return hypervisor.Capabilities{ | ||
| SupportsSnapshot: false, // Not implemented in first pass | ||
| SupportsHotplugMemory: false, // Not implemented in first pass | ||
| SupportsSnapshot: true, // Uses QMP migrate file:// for snapshot | ||
| SupportsHotplugMemory: false, // Not implemented - balloon not configured | ||
| SupportsPause: true, | ||
| SupportsVsock: true, | ||
| SupportsGPUPassthrough: true, | ||
|
|
@@ -119,10 +121,40 @@ func (q *QEMU) Resume(ctx context.Context) error { | |
| return nil | ||
| } | ||
|
|
||
| // Snapshot creates a VM snapshot. | ||
| // Not implemented in first pass. | ||
| // Snapshot creates a VM snapshot using QEMU's migrate-to-file mechanism. | ||
| // The VM state is saved to destPath/memory file. | ||
| // The VM config is copied to destPath for restore (QEMU requires exact arg match). | ||
| func (q *QEMU) Snapshot(ctx context.Context, destPath string) error { | ||
| return fmt.Errorf("snapshot not supported by QEMU implementation") | ||
| // QEMU uses migrate to file for snapshots | ||
| // The "file:" protocol is deprecated in QEMU 7.2+, use "exec:cat > path" instead | ||
| memoryFile := destPath + "/memory" | ||
| uri := "exec:cat > " + memoryFile | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shell command paths not escaped for spaces/metacharactersThe QEMU Additional Locations (1)
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. follow up |
||
| if err := q.client.Migrate(uri); err != nil { | ||
sjmiller609 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Remove(q.socketPath) | ||
| return fmt.Errorf("migrate: %w", err) | ||
| } | ||
|
|
||
| // Wait for migration to complete | ||
| if err := q.client.WaitMigration(ctx, migrationTimeout); err != nil { | ||
| Remove(q.socketPath) | ||
| return fmt.Errorf("wait migration: %w", err) | ||
| } | ||
|
|
||
| // Copy VM config from instance dir to snapshot dir | ||
| // QEMU restore requires exact same command-line args as when snapshot was taken | ||
| instanceDir := filepath.Dir(q.socketPath) | ||
| srcConfig := filepath.Join(instanceDir, vmConfigFile) | ||
| dstConfig := filepath.Join(destPath, vmConfigFile) | ||
|
|
||
| configData, err := os.ReadFile(srcConfig) | ||
| if err != nil { | ||
| return fmt.Errorf("read vm config for snapshot: %w", err) | ||
| } | ||
| if err := os.WriteFile(dstConfig, configData, 0644); err != nil { | ||
| return fmt.Errorf("write vm config to snapshot: %w", err) | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| // ResizeMemory changes the VM's memory allocation. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.