From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server 06/11] qmp client: add $noerr argument
Date: Mon, 5 May 2025 14:57:19 +0200 [thread overview]
Message-ID: <20250505125724.75620-7-f.ebner@proxmox.com> (raw)
In-Reply-To: <20250505125724.75620-1-f.ebner@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
next prev parent reply other threads:[~2025-05-05 12:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-05 12:57 [pve-devel] [PATCH-SERIES qemu-server 00/11] better handle lost freeze command Fiona Ebner
2025-05-05 12:57 ` [pve-devel] [PATCH qemu-server 01/11] agent: drop unused $noerr argument from helpers Fiona Ebner
2025-05-05 12:57 ` [pve-devel] [PATCH qemu-server 02/11] api: agent: improve module imports Fiona Ebner
2025-05-05 12:57 ` [pve-devel] [PATCH qemu-server 03/11] agent: code style: order module imports according to style guide Fiona Ebner
2025-05-05 12:57 ` [pve-devel] [PATCH qemu-server 04/11] agent: avoid dependency on QemuConfig module Fiona Ebner
2025-05-05 12:57 ` [pve-devel] [PATCH qemu-server 05/11] qmp client: remove erroneous comment Fiona Ebner
2025-05-05 12:57 ` Fiona Ebner [this message]
2025-05-05 12:57 ` [pve-devel] [PATCH qemu-server 07/11] agent: implement fsfreeze helper to better handle lost commands Fiona Ebner
2025-05-05 13:57 ` Mira Limbeck
2025-05-05 14:01 ` Fiona Ebner
2025-05-05 12:57 ` [pve-devel] [PATCH qemu-server 08/11] agent: avoid use of deprecated check_running() function Fiona Ebner
2025-05-05 12:57 ` [pve-devel] [PATCH qemu-server 09/11] agent: move qga_check_running() helper to agent module Fiona Ebner
2025-05-05 12:57 ` [pve-devel] [PATCH qemu-server 10/11] agent: prefer usage of get_qga_key() helper Fiona Ebner
2025-05-05 12:57 ` [pve-devel] [PATCH qemu-server 11/11] agent: move guest agent format and parsing to agent module Fiona Ebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250505125724.75620-7-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal