all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Hannes Duerr <h.duerr@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v4 qemu-server 2/4] Move NEW_DISK_RE to QemuServer/Drive.pm
Date: Fri, 17 Nov 2023 12:53:09 +0100	[thread overview]
Message-ID: <20231117115311.111320-3-h.duerr@proxmox.com> (raw)
In-Reply-To: <20231117115311.111320-1-h.duerr@proxmox.com>

Move it due to better context and preparation of fix

Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
---
 PVE/API2/Qemu.pm        | 10 ++++------
 PVE/QemuServer/Drive.pm |  1 +
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 38bdaab..b9c8f20 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -86,8 +86,6 @@ my $foreach_volume_with_alloc = sub {
     }
 };
 
-my $NEW_DISK_RE = qr!^(([^/:\s]+):)?(\d+(\.\d+)?)$!;
-
 my $check_drive_param = sub {
     my ($param, $storecfg, $extra_checks) = @_;
 
@@ -98,7 +96,7 @@ my $check_drive_param = sub {
 	raise_param_exc({ $opt => "unable to parse drive options" }) if !$drive;
 
 	if ($drive->{'import-from'}) {
-	    if ($drive->{file} !~ $NEW_DISK_RE || $3 != 0) {
+	    if ($drive->{file} !~ $PVE::QemuServer::Drive::NEW_DISK_RE || $3 != 0) {
 		raise_param_exc({
 		    $opt => "'import-from' requires special syntax - ".
 			"use <storage ID>:0,import-from=<source>",
@@ -142,7 +140,7 @@ my $check_storage_access = sub {
 	    # nothing to check
 	} elsif ($isCDROM && ($volid eq 'cdrom')) {
 	    $rpcenv->check($authuser, "/", ['Sys.Console']);
-	} elsif (!$isCDROM && ($volid =~ $NEW_DISK_RE)) {
+	} elsif (!$isCDROM && ($volid =~ $PVE::QemuServer::Drive::NEW_DISK_RE)) {
 	    my ($storeid, $size) = ($2 || $default_storage, $3);
 	    die "no storage ID specified (and no default storage)\n" if !$storeid;
 	    $rpcenv->check($authuser, "/storage/$storeid", ['Datastore.AllocateSpace']);
@@ -365,7 +363,7 @@ my $create_disks = sub {
 	    delete $disk->{format}; # no longer needed
 	    $res->{$ds} = PVE::QemuServer::print_drive($disk);
 	    print "$ds: successfully created disk '$res->{$ds}'\n";
-	} elsif ($volid =~ $NEW_DISK_RE) {
+	} elsif ($volid =~ $PVE::QemuServer::Drive::NEW_DISK_RE) {
 	    my ($storeid, $size) = ($2 || $default_storage, $3);
 	    die "no storage ID specified (and no default storage)\n" if !$storeid;
 
@@ -1626,7 +1624,7 @@ my $update_vm_api  = sub {
 	return if defined($volname) && $volname eq 'cloudinit';
 
 	my $format;
-	if ($volid =~ $NEW_DISK_RE) {
+	if ($volid =~ $PVE::QemuServer::Drive::NEW_DISK_RE) {
 	    $storeid = $2;
 	    $format = $drive->{format} || PVE::Storage::storage_default_format($storecfg, $storeid);
 	} else {
diff --git a/PVE/QemuServer/Drive.pm b/PVE/QemuServer/Drive.pm
index dce1398..6d94a2f 100644
--- a/PVE/QemuServer/Drive.pm
+++ b/PVE/QemuServer/Drive.pm
@@ -34,6 +34,7 @@ my $MAX_SCSI_DISKS = 31;
 my $MAX_VIRTIO_DISKS = 16;
 our $MAX_SATA_DISKS = 6;
 our $MAX_UNUSED_DISKS = 256;
+our $NEW_DISK_RE = qr!^(([^/:\s]+):)?(\d+(\.\d+)?)$!;
 
 our $drivedesc_hash;
 # Schema when disk allocation is possible.
-- 
2.39.2





  parent reply	other threads:[~2023-11-17 11:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-17 11:53 [pve-devel] [PATCH v4 qemu-server 0/4] fix #4957: add vendor and product information passthrough for SCSI-Disks Hannes Duerr
2023-11-17 11:53 ` [pve-devel] [PATCH v4 qemu-server 1/4] Move path_is_scsi to QemuServer/Drive.pm Hannes Duerr
2023-11-17 11:53 ` Hannes Duerr [this message]
2023-11-17 11:53 ` [pve-devel] [PATCH v4 qemu-server 3/4] drive: Create get_scsi_devicetype Hannes Duerr
2023-11-17 11:53 ` [pve-devel] [PATCH v4 qemu-server 4/4] fix #4957: add vendor and product information passthrough for SCSI-Disks Hannes Duerr
2023-11-17 12:24   ` Hannes Dürr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231117115311.111320-3-h.duerr@proxmox.com \
    --to=h.duerr@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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