all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH qemu-server] fix #4085: properly activate cicustom storage(s)
@ 2024-01-25 12:33 Fabian Grünbichler
  2024-01-30 14:34 ` Fiona Ebner
  0 siblings, 1 reply; 3+ messages in thread
From: Fabian Grünbichler @ 2024-01-25 12:33 UTC (permalink / raw)
  To: pve-devel

PVE::Storage::path() neither activates the storage of the passed-in volume, nor
does it ensure that the returned value is actually a file or block device, so
this actually fixes two issues. PVE::Storage::abs_filesystem_path() actually
takes care of both, while still calling path() under the hood (since $volid
here is always a proper volid, unless we change the cicustom schema at some
point in the future).

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
Tested by forcefully de-activating a storage only used for cicustom volumes
right before starting the VM in question

 PVE/QemuServer/Cloudinit.pm | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/PVE/QemuServer/Cloudinit.pm b/PVE/QemuServer/Cloudinit.pm
index 7449993a..9a500f8a 100644
--- a/PVE/QemuServer/Cloudinit.pm
+++ b/PVE/QemuServer/Cloudinit.pm
@@ -550,8 +550,11 @@ sub get_custom_cloudinit_files {
 sub read_cloudinit_snippets_file {
     my ($storage_conf, $volid) = @_;
 
-    my ($full_path, undef, $type) = PVE::Storage::path($storage_conf, $volid);
-    die "$volid is not in the snippets directory\n" if $type ne 'snippets';
+    my ($vtype, undef, undef, undef, undef, undef, undef) = PVE::Storage::parse_volname($storage_conf, $volid);
+
+    die "$volid is not in the snippets directory\n" if $vtype ne 'snippets';
+
+    my $full_path = PVE::Storage::abs_filesystem_path($storage_conf, $volid, 1);
     return PVE::Tools::file_get_contents($full_path, 1 * 1024 * 1024);
 }
 
-- 
2.39.2





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pve-devel] [PATCH qemu-server] fix #4085: properly activate cicustom storage(s)
  2024-01-25 12:33 [pve-devel] [PATCH qemu-server] fix #4085: properly activate cicustom storage(s) Fabian Grünbichler
@ 2024-01-30 14:34 ` Fiona Ebner
  2024-01-31 11:29   ` [pve-devel] applied: " Fabian Grünbichler
  0 siblings, 1 reply; 3+ messages in thread
From: Fiona Ebner @ 2024-01-30 14:34 UTC (permalink / raw)
  To: Proxmox VE development discussion, Fabian Grünbichler

Am 25.01.24 um 13:33 schrieb Fabian Grünbichler:
> PVE::Storage::path() neither activates the storage of the passed-in volume, nor
> does it ensure that the returned value is actually a file or block device, so
> this actually fixes two issues. PVE::Storage::abs_filesystem_path() actually
> takes care of both, while still calling path() under the hood (since $volid
> here is always a proper volid, unless we change the cicustom schema at some
> point in the future).
> 
> Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>

Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>

> ---
> Tested by forcefully de-activating a storage only used for cicustom volumes
> right before starting the VM in question
> 
>  PVE/QemuServer/Cloudinit.pm | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/PVE/QemuServer/Cloudinit.pm b/PVE/QemuServer/Cloudinit.pm
> index 7449993a..9a500f8a 100644
> --- a/PVE/QemuServer/Cloudinit.pm
> +++ b/PVE/QemuServer/Cloudinit.pm
> @@ -550,8 +550,11 @@ sub get_custom_cloudinit_files {
>  sub read_cloudinit_snippets_file {
>      my ($storage_conf, $volid) = @_;
>  
> -    my ($full_path, undef, $type) = PVE::Storage::path($storage_conf, $volid);
> -    die "$volid is not in the snippets directory\n" if $type ne 'snippets';
> +    my ($vtype, undef, undef, undef, undef, undef, undef) = PVE::Storage::parse_volname($storage_conf, $volid);

Style nit: line too long. Could be just
my ($vtype) = ...

> +
> +    die "$volid is not in the snippets directory\n" if $vtype ne 'snippets';
> +
> +    my $full_path = PVE::Storage::abs_filesystem_path($storage_conf, $volid, 1);
>      return PVE::Tools::file_get_contents($full_path, 1 * 1024 * 1024);
>  }
>  




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pve-devel] applied: [PATCH qemu-server] fix #4085: properly activate cicustom storage(s)
  2024-01-30 14:34 ` Fiona Ebner
@ 2024-01-31 11:29   ` Fabian Grünbichler
  0 siblings, 0 replies; 3+ messages in thread
From: Fabian Grünbichler @ 2024-01-31 11:29 UTC (permalink / raw)
  To: Fiona Ebner, Proxmox VE development discussion

On January 30, 2024 3:34 pm, Fiona Ebner wrote:
> Am 25.01.24 um 13:33 schrieb Fabian Grünbichler:
>> PVE::Storage::path() neither activates the storage of the passed-in volume, nor
>> does it ensure that the returned value is actually a file or block device, so
>> this actually fixes two issues. PVE::Storage::abs_filesystem_path() actually
>> takes care of both, while still calling path() under the hood (since $volid
>> here is always a proper volid, unless we change the cicustom schema at some
>> point in the future).
>> 
>> Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
> 
> Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>

with this added

> 
>> ---
>> Tested by forcefully de-activating a storage only used for cicustom volumes
>> right before starting the VM in question
>> 
>>  PVE/QemuServer/Cloudinit.pm | 7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>> 
>> diff --git a/PVE/QemuServer/Cloudinit.pm b/PVE/QemuServer/Cloudinit.pm
>> index 7449993a..9a500f8a 100644
>> --- a/PVE/QemuServer/Cloudinit.pm
>> +++ b/PVE/QemuServer/Cloudinit.pm
>> @@ -550,8 +550,11 @@ sub get_custom_cloudinit_files {
>>  sub read_cloudinit_snippets_file {
>>      my ($storage_conf, $volid) = @_;
>>  
>> -    my ($full_path, undef, $type) = PVE::Storage::path($storage_conf, $volid);
>> -    die "$volid is not in the snippets directory\n" if $type ne 'snippets';
>> +    my ($vtype, undef, undef, undef, undef, undef, undef) = PVE::Storage::parse_volname($storage_conf, $volid);
> 
> Style nit: line too long. Could be just
> my ($vtype) = ...

and this addressed as well ;) thanks!

> 
>> +
>> +    die "$volid is not in the snippets directory\n" if $vtype ne 'snippets';
>> +
>> +    my $full_path = PVE::Storage::abs_filesystem_path($storage_conf, $volid, 1);
>>      return PVE::Tools::file_get_contents($full_path, 1 * 1024 * 1024);
>>  }
>>  
> 




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-01-31 11:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-25 12:33 [pve-devel] [PATCH qemu-server] fix #4085: properly activate cicustom storage(s) Fabian Grünbichler
2024-01-30 14:34 ` Fiona Ebner
2024-01-31 11:29   ` [pve-devel] applied: " Fabian Grünbichler

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal