From 5b9d692ae7765e2dd0bf07e773f2fe31778191f9 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 20 Oct 2011 11:18:46 +0200 Subject: [PATCH] allow to pass volume IDs in create_vm (restore) --- PVE/API2/Qemu.pm | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 957a398..cd63cfb 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -2,6 +2,7 @@ package PVE::API2::Qemu; use strict; use warnings; +use Cwd 'abs_path'; use PVE::Cluster; use PVE::SafeSyslog; @@ -145,8 +146,20 @@ __PACKAGE__->register_method({ my $keystr = join(' ', keys %$param); raise_param_exc({ archive => "option conflicts with other options ($keystr)"}) if $keystr; - die "pipe requires cli environment\n" - if $archive eq '-' && $rpcenv->{type} ne 'cli'; + if ($archive eq '-') { + die "pipe requires cli environment\n" + && $rpcenv->{type} ne 'cli'; + } else { + if (PVE::Storage::parse_volume_id($archive, 1)) { + $archive = PVE::Storage::path($storecfg, $archive); + } else { + raise_param_exc({ archive => "Only root can pass arbitrary paths." }) + if $user ne 'root@pam'; + + $archive = abs_path($archive); + } + die "can't find file '$archive'\n" if ! -f $archive; + } } my $restorefn = sub { -- 2.39.2