Qm guest exec cannot support Chinese characters

xiaolin0199

Well-Known Member
Oct 16, 2018
37
1
48
40
HI,ALL:

I am currently experiencing a problem, I am using qga(qm guest exec <commond>) to implement a function to set the IP for the virtual machine.
At present, the basic functions have been implemented, and the IP and DNS information can be successfully modified for the network card.
But when the network name is Chinese, it will fail, prompting timeout

Code:
root@vcloud151:~# pvesh create /nodes/vcloud151/qemu/226/agent/vmnetwork --netid net1 --isdhcp 0 --ipaddr 172.16.18.159 --netmask 255.255.255.0 --gateway 172.16.18.1 --dns 114.114.114.114
Wide character in print at /usr/share/perl5/PVE/API2/Qemu/Agent.pm line 538.
cmd=C:\Windows\System32\netsh.exe interface ipv4 set address name=本地连接 static 172.16.18.159 255.255.255.0 172.16.18.1
Wide character in print at /usr/share/perl5/PVE/API2/Qemu/Agent.pm line 539.
dnscmd=C:\Windows\System32\netsh.exe interface ipv4 set dnsservers name=本地连接 static 114.114.114.114 validate=no
VM 226 qmp command 'guest-exec' failed - got timeout

vmnetwork Is an API interface I wrote myself, using PVE::QemuServer::Agent::qemu_exec($vmid, $cmd)

Does anyone know how to deal with this situation? Thank you
 
Wide character in print at /usr/share/perl5/PVE/API2/Qemu/Agent.pm line 538.
this occurs when using codepoints > 255 in perl strings while printing

i am not sure what you did exactly, but you can try to utf8 encode your strings, so that the vm gets an it as utf8 bytes
(replace utf8 with whatever you need for your vm)
 
this occurs when using codepoints > 255 in perl strings while printing

i am not sure what you did exactly, but you can try to utf8 encode your strings, so that the vm gets an it as utf8 bytes
(replace utf8 with whatever you need for your vm)

Thank you for your reply。I have done utf8 processing on the NIC name,like this

Code:
Encode::encode('utf8', $iface)

The problem of wide characters has been dealt with,But there will still be previous errors

Code:
root@vcloud151:~# pvesh create /nodes/vcloud151/qemu/226/agent/vmnetwork --netid net1 --isdhcp 0 --ipaddr 172.16.18.159 --netmask 255.255.255.0 --gateway 172.16.18.1 --dns 114.114.114.114
cmd=C:\Windows\System32\netsh.exe interface ipv4 set address name=本地连接 static 172.16.18.159 255.255.255.0 172.16.18.1
dnscmd=C:\Windows\System32\netsh.exe interface ipv4 set dnsservers name=本地连接 static 114.114.114.114 validate=no
VM 226 qmp command 'guest-exec' failed - got timeout

VM 226 qmp command 'guest-exec' failed - got timeout

Still will prompt quest-exec timeout problem。In what direction can I modify this problem and solve it?

Thank you.
 
is the guest agent working at all? is it installed in the guest and running?
 
mhmm... does the call to the binary in the vm work as expected? do you get any error logs inside?
 
mhmm... does the call to the binary in the vm work as expected? do you get any error logs inside?

C:\Windows\System32\netsh.exe interface ipv4 set address name=本地连接 static 172.16.18.159 255.255.255.0 172.16.18.1
C:\Windows\System32\netsh.exe interface ipv4 set dnsservers name=本地连接 static 114.114.114.114 validate=no


The above command can be successfully run directly in the virtual machine.

The log in the node is that got timeout

VM 226 qmp command 'guest-exec' failed - got timeout

How can I confirm the reason for the timeout? Is it on the QMP sender or on the QGA receiver?

Thank you
 
how long does it usually take?


I seem to have solved it, I need to modify the QMPClient.pm file.

Code:
265                 $qmpcmd = to_json({ execute => 'guest-sync-delimited',
 266                                     arguments => { id => int($cmd->{id})}}) .
 267                     to_json({ execute => $cmd->{execute}, arguments => $cmd->{arguments}});

Modify the corresponding "to_json" to "encode_json"

Code:
265                 $qmpcmd = encode_json({ execute => 'guest-sync-delimited',

 266                                     arguments => { id => int($cmd->{id})}}) .

 267                     encode_json({ execute => $cmd->{execute}, arguments => $cmd->{arguments}});
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!