[pve-devel] [PATCH qemu-server v2] fix #947: reenable disk/cdrom passthrough
Dominik Csapak
d.csapak at proxmox.com
Thu Apr 21 11:40:24 CEST 2016
previously, we did not check the file parameter of a disk,
allowing passthrough of a block device (by design)
with the change to the json parser for the disks, the format
became 'pve-volume-id' which is only valid for our volume ids
(and later we also allowed the value 'none')
this patch alternatively checks if the parameter is a path
or 'cdrom'
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
changes from v1:
* do not get the real path (because we do not want to invoke a syscall here)
* do not check if its in /dev (maybe we want a file)
* do not check if its a block device (same reason as #1)
* also check for 'cdrom'
PVE/QemuServer.pm | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 189d760..cd53978 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -619,11 +619,15 @@ for (my $i = 0; $i < $MAX_NETS; $i++) {
$confdesc->{"net$i"} = $netdesc;
}
-PVE::JSONSchema::register_format('pve-volume-id-or-none', \&verify_volume_id_or_none);
-sub verify_volume_id_or_none {
+PVE::JSONSchema::register_format('pve-volume-id-or-qm-path', \&verify_volume_id_or_qm_path);
+sub verify_volume_id_or_qm_path {
my ($volid, $noerr) = @_;
- return $volid if $volid eq 'none';
+ if ($volid eq 'none' || $volid eq 'cdrom' || $volid =~ m|^/|) {
+ return $volid;
+ }
+
+ # if its neither 'none' nor 'cdrom' nor a path, check if its a volume-id
$volid = eval { PVE::JSONSchema::check_format('pve-volume-id', $volid, '') };
if ($@) {
return undef if $noerr;
@@ -638,7 +642,7 @@ my %drivedesc_base = (
volume => { alias => 'file' },
file => {
type => 'string',
- format => 'pve-volume-id-or-none',
+ format => 'pve-volume-id-or-qm-path',
default_key => 1,
format_description => 'volume',
description => "The drive's backing volume.",
--
2.1.4
More information about the pve-devel
mailing list