[PATCH] storage: create logical volume with --yes option

Kristina Hanicova posted 1 patch 2 years, 9 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/9b9119ec2ca201509f4958603b043832959bb133.1626947123.git.khanicov@redhat.com
src/storage/storage_backend_logical.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] storage: create logical volume with --yes option
Posted by Kristina Hanicova 2 years, 9 months ago
If lvcreate found an existing signature when trying to create a
new logical volume (E.g. left after some deleted volume), the
action failed due to inability to answer interactive question to
wiping it (lvcreate assumed 'no' was the answer). With added
option --yes to the command line, the answer to any interactive
question is assumed to be yes. Therefore, lvcreate wipes the
signature and the new volume is created successfully.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1940413

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
---
 src/storage/storage_backend_logical.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c
index ed8e47d880..02ede74aeb 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -863,6 +863,8 @@ virStorageBackendLogicalLVCreate(virStorageVolDef *vol,
     else
         virCommandAddArg(cmd, def->source.name);
 
+    virCommandAddArg(cmd, "--yes");
+
     return virCommandRun(cmd, NULL);
 }
 
-- 
2.31.1

Re: [PATCH] storage: create logical volume with --yes option
Posted by Michal Prívozník 2 years, 9 months ago
On 7/22/21 11:45 AM, Kristina Hanicova wrote:
> If lvcreate found an existing signature when trying to create a
> new logical volume (E.g. left after some deleted volume), the
> action failed due to inability to answer interactive question to
> wiping it (lvcreate assumed 'no' was the answer). With added
> option --yes to the command line, the answer to any interactive
> question is assumed to be yes. Therefore, lvcreate wipes the
> signature and the new volume is created successfully.
> 
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1940413
> 
> Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
> ---
>  src/storage/storage_backend_logical.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c
> index ed8e47d880..02ede74aeb 100644
> --- a/src/storage/storage_backend_logical.c
> +++ b/src/storage/storage_backend_logical.c
> @@ -863,6 +863,8 @@ virStorageBackendLogicalLVCreate(virStorageVolDef *vol,
>      else
>          virCommandAddArg(cmd, def->source.name);
>  
> +    virCommandAddArg(cmd, "--yes");
> +
>      return virCommandRun(cmd, NULL);
>  }
>  
> 

Initially, this looked like a big hammer, but apparently, that is what
libguestfs did too:

https://github.com/libguestfs/libguestfs/commit/21cd97732c4973db835b8b6540c8ad582ebd2bda

and it's even advised by lvm2 developers:

https://bugzilla.redhat.com/show_bug.cgi?id=1894692

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

and pushed.

Michal