[pve-devel] [PATCH qemu-server v4 2/2] cd rom handling: refactor cd rom path helper function

Stefan Sterz s.sterz at proxmox.com
Tue Dec 20 11:30:37 CET 2022


to stop returning results of assignments

Signed-off-by: Stefan Sterz <s.sterz at proxmox.com>
---
drop this if unwanted/unneeded

 PVE/QemuServer.pm | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 3837bd9..8d8252d 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -1289,12 +1289,16 @@ sub get_cdrom_path {
 
     return $cdrom_path if defined($cdrom_path);
 
-    return $cdrom_path = "/dev/cdrom" if -l "/dev/cdrom";
-    return $cdrom_path = "/dev/cdrom1" if -l "/dev/cdrom1";
-    return $cdrom_path = "/dev/cdrom2" if -l "/dev/cdrom2";
-
-    log_warn("no physical CD-ROM available, ignoring");
-    $cdrom_path = '';
+    if (-l "/dev/cdrom") {
+	$cdrom_path = "/dev/cdrom";
+    } elsif (-l "/dev/cdrom1") {
+	$cdrom_path = "/dev/cdrom1";
+    } elsif (-l "/dev/cdrom2") {
+	$cdrom_path = "/dev/cdrom2";
+    } else {
+	log_warn("no physical CD-ROM available, ignoring");
+	$cdrom_path = '';
+    }
 
     return $cdrom_path;
 }
-- 
2.30.2






More information about the pve-devel mailing list