Is it possible to pause a VM from API?

IvanGomezGon

New Member
Jun 6, 2023
4
1
3
Hey! So I can see from the API viewer you can reboot, reset, resume, shutdown, start, stop and suspend, but there seems to be no option to pause a VM.
Am I missing something obvious? Could I instead suspend to get a similar effect?

Thanks!
 
Pause and Suspend are the same thing. You can confirm that by :
a) tail -f /var/log/pveproxy/access.log
b) execute Pause via gui
c) notice the API called:
::ffff:172.16.9.3 - root@pam [06/06/2023:14:05:03 -0400] "POST /api2/extjs/nodes/pve7demo1/qemu/301/status/suspend HTTP/1.1" 200 86



Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
  • Like
Reactions: IvanGomezGon
Pause and Suspend are the same thing. You can confirm that by :
a) tail -f /var/log/pveproxy/access.log
b) execute Pause via gui
c) notice the API called:
::ffff:172.16.9.3 - root@pam [06/06/2023:14:05:03 -0400] "POST /api2/extjs/nodes/pve7demo1/qemu/301/status/suspend HTTP/1.1" 200 86



Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
I see, thanks! Only problem I encounter is when I retrieve the status, I can't differentiate from paused and running, in both cases shows as running. Any ideas how to get around it?
 
Code:
pvesh get /nodes/pve7demo1/qemu/301/status/current
┌─────────────────┬────────────────────┐
│ key             │ value              │
╞═════════════════╪════════════════════╡
│ cpus            │ 1                  │
├─────────────────┼────────────────────┤
│ ha              │ {"managed":0}      │
├─────────────────┼────────────────────┤
│ maxdisk         │ 112.00 MiB         │
├─────────────────┼────────────────────┤
│ maxmem          │ 256.00 MiB         │
├─────────────────┼────────────────────┤
│ name            │ Copy-of-VM-vm300   │
├─────────────────┼────────────────────┤
│ pid             │ 1323389            │
├─────────────────┼────────────────────┤
│ qmpstatus       │ paused             │
├─────────────────┼────────────────────┤
│ running-machine │ pc-i440fx-7.2+pve0 │
├─────────────────┼────────────────────┤
│ running-qemu    │ 7.2.0              │
├─────────────────┼────────────────────┤
│ status          │ running            │
├─────────────────┼────────────────────┤
│ uptime          │ 5d 7h 11m          │
├─────────────────┼────────────────────┤
│ vmid            │ 301                │
└─────────────────┴────────────────────┘



Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
Code:
pvesh get /nodes/pve7demo1/qemu/301/status/current
┌─────────────────┬────────────────────┐
│ key             │ value              │
╞═════════════════╪════════════════════╡
│ cpus            │ 1                  │
├─────────────────┼────────────────────┤
│ ha              │ {"managed":0}      │
├─────────────────┼────────────────────┤
│ maxdisk         │ 112.00 MiB         │
├─────────────────┼────────────────────┤
│ maxmem          │ 256.00 MiB         │
├─────────────────┼────────────────────┤
│ name            │ Copy-of-VM-vm300   │
├─────────────────┼────────────────────┤
│ pid             │ 1323389            │
├─────────────────┼────────────────────┤
│ qmpstatus       │ paused             │
├─────────────────┼────────────────────┤
│ running-machine │ pc-i440fx-7.2+pve0 │
├─────────────────┼────────────────────┤
│ running-qemu    │ 7.2.0              │
├─────────────────┼────────────────────┤
│ status          │ running            │
├─────────────────┼────────────────────┤
│ uptime          │ 5d 7h 11m          │
├─────────────────┼────────────────────┤
│ vmid            │ 301                │
└─────────────────┴────────────────────┘



Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
Indeed, with status/current I can get the qmpstatus with no problem, the problem arises with nodes/{node}/qemu. As said in the doc https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu it should also contain qmpstatus, but for each VM of the cluster, I only get this params, where qmqstatus is nowhere to be found:
Code:
cpu:0.634245694812055
cpus: 1
disk: 0
diskread: 0
diskwrite: 0
maxdisk: 34359738368
maxmem: 2147483648
mem: 43727506
name: 'Copy-of-VM-proxmoxtest'
netin: 94
netout: 0
pid: 24276
status: 'running'
uptime: 2543
vmid: 101
 
the document describes two parameters that you can specify, one of them is optional - give it a try :)


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
shoot, that's just what I needed, but when I define full=true to get the full status, it still outputs the same as before. Anyways, I will just loop for each node and get currentStatus or I will just check if CPU Usage is minimum, thanks for the help!
 
Last edited:
  • Like
Reactions: bbgeek17

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!