[pve-devel] [PATCH qemu-server 4/8] drive schema: allow 'none' again

Wolfgang Bumiller w.bumiller at proxmox.com
Wed Mar 30 12:20:09 CEST 2016


---
 PVE/QemuServer.pm | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 39c9788..bb9624b 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -516,13 +516,26 @@ 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 {
+    my ($volid, $noerr) = @_;
+
+    return $volid if $volid eq 'none';
+    $volid = eval { PVE::JSONSchema::check_format('pve-volume-id', $volid, '') };
+    if ($@) {
+	return undef if $noerr;
+	die $@;
+    }
+    return $volid;
+}
+
 my $drivename_hash;
 
 my %drivedesc_base = (
     volume => { alias => 'file' },
     file => {
 	type => 'string',
-	format => 'pve-volume-id',
+	format => 'pve-volume-id-or-none',
 	default_key => 1,
 	format_description => 'volume',
 	description => "The drive's backing volume.",
-- 
2.1.4





More information about the pve-devel mailing list