Proxmox API - Edit Disk io_limit issues

Vengance

Active Member
May 21, 2016
197
7
38
31
Hi,

I'm trying to edit the io read and write limit for an existing vm disk via the api.
However the request fails with the response ""scsi0": "'import-from' requires special syntax - use <storage ID>:0,import-from=<source>".

I'm not quite sure how to properly format the request and which values are needed.


Code:
// Set resources
        $response1 = Http::withToken($apikey)->asForm()->post('https://' . $server->hostname . ':8006/api2/json/nodes/' . $server->node . '/qemu/' . $vmid . '/config', [
            'cores' => $cores,
            'cpulimit' => $cpuLimit,
            'memory' => $memory,
            'net0' => "model=virtio,rate=" . $portLimit,
            'scsi0' => "import-from=local-zfs:base-" . $templateid . "-disk-0,file=local-zfs:base-" . $templateid . "-disk-0,mbps_rd=" . $ioLimit . ",mbps_wr=" . $ioLimit,
        ]);
 

fiona

Proxmox Staff Member
Staff member
Aug 1, 2019
2,017
362
88
Hi,
if the disk already exists you shouldn't use import-from (that would create a new disk and copy over the contents of the other disk), but just set scsi0 to <storage>:<disk>,mbps_rd=<val>,... where <storage>:<disk> is the currently attached disk (which you can GET from the current configuration).
 
  • Like
Reactions: Vengance

Vengance

Active Member
May 21, 2016
197
7
38
31
Hi,
if the disk already exists you shouldn't use import-from (that would create a new disk and copy over the contents of the other disk), but just set scsi0 to <storage>:<disk>,mbps_rd=<val>,... where <storage>:<disk> is the currently attached disk (which you can GET from the current configuration).
Works like a charm, thank you!
 

Vengance

Active Member
May 21, 2016
197
7
38
31
Hmm, irgendwie tauchen bei mir auch weiterhin eine zusätzliche Unused Disk 0 auf.
Hier der API call
Code:
'scsi0' => "local-zfs:base-" . $templateid . "-disk-0,mbps_rd=" . $ioLimit . ",mbps_wr=" . $ioLimit,

Resultat:
1657061632509.png
 

fiona

Proxmox Staff Member
Staff member
Aug 1, 2019
2,017
362
88
Hmm, irgendwie tauchen bei mir auch weiterhin eine zusätzliche Unused Disk 0 auf.
Hier der API call
Code:
'scsi0' => "local-zfs:base-" . $templateid . "-disk-0,mbps_rd=" . $ioLimit . ",mbps_wr=" . $ioLimit,

Resultat:
View attachment 38707
Ich denke das Problem ist, dass Du nicht die selbe Disk i.e. local-zfs:base-9000-disk-0/vm-disk-0 zuweist, sondern die Disk der Template-VM i.e. local-zfs:base-9000-disk-0.

Wie gesagt, am besten einen GET-Call auf die Config machen, den Wert von scsi0 parsen und die gewünschten Optionen anhängen/ersetzen.
 
  • Like
Reactions: Vengance

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 your own in 60 seconds.

Buy now!