Skip to content

Commit 61c622e

Browse files
authored
Merge pull request #1980 from stgraber/main
incusd/device/disk: Fix registration of custom volumes
2 parents 3ca5831 + 740eed0 commit 61c622e

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

internal/server/device/disk.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -746,13 +746,13 @@ func (d *disk) UpdatableFields(oldDevice Type) []string {
746746
func (d *disk) Register() error {
747747
d.logger.Debug("Initialising mounted disk ref counter")
748748

749-
// Load the pool.
750-
pool, err := storagePools.LoadByInstance(d.state, d.inst)
751-
if err != nil {
752-
return err
753-
}
754-
755749
if d.config["path"] == "/" {
750+
// Load the pool.
751+
pool, err := storagePools.LoadByInstance(d.state, d.inst)
752+
if err != nil {
753+
return err
754+
}
755+
756756
// Try to mount the volume that should already be mounted to reinitialize the ref counter.
757757
_, err = pool.MountInstance(d.inst, nil)
758758
if err != nil {
@@ -764,6 +764,12 @@ func (d *disk) Register() error {
764764
return err
765765
}
766766

767+
// Load the pool.
768+
pool, err := storagePools.LoadByName(d.state, d.config["pool"])
769+
if err != nil {
770+
return fmt.Errorf("Failed to get storage pool %q: %w", d.config["pool"], err)
771+
}
772+
767773
// Parse the volume name and path.
768774
volFields := strings.SplitN(d.config["source"], "/", 2)
769775
volName := volFields[0]

0 commit comments

Comments
 (0)