write-file API call doesn't work as supposed

DmitryShm

New Member
May 29, 2019
5
0
1
39
Hi, friends.

I'm the Proxmox VE 5.2 user and would like to ask you about write-file QEmu agent request of VE API. Using the following command sequence to write a file on QEmu VM with the "system-test" snapshot created
Code:
$ robotLoginData=$(curl -k -d "username=$pveLogin@pve&password=$pvePassword" [https]://$pveHostPort/api2/json/access/ticket)
$ robotCSRFPreventionToken=$(echo $robotLoginData | jq -r '.data.CSRFPreventionToken')
$ robotTicket=$(echo $robotLoginData | jq -r '.data.ticket')
$ curl -k -b "PVEAuthCookie=$robotTicket" -H "CSRFPreventionToken: $robotCSRFPreventionToken" -X POST [https]://$pveHostPort/api2/json/nodes/$pveNode/qemu/$pveVm/snapshot/system-test/rollback
$ curl -k -b "PVEAuthCookie=$robotTicket" -H "CSRFPreventionToken: $robotCSRFPreventionToken" -d "content=12345" -d "file=12345.txt" -X POST [https]://$pveHostPort/api2/json/nodes/$pveNode/qemu/$pveVm/agent/file-write
I want to create 12345.txt file on the remote VM. Everything is fine, except the last command, which returns
Code:
{"data":null}
And it's stated the agent/file-write command correct answer when it succeeded. But after the command succeeds there's no file 12345.txt on VM exists.

If you have used VE API please help me to understand how to manage the write-file QEmu agent requests.
 
Last edited:
works here without problem, maybe you looked in the wrong folder?

if you do not specify an absolute path (like you did with '12345.txt') it turns up in the root directory ('/12345.txt')
 
When I call
Code:
$ curl -k -b "PVEAuthCookie=$robotTicket" [https]://$pveHostPort/api2/json/nodes/$pveNode/qemu/$pveVm/agent/info | python -m json.tool
I get
Code:
{
    "data": {
        "result": {
            "supported_commands": [
                {
                    "enabled": true,
                    "name": "guest-set-user-password"
                },
                {
                    "enabled": true,
                    "name": "guest-get-vcpus"
                },
                {
                    "enabled": true,
                    "name": "guest-suspend-ram"
                },
                {
                    "enabled": true,
                    "name": "guest-suspend-disk"
                },
                {
                    "enabled": true,
                    "name": "guest-fsfreeze-thaw"
                },
                {
                    "enabled": true,
                    "name": "guest-fsfreeze-freeze"
                },
                {
                    "enabled": true,
                    "name": "guest-fsfreeze-status"
                },
                {
                    "enabled": true,
                    "name": "guest-shutdown"
                },
                {
                    "enabled": true,
                    "name": "guest-info"
                },
                {
                    "enabled": true,
                    "name": "guest-set-time"
                },
                {
                    "enabled": true,
                    "name": "guest-get-time"
                },
                {
                    "enabled": true,
                    "name": "guest-ping"
                },
                {
                    "enabled": true,
                    "name": "guest-sync"
                },
                {
                    "enabled": true,
                    "name": "guest-sync-delimited"
                }
            ],
            "version": "0.12.1"
        }
    }
}
So the version doesn't match yours and there's no support for file-write command . Where can I get new versions of QEmu agents for windows VMs? I got mine from virtio-win-0.1.141.iso (fedorapeople site).
 
I've used virtio-win-0.1.171.iso and everything worked out. Thank you!

virtio-win-0.1.171.iso (the latest package) is quite strange. When I updated QEmuAgent the agent/info command told me that it's version is "100.0.0".
 

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!