diff --git a/doc/explanation/storage.md b/doc/explanation/storage.md index a1eb7bb930fb..add8827d3d51 100644 --- a/doc/explanation/storage.md +++ b/doc/explanation/storage.md @@ -161,7 +161,7 @@ Each storage volume uses one of the following content types: `iso` : This content type is used for custom ISO volumes. - A custom storage volume of type `iso` can only be created by importing an ISO file using [`lxc storage volume import`](lxc_storage_volume_import.md). + A custom storage volume of type `iso` can only be created by importing an ISO file using [`lxc storage volume import`](lxc_storage_volume_import.md) or by copying another volume. Custom storage volumes of content type `iso` can only be attached to virtual machines. They can be attached to multiple machines simultaneously as they are always read-only. diff --git a/lxd/storage_volumes.go b/lxd/storage_volumes.go index 3621805e4fff..2909cddb56fe 100644 --- a/lxd/storage_volumes.go +++ b/lxd/storage_volumes.go @@ -1094,6 +1094,11 @@ func storagePoolVolumesPost(d *Daemon, r *http.Request) response.Response { switch req.Source.Type { case "": + // Makes no sense to create an empty ISO volume. + if req.ContentType == "iso" { + return response.BadRequest(errors.New("Creation of empty iso volumes is not allowed, either copy or import")) + } + return doVolumeCreateOrCopy(s, r, requestProjectName, projectName, poolName, &req) case api.SourceTypeCopy: if dbVolume != nil { diff --git a/test/suites/storage_local_volume_handling.sh b/test/suites/storage_local_volume_handling.sh index 5631ebd518f8..ae67460e350c 100755 --- a/test/suites/storage_local_volume_handling.sh +++ b/test/suites/storage_local_volume_handling.sh @@ -132,6 +132,9 @@ test_storage_local_volume_handling() { lxc storage volume move "${pool}1/vol1" "${pool}1/vol1" --project "${project}" --target-project default lxc storage volume show "${pool}1" vol1 --project default + # Create empty ISO volumes is not allowed + ! lxc storage volume create "${pool}" isoVol --type=iso || false + # Create new pools lxc storage create pool_1 dir lxc storage create pool_2 dir