mirror of
https://github.com/Corsinvest/cv4pve-api-powershell.git
synced 2026-04-25 12:15:48 +03:00
[GH-ISSUE #43] Incorrect put method for NetN parameter "Set-PveQemuConfig" #29
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/cv4pve-api-powershell#29
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @beavis108 on GitHub (Sep 8, 2025).
Original GitHub issue: https://github.com/Corsinvest/cv4pve-api-powershell/issues/43
The cmdlet Set-PveQemuConfig -PveTicket $Connection -Node $VM.node -Vmid $VM.vmid -NetN $NewConfig has an incorrect data structure for the NetN part. It is not a hashtable, proxmox need a string.
This is the correct code for the part to configure the netadapter option:
function Set-PveNodesQemuConfig
{
<#
.DESCRIPTION
Set virtual machine options (synchronous API) - You should consider using the POST method instead for any actions involving hotplug or storage allocation.
.PARAMETER PveTicket
Ticket data connection.
.PARAMETER Acpi
Enable/disable ACPI.
.PARAMETER Affinity
List of host cores used to execute guest processes, for example':' 0,5,8-11
.PARAMETER Agent
Enable/disable communication with the QEMU Guest Agent and its properties.
.PARAMETER AmdSev
Secure Encrypted Virtualization (SEV) features by AMD CPUs
.PARAMETER Arch
Virtual processor architecture. Defaults to the host. Enum: x86_64,aarch64
.PARAMETER Args_
Arbitrary arguments passed to kvm.
.PARAMETER Audio0
Configure a audio device, useful in combination with QXL/Spice.
.PARAMETER Autostart
Automatic restart after crash (currently ignored).
.PARAMETER Balloon
Amount of target RAM for the VM in MiB. Using zero disables the ballon driver.
.PARAMETER Bios
Select BIOS implementation. Enum: seabios,ovmf
.PARAMETER Boot
Specify guest boot order. Use the 'order=' sub-property as usage with no key or 'legacy=' is deprecated.
.PARAMETER Bootdisk
Enable booting from specified disk. Deprecated':' Use 'boot':' order=foo;bar' instead.
.PARAMETER Cdrom
This is an alias for option -ide2
.PARAMETER Cicustom
cloud-init':' Specify custom files to replace the automatically generated ones at start.
.PARAMETER Cipassword
cloud-init':' Password to assign the user. Using this is generally not recommended. Use ssh keys instead. Also note that older cloud-init versions do not support hashed passwords.
.PARAMETER Citype
Specifies the cloud-init configuration format. The default depends on the configured operating system type (
ostype. We use thenocloudformat for Linux, andconfigdrive2for windows. Enum: configdrive2,nocloud,opennebula.PARAMETER Ciupgrade
cloud-init':' do an automatic package upgrade after the first boot.
.PARAMETER Ciuser
cloud-init':' User name to change ssh keys and password for instead of the image's configured default user.
.PARAMETER Cores
The number of cores per socket.
.PARAMETER Cpu
Emulated CPU type.
.PARAMETER Cpulimit
Limit of CPU usage.
.PARAMETER Cpuunits
CPU weight for a VM, will be clamped to [1, 10000] in cgroup v2.
.PARAMETER Delete
A list of settings you want to delete.
.PARAMETER Description
Description for the VM. Shown in the web-interface VM's summary. This is saved as comment inside the configuration file.
.PARAMETER Digest
Prevent changes if current configuration file has different SHA1 digest. This can be used to prevent concurrent modifications.
.PARAMETER Efidisk0
Configure a disk for storing EFI vars. Use the special syntax STORAGE_ID':'SIZE_IN_GiB to allocate a new volume. Note that SIZE_IN_GiB is ignored here and that the default EFI vars are copied to the volume instead. Use STORAGE_ID':'0 and the 'import-from' parameter to import from an existing volume.
.PARAMETER Force
Force physical removal. Without this, we simple remove the disk from the config file and create an additional configuration entry called 'unused[n]', which contains the volume ID. Unlink of unused[n] always cause physical removal.
.PARAMETER Freeze
Freeze CPU at startup (use 'c' monitor command to start execution).
.PARAMETER Hookscript
Script that will be executed during various steps in the vms lifetime.
.PARAMETER HostpciN
Map host PCI devices into guest.
.PARAMETER Hotplug
Selectively enable hotplug features. This is a comma separated list of hotplug features':' 'network', 'disk', 'cpu', 'memory', 'usb' and 'cloudinit'. Use '0' to disable hotplug completely. Using '1' as value is an alias for the default
network,disk,usb. USB hotplugging is possible for guests with machine version >= 7.1 and ostype l26 or windows > 7..PARAMETER Hugepages
Enable/disable hugepages memory. Enum: any,2,1024
.PARAMETER IdeN
Use volume as IDE hard disk or CD-ROM (n is 0 to 3). Use the special syntax STORAGE_ID':'SIZE_IN_GiB to allocate a new volume. Use STORAGE_ID':'0 and the 'import-from' parameter to import from an existing volume.
.PARAMETER IpconfigN
cloud-init':' Specify IP addresses and gateways for the corresponding interface.IP addresses use CIDR notation, gateways are optional but need an IP of the same type specified.The special string 'dhcp' can be used for IP addresses to use DHCP, in which case no explicitgateway should be provided.For IPv6 the special string 'auto' can be used to use stateless autoconfiguration. This requirescloud-init 19.4 or newer.If cloud-init is enabled and neither an IPv4 nor an IPv6 address is specified, it defaults to usingdhcp on IPv4.
.PARAMETER Ivshmem
Inter-VM shared memory. Useful for direct communication between VMs, or to the host.
.PARAMETER Keephugepages
Use together with hugepages. If enabled, hugepages will not not be deleted after VM shutdown and can be used for subsequent starts.
.PARAMETER Keyboard
Keyboard layout for VNC server. This option is generally not required and is often better handled from within the guest OS. Enum: de,de-ch,da,en-gb,en-us,es,fi,fr,fr-be,fr-ca,fr-ch,hu,is,it,ja,lt,mk,nl,no,pl,pt,pt-br,sv,sl,tr
.PARAMETER Kvm
Enable/disable KVM hardware virtualization.
.PARAMETER Localtime
Set the real time clock (RTC) to local time. This is enabled by default if the
ostypeindicates a Microsoft Windows OS..PARAMETER Lock
Lock/unlock the VM. Enum: backup,clone,create,migrate,rollback,snapshot,snapshot-delete,suspending,suspended
.PARAMETER Machine
Specify the QEMU machine.
.PARAMETER Memory
Memory properties.
.PARAMETER MigrateDowntime
Set maximum tolerated downtime (in seconds) for migrations. Should the migration not be able to converge in the very end, because too much newly dirtied RAM needs to be transferred, the limit will be increased automatically step-by-step until migration can converge.
.PARAMETER MigrateSpeed
Set maximum speed (in MB/s) for migrations. Value 0 is no limit.
.PARAMETER Name
Set a name for the VM. Only used on the configuration web interface.
.PARAMETER Nameserver
cloud-init':' Sets DNS server IP address for a container. Create will automatically use the setting from the host if neither searchdomain nor nameserver are set.
.PARAMETER NetN
Specify network devices.
.PARAMETER Node
The cluster node name.
.PARAMETER Numa
Enable/disable NUMA.
.PARAMETER NumaN
NUMA topology.
.PARAMETER Onboot
Specifies whether a VM will be started during system bootup.
.PARAMETER Ostype
Specify guest operating system. Enum: other,wxp,w2k,w2k3,w2k8,wvista,win7,win8,win10,win11,l24,l26,solaris
.PARAMETER ParallelN
Map host parallel devices (n is 0 to 2).
.PARAMETER Protection
Sets the protection flag of the VM. This will disable the remove VM and remove disk operations.
.PARAMETER Reboot
Allow reboot. If set to '0' the VM exit on reboot.
.PARAMETER Revert
Revert a pending change.
.PARAMETER Rng0
Configure a VirtIO-based Random Number Generator.
.PARAMETER SataN
Use volume as SATA hard disk or CD-ROM (n is 0 to 5). Use the special syntax STORAGE_ID':'SIZE_IN_GiB to allocate a new volume. Use STORAGE_ID':'0 and the 'import-from' parameter to import from an existing volume.
.PARAMETER ScsiN
Use volume as SCSI hard disk or CD-ROM (n is 0 to 30). Use the special syntax STORAGE_ID':'SIZE_IN_GiB to allocate a new volume. Use STORAGE_ID':'0 and the 'import-from' parameter to import from an existing volume.
.PARAMETER Scsihw
SCSI controller model Enum: lsi,lsi53c810,virtio-scsi-pci,virtio-scsi-single,megasas,pvscsi
.PARAMETER Searchdomain
cloud-init':' Sets DNS search domains for a container. Create will automatically use the setting from the host if neither searchdomain nor nameserver are set.
.PARAMETER SerialN
Create a serial device inside the VM (n is 0 to 3)
.PARAMETER Shares
Amount of memory shares for auto-ballooning. The larger the number is, the more memory this VM gets. Number is relative to weights of all other running VMs. Using zero disables auto-ballooning. Auto-ballooning is done by pvestatd.
.PARAMETER Skiplock
Ignore locks - only root is allowed to use this option.
.PARAMETER Smbios1
Specify SMBIOS type 1 fields.
.PARAMETER Smp
The number of CPUs. Please use option -sockets instead.
.PARAMETER Sockets
The number of CPU sockets.
.PARAMETER SpiceEnhancements
Configure additional enhancements for SPICE.
.PARAMETER Sshkeys
cloud-init':' Setup public SSH keys (one key per line, OpenSSH format).
.PARAMETER Startdate
Set the initial date of the real time clock. Valid format for date are':''now' or '2006-06-17T16':'01':'21' or '2006-06-17'.
.PARAMETER Startup
Startup and shutdown behavior. Order is a non-negative number defining the general startup order. Shutdown in done with reverse ordering. Additionally you can set the 'up' or 'down' delay in seconds, which specifies a delay to wait before the next VM is started or stopped.
.PARAMETER Tablet
Enable/disable the USB tablet device.
.PARAMETER Tags
Tags of the VM. This is only meta information.
.PARAMETER Tdf
Enable/disable time drift fix.
.PARAMETER Template
Enable/disable Template.
.PARAMETER Tpmstate0
Configure a Disk for storing TPM state. The format is fixed to 'raw'. Use the special syntax STORAGE_ID':'SIZE_IN_GiB to allocate a new volume. Note that SIZE_IN_GiB is ignored here and 4 MiB will be used instead. Use STORAGE_ID':'0 and the 'import-from' parameter to import from an existing volume.
.PARAMETER UnusedN
Reference to unused volumes. This is used internally, and should not be modified manually.
.PARAMETER UsbN
Configure an USB device (n is 0 to 4, for machine version >= 7.1 and ostype l26 or windows > 7, n can be up to 14).
.PARAMETER Vcpus
Number of hotplugged vcpus.
.PARAMETER Vga
Configure the VGA hardware.
.PARAMETER VirtioN
Use volume as VIRTIO hard disk (n is 0 to 15). Use the special syntax STORAGE_ID':'SIZE_IN_GiB to allocate a new volume. Use STORAGE_ID':'0 and the 'import-from' parameter to import from an existing volume.
.PARAMETER VirtiofsN
Configuration for sharing a directory between host and guest using Virtio-fs.
.PARAMETER Vmgenid
Set VM Generation ID. Use '1' to autogenerate on create or update, pass '0' to disable explicitly.
.PARAMETER Vmid
The (unique) ID of the VM.
.PARAMETER Vmstatestorage
Default storage for VM state volumes/files.
.PARAMETER Watchdog
Create a virtual hardware watchdog device.
.OUTPUTS
PveResponse. Return response.
#>
[OutputType([PveResponse])]
[CmdletBinding()]
Param(
[Parameter(ValueFromPipelineByPropertyName)]
[PveTicket]$PveTicket,
}
How to use the new code part:
Rebuild string
$NewConfig = "{0}={1},bridge={2},firewall={3}" -f
#$NewConfig = "{0},bridge={1},firewall={2}" -f#$NewConfig = "bridge={0}" -f
$ConfigHash.model,$ConfigHash.macaddr,
$ConfigHash.bridge,$ConfigHash.firewall
Set-PveQemuConfig -PveTicket $Connection -Node $VM.node -Vmid $VM.vmid -NetN $NewConfig
@beavis108 commented on GitHub (Sep 8, 2025):
Add following parameters:
[Parameter(ValueFromPipelineByPropertyName)]
[string]$NetN,
[Parameter(ValueFromPipelineByPropertyName)]
[int]$NetId,
Add parameter process:
if($PSBoundParameters.ContainsKey('NetN')) { $parameters["net$NetId"] = $NetN }
Remove or comment out:
#if($PSBoundParameters.ContainsKey('NetN')) { $NetN.keys | ForEach-Object { $parameters['net' + $] = $NetN[$] } }
How to use cmdlet:
Set-PveQemuConfig -PveTicket $Connection -Node $VM.node -Vmid $VM.vmid -NetId 1 -NetN $NewConfig
@franklupo commented on GitHub (Sep 9, 2025):
@franklupo commented on GitHub (Sep 10, 2025):
News?