From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pve-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id C5D501FF162 for <inbox@lore.proxmox.com>; Mon, 5 May 2025 14:59:00 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 855511C78A; Mon, 5 May 2025 14:58:31 +0200 (CEST) From: Fiona Ebner <f.ebner@proxmox.com> To: pve-devel@lists.proxmox.com Date: Mon, 5 May 2025 14:57:19 +0200 Message-Id: <20250505125724.75620-7-f.ebner@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250505125724.75620-1-f.ebner@proxmox.com> References: <20250505125724.75620-1-f.ebner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.036 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH qemu-server 06/11] qmp client: add $noerr argument X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/> List-Post: <mailto:pve-devel@lists.proxmox.com> List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com> Using the $noerr argument will allow callers to opt-in to handling errors themselves. Signed-off-by: Fiona Ebner <f.ebner@proxmox.com> --- PVE/QMPClient.pm | 8 +++++--- PVE/QemuServer/Monitor.pm | 11 ++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/PVE/QMPClient.pm b/PVE/QMPClient.pm index eefd17a5..0f08e678 100644 --- a/PVE/QMPClient.pm +++ b/PVE/QMPClient.pm @@ -86,7 +86,7 @@ sub queue_cmd { # execute a single command sub cmd { - my ($self, $vmid, $cmd, $timeout) = @_; + my ($self, $vmid, $cmd, $timeout, $noerr) = @_; my $result; @@ -143,8 +143,10 @@ sub cmd { $self->queue_execute($timeout, 2); - die "VM $vmid qmp command '$cmd->{execute}' failed - $queue_info->{error}" - if defined($queue_info->{error}); + if (defined($queue_info->{error})) { + die "VM $vmid qmp command '$cmd->{execute}' failed - $queue_info->{error}" if !$noerr; + $result = { error => $queue_info->{error} }; + } return $result; }; diff --git a/PVE/QemuServer/Monitor.pm b/PVE/QemuServer/Monitor.pm index 937006ae..5e16edac 100644 --- a/PVE/QemuServer/Monitor.pm +++ b/PVE/QemuServer/Monitor.pm @@ -12,14 +12,19 @@ our @EXPORT_OK = qw( mon_cmd ); +# Supported custom options not in the QMP schema: +# timeout - wait at most for this amount of time. If there was no actual error, the QMP/QGA command +# will still continue to be executed even after the timeout reached. +# noerr - do not die when the command gets an error or the timeout is hit. The caller needs to +# handle the error that is returned as a structured result. sub qmp_cmd { my ($vmid, $cmd) = @_; my $res; - my $timeout; + my ($noerr, $timeout); if ($cmd->{arguments}) { - $timeout = delete $cmd->{arguments}->{timeout}; + ($noerr, $timeout) = delete($cmd->{arguments}->@{qw(noerr timeout)}); } eval { @@ -28,7 +33,7 @@ sub qmp_cmd { if (-e $sname) { # test if VM is reasonably new and supports qmp/qga my $qmpclient = PVE::QMPClient->new(); - $res = $qmpclient->cmd($vmid, $cmd, $timeout); + $res = $qmpclient->cmd($vmid, $cmd, $timeout, $noerr); } else { die "unable to open monitor socket\n"; } -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel