This guide covers common issues, configuration patterns, and solutions when working with the Proxmox VE API in Java.
Many VM/CT configuration methods use indexed parameters represented as Map<Integer, String> where the key is the index and the value is the configuration string.
Proxmox VE uses indexed parameters for devices that can have multiple instances. In the Java API, all indexed parameters are represented as Map<Integer, String> where the key is the device index (0, 1, 2...) and the value is the configuration string.
Common Parameters:
- netN - Network interfaces
- scsiN / virtioN / sataN / ideN - Disk devices
- ipconfigN - Cloud-init network configuration
- hostpciN / usbN - Hardware passthrough
- mpN - LXC mount points (containers only)
Note: Proxmox VE supports many other indexed parameters. All use the same
Map<Integer, String>pattern. For a complete list, refer to the Proxmox VE API Documentation.
import it.corsinvest.proxmoxve.api.*;
var client = new PveClient("pve.example.com", 8006);
client.login("root@pam", "password");
// Configure network interfaces
var networks = Map.of(
0, "model=virtio,bridge=vmbr0,firewall=1",
1, "model=e1000,bridge=vmbr1"
);
// Configure disks
var disks = Map.of(
0, "local-lvm:32,cache=writethrough",
1, "local-lvm:64,iothread=1"
);
client.getNodes().get("pve1").getQemu().get(100).getConfig().updateVm(
networks, // netN
disks // scsiN
);Format: model=<model>,bridge=<bridge>[,option=value,...]
| Parameter | Description | Example Values |
|---|---|---|
| model | Network card model | virtio, e1000, rtl8139, vmxnet3 |
| bridge | Bridge to connect to | vmbr0, vmbr1 |
| firewall | Enable firewall | 0, 1 |
| link_down | Disconnect interface | 0, 1 |
| macaddr | MAC address | A2:B3:C4:D5:E6:F7 |
| mtu | MTU size | 1500, 9000 |
| queues | Number of queues | 1, 2, 4, 8 |
| rate | Rate limit (MB/s) | 10, 100 |
| tag | VLAN tag | 100, 200 |
| trunks | VLAN trunks | 10;20;30 |
// Basic VirtIO network
var networks = Map.of(
0, "model=virtio,bridge=vmbr0"
);
// Network with VLAN and firewall
var networks = Map.of(
0, "model=virtio,bridge=vmbr0,tag=100,firewall=1"
);
// Multiple networks with different settings
var networks = Map.of(
0, "model=virtio,bridge=vmbr0,firewall=1",
1, "model=e1000,bridge=vmbr1,rate=100",
2, "model=virtio,bridge=vmbr0,tag=200,queues=4"
);Format: <storage>:<size>[,option=value,...]
Or for existing volumes: <storage>:<volume>[,option=value,...]
- scsiN - SCSI disks (0-30), most common, supports all features
- virtioN - VirtIO disks (0-15), high performance
- sataN - SATA disks (0-5), legacy compatibility
- ideN - IDE disks (0-3), legacy, often used for CD-ROM
- efidisk0 - EFI disk for UEFI boot
| Parameter | Description | Example Values |
|---|---|---|
| cache | Cache mode | none, writethrough, writeback, directsync, unsafe |
| discard | Enable TRIM/discard | on, ignore |
| iothread | Enable IO thread | 0, 1 |
| ssd | SSD emulation | 0, 1 |
| backup | Include in backup | 0, 1 |
| replicate | Enable replication | 0, 1 |
| media | Media type | disk, cdrom |
| size | Disk size | 32G, 100G, 1T |
// Basic SCSI disk - 32GB
var disks = Map.of(
0, "local-lvm:32"
);
// SCSI disk with options
var disks = Map.of(
0, "local-lvm:32,cache=writethrough,iothread=1,discard=on"
);
// Multiple SCSI disks
var disks = Map.of(
0, "local-lvm:32,cache=writethrough,iothread=1", // OS disk
1, "local-lvm:100,cache=none,iothread=1,discard=on", // Data disk
2, "local-lvm:200,backup=0" // Temp disk, no backup
);// VirtIO disks for maximum performance
var disks = Map.of(
0, "local-lvm:32,cache=writethrough,discard=on",
1, "ceph-storage:100,cache=none,iothread=1"
);// SATA disk
var sataDisks = Map.of(
0, "local-lvm:32"
);
// IDE CD-ROM
var ideDisks = Map.of(
2, "local:iso/ubuntu-22.04.iso,media=cdrom"
);// EFI disk for UEFI boot
String efidisk = "local-lvm:1,efitype=4m,pre-enrolled-keys=0";
client.getNodes().get("pve1").getQemu().get(100).getConfig().updateVm(
"ovmf", // bios
efidisk // efidisk0
);Format: ip=<address>,gw=<gateway>[,option=value,...]
// DHCP on all interfaces
var ipconfig = Map.of(
0, "ip=dhcp"
);
// Static IP configuration
var ipconfig = Map.of(
0, "ip=192.168.1.100/24,gw=192.168.1.1"
);
// Multiple interfaces with different configs
var ipconfig = Map.of(
0, "ip=192.168.1.100/24,gw=192.168.1.1", // Management
1, "ip=10.0.0.100/24", // Internal network
2, "ip=dhcp" // External network via DHCP
);
// IPv6 with auto-configuration
var ipconfig = Map.of(
0, "ip=192.168.1.100/24,gw=192.168.1.1,ip6=auto"
);var client = new PveClient("pve.example.com", 8006);
client.login("admin@pve", "password");
// VM identifiers
int vmid = 101;
String vmName = "ubuntu-server";
String node = "pve1";
// Hardware resources
int memory = 4096; // 4GB RAM
int cores = 2;
int sockets = 1;
// Configure VirtIO disks
var disks = Map.of(
0, "local-lvm:32,cache=writethrough,discard=on"
);
// Configure network interfaces
var networks = Map.of(
0, "model=virtio,bridge=vmbr0,firewall=1"
);
// Cloud-init IP configuration
var ipconfig = Map.of(
0, "ip=192.168.1.100/24,gw=192.168.1.1"
);
// OS and boot settings
String ostype = "l26";
String scsihw = "virtio-scsi-single";
String boot = "order=virtio0";
String agent = "enabled=1";
// Cloud-init credentials and network
String ciuser = "admin";
String cipassword = "SecurePassword123!";
String sshkeys = "ssh-rsa AAAAB3NzaC1yc2E...";
String nameserver = "8.8.8.8 8.8.4.4";
String searchdomain = "example.com";
client.getNodes().get(node).getQemu().createVm(
vmid,
vmName,
memory,
cores,
sockets,
ostype,
disks, // virtioN
networks, // netN
ipconfig, // ipconfigN
scsihw,
boot,
agent,
ciuser,
cipassword,
sshkeys,
nameserver,
searchdomain
);
System.out.println("VM " + vmid + " created successfully with cloud-init!");Check configuration:
var config = client.getNodes().get("pve1").getQemu().get(100).getConfig().vmConfig().getData();
// Verify configuration is valid
System.out.println(config);Common issues:
- Missing boot disk: Verify
bootparameter points to valid disk - Invalid network bridge: Check bridge exists on node
- Insufficient resources: Verify memory/CPU allocation
Verify storage exists and has space:
var storages = client.getNodes().get("pve1").getStorage().index();
for (var storage : storages.getData()) {
System.out.println("Storage: " + storage.get("storage").asText());
System.out.println(" Type: " + storage.get("type").asText());
System.out.println(" Available: " + storage.get("avail").asText());
}Verify bridge configuration:
var networks = client.getNodes().get("pve1").getNetwork().index();
for (var net : networks.getData()) {
if ("bridge".equals(net.get("type").asText())) {
System.out.println("Bridge: " + net.get("iface").asText());
}
}For more details on specific parameters and options, refer to the Proxmox VE API Documentation.