mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-10-04 21:14:21 +00:00
print drive commandline: die if drive with ISO sets no explicit media
The `media` option defaults to `disk` if not present, which attaches the drive read-write. This can be unexpected for ISO volumes. Hence, when constructing the QEMU command line, require that drives with ISO volumes explicitly set `media` and die if this is not the case. This breaks VM start and live-migration if such a drive is present, and hotplug for such drives. Users can fix this by editing the VM config to set `media` explicitly. Also add a cfg2cmd test for the error. Suggested-by: Fiona Ebner <f.ebner@proxmox.com> Signed-off-by: Friedrich Weber <f.weber@proxmox.com> Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
parent
6a956f8604
commit
2e2f8cb7a3
@ -1443,6 +1443,7 @@ sub print_drive_commandline_full {
|
|||||||
|
|
||||||
my ($storeid) = PVE::Storage::parse_volume_id($drive->{file}, 1);
|
my ($storeid) = PVE::Storage::parse_volume_id($drive->{file}, 1);
|
||||||
my $scfg = $storeid ? PVE::Storage::storage_config($storecfg, $storeid) : undef;
|
my $scfg = $storeid ? PVE::Storage::storage_config($storecfg, $storeid) : undef;
|
||||||
|
my $vtype = $storeid ? (PVE::Storage::parse_volname($storecfg, $drive->{file}))[0] : undef;
|
||||||
|
|
||||||
my ($path, $format) = PVE::QemuServer::Drive::get_path_and_format(
|
my ($path, $format) = PVE::QemuServer::Drive::get_path_and_format(
|
||||||
$storecfg, $vmid, $drive, $live_restore_name);
|
$storecfg, $vmid, $drive, $live_restore_name);
|
||||||
@ -1514,6 +1515,9 @@ sub print_drive_commandline_full {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
die "$drive_id: explicit media parameter is required for iso images\n"
|
||||||
|
if !defined($drive->{media}) && defined($vtype) && $vtype eq 'iso';
|
||||||
|
|
||||||
if (!drive_is_cdrom($drive)) {
|
if (!drive_is_cdrom($drive)) {
|
||||||
my $detectzeroes;
|
my $detectzeroes;
|
||||||
if (defined($drive->{detect_zeroes}) && !$drive->{detect_zeroes}) {
|
if (defined($drive->{detect_zeroes}) && !$drive->{detect_zeroes}) {
|
||||||
|
15
test/cfg2cmd/ide-no-media-error.conf
Normal file
15
test/cfg2cmd/ide-no-media-error.conf
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# TEST: Config that doesn't specify an explicit `media` for an ISO drive
|
||||||
|
# EXPECT_ERROR: ide3: explicit media parameter is required for iso images
|
||||||
|
bootdisk: scsi0
|
||||||
|
cores: 2
|
||||||
|
ide0: cifs-store:iso/zero.iso,media=cdrom,size=112M
|
||||||
|
ide1: cifs-store:iso/one.iso,media=cdrom,size=112M
|
||||||
|
ide2: cifs-store:iso/two.iso,media=disk,size=112M
|
||||||
|
ide3: cifs-store:iso/three.iso,size=112M
|
||||||
|
memory: 512
|
||||||
|
net0: virtio=2E:01:68:F9:9C:87,bridge=vmbr0
|
||||||
|
ostype: l26
|
||||||
|
scsi0: local:100/vm-100-disk-2.qcow2,size=10G
|
||||||
|
scsihw: virtio-scsi-pci
|
||||||
|
smbios1: uuid=3dd750ce-d910-44d0-9493-525c0be4e687
|
||||||
|
vmgenid: 54d1c06c-8f5b-440f-b5b2-6eab1380e13d
|
Loading…
Reference in New Issue
Block a user