Problem with Proxmox 8.0 API qemu exec

Rebirthz

Member
Jan 13, 2020
10
0
21
24
Hi,

I have install new Node with Proxmox 8.0.3.

Before this node I used API for config IP, DNS, firewall, etc..

But this Node cannot use API I setting same as other node

1695641012891.png
1695641034832.png
if it work It will return pid.

1695641107654.png


I'm try with shell command: qm guest exec 101 kvm fwoff
It actually work Turn off Windows firewall
I try another API command (get-users) it work.

1695641256641.png

In VM I have cloned it from another Node already install Virtio guest tool.

On PvE 8.0 Do I need to set anything up?
 
is there any error message when you try? what does the server return?

my guess is that you need to send the command parts as an array instead of a single string so

Code:
'command' => ['kvm', 'fwoff']
instead of
Code:
'command' => 'kvm fwoff'
 
is there any error message when you try? what does the server return?

my guess is that you need to send the command parts as an array instead of a single string so

Code:
'command' => ['kvm', 'fwoff']
instead of
Code:
'command' => 'kvm fwoff'
Thanks for reply!!!

I try to change with your code
It show like this
stdClass Object ( [errors] => stdClass Object ( [command[1]] => property is not defined in schema and the schema does not allow additional properties [command] => property is missing and it is not optional [command[0]] => property is not defined in schema and the schema does not allow additional properties ) [data] => )
1695644973524.png


On my kvm.bat have to send command 'fwoff'
1695644676809.png

How can I send with parameter?

I use this in PvE 7.4
kvm fwon (to turn on firewall)
kvm fwoff (to turn off firewall)
kvm ipv4 192.168.0.0 (to setting VM Ip)

Thanks!
 
Last edited:
I try to change with your code
It show like this
stdClass Object ( [errors] => stdClass Object ( [command[1]] => property is not defined in schema and the schema does not allow additional properties [command] => property is missing and it is not optional [command[0]] => property is not defined in schema and the schema does not allow additional properties ) [data] => )
ok it seems that the request is somehow wrongly encoded? it tries to send command[0] and command[1] which is wrong, it has to send command as an array (which requires json encoding on the body. i don't know how or if you can configure that in your language/tools

what is the error message when you try your original request with 'command' => 'kvm fwoff' ?
 
ok it seems that the request is somehow wrongly encoded? it tries to send command[0] and command[1] which is wrong, it has to send command as an array (which requires json encoding on the body. i don't know how or if you can configure that in your language/tools

what is the error message when you try your original request with 'command' => 'kvm fwoff' ?
this message show when use 'command' => 'kvm fwoff'

stdClass Object ( [data] => )


NOW I edit my code to array
with code "command" => ["kvm", 'fwoff']

it show this message
stdClass Object ( [errors] => stdClass Object ( [{"command":["kvm","fwoff"]}] => property is not defined in schema and the schema does not allow additional properties [command] => property is missing and it is not optional ) [data] => )
 
Last edited:
can you check what the exact/complete http request and response is?
 
can you check what the exact/complete http request and response is?
Thanks for reply!

what do you mean ?
I'm sorry my bad in English

now i'm try this code
PHP:
$create = array("command" => 'kvm',);
$send = Request::Request("/nodes/$firstNode/qemu/$vmid/agent/exec", $create, 'POST');
print_r($send);
Print
PHP:
stdClass Object ( [data] => stdClass Object ( [pid] => 4012 ) )

It working normal but when I adding parameter like in PvE 7.4 It will not working

Example
PHP:
$create = array("command" => 'kvm setIp 192.168.0.5 255.255.255.0 192.168.0.254');
$send = Request::Request("/nodes/$firstNode/qemu/$vmid/agent/exec", $create, 'POST');
print_r($send);

In PvE 7.4 it work normal.
 
Last edited:
Update!

Now I'm try in Postman

in this case and it work
Sending 'command' 2 times
1695723440152.png

but in php how it can have samekey i'm try

PHP:
$create = array(
                "command" => 'kvm',
                "command" => 'fwon',
);

it cannot work
 
Thanks for reply!

what do you mean ?
I'm sorry my bad in English
i mean i would like to see the raw http request and raw http response, not what you send/get in your php script, normally

now i'm try this code
PHP:
$create = array("command" => 'kvm',);
$send = Request::Request("/nodes/$firstNode/qemu/$vmid/agent/exec", $create, 'POST');
print_r($send);
Print
PHP:
stdClass Object ( [data] => stdClass Object ( [pid] => 4012 ) )

It working normal but when I adding parameter like in PvE 7.4 It will not working

Example
PHP:
$create = array("command" => 'kvm setIp 192.168.0.5 255.255.255.0 192.168.0.254');
$send = Request::Request("/nodes/$firstNode/qemu/$vmid/agent/exec", $create, 'POST');
print_r($send);

In PvE 7.4 it work normal.
ok, so the api call changed so that it now takes an array instead of a string (and splitting somewhere)

i don't know which php client you use, but you either have to tell it to repeat the parameter (as you wrote) or to send the request parameter as json and use a proper array
 

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!