From a7836470392866d360ad404031a60c4a4b0c5567 Mon Sep 17 00:00:00 2001 From: hamistao Date: Thu, 12 Dec 2024 00:52:41 -0300 Subject: [PATCH 1/3] lxd: Deny creating an empty ISO volume Signed-off-by: hamistao --- lxd/storage_volumes.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lxd/storage_volumes.go b/lxd/storage_volumes.go index 3716acd86df7..3dc85120f425 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 "copy": if dbVolume != nil { From ed5a0f6e356e797c51b588ec7e80b67d40a27dff Mon Sep 17 00:00:00 2001 From: hamistao Date: Thu, 12 Dec 2024 00:57:36 -0300 Subject: [PATCH 2/3] test: Can't create empty iso volume Signed-off-by: hamistao --- test/suites/storage_local_volume_handling.sh | 3 +++ 1 file changed, 3 insertions(+) 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 From 78e7b23fcfcf8defb285bda2659c017305292efa Mon Sep 17 00:00:00 2001 From: hamistao Date: Thu, 12 Dec 2024 01:03:02 -0300 Subject: [PATCH 3/3] doc: ISO volumes can be created from copies Signed-off-by: hamistao --- doc/explanation/storage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/explanation/storage.md b/doc/explanation/storage.md index 5966f45871b0..4721df8dadbf 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.