Skip to content

Do not allow mounting of custom block volume snapshots #1720

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

Merged
merged 1 commit into from
Mar 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions internal/server/device/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,9 +540,10 @@ func (d *disk) validateConfig(instConf instance.ConfigReader) error {
}
}

// Parse the volume name and path.
volFields := strings.SplitN(d.config["source"], "/", 2)

if dbVolume == nil {
// Parse the volume name and path.
volFields := strings.SplitN(d.config["source"], "/", 2)
volName := volFields[0]

// GetStoragePoolVolume returns a volume with an empty Location field for remote drivers.
Expand Down Expand Up @@ -579,6 +580,11 @@ func (d *disk) validateConfig(instConf instance.ConfigReader) error {
if d.config["path"] != "" {
return fmt.Errorf("Custom block volumes cannot have a path defined")
}

if len(volFields) > 1 {
return fmt.Errorf("Custom block volume snapshots cannot be used directly")
}

} else if contentType == db.StoragePoolVolumeContentTypeISO {
if instConf.Type() == instancetype.Container {
return fmt.Errorf("Custom ISO volumes cannot be used on containers")
Expand Down
Loading