Skip to content

Commit

Permalink
lxd/instance_post: Prevent live migration of instances with custom vo…
Browse files Browse the repository at this point in the history
…lumes

Signed-off-by: Din Music <din.music@canonical.com>
  • Loading branch information
MusicDin committed Jan 17, 2024
1 parent 908e12b commit 167f231
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lxd/instance_post.go
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,16 @@ func migrateInstance(s *state.State, r *http.Request, inst instance.Instance, ta
return err
}

// Check if we are migrating a ceph-based instance.
// In case of live migration, only root disk can be migrated.
if req.Live && inst.IsRunning() {
for _, rawConfig := range inst.ExpandedDevices() {
if rawConfig["type"] == "disk" && !shared.IsRootDiskDevice(rawConfig) {
return fmt.Errorf("Cannot live migrate instance with attached custom volume")
}
}
}

// Retrieve storage pool of the source instance.
srcPool, err := storagePools.LoadByInstance(s, inst)
if err != nil {
return fmt.Errorf("Failed loading instance storage pool: %w", err)
Expand Down

0 comments on commit 167f231

Please sign in to comment.