Skip to content

Commit

Permalink
incusd/instance: Fallback to stateless start when no state available
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Graber <[email protected]>
  • Loading branch information
stgraber committed Jan 25, 2024
1 parent 2cf1383 commit 9fb0576
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
8 changes: 1 addition & 7 deletions internal/server/instance/drivers/driver_lxc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2425,13 +2425,7 @@ func (d *lxc) Start(stateful bool) error {
}

// If stateful, restore now.
if stateful {
if !d.stateful {
err = fmt.Errorf("Instance has no existing state to restore")
op.Done(err)
return err
}

if stateful && d.stateful {
d.logger.Info("Restoring stateful checkpoint")

criuMigrationArgs := instance.CriuMigrationArgs{
Expand Down
11 changes: 5 additions & 6 deletions internal/server/instance/drivers/driver_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -1438,13 +1438,12 @@ func (d *qemu) start(stateful bool, op *operationlock.InstanceOperation) error {

// If stateful, restore now.
if stateful {
if !d.stateful {
err = fmt.Errorf("Instance has no existing state to restore")
op.Done(err)
return err
if d.stateful {
qemuCmd = append(qemuCmd, "-incoming", "defer")
} else {
// No state to restore, just start as normal.
stateful = false
}

qemuCmd = append(qemuCmd, "-incoming", "defer")
} else if d.stateful {
// Stateless start requested but state is present, delete it.
err := os.Remove(d.StatePath())
Expand Down

0 comments on commit 9fb0576

Please sign in to comment.