mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-29 16:38:49 +00:00
move CD-ROM related helpers to drive module
This was the only user of List::Util, so move that too. No functional change intended. Signed-off-by: Fiona Ebner <f.ebner@proxmox.com> Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> Tested-by: Friedrich Weber <f.weber@proxmox.com>
This commit is contained in:
parent
d55f7ced32
commit
caddaa62c7
@ -18,7 +18,6 @@ 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);
|
||||
@ -1193,35 +1192,6 @@ sub option_exists {
|
||||
return defined($confdesc->{$key});
|
||||
}
|
||||
|
||||
my $cdrom_path;
|
||||
sub get_cdrom_path {
|
||||
|
||||
return $cdrom_path if defined($cdrom_path);
|
||||
|
||||
$cdrom_path = first { -l $_ } map { "/dev/cdrom$_" } ('', '1', '2');
|
||||
|
||||
if (!defined($cdrom_path)) {
|
||||
log_warn("no physical CD-ROM available, ignoring");
|
||||
$cdrom_path = '';
|
||||
}
|
||||
|
||||
return $cdrom_path;
|
||||
}
|
||||
|
||||
sub get_iso_path {
|
||||
my ($storecfg, $vmid, $cdrom) = @_;
|
||||
|
||||
if ($cdrom eq 'cdrom') {
|
||||
return get_cdrom_path();
|
||||
} elsif ($cdrom eq 'none') {
|
||||
return '';
|
||||
} elsif ($cdrom =~ m|^/|) {
|
||||
return $cdrom;
|
||||
} else {
|
||||
return PVE::Storage::path($storecfg, $cdrom);
|
||||
}
|
||||
}
|
||||
|
||||
# try to convert old style file names to volume IDs
|
||||
sub filename_to_volume_id {
|
||||
my ($vmid, $file, $media) = @_;
|
||||
@ -1506,7 +1476,7 @@ sub print_drive_commandline_full {
|
||||
my $scfg = $storeid ? PVE::Storage::storage_config($storecfg, $storeid) : undef;
|
||||
|
||||
if (drive_is_cdrom($drive)) {
|
||||
$path = get_iso_path($storecfg, $vmid, $volid);
|
||||
$path = PVE::QemuServer::Drive::get_iso_path($storecfg, $vmid, $volid);
|
||||
die "$drive_id: cannot back cdrom drive with a live restore image\n" if $live_restore_name;
|
||||
} else {
|
||||
if ($storeid) {
|
||||
@ -5416,7 +5386,7 @@ sub vmconfig_update_disk {
|
||||
vmconfig_register_unused_drive($storecfg, $vmid, $conf, $old_drive);
|
||||
}
|
||||
} else {
|
||||
my $path = get_iso_path($storecfg, $vmid, $drive->{file});
|
||||
my $path = PVE::QemuServer::Drive::get_iso_path($storecfg, $vmid, $drive->{file});
|
||||
|
||||
# force eject if locked
|
||||
mon_cmd($vmid, "eject", force => JSON::true, id => "$opt");
|
||||
|
@ -6,7 +6,9 @@ use warnings;
|
||||
use Storable qw(dclone);
|
||||
|
||||
use IO::File;
|
||||
use List::Util qw(first);
|
||||
|
||||
use PVE::RESTEnvironment qw(log_warn);
|
||||
use PVE::Storage;
|
||||
use PVE::JSONSchema qw(get_standard_option);
|
||||
|
||||
@ -70,6 +72,34 @@ sub checked_volume_format {
|
||||
return (checked_parse_volname($storecfg, $volid))[6];
|
||||
}
|
||||
|
||||
my $cdrom_path;
|
||||
sub get_cdrom_path {
|
||||
return $cdrom_path if defined($cdrom_path);
|
||||
|
||||
$cdrom_path = first { -l $_ } map { "/dev/cdrom$_" } ('', '1', '2');
|
||||
|
||||
if (!defined($cdrom_path)) {
|
||||
log_warn("no physical CD-ROM available, ignoring");
|
||||
$cdrom_path = '';
|
||||
}
|
||||
|
||||
return $cdrom_path;
|
||||
}
|
||||
|
||||
sub get_iso_path {
|
||||
my ($storecfg, $vmid, $cdrom) = @_;
|
||||
|
||||
if ($cdrom eq 'cdrom') {
|
||||
return get_cdrom_path();
|
||||
} elsif ($cdrom eq 'none') {
|
||||
return '';
|
||||
} elsif ($cdrom =~ m|^/|) {
|
||||
return $cdrom;
|
||||
} else {
|
||||
return PVE::Storage::path($storecfg, $cdrom);
|
||||
}
|
||||
}
|
||||
|
||||
my $MAX_IDE_DISKS = 4;
|
||||
my $MAX_SCSI_DISKS = 31;
|
||||
my $MAX_VIRTIO_DISKS = 16;
|
||||
|
Loading…
Reference in New Issue
Block a user