From 4d47a9f510e9def5dc84cb629fd7f658f0f3b829 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Thu, 10 Feb 2022 16:27:55 +0100 Subject: [PATCH] api: qga file-write: drop the check for base64 it's potentially expensive to check and the user already needs to explicitly turn auto-encoding off, besides QEMU/QGA should handle that and just error out gracefully on bogus base64 values. Signed-off-by: Thomas Lamprecht --- PVE/API2/Qemu/Agent.pm | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/PVE/API2/Qemu/Agent.pm b/PVE/API2/Qemu/Agent.pm index 034b1504..7d35fe76 100644 --- a/PVE/API2/Qemu/Agent.pm +++ b/PVE/API2/Qemu/Agent.pm @@ -488,11 +488,8 @@ __PACKAGE__->register_method({ my ($param) = @_; my $vmid = $param->{vmid}; - my $encode = $param->{encode} // 1; - my $buf = $encode ? encode_base64($param->{content}) : $param->{content}; - die "content is not base64 encoded\n" - if !$encode && $buf !~ m@^(?:[A-Z0-9+/]{4})*(?:[A-Z0-9+/]{2}==|[A-Z0-9+/]{3}=)?$@mi; + my $buf = ($param->{encode} // 1) ? encode_base64($param->{content}) : $param->{content}; my $qgafh = agent_cmd($vmid, "file-open", { path => $param->{file}, mode => 'wb' }, "can't open file"); my $write = agent_cmd($vmid, "file-write", { handle => $qgafh, 'buf-b64' => $buf }, "can't write to file");