[pve-devel] [PATCH RESEND qemu-server] Fix #1174: remove pve-qm-drive
Wolfgang Bumiller
w.bumiller at proxmox.com
Tue Oct 18 10:38:58 CEST 2016
Let 'cdrom' use the pve-qm-ide format, as it's supposed to
be an alias to ide2.
We're not using the 'alias' schema property since the qemu
configs still use a custom parser (due to the
pending-changes system and the filename-to-volume-id
conversion for legacy support) which does not deal with
schema aliases.
---
Note that this is marked as a resend as this patch already found its way onto
the list a while ago (prior to the #1174 bugzilla entry).
PVE/QemuServer.pm | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 44aa249..728110f 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -452,7 +452,7 @@ EODESCR
},
cdrom => {
optional => 1,
- type => 'string', format => 'pve-qm-drive',
+ type => 'string', format => 'pve-qm-ide',
typetext => 'volume',
description => "This is an alias for option -ide2",
},
@@ -854,6 +854,7 @@ my $ide_fmt = {
%rerror_fmt,
%model_fmt,
};
+PVE::JSONSchema::register_format("pve-qm-ide", $ide_fmt);
my $idedesc = {
optional => 1,
@@ -2013,12 +2014,6 @@ sub check_type {
die "type check ('number') failed - got '$value'\n";
} elsif ($type eq 'string') {
if (my $fmt = $confdesc->{$key}->{format}) {
- if ($fmt eq 'pve-qm-drive') {
- # special case - we need to pass $key to parse_drive()
- my $drive = parse_drive($key, $value);
- return $value if $drive;
- die "unable to parse drive options\n";
- }
PVE::JSONSchema::check_format($fmt, $value);
return $value;
}
@@ -2166,8 +2161,9 @@ sub parse_vm_config {
if ($@) {
warn "vm $vmid - unable to parse value of '$key' - $@";
} else {
+ $key = 'ide2' if $key eq 'cdrom';
my $fmt = $confdesc->{$key}->{format};
- if ($fmt && $fmt eq 'pve-qm-drive') {
+ if ($fmt && $fmt =~ /^pve-qm-(?:ide|scsi|virtio|sata)$/) {
my $v = parse_drive($key, $value);
if (my $volid = filename_to_volume_id($vmid, $v->{file}, $v->{media})) {
$v->{file} = $volid;
@@ -2178,11 +2174,7 @@ sub parse_vm_config {
}
}
- if ($key eq 'cdrom') {
- $conf->{ide2} = $value;
- } else {
- $conf->{$key} = $value;
- }
+ $conf->{$key} = $value;
}
}
}
--
2.1.4
More information about the pve-devel
mailing list