]> git.proxmox.com Git - qemu-server.git/commitdiff
cdrom path: code reduction
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 13 Jan 2023 12:52:39 +0000 (13:52 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 13 Jan 2023 12:52:39 +0000 (13:52 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/QemuServer.pm

index 6155f4daf7d228d88f259ac68ea0f01d06ac89a5..f4b15fd2bfda6f2aa13cd5c91d96c465a3ae95c2 100644 (file)
@@ -19,6 +19,7 @@ use IO::Select;
 use IO::Socket::UNIX;
 use IPC::Open3;
 use JSON;
+use List::Util qw(first);
 use MIME::Base64;
 use POSIX;
 use Storable qw(dclone);
@@ -1289,13 +1290,9 @@ sub get_cdrom_path {
 
     return $cdrom_path if defined($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 {
+    $cdrom_path = first { -l $_ } map { "/dev/cdrom$_" } ('', '1', '2');
+
+    if (!defined($cdrom_path)) {
        log_warn("no physical CD-ROM available, ignoring");
        $cdrom_path = '';
     }