[pve-devel] [PATCH qemu-server 1/4] qmp client: encode JSON as UTF-8 to fix PBS backup when password contains multi-byte UTF-8
Fiona Ebner
f.ebner at proxmox.com
Wed Oct 1 12:47:10 CEST 2025
As reported in the community forum, PBS backup of VMs would not work
when the password contained a multi-byte UTF-8 character [0].
The reason is that when writing a string in Perl's internal
representation with character values >= 128 to the QMP socket, QEMU
seems to have a bug where it reads too few characters (one less for
each char value >= 128). In such a case, the QMP client will just time
out, as the command is never completely read on the QEMU side.
Stuffing with additional characters would actually lead to QEMU
reading enough characters and executing the command, but Perl's
internal representation should not be submitted to QMP in the first
place. Encode the JSON properly as UTF-8 to avoid the issue.
In particular, this makes backing up a VM to PBS possible when the PBS
password contains multi-byte UTF-8 characters.
This also fixes future similar issues, for example when a QMP command
is passed a filesystem path with multi-byte UTF-8 characters.
[0]: https://forum.proxmox.com/threads/172871/post-804921
Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
Unfortunately, doing the same for QGA is not yet enough to fix issue
#6609.
src/PVE/QMPClient.pm | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/PVE/QMPClient.pm b/src/PVE/QMPClient.pm
index 7b19be9d..46d8b299 100644
--- a/src/PVE/QMPClient.pm
+++ b/src/PVE/QMPClient.pm
@@ -291,12 +291,14 @@ my $check_queue = sub {
. "\n";
} else {
-
- $qmpcmd = to_json({
- execute => $cmd->{execute},
- arguments => $cmd->{arguments},
- id => $cmd->{id},
- });
+ $qmpcmd = to_json(
+ {
+ execute => $cmd->{execute},
+ arguments => $cmd->{arguments},
+ id => $cmd->{id},
+ },
+ { utf8 => 1 },
+ );
}
if ($fd >= 0) {
--
2.47.3
More information about the pve-devel
mailing list