Proxmox API - Edit Disk io_limit issues

Vengance

Renowned Member
May 21, 2016
271
12
83
35
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,
        ]);
 
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
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!
 
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
 
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