yes, but the vmid is reserved (config file is created) when the clone start.There are several other things that are happening during the clone operation:
- system has to find next available vmid, confirm its not in use
I don't care, I have full nvme ceph cluster- a disk/slice/file/etc needs to be allocated from the storage, some backends are faster than others. Even in thin clone operation there could be backend contention.
not related, it's generated at vm startup- If you have a cloud-init disk, its not cloned and needs to be generated
adding a write only lock could prevent change, and still allow read.- Even with template, although the disk is RO you are not prevented from modifying the configuration of the Template, ie adding/removing a device.
Anyway, you can create 20 templates, and clone them in parallel. you still don't have any protection about the load.And this is just on the surface. Although I am not a PVE developer, I can see many potentials for a race condition. Faster systems may fare better, but may behave differently under load. The only way to have predictable result across variety of systems is to use a lock.
#!/usr/bin/bash
VMID=${1-"100"}
NAME=vm$VMID
OSIMAGE=cirros-0.5.2-x86_64-disk.img
STORAGE=blockbridge
qm create $VMID --memory 128 --name template --bootdisk virtio0 --socket 1 --onboot no
qm importdisk $VMID ./$OSIMAGE $STORAGE --format raw
qm set $VMID --scsihw virtio-scsi-pci --scsi0 $STORAGE:vm-$VMID-disk-0
qm set $VMID -net0 e1000,bridge=vmbr0,firewall=1
qm set $VMID --serial0 socket --vga serial0
qm template $VMID
#!/usr/bin/bash
curl --insecure --cookie "$(<./.cookie)" --header "$(<./.csrftoken)" -X POST https://localhost:8006/api2/json/nodes/pve7test1/qemu \
--data-urlencode "onboot=0" \
--data-urlencode "bootdisk=virtio0" \
--data-urlencode "name=vm$1" \
--data-urlencode "serial0=socket" \
--data-urlencode "vga=serial0" \
--data-urlencode "virtio0=blockbridge:vm-$1-disk-0" \
--data memory=128 \
--data vmid=$1
#!/usr/bin/bash
API_NODE=blockbridge-api
TOKEN=$(curl -sk -X POST -H 'Content-Type: application/json' -d '{"username":"proxmox","password":"proxmox"}' "https://"$API_NODE"/api/oauth2/token" | jq -r .access_token)
snapshotid=$(curl -skX GET https://$API_NODE/api/snapshot -H "Authorization: Bearer $TOKEN"|jq -r .[].serial)
RESERVE=$(curl -skX GET https://$API_NODE/api/snapshot -H "Authorization: Bearer $TOKEN"|jq -r .[].capacity)
token=$(curl -skX POST https://$API_NODE/api/product/search \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $TOKEN" \
-d '{"capacity":"'$RESERVE'"}' | jq -r .products[].token )
curl -skX POST https://$API_NODE/api/vss \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d \
'{
"token":"'$token'",
"vss":{"label": "blockbridge:vm-'$1'-disk-0"},
"disk":{"create": true,
"label": "base",
"src": "snapshot",
"snapshot_id": "'$snapshotid'"}
}'
We use essential cookies to make this site work, and optional cookies to enhance your experience.