Skip to content

Commit 70c9316

Browse files
authored
Merge pull request #1720 from presztak/disallow_mount_snapshots
Do not allow mounting of custom block volume snapshots
2 parents 22275f1 + 4b88ca4 commit 70c9316

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

internal/server/device/disk.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,10 @@ func (d *disk) validateConfig(instConf instance.ConfigReader) error {
540540
}
541541
}
542542

543+
// Parse the volume name and path.
544+
volFields := strings.SplitN(d.config["source"], "/", 2)
545+
543546
if dbVolume == nil {
544-
// Parse the volume name and path.
545-
volFields := strings.SplitN(d.config["source"], "/", 2)
546547
volName := volFields[0]
547548

548549
// GetStoragePoolVolume returns a volume with an empty Location field for remote drivers.
@@ -579,6 +580,11 @@ func (d *disk) validateConfig(instConf instance.ConfigReader) error {
579580
if d.config["path"] != "" {
580581
return fmt.Errorf("Custom block volumes cannot have a path defined")
581582
}
583+
584+
if len(volFields) > 1 {
585+
return fmt.Errorf("Custom block volume snapshots cannot be used directly")
586+
}
587+
582588
} else if contentType == db.StoragePoolVolumeContentTypeISO {
583589
if instConf.Type() == instancetype.Container {
584590
return fmt.Errorf("Custom ISO volumes cannot be used on containers")

0 commit comments

Comments
 (0)