From 189aa8de30bfeb265bd364925da2eb8362fb8598 Mon Sep 17 00:00:00 2001 From: Tinyblargon <76069640+Tinyblargon@users.noreply.github.com> Date: Tue, 30 Jan 2024 17:57:57 +0000 Subject: [PATCH 1/9] test: update for Kibibyte size --- proxmox/config_qemu_test.go | 656 +++++++++++++++++++++++++++++++----- 1 file changed, 577 insertions(+), 79 deletions(-) diff --git a/proxmox/config_qemu_test.go b/proxmox/config_qemu_test.go index ce7daae7..b0dc24b7 100644 --- a/proxmox/config_qemu_test.go +++ b/proxmox/config_qemu_test.go @@ -73,12 +73,26 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { Format: format_Raw, Replicate: true, Serial: "558485ef-478", - Size: 32, + Size: 33554432, Storage: "Test", WorldWideName: "0x5000D31000C9876F", }}}}}, output: map[string]interface{}{"ide0": "Test:32,aio=native,cache=directsync,discard=on,format=raw,iops_rd=34,iops_rd_max=78,iops_rd_max_length=3,iops_wr=23,iops_wr_max=89,iops_wr_max_length=4,mbps_rd=10.3,mbps_rd_max=99.2,mbps_wr=45.23,mbps_wr_max=79.23,serial=558485ef-478,ssd=1,wwn=0x5000D31000C9876F"}, }, + {name: "Create Disks.Ide.Disk_X.Disk Create Gibibyte", + config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{ + Size: 33554432, + Storage: "Test", + }}}}}, + output: map[string]interface{}{"ide0": "Test:32,backup=0,replicate=0"}, + }, + {name: "Create Disks.Ide.Disk_X.Disk Create Kibibyte", + config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{ + Size: 33554433, + Storage: "Test", + }}}}}, + output: map[string]interface{}{"ide0": "Test:0,backup=0,replicate=0"}, + }, {name: "Create Disks.Ide.Disk_X.Disk.AsyncIO", config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{AsyncIO: QemuDiskAsyncIO_Native}}}}}, output: map[string]interface{}{"ide1": ",aio=native,backup=0,replicate=0"}, @@ -358,11 +372,25 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { Format: QemuDiskFormat_Qcow2, Replicate: true, Serial: "ab_C-12_3", - Size: 32, + Size: 16777216, Storage: "Test", WorldWideName: "0x5009876000A321DC", }}}}}, - output: map[string]interface{}{"sata0": "Test:32,aio=native,cache=unsafe,discard=on,format=qcow2,iops_rd=34,iops_rd_max=78,iops_rd_max_length=3,iops_wr=23,iops_wr_max=89,iops_wr_max_length=4,mbps_rd=10.3,mbps_rd_max=99.2,mbps_wr=45.23,mbps_wr_max=79.23,serial=ab_C-12_3,ssd=1,wwn=0x5009876000A321DC"}, + output: map[string]interface{}{"sata0": "Test:16,aio=native,cache=unsafe,discard=on,format=qcow2,iops_rd=34,iops_rd_max=78,iops_rd_max_length=3,iops_wr=23,iops_wr_max=89,iops_wr_max_length=4,mbps_rd=10.3,mbps_rd_max=99.2,mbps_wr=45.23,mbps_wr_max=79.23,serial=ab_C-12_3,ssd=1,wwn=0x5009876000A321DC"}, + }, + {name: "Create Disks.Sata.Disk_X.Disk Create Gibibyte", + config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ + Size: 16777216, + Storage: "Test", + }}}}}, + output: map[string]interface{}{"sata0": "Test:16,backup=0,replicate=0"}, + }, + {name: "Create Disks.Sata.Disk_X.Disk Create Kibibyte", + config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ + Size: 16777217, + Storage: "Test", + }}}}}, + output: map[string]interface{}{"sata0": "Test:0,backup=0,replicate=0"}, }, {name: "Create Disks.Sata.Disk_X.Disk.AsyncIO", config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{AsyncIO: QemuDiskAsyncIO_Native}}}}}, @@ -645,11 +673,25 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { ReadOnly: true, Replicate: true, Serial: "558485ef-478", - Size: 32, + Size: 76546048, Storage: "Test", WorldWideName: "0x500D567800BAC321", }}}}}, - output: map[string]interface{}{"scsi0": "Test:32,aio=native,cache=directsync,discard=on,format=raw,iops_rd=34,iops_rd_max=78,iops_rd_max_length=3,iops_wr=23,iops_wr_max=89,iops_wr_max_length=4,iothread=1,mbps_rd=10.3,mbps_rd_max=99.2,mbps_wr=45.23,mbps_wr_max=79.23,ro=1,serial=558485ef-478,ssd=1,wwn=0x500D567800BAC321"}, + output: map[string]interface{}{"scsi0": "Test:73,aio=native,cache=directsync,discard=on,format=raw,iops_rd=34,iops_rd_max=78,iops_rd_max_length=3,iops_wr=23,iops_wr_max=89,iops_wr_max_length=4,iothread=1,mbps_rd=10.3,mbps_rd_max=99.2,mbps_wr=45.23,mbps_wr_max=79.23,ro=1,serial=558485ef-478,ssd=1,wwn=0x500D567800BAC321"}, + }, + {name: "Create Disks.Scsi.Disk_X.Disk Create Gibibyte", + config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_0: &QemuScsiStorage{Disk: &QemuScsiDisk{ + Size: 76546048, + Storage: "Test", + }}}}}, + output: map[string]interface{}{"scsi0": "Test:73,backup=0,replicate=0"}, + }, + {name: "Create Disks.Scsi.Disk_X.Disk Create Kibibyte", + config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_0: &QemuScsiStorage{Disk: &QemuScsiDisk{ + Size: 76546049, + Storage: "Test", + }}}}}, + output: map[string]interface{}{"scsi0": "Test:0,backup=0,replicate=0"}, }, {name: "Create Disks.Scsi.Disk_X.Disk.AsyncIO", config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_1: &QemuScsiStorage{Disk: &QemuScsiDisk{AsyncIO: QemuDiskAsyncIO_Native}}}}}, @@ -949,11 +991,25 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { ReadOnly: true, Replicate: true, Serial: "558485ef-478", - Size: 32, + Size: 8238661632, Storage: "Test", WorldWideName: "0x500A7B0800F345D2", }}}}}, - output: map[string]interface{}{"virtio0": "Test:32,aio=native,cache=directsync,discard=on,format=raw,iops_rd=34,iops_rd_max=78,iops_rd_max_length=3,iops_wr=23,iops_wr_max=89,iops_wr_max_length=4,iothread=1,mbps_rd=10.3,mbps_rd_max=99.2,mbps_wr=45.23,mbps_wr_max=79.23,ro=1,serial=558485ef-478,wwn=0x500A7B0800F345D2"}, + output: map[string]interface{}{"virtio0": "Test:7857,aio=native,cache=directsync,discard=on,format=raw,iops_rd=34,iops_rd_max=78,iops_rd_max_length=3,iops_wr=23,iops_wr_max=89,iops_wr_max_length=4,iothread=1,mbps_rd=10.3,mbps_rd_max=99.2,mbps_wr=45.23,mbps_wr_max=79.23,ro=1,serial=558485ef-478,wwn=0x500A7B0800F345D2"}, + }, + {name: "Create Disks.VirtIO.Disk_X.Disk Create Gibibyte", + config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_0: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ + Size: 8238661632, + Storage: "Test", + }}}}}, + output: map[string]interface{}{"virtio0": "Test:7857,backup=0,replicate=0"}, + }, + {name: "Create Disks.VirtIO.Disk_X.Disk Create Kibibyte", + config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_0: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ + Size: 8238661633, + Storage: "Test", + }}}}}, + output: map[string]interface{}{"virtio0": "Test:0,backup=0,replicate=0"}, }, {name: "Create Disks.VirtIO.Disk_X.Disk.AsyncIO", config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_1: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{AsyncIO: QemuDiskAsyncIO_Native}}}}}, @@ -1432,68 +1488,130 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { }}}}}, output: map[string]interface{}{"ide1": "test2:vm-0-disk-23,backup=0,replicate=0"}, }, - {name: "Update Disk.Ide.Disk_X.Disk RESIZE DOWN File", + {name: "Update Disk.Ide.Disk_X.Disk RESIZE DOWN Gibibyte File", currentConfig: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ Format: QemuDiskFormat_Raw, Id: 23, - Size: 10, + Size: 9437185, Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ Format: QemuDiskFormat_Raw, - Size: 9, + Size: 9437184, Storage: "test", }}}}}, output: map[string]interface{}{"ide2": "test:9,backup=0,format=raw,replicate=0"}, }, - {name: "Update Disk.Ide.Disk_X.Disk RESIZE DOWN File LinkedClone", + {name: "Update Disk.Ide.Disk_X.Disk RESIZE DOWN Gibibyte File LinkedClone", currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ Format: QemuDiskFormat_Raw, Id: 23, LinkedDiskId: &uint1, - Size: 10, + Size: 9437185, Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ Format: QemuDiskFormat_Raw, - Size: 9, + Size: 9437184, Storage: "test", }}}}}, output: map[string]interface{}{"ide2": "test:9,backup=0,format=raw,replicate=0"}, }, - {name: "Update Disk.Ide.Disk_X.Disk RESIZE DOWN Volume", + {name: "Update Disk.Ide.Disk_X.Disk RESIZE DOWN Gibibyte Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ Id: 23, - Size: 10, + Size: 9437185, Storage: "test", syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ Format: QemuDiskFormat_Raw, - Size: 9, + Size: 9437184, Storage: "test", }}}}}, output: map[string]interface{}{"ide2": "test:9,backup=0,format=raw,replicate=0"}, }, - {name: "Update Disk.Ide.Disk_X.Disk RESIZE DOWN Volume LinkedClone", + {name: "Update Disk.Ide.Disk_X.Disk RESIZE DOWN Gibibyte Volume LinkedClone", currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ Id: 23, LinkedDiskId: &uint1, - Size: 10, + Size: 9437185, Storage: "test", syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ Format: QemuDiskFormat_Raw, - Size: 9, + Size: 9437184, Storage: "test", }}}}}, output: map[string]interface{}{"ide2": "test:9,backup=0,format=raw,replicate=0"}, }, + {name: "Update Disk.Ide.Disk_X.Disk RESIZE DOWN Kibibyte File", + currentConfig: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ + Format: QemuDiskFormat_Raw, + Id: 23, + Size: 9437186, + Storage: "test", + }}}}}, + config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ + Format: QemuDiskFormat_Raw, + Size: 9437185, + Storage: "test", + }}}}}, + output: map[string]interface{}{"ide2": "test:0,backup=0,format=raw,replicate=0"}, + }, + {name: "Update Disk.Ide.Disk_X.Disk RESIZE DOWN Kibibyte File LinkedClone", + currentConfig: ConfigQemu{ + LinkedVmId: 100, + Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + Size: 9437186, + Storage: "test", + }}}}}, + config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ + Format: QemuDiskFormat_Raw, + Size: 9437185, + Storage: "test", + }}}}}, + output: map[string]interface{}{"ide2": "test:0,backup=0,format=raw,replicate=0"}, + }, + {name: "Update Disk.Ide.Disk_X.Disk RESIZE DOWN Kibibyte Volume", + currentConfig: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ + Id: 23, + Size: 9437186, + Storage: "test", + syntax: diskSyntaxVolume, + }}}}}, + config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ + Format: QemuDiskFormat_Raw, + Size: 9437185, + Storage: "test", + }}}}}, + output: map[string]interface{}{"ide2": "test:0,backup=0,format=raw,replicate=0"}, + }, + {name: "Update Disk.Ide.Disk_X.Disk RESIZE DOWN Kibibyte Volume LinkedClone", + currentConfig: ConfigQemu{ + LinkedVmId: 100, + Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ + Id: 23, + LinkedDiskId: &uint1, + Size: 9437186, + Storage: "test", + syntax: diskSyntaxVolume, + }}}}}, + config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ + Format: QemuDiskFormat_Raw, + Size: 9437185, + Storage: "test", + }}}}}, + output: map[string]interface{}{"ide2": "test:0,backup=0,format=raw,replicate=0"}, + }, {name: "Update Disk.Ide.Disk_X.Disk RESIZE UP File", currentConfig: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{ Format: QemuDiskFormat_Raw, @@ -1861,66 +1979,126 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { }}}}}, output: map[string]interface{}{"sata5": "test2:vm-0-disk-23,backup=0,replicate=0"}, }, - {name: "Update Disk.Sata.Disk_X.Disk RESIZE DOWN File", + {name: "Update Disk.Sata.Disk_X.Disk RESIZE DOWN Gibibyte File", currentConfig: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ Format: QemuDiskFormat_Raw, Id: 23, - Size: 10, + Size: 9437185, Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ Format: QemuDiskFormat_Raw, - Size: 9, + Size: 9437184, Storage: "test", }}}}}, output: map[string]interface{}{"sata0": "test:9,backup=0,format=raw,replicate=0"}, }, - {name: "Update Disk.Sata.Disk_X.Disk RESIZE DOWN File LinkedClone", + {name: "Update Disk.Sata.Disk_X.Disk RESIZE DOWN Gibibyte File LinkedClone", currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ Format: QemuDiskFormat_Raw, Id: 23, LinkedDiskId: &uint1, - Size: 10, + Size: 9437185, Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ Format: QemuDiskFormat_Raw, - Size: 9, + Size: 9437184, Storage: "test", }}}}}, output: map[string]interface{}{"sata0": "test:9,backup=0,format=raw,replicate=0"}, }, - {name: "Update Disk.Sata.Disk_X.Disk RESIZE DOWN Volume", + {name: "Update Disk.Sata.Disk_X.Disk RESIZE DOWN Gibibyte Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ Id: 23, - Size: 10, + Size: 9437185, Storage: "test", syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ - Size: 9, + Size: 9437184, Storage: "test", }}}}}, output: map[string]interface{}{"sata0": "test:9,backup=0,replicate=0"}, }, - {name: "Update Disk.Sata.Disk_X.Disk RESIZE DOWN Volume LinkedClone", + {name: "Update Disk.Sata.Disk_X.Disk RESIZE DOWN Gibibyte Volume LinkedClone", currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ Id: 23, LinkedDiskId: &uint1, - Size: 10, + Size: 9437185, Storage: "test", syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ - Size: 9, + Size: 9437184, Storage: "test", }}}}}, output: map[string]interface{}{"sata0": "test:9,backup=0,replicate=0"}, }, + {name: "Update Disk.Sata.Disk_X.Disk RESIZE DOWN Kibibyte File", + currentConfig: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ + Format: QemuDiskFormat_Raw, + Id: 23, + Size: 9437186, + Storage: "test", + }}}}}, + config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ + Format: QemuDiskFormat_Raw, + Size: 9437185, + Storage: "test", + }}}}}, + output: map[string]interface{}{"sata0": "test:0,backup=0,format=raw,replicate=0"}, + }, + {name: "Update Disk.Sata.Disk_X.Disk RESIZE DOWN Kibibyte File LinkedClone", + currentConfig: ConfigQemu{ + LinkedVmId: 100, + Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + Size: 9437186, + Storage: "test", + }}}}}, + config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ + Format: QemuDiskFormat_Raw, + Size: 9437185, + Storage: "test", + }}}}}, + output: map[string]interface{}{"sata0": "test:0,backup=0,format=raw,replicate=0"}, + }, + {name: "Update Disk.Sata.Disk_X.Disk RESIZE DOWN Kibibyte Volume", + currentConfig: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ + Id: 23, + Size: 9437186, + Storage: "test", + syntax: diskSyntaxVolume, + }}}}}, + config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ + Size: 9437185, + Storage: "test", + }}}}}, + output: map[string]interface{}{"sata0": "test:0,backup=0,replicate=0"}, + }, + {name: "Update Disk.Sata.Disk_X.Disk RESIZE DOWN Kibibyte Volume LinkedClone", + currentConfig: ConfigQemu{ + LinkedVmId: 100, + Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ + Id: 23, + LinkedDiskId: &uint1, + Size: 9437186, + Storage: "test", + syntax: diskSyntaxVolume, + }}}}}, + config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ + Size: 9437185, + Storage: "test", + }}}}}, + output: map[string]interface{}{"sata0": "test:0,backup=0,replicate=0"}, + }, {name: "Update Disk.Sata.Disk_X.Disk RESIZE UP File", currentConfig: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_1: &QemuSataStorage{Disk: &QemuSataDisk{ Format: QemuDiskFormat_Raw, @@ -2284,68 +2462,130 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { }}}}}, output: map[string]interface{}{"scsi17": "test2:vm-0-disk-23,backup=0,replicate=0"}, }, - {name: "Update Disk.Scsi.Disk_X.Disk RESIZE DOWN File", + {name: "Update Disk.Scsi.Disk_X.Disk RESIZE DOWN Gibibyte File", currentConfig: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ Format: QemuDiskFormat_Raw, Id: 23, - Size: 10, + Size: 9437185, Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ Format: QemuDiskFormat_Raw, - Size: 9, + Size: 9437184, Storage: "test", }}}}}, output: map[string]interface{}{"scsi18": "test:9,backup=0,format=raw,replicate=0"}, }, - {name: "Update Disk.Scsi.Disk_X.Disk RESIZE DOWN File LinkedClone", + {name: "Update Disk.Scsi.Disk_X.Disk RESIZE DOWN Gibibyte File LinkedClone", currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ Format: QemuDiskFormat_Raw, Id: 23, LinkedDiskId: &uint1, - Size: 10, + Size: 9437185, Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ Format: QemuDiskFormat_Raw, - Size: 9, + Size: 9437184, Storage: "test", }}}}}, output: map[string]interface{}{"scsi18": "test:9,backup=0,format=raw,replicate=0"}, }, - {name: "Update Disk.Scsi.Disk_X.Disk RESIZE DOWN Volume", + {name: "Update Disk.Scsi.Disk_X.Disk RESIZE DOWN Gibibyte Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ Id: 23, - Size: 10, + Size: 9437185, Storage: "test", syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ Format: QemuDiskFormat_Raw, - Size: 9, + Size: 9437184, Storage: "test", }}}}}, output: map[string]interface{}{"scsi18": "test:9,backup=0,format=raw,replicate=0"}, }, - {name: "Update Disk.Scsi.Disk_X.Disk RESIZE DOWN Volume LinkedClone", + {name: "Update Disk.Scsi.Disk_X.Disk RESIZE DOWN Gibibyte Volume LinkedClone", currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ Id: 23, LinkedDiskId: &uint1, - Size: 10, + Size: 9437185, Storage: "test", syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ Format: QemuDiskFormat_Raw, - Size: 9, + Size: 9437184, Storage: "test", }}}}}, output: map[string]interface{}{"scsi18": "test:9,backup=0,format=raw,replicate=0"}, }, + {name: "Update Disk.Scsi.Disk_X.Disk RESIZE DOWN Kibibyte File", + currentConfig: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ + Format: QemuDiskFormat_Raw, + Id: 23, + Size: 9437186, + Storage: "test", + }}}}}, + config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ + Format: QemuDiskFormat_Raw, + Size: 9437185, + Storage: "test", + }}}}}, + output: map[string]interface{}{"scsi18": "test:0,backup=0,format=raw,replicate=0"}, + }, + {name: "Update Disk.Scsi.Disk_X.Disk RESIZE DOWN Kibibyte File LinkedClone", + currentConfig: ConfigQemu{ + LinkedVmId: 100, + Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + Size: 9437186, + Storage: "test", + }}}}}, + config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ + Format: QemuDiskFormat_Raw, + Size: 9437185, + Storage: "test", + }}}}}, + output: map[string]interface{}{"scsi18": "test:0,backup=0,format=raw,replicate=0"}, + }, + {name: "Update Disk.Scsi.Disk_X.Disk RESIZE DOWN Kibibyte Volume", + currentConfig: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ + Id: 23, + Size: 9437186, + Storage: "test", + syntax: diskSyntaxVolume, + }}}}}, + config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ + Format: QemuDiskFormat_Raw, + Size: 9437185, + Storage: "test", + }}}}}, + output: map[string]interface{}{"scsi18": "test:0,backup=0,format=raw,replicate=0"}, + }, + {name: "Update Disk.Scsi.Disk_X.Disk RESIZE DOWN Kibibyte Volume LinkedClone", + currentConfig: ConfigQemu{ + LinkedVmId: 100, + Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ + Id: 23, + LinkedDiskId: &uint1, + Size: 9437186, + Storage: "test", + syntax: diskSyntaxVolume, + }}}}}, + config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ + Format: QemuDiskFormat_Raw, + Size: 9437185, + Storage: "test", + }}}}}, + output: map[string]interface{}{"scsi18": "test:0,backup=0,format=raw,replicate=0"}, + }, {name: "Update Disk.Scsi.Disk_X.Disk RESIZE UP File", currentConfig: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_19: &QemuScsiStorage{Disk: &QemuScsiDisk{ Format: QemuDiskFormat_Raw, @@ -2715,68 +2955,130 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { }}}}}, output: map[string]interface{}{"virtio1": "test2:vm-0-disk-23,backup=0,replicate=0"}, }, - {name: "Update Disk.VirtIO.Disk_X.Disk RESIZE DOWN File", + {name: "Update Disk.VirtIO.Disk_X.Disk RESIZE DOWN Gibibyte File", currentConfig: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ Format: QemuDiskFormat_Raw, Id: 23, - Size: 10, + Size: 9437185, Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ Format: QemuDiskFormat_Raw, - Size: 9, + Size: 9437184, Storage: "test", }}}}}, output: map[string]interface{}{"virtio2": "test:9,backup=0,format=raw,replicate=0"}, }, - {name: "Update Disk.VirtIO.Disk_X.Disk RESIZE DOWN File LinkedClone", + {name: "Update Disk.VirtIO.Disk_X.Disk RESIZE DOWN Gibibyte File LinkedClone", currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ Format: QemuDiskFormat_Raw, Id: 23, LinkedDiskId: &uint1, - Size: 10, + Size: 9437185, Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ Format: QemuDiskFormat_Raw, - Size: 9, + Size: 9437184, Storage: "test", }}}}}, output: map[string]interface{}{"virtio2": "test:9,backup=0,format=raw,replicate=0"}, }, - {name: "Update Disk.VirtIO.Disk_X.Disk RESIZE DOWN Volume", + {name: "Update Disk.VirtIO.Disk_X.Disk RESIZE DOWN Gibibyte Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ Id: 23, - Size: 10, + Size: 9437185, Storage: "test", syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ Format: QemuDiskFormat_Raw, - Size: 9, + Size: 9437184, Storage: "test", }}}}}, output: map[string]interface{}{"virtio2": "test:9,backup=0,format=raw,replicate=0"}, }, - {name: "Update Disk.VirtIO.Disk_X.Disk RESIZE DOWN Volume LinkedClone", + {name: "Update Disk.VirtIO.Disk_X.Disk RESIZE DOWN Gibibyte Volume LinkedClone", currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ Id: 23, LinkedDiskId: &uint1, - Size: 10, + Size: 9437185, Storage: "test", syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ Format: QemuDiskFormat_Raw, - Size: 9, + Size: 9437184, Storage: "test", }}}}}, output: map[string]interface{}{"virtio2": "test:9,backup=0,format=raw,replicate=0"}, }, + {name: "Update Disk.VirtIO.Disk_X.Disk RESIZE DOWN Kibibyte File", + currentConfig: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ + Format: QemuDiskFormat_Raw, + Id: 23, + Size: 9437186, + Storage: "test", + }}}}}, + config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ + Format: QemuDiskFormat_Raw, + Size: 9437185, + Storage: "test", + }}}}}, + output: map[string]interface{}{"virtio2": "test:0,backup=0,format=raw,replicate=0"}, + }, + {name: "Update Disk.VirtIO.Disk_X.Disk RESIZE DOWN Kibibyte File LinkedClone", + currentConfig: ConfigQemu{ + LinkedVmId: 100, + Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + Size: 9437186, + Storage: "test", + }}}}}, + config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ + Format: QemuDiskFormat_Raw, + Size: 9437185, + Storage: "test", + }}}}}, + output: map[string]interface{}{"virtio2": "test:0,backup=0,format=raw,replicate=0"}, + }, + {name: "Update Disk.VirtIO.Disk_X.Disk RESIZE DOWN Kibibyte Volume", + currentConfig: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ + Id: 23, + Size: 9437186, + Storage: "test", + syntax: diskSyntaxVolume, + }}}}}, + config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ + Format: QemuDiskFormat_Raw, + Size: 9437185, + Storage: "test", + }}}}}, + output: map[string]interface{}{"virtio2": "test:0,backup=0,format=raw,replicate=0"}, + }, + {name: "Update Disk.VirtIO.Disk_X.Disk RESIZE DOWN Kibibyte Volume LinkedClone", + currentConfig: ConfigQemu{ + LinkedVmId: 100, + Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ + Id: 23, + LinkedDiskId: &uint1, + Size: 9437186, + Storage: "test", + syntax: diskSyntaxVolume, + }}}}}, + config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ + Format: QemuDiskFormat_Raw, + Size: 9437185, + Storage: "test", + }}}}}, + output: map[string]interface{}{"virtio2": "test:0,backup=0,format=raw,replicate=0"}, + }, {name: "Update Disk.VirtIO.Disk_X.Disk RESIZE UP File", currentConfig: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_3: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ Format: QemuDiskFormat_Raw, @@ -3040,7 +3342,7 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { Id: uint53, Replicate: false, Serial: "disk-9763", - Size: 1032, + Size: 1082130432, Storage: "test2", WorldWideName: "0x500F753600A987E1", }}}}}, @@ -3070,7 +3372,7 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { LinkedDiskId: &uint1, Replicate: false, Serial: "disk-9763", - Size: 1032, + Size: 1082130432, Storage: "test2", WorldWideName: "0x500679CE00B1DAF4", }}}}}, @@ -3251,6 +3553,17 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { }, {name: "Disks Ide Disk size G", input: map[string]interface{}{"ide0": "test2:100/vm-100-disk-53.qcow2,size=1032G"}, + output: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{ + Backup: true, + Format: QemuDiskFormat_Qcow2, + Id: uint53, + Replicate: true, + Size: 1082130432, + Storage: "test2", + }}}}}, + }, + {name: "Disks Ide Disk size K", + input: map[string]interface{}{"ide0": "test2:100/vm-100-disk-53.qcow2,size=1032K"}, output: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{ Backup: true, Format: QemuDiskFormat_Qcow2, @@ -3260,6 +3573,17 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { Storage: "test2", }}}}}, }, + {name: "Disks Ide Disk size M", + input: map[string]interface{}{"ide0": "test2:100/vm-100-disk-53.qcow2,size=1032M"}, + output: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{ + Backup: true, + Format: QemuDiskFormat_Qcow2, + Id: uint53, + Replicate: true, + Size: 1056768, + Storage: "test2", + }}}}}, + }, {name: "Disks Ide Disk size T", input: map[string]interface{}{"ide0": "test2:100/vm-100-disk-53.qcow2,size=2T"}, output: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{ @@ -3267,7 +3591,7 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { Format: QemuDiskFormat_Qcow2, Id: uint53, Replicate: true, - Size: 2048, + Size: 2147483648, Storage: "test2", }}}}}, }, @@ -3348,7 +3672,7 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", Replicate: false, Serial: "disk-9763", - Size: 1, + Size: 1048576, WorldWideName: "0x500CBE4300D978A6", }}}}}, }, @@ -3494,13 +3818,40 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { Serial: "disk-9763", }}}}}, }, - {name: "Disks Ide Passthrough size", - input: map[string]interface{}{"ide0": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=1G"}, + {name: "Disks Ide Passthrough size G", + input: map[string]interface{}{"ide0": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=10G"}, output: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Passthrough: &QemuIdePassthrough{ Backup: true, File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", Replicate: true, - Size: 1, + Size: 10485760, + }}}}}, + }, + {name: "Disks Ide Passthrough size K", + input: map[string]interface{}{"ide0": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=10K"}, + output: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Passthrough: &QemuIdePassthrough{ + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + Size: 10, + }}}}}, + }, + {name: "Disks Ide Passthrough size M", + input: map[string]interface{}{"ide0": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=10M"}, + output: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Passthrough: &QemuIdePassthrough{ + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + Size: 10240, + }}}}}, + }, + {name: "Disks Ide Passthrough size T", + input: map[string]interface{}{"ide0": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=10T"}, + output: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Passthrough: &QemuIdePassthrough{ + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + Size: 10737418240, }}}}}, }, {name: "Disks Ide Passthrough ssd", @@ -3586,7 +3937,7 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { Id: uint47, Replicate: false, Serial: "disk-9763", - Size: 32, + Size: 33554432, Storage: "test2", WorldWideName: "0x500DFA8900E3C641", }}}}}, @@ -3616,7 +3967,7 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { LinkedDiskId: &uint1, Replicate: false, Serial: "disk-9763", - Size: 32, + Size: 33554432, Storage: "test2", WorldWideName: "0x5003B97600A8F2D4", }}}}}, @@ -3801,6 +4152,17 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { }, {name: "Disks Sata Disk size G", input: map[string]interface{}{"sata4": "test2:100/vm-100-disk-47.qcow2,size=32G"}, + output: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Disk: &QemuSataDisk{ + Backup: true, + Format: QemuDiskFormat_Qcow2, + Id: uint47, + Replicate: true, + Size: 33554432, + Storage: "test2", + }}}}}, + }, + {name: "Disks Sata Disk size K", + input: map[string]interface{}{"sata4": "test2:100/vm-100-disk-47.qcow2,size=32K"}, output: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Disk: &QemuSataDisk{ Backup: true, Format: QemuDiskFormat_Qcow2, @@ -3810,6 +4172,17 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { Storage: "test2", }}}}}, }, + {name: "Disks Sata Disk size M", + input: map[string]interface{}{"sata4": "test2:100/vm-100-disk-47.qcow2,size=32M"}, + output: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Disk: &QemuSataDisk{ + Backup: true, + Format: QemuDiskFormat_Qcow2, + Id: uint47, + Replicate: true, + Size: 32768, + Storage: "test2", + }}}}}, + }, {name: "Disks Sata Disk size T", input: map[string]interface{}{"sata4": "test2:100/vm-100-disk-47.qcow2,size=3T"}, output: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Disk: &QemuSataDisk{ @@ -3817,7 +4190,7 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { Format: QemuDiskFormat_Qcow2, Id: uint47, Replicate: true, - Size: 3072, + Size: 3221225472, Storage: "test2", }}}}}, }, @@ -3898,7 +4271,7 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", Replicate: false, Serial: "disk-9763", - Size: 1, + Size: 1048576, WorldWideName: "500E9FBC00F2A6D3", }}}}}, }, @@ -4044,13 +4417,40 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { Serial: "disk-9763", }}}}}, }, - {name: "Disks Sata Passthrough size", - input: map[string]interface{}{"sata4": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=1G"}, + {name: "Disks Sata Passthrough size G", + input: map[string]interface{}{"sata4": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=3G"}, output: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Passthrough: &QemuSataPassthrough{ Backup: true, File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", Replicate: true, - Size: 1, + Size: 3145728, + }}}}}, + }, + {name: "Disks Sata Passthrough size K", + input: map[string]interface{}{"sata4": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=5789K"}, + output: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Passthrough: &QemuSataPassthrough{ + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + Size: 5789, + }}}}}, + }, + {name: "Disks Sata Passthrough size M", + input: map[string]interface{}{"sata4": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=45M"}, + output: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Passthrough: &QemuSataPassthrough{ + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + Size: 46080, + }}}}}, + }, + {name: "Disks Sata Passthrough size T", + input: map[string]interface{}{"sata4": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=7T"}, + output: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Passthrough: &QemuSataPassthrough{ + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + Size: 7516192768, }}}}}, }, {name: "Disks Sata Passthrough ssd", @@ -4138,7 +4538,7 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { ReadOnly: true, Replicate: false, Serial: "disk-9763", - Size: 32, + Size: 33554432, Storage: "test", WorldWideName: "0x500AF18700E9CD25", }}}}}, @@ -4170,7 +4570,7 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { ReadOnly: true, Replicate: false, Serial: "disk-9763", - Size: 32, + Size: 33554432, Storage: "test", WorldWideName: "0x500879DC00F3BE6A", }}}}}, @@ -4373,6 +4773,17 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { }, {name: "Disks Scsi Disk size G", input: map[string]interface{}{"scsi18": "test:100/vm-100-disk-2.qcow2,size=32G"}, + output: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ + Backup: true, + Format: QemuDiskFormat_Qcow2, + Id: uint2, + Replicate: true, + Size: 33554432, + Storage: "test", + }}}}}, + }, + {name: "Disks Scsi Disk size K", + input: map[string]interface{}{"scsi18": "test:100/vm-100-disk-2.qcow2,size=32K"}, output: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ Backup: true, Format: QemuDiskFormat_Qcow2, @@ -4382,6 +4793,17 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { Storage: "test", }}}}}, }, + {name: "Disks Scsi Disk size M", + input: map[string]interface{}{"scsi18": "test:100/vm-100-disk-2.qcow2,size=32M"}, + output: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ + Backup: true, + Format: QemuDiskFormat_Qcow2, + Id: uint2, + Replicate: true, + Size: 32768, + Storage: "test", + }}}}}, + }, {name: "Disks Scsi Disk size T", input: map[string]interface{}{"scsi18": "test:100/vm-100-disk-2.qcow2,size=4T"}, output: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ @@ -4389,7 +4811,7 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { Format: QemuDiskFormat_Qcow2, Id: uint2, Replicate: true, - Size: 4096, + Size: 4294967296, Storage: "test", }}}}}, }, @@ -4472,7 +4894,7 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { ReadOnly: true, Replicate: false, Serial: "disk-9763", - Size: 1, + Size: 1048576, WorldWideName: "500CB15600D8FE32", }}}}}, }, @@ -4636,8 +5058,17 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { Serial: "disk-9763", }}}}}, }, - {name: "Disks Scsi Passthrough size", + {name: "Disks Scsi Passthrough size G", input: map[string]interface{}{"scsi18": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=1G"}, + output: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Passthrough: &QemuScsiPassthrough{ + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + Size: 1048576, + }}}}}, + }, + {name: "Disks Scsi Passthrough size K", + input: map[string]interface{}{"scsi18": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=1K"}, output: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Passthrough: &QemuScsiPassthrough{ Backup: true, File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", @@ -4645,6 +5076,24 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { Size: 1, }}}}}, }, + {name: "Disks Scsi Passthrough size M", + input: map[string]interface{}{"scsi18": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=1M"}, + output: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Passthrough: &QemuScsiPassthrough{ + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + Size: 1024, + }}}}}, + }, + {name: "Disks Scsi Passthrough size T", + input: map[string]interface{}{"scsi18": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=1T"}, + output: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Passthrough: &QemuScsiPassthrough{ + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + Size: 1073741824, + }}}}}, + }, {name: "Disks Scsi Passthrough ssd", input: map[string]interface{}{"scsi19": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,ssd=1"}, output: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_19: &QemuScsiStorage{Passthrough: &QemuScsiPassthrough{ @@ -4729,7 +5178,7 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { ReadOnly: true, Replicate: false, Serial: "disk-9763", - Size: 32, + Size: 33554432, Storage: "test2", WorldWideName: "0x50015B3900F8EAD2", }}}}}, @@ -4760,7 +5209,7 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { ReadOnly: true, Replicate: false, Serial: "disk-9763", - Size: 32, + Size: 33554432, Storage: "test2", WorldWideName: "0x500FA2D000C69587", }}}}}, @@ -4967,6 +5416,17 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { }, {name: "Disks VirtIO Disk size G", input: map[string]interface{}{"virtio2": "test2:100/vm-100-disk-31.qcow2,size=32G"}, + output: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ + Backup: true, + Format: QemuDiskFormat_Qcow2, + Id: uint31, + Replicate: true, + Size: 33554432, + Storage: "test2", + }}}}}, + }, + {name: "Disks VirtIO Disk size K", + input: map[string]interface{}{"virtio2": "test2:100/vm-100-disk-31.qcow2,size=32K"}, output: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ Backup: true, Format: QemuDiskFormat_Qcow2, @@ -4976,6 +5436,17 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { Storage: "test2", }}}}}, }, + {name: "Disks VirtIO Disk size M", + input: map[string]interface{}{"virtio2": "test2:100/vm-100-disk-31.qcow2,size=32M"}, + output: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ + Backup: true, + Format: QemuDiskFormat_Qcow2, + Id: uint31, + Replicate: true, + Size: 32768, + Storage: "test2", + }}}}}, + }, {name: "Disks VirtIO Disk size T", input: map[string]interface{}{"virtio2": "test2:100/vm-100-disk-31.qcow2,size=5T"}, output: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ @@ -4983,7 +5454,7 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { Format: QemuDiskFormat_Qcow2, Id: uint31, Replicate: true, - Size: 5120, + Size: 5368709120, Storage: "test2", }}}}}, }, @@ -5054,7 +5525,7 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { ReadOnly: true, Replicate: false, Serial: "disk-9763", - Size: 1, + Size: 1048576, WorldWideName: "0x500B6ED600F1C945", }}}}}, }, @@ -5218,8 +5689,17 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { Serial: "disk-9763", }}}}}, }, - {name: "Disks VirtIO Passthrough size", + {name: "Disks VirtIO Passthrough size G", input: map[string]interface{}{"virtio2": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=1G"}, + output: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Passthrough: &QemuVirtIOPassthrough{ + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + Size: 1048576, + }}}}}, + }, + {name: "Disks VirtIO Passthrough size K", + input: map[string]interface{}{"virtio2": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=1K"}, output: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Passthrough: &QemuVirtIOPassthrough{ Backup: true, File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", @@ -5227,6 +5707,24 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { Size: 1, }}}}}, }, + {name: "Disks VirtIO Passthrough size M", + input: map[string]interface{}{"virtio2": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=1M"}, + output: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Passthrough: &QemuVirtIOPassthrough{ + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + Size: 1024, + }}}}}, + }, + {name: "Disks VirtIO Passthrough size T", + input: map[string]interface{}{"virtio2": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=1T"}, + output: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Passthrough: &QemuVirtIOPassthrough{ + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + Size: 1073741824, + }}}}}, + }, {name: "Disks VirtIO Passthrough wwn", input: map[string]interface{}{"virtio2": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,wwn=0x5008FA6500D9C8B3"}, output: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Passthrough: &QemuVirtIOPassthrough{ From 69e86d5499d6bd59c6fae2cd7fad619d27f0ff85 Mon Sep 17 00:00:00 2001 From: Tinyblargon <76069640+Tinyblargon@users.noreply.github.com> Date: Tue, 30 Jan 2024 17:59:44 +0000 Subject: [PATCH 2/9] feat: disk size in K M G T disk size in Kibibyte, Mebibyte, Gibibyte, Tibibyte --- proxmox/config_qemu_disk.go | 17 ++++++----------- proxmox/constants.go | 9 +++++++++ proxmox/util.go | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 11 deletions(-) create mode 100644 proxmox/constants.go diff --git a/proxmox/config_qemu_disk.go b/proxmox/config_qemu_disk.go index 88c506c0..6fb1f95f 100644 --- a/proxmox/config_qemu_disk.go +++ b/proxmox/config_qemu_disk.go @@ -253,7 +253,11 @@ func (disk qemuDisk) formatDisk(vmID, LinkedVmId uint, currentStorage string, cu func (disk qemuDisk) mapToApiValues(vmID, LinkedVmId uint, currentStorage string, currentFormat QemuDiskFormat, syntax diskSyntaxEnum, create bool) (settings string) { if disk.Storage != "" { if create { - settings = disk.Storage + ":" + strconv.Itoa(int(disk.Size)) + if disk.Size%gibibyte == 0 { + settings = disk.Storage + ":" + strconv.FormatInt(int64(disk.Size/gibibyte), 10) + } else { + settings = disk.Storage + ":0" + } } else { settings = disk.formatDisk(vmID, LinkedVmId, currentStorage, currentFormat, syntax) } @@ -421,16 +425,7 @@ func (qemuDisk) mapToStruct(diskData string, settings map[string]interface{}, li disk.Serial = QemuDiskSerial(value.(string)) } if value, isSet := settings["size"]; isSet { - sizeString := value.(string) - if len(sizeString) > 1 { - diskSize, _ := strconv.Atoi(sizeString[0 : len(sizeString)-1]) - switch sizeString[len(sizeString)-1:] { - case "G": - disk.Size = uint(diskSize) - case "T": - disk.Size = uint(diskSize * 1024) - } - } + disk.Size = kibibyteParse(value.(string)) } if value, isSet := settings["ssd"]; isSet { disk.EmulateSSD, _ = strconv.ParseBool(value.(string)) diff --git a/proxmox/constants.go b/proxmox/constants.go new file mode 100644 index 00000000..1c334f69 --- /dev/null +++ b/proxmox/constants.go @@ -0,0 +1,9 @@ +package proxmox + +// Constants that are not explicitly related to a specific type go here. + +const ( + mebibyte uint = 1024 + gibibyte uint = 1048576 + tebibyte uint = 1073741824 +) diff --git a/proxmox/util.go b/proxmox/util.go index e39fefe8..106a4f34 100644 --- a/proxmox/util.go +++ b/proxmox/util.go @@ -234,6 +234,21 @@ func floatToTrimmedString(f float64, maxDecimals uint8) (s string) { return } +func kibibyteParse(rawSize string) (size uint) { + tmpSize, _ := strconv.ParseInt(rawSize[:len(rawSize)-1], 10, 0) + switch rawSize[len(rawSize)-1:] { + case "T": + size = uint(tmpSize) * tebibyte + case "G": + size = uint(tmpSize) * gibibyte + case "M": + size = uint(tmpSize) * mebibyte + case "K": + size = uint(tmpSize) + } + return +} + func splitStringOfSettings(settings string) map[string]interface{} { settingValuePairs := strings.Split(settings, ",") settingMap := map[string]interface{}{} From 651e9e2838e554b24dcc34141d4db0117dffbf6f Mon Sep 17 00:00:00 2001 From: Tinyblargon <76069640+Tinyblargon@users.noreply.github.com> Date: Tue, 30 Jan 2024 18:00:41 +0000 Subject: [PATCH 3/9] feat: Resize disk in Kibibyte --- proxmox/config_qemu_disk.go | 6 +++--- proxmox/config_qemu_disk_test.go | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/proxmox/config_qemu_disk.go b/proxmox/config_qemu_disk.go index 6fb1f95f..1993eb3a 100644 --- a/proxmox/config_qemu_disk.go +++ b/proxmox/config_qemu_disk.go @@ -806,7 +806,7 @@ func (disk *qemuDiskMark) markChanges(currentDisk *qemuDiskMark, id QemuDiskId, if disk.Size > currentDisk.Size { changes.Resize = append(changes.Resize, qemuDiskResize{ Id: id, - SizeInGigaBytes: disk.Size, + SizeInKibibytes: disk.Size, }) } if disk.Storage != currentDisk.Storage || disk.Format != currentDisk.Format { @@ -845,13 +845,13 @@ func (serial QemuDiskSerial) Validate() error { type qemuDiskResize struct { Id QemuDiskId - SizeInGigaBytes uint + SizeInKibibytes uint } // Increase the disk size to the specified amount in gigabytes // Decrease of disk size is not permitted. func (disk qemuDiskResize) resize(vmr *VmRef, client *Client) (exitStatus string, err error) { - return client.PutWithTask(map[string]interface{}{"disk": disk.Id, "size": strconv.Itoa(int(disk.SizeInGigaBytes)) + "G"}, fmt.Sprintf("/nodes/%s/%s/%d/resize", vmr.node, vmr.vmType, vmr.vmId)) + return client.PutWithTask(map[string]interface{}{"disk": disk.Id, "size": strconv.FormatInt(int64(disk.SizeInKibibytes), 10) + "K"}, fmt.Sprintf("/nodes/%s/%s/%d/resize", vmr.node, vmr.vmType, vmr.vmId)) } type qemuDiskMove struct { diff --git a/proxmox/config_qemu_disk_test.go b/proxmox/config_qemu_disk_test.go index b8e465ac..1f2bfa55 100644 --- a/proxmox/config_qemu_disk_test.go +++ b/proxmox/config_qemu_disk_test.go @@ -926,10 +926,10 @@ func Test_QemuStorages_markDiskChanges(t *testing.T) { {Format: &format_Raw, Id: "virtio3", Storage: "NewStorage"}, }, Resize: []qemuDiskResize{ - {Id: "ide0", SizeInGigaBytes: 100}, - {Id: "sata1", SizeInGigaBytes: 50}, - {Id: "scsi2", SizeInGigaBytes: 33}, - {Id: "virtio3", SizeInGigaBytes: 99}, + {Id: "ide0", SizeInKibibytes: 100}, + {Id: "sata1", SizeInKibibytes: 50}, + {Id: "scsi2", SizeInKibibytes: 33}, + {Id: "virtio3", SizeInKibibytes: 99}, }, }, }, @@ -997,10 +997,10 @@ func Test_QemuStorages_markDiskChanges(t *testing.T) { VirtIO: &QemuVirtIODisks{Disk_6: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, }, output: &qemuUpdateChanges{Resize: []qemuDiskResize{ - {Id: "ide3", SizeInGigaBytes: 90}, - {Id: "sata4", SizeInGigaBytes: 80}, - {Id: "scsi5", SizeInGigaBytes: 50}, - {Id: "virtio6", SizeInGigaBytes: 33}, + {Id: "ide3", SizeInKibibytes: 90}, + {Id: "sata4", SizeInKibibytes: 80}, + {Id: "scsi5", SizeInKibibytes: 50}, + {Id: "virtio6", SizeInKibibytes: 33}, }}, }, {name: "Disk.Size SMALLER", From 2bd32a2988df6ca8be00dadd48e9a676a8709631 Mon Sep 17 00:00:00 2001 From: Tinyblargon <76069640+Tinyblargon@users.noreply.github.com> Date: Tue, 30 Jan 2024 18:01:54 +0000 Subject: [PATCH 4/9] refactor: extract disk resize loop to func --- proxmox/config_qemu.go | 7 ++----- proxmox/config_qemu_disk.go | 11 +++++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/proxmox/config_qemu.go b/proxmox/config_qemu.go index ce33235c..32876eaf 100644 --- a/proxmox/config_qemu.go +++ b/proxmox/config_qemu.go @@ -872,11 +872,8 @@ func (newConfig ConfigQemu) setAdvanced(currentConfig *ConfigQemu, rebootIfNeede return } } - for _, e := range markedDisks.Resize { // increase Disks in size - _, err = e.resize(vmr, client) - if err != nil { - return false, err - } + if err = resizeDisks(vmr, client, markedDisks.Resize); err != nil { // increase Disks in size + return false, err } itemsToDeleteBeforeUpdate = newConfig.Disks.cloudInitRemove(*currentConfig.Disks) } diff --git a/proxmox/config_qemu_disk.go b/proxmox/config_qemu_disk.go index 1993eb3a..0f61478e 100644 --- a/proxmox/config_qemu_disk.go +++ b/proxmox/config_qemu_disk.go @@ -1160,3 +1160,14 @@ func MoveQemuDisk(format *QemuDiskFormat, diskId QemuDiskId, storage string, del _, err = disk.move(deleteAfterMove, vmr, client) return } + +// increase Disks in size +func resizeDisks(vmr *VmRef, client *Client, disks []qemuDiskResize) (err error) { + for _, e := range disks { + _, err = e.resize(vmr, client) + if err != nil { + return + } + } + return +} From 7c468ba56f87d53c18ec2747b4cf3d12c9b05238 Mon Sep 17 00:00:00 2001 From: Tinyblargon <76069640+Tinyblargon@users.noreply.github.com> Date: Wed, 31 Jan 2024 11:05:40 +0000 Subject: [PATCH 5/9] feat: build list of disk to resize select the disks that have been created with 0 size and should be resized --- proxmox/config_qemu_disk.go | 32 ++++++ proxmox/config_qemu_disk_ide.go | 20 ++++ proxmox/config_qemu_disk_sata.go | 18 +++ proxmox/config_qemu_disk_scsi.go | 18 +++ proxmox/config_qemu_disk_test.go | 177 +++++++++++++++++++++++++++++ proxmox/config_qemu_disk_virtio.go | 18 +++ 6 files changed, 283 insertions(+) diff --git a/proxmox/config_qemu_disk.go b/proxmox/config_qemu_disk.go index 0f61478e..c51e181f 100644 --- a/proxmox/config_qemu_disk.go +++ b/proxmox/config_qemu_disk.go @@ -1078,6 +1078,38 @@ func (storages QemuStorages) markDiskChanges(currentStorages QemuStorages) *qemu return changes } +// Select all new disks that do not have their size in gibigytes for resizing to the specified size +func (newStorages QemuStorages) selectInitialResize(currentStorages *QemuStorages) (resize []qemuDiskResize) { + if currentStorages == nil { + if newStorages.Ide != nil { + resize = newStorages.Ide.selectInitialResize(nil) + } + if newStorages.Sata != nil { + resize = append(resize, newStorages.Sata.selectInitialResize(nil)...) + } + if newStorages.Scsi != nil { + resize = append(resize, newStorages.Scsi.selectInitialResize(nil)...) + } + if newStorages.VirtIO != nil { + resize = append(resize, newStorages.VirtIO.selectInitialResize(nil)...) + } + return + } + if newStorages.Ide != nil { + resize = newStorages.Ide.selectInitialResize(currentStorages.Ide) + } + if newStorages.Sata != nil { + resize = append(resize, newStorages.Sata.selectInitialResize(currentStorages.Sata)...) + } + if newStorages.Scsi != nil { + resize = append(resize, newStorages.Scsi.selectInitialResize(currentStorages.Scsi)...) + } + if newStorages.VirtIO != nil { + resize = append(resize, newStorages.VirtIO.selectInitialResize(currentStorages.VirtIO)...) + } + return +} + func (storages QemuStorages) Validate() (err error) { var numberOfCloudInitDevices uint8 var CloudInit uint8 diff --git a/proxmox/config_qemu_disk_ide.go b/proxmox/config_qemu_disk_ide.go index 758ef139..1ca1c6d6 100644 --- a/proxmox/config_qemu_disk_ide.go +++ b/proxmox/config_qemu_disk_ide.go @@ -125,6 +125,26 @@ func (disks QemuIdeDisks) markDiskChanges(currentDisks *QemuIdeDisks, changes *q } } +func (disks QemuIdeDisks) selectInitialResize(currentDisks *QemuIdeDisks) (resize []qemuDiskResize) { + tmpCurrentDisks := QemuIdeDisks{} + if currentDisks != nil { + tmpCurrentDisks = *currentDisks + } + diskMap := disks.mapToIntMap() + currentDiskMap := tmpCurrentDisks.mapToIntMap() + for i := range diskMap { + if diskMap[i] != nil && diskMap[i].Disk != nil && diskMap[i].Disk.Size%gibibyte != 0 && (currentDiskMap[i] == nil || currentDiskMap[i].Disk == nil || diskMap[i].Disk.Size < currentDiskMap[i].Disk.Size) { + aaa := diskMap[i].Disk.Size % gibibyte + _ = aaa + resize = append(resize, qemuDiskResize{ + Id: QemuDiskId("ide" + strconv.Itoa(int(i))), + SizeInKibibytes: diskMap[i].Disk.Size, + }) + } + } + return resize +} + func (disks QemuIdeDisks) Validate() (err error) { _, err = disks.validate() return diff --git a/proxmox/config_qemu_disk_sata.go b/proxmox/config_qemu_disk_sata.go index eea90c6c..b11f0d9c 100644 --- a/proxmox/config_qemu_disk_sata.go +++ b/proxmox/config_qemu_disk_sata.go @@ -137,6 +137,24 @@ func (disks QemuSataDisks) markDiskChanges(currentDisks *QemuSataDisks, changes } } +func (disks QemuSataDisks) selectInitialResize(currentDisks *QemuSataDisks) (resize []qemuDiskResize) { + tmpCurrentDisks := QemuSataDisks{} + if currentDisks != nil { + tmpCurrentDisks = *currentDisks + } + diskMap := disks.mapToIntMap() + currentDiskMap := tmpCurrentDisks.mapToIntMap() + for i := range diskMap { + if diskMap[i] != nil && diskMap[i].Disk != nil && diskMap[i].Disk.Size%gibibyte != 0 && (currentDiskMap[i] == nil || currentDiskMap[i].Disk == nil || diskMap[i].Disk.Size < currentDiskMap[i].Disk.Size) { + resize = append(resize, qemuDiskResize{ + Id: QemuDiskId("sata" + strconv.Itoa(int(i))), + SizeInKibibytes: diskMap[i].Disk.Size, + }) + } + } + return resize +} + func (disks QemuSataDisks) Validate() (err error) { _, err = disks.validate() return diff --git a/proxmox/config_qemu_disk_scsi.go b/proxmox/config_qemu_disk_scsi.go index 623899ca..4f470ccb 100644 --- a/proxmox/config_qemu_disk_scsi.go +++ b/proxmox/config_qemu_disk_scsi.go @@ -291,6 +291,24 @@ func (disks QemuScsiDisks) markDiskChanges(currentDisks *QemuScsiDisks, changes } } +func (disks QemuScsiDisks) selectInitialResize(currentDisks *QemuScsiDisks) (resize []qemuDiskResize) { + tmpCurrentDisks := QemuScsiDisks{} + if currentDisks != nil { + tmpCurrentDisks = *currentDisks + } + diskMap := disks.mapToIntMap() + currentDiskMap := tmpCurrentDisks.mapToIntMap() + for i := range diskMap { + if diskMap[i] != nil && diskMap[i].Disk != nil && diskMap[i].Disk.Size%gibibyte != 0 && (currentDiskMap[i] == nil || currentDiskMap[i].Disk == nil || diskMap[i].Disk.Size < currentDiskMap[i].Disk.Size) { + resize = append(resize, qemuDiskResize{ + Id: QemuDiskId("scsi" + strconv.Itoa(int(i))), + SizeInKibibytes: diskMap[i].Disk.Size, + }) + } + } + return resize +} + func (disks QemuScsiDisks) Validate() (err error) { _, err = disks.validate() return diff --git a/proxmox/config_qemu_disk_test.go b/proxmox/config_qemu_disk_test.go index 1f2bfa55..07c02678 100644 --- a/proxmox/config_qemu_disk_test.go +++ b/proxmox/config_qemu_disk_test.go @@ -1049,6 +1049,183 @@ func Test_QemuStorages_markDiskChanges(t *testing.T) { } } +func Test_QemuStorages_selectInitialResize(t *testing.T) { + type testInput struct { + currentStorages *QemuStorages + newStorages QemuStorages + } + tests := []struct { + name string + input testInput + output []qemuDiskResize + }{ + {name: "Disks Resize Down Gibibytes", + input: testInput{currentStorages: &QemuStorages{ + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 10485761}}}, + Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Size: 1048577}}}, + Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 70254593}}}, + VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 872415233}}}, + }, newStorages: QemuStorages{ + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 10485760}}}, + Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Size: 1048576}}}, + Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 70254592}}}, + VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 872415232}}}, + }}, + }, + {name: "Disks Resize Down Kibibytes", + input: testInput{currentStorages: &QemuStorages{ + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 94384}}}, + Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Size: 75}}}, + Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 8584654835893}}}, + VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 19695729}}}, + }, newStorages: QemuStorages{ + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 943}}}, + Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Size: 7}}}, + Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 8584654835}}}, + VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 19695}}}, + }}, + output: []qemuDiskResize{ + {Id: "ide1", SizeInKibibytes: 943}, + {Id: "sata2", SizeInKibibytes: 7}, + {Id: "scsi3", SizeInKibibytes: 8584654835}, + {Id: "virtio4", SizeInKibibytes: 19695}, + }, + }, + {name: "Disks Resize Up", + input: testInput{currentStorages: &QemuStorages{ + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 943}}}, + Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Size: 7}}}, + Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 8584654835}}}, + VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 19695}}}, + }, newStorages: QemuStorages{ + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 94384}}}, + Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Size: 75}}}, + Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 8584654835893}}}, + VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 19695729}}}, + }}, + }, + {name: "Disks Same", + input: testInput{currentStorages: &QemuStorages{ + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 94384}}}, + Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Size: 75}}}, + Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 8584654835893}}}, + VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 19695729}}}, + }, newStorages: QemuStorages{ + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 94384}}}, + Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Size: 75}}}, + Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 8584654835893}}}, + VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 19695729}}}, + }}, + }, + {name: "Don't resize cause whole x gibibyte", + input: testInput{currentStorages: nil, newStorages: QemuStorages{ + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 1048576}}}, + Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Size: 10485760}}}, + Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 47185920}}}, + VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 480247808}}}, + }}, + }, + {name: "newStorages empty", + input: testInput{currentStorages: &QemuStorages{ + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 94384}}}, + Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Size: 75}}}, + Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 8584654835893}}}, + VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 19695729}}}, + }, newStorages: QemuStorages{}}, + }, + {name: "No current disks 1 x kibibyte", + input: testInput{currentStorages: nil, newStorages: QemuStorages{ + Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 7867}}}, + Sata: &QemuSataDisks{Disk_1: &QemuSataStorage{Disk: &QemuSataDisk{Size: 985947483}}}, + Scsi: &QemuScsiDisks{Disk_2: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 577564}}}, + VirtIO: &QemuVirtIODisks{Disk_3: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 323}}}, + }}, + output: []qemuDiskResize{ + {Id: "ide0", SizeInKibibytes: 7867}, + {Id: "sata1", SizeInKibibytes: 985947483}, + {Id: "scsi2", SizeInKibibytes: 577564}, + {Id: "virtio3", SizeInKibibytes: 323}, + }, + }, + {name: "No current disks 2 x kibibyte", + input: testInput{currentStorages: &QemuStorages{}, newStorages: QemuStorages{ + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 7867}}}, + Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Size: 985947483}}}, + Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 577564}}}, + VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 323}}}, + }}, + output: []qemuDiskResize{ + {Id: "ide1", SizeInKibibytes: 7867}, + {Id: "sata2", SizeInKibibytes: 985947483}, + {Id: "scsi3", SizeInKibibytes: 577564}, + {Id: "virtio4", SizeInKibibytes: 323}, + }, + }, + {name: "No current disks 3 x kibibyte", + input: testInput{currentStorages: &QemuStorages{ + Ide: &QemuIdeDisks{}, + Sata: &QemuSataDisks{}, + Scsi: &QemuScsiDisks{}, + VirtIO: &QemuVirtIODisks{}, + }, newStorages: QemuStorages{ + Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 7867}}}, + Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{Size: 985947483}}}, + Scsi: &QemuScsiDisks{Disk_4: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 577564}}}, + VirtIO: &QemuVirtIODisks{Disk_5: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 323}}}, + }}, + output: []qemuDiskResize{ + {Id: "ide2", SizeInKibibytes: 7867}, + {Id: "sata3", SizeInKibibytes: 985947483}, + {Id: "scsi4", SizeInKibibytes: 577564}, + {Id: "virtio5", SizeInKibibytes: 323}, + }, + }, + {name: "No current disks 4 x kibibyte", + input: testInput{currentStorages: &QemuStorages{ + Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{}}, + Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{}}, + Scsi: &QemuScsiDisks{Disk_5: &QemuScsiStorage{}}, + VirtIO: &QemuVirtIODisks{Disk_6: &QemuVirtIOStorage{}}, + }, newStorages: QemuStorages{ + Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 7867}}}, + Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Disk: &QemuSataDisk{Size: 985947483}}}, + Scsi: &QemuScsiDisks{Disk_5: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 577564}}}, + VirtIO: &QemuVirtIODisks{Disk_6: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 323}}}, + }}, + output: []qemuDiskResize{ + {Id: "ide3", SizeInKibibytes: 7867}, + {Id: "sata4", SizeInKibibytes: 985947483}, + {Id: "scsi5", SizeInKibibytes: 577564}, + {Id: "virtio6", SizeInKibibytes: 323}, + }, + }, + {name: "No current disks 5 x kibibyte", + input: testInput{currentStorages: &QemuStorages{ + Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{CdRom: &QemuCdRom{}}}, + Sata: &QemuSataDisks{Disk_5: &QemuSataStorage{Passthrough: &QemuSataPassthrough{}}}, + Scsi: &QemuScsiDisks{Disk_6: &QemuScsiStorage{CloudInit: &QemuCloudInitDisk{}}}, + VirtIO: &QemuVirtIODisks{Disk_7: &QemuVirtIOStorage{CdRom: &QemuCdRom{}}}, + }, newStorages: QemuStorages{ + Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 7867}}}, + Sata: &QemuSataDisks{Disk_5: &QemuSataStorage{Disk: &QemuSataDisk{Size: 985947483}}}, + Scsi: &QemuScsiDisks{Disk_6: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 577564}}}, + VirtIO: &QemuVirtIODisks{Disk_7: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 323}}}, + }}, + output: []qemuDiskResize{ + {Id: "ide0", SizeInKibibytes: 7867}, + {Id: "sata5", SizeInKibibytes: 985947483}, + {Id: "scsi6", SizeInKibibytes: 577564}, + {Id: "virtio7", SizeInKibibytes: 323}, + }, + }, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + require.Equal(t, test.output, test.input.newStorages.selectInitialResize(test.input.currentStorages), test.name) + }) + } +} + func Test_QemuWorldWideName_Validate(t *testing.T) { testRunes := struct { legal []string diff --git a/proxmox/config_qemu_disk_virtio.go b/proxmox/config_qemu_disk_virtio.go index 8e7f2827..bdf53e20 100644 --- a/proxmox/config_qemu_disk_virtio.go +++ b/proxmox/config_qemu_disk_virtio.go @@ -199,6 +199,24 @@ func (disks QemuVirtIODisks) markDiskChanges(currentDisks *QemuVirtIODisks, chan } } +func (disks QemuVirtIODisks) selectInitialResize(currentDisks *QemuVirtIODisks) (resize []qemuDiskResize) { + tmpCurrentDisks := QemuVirtIODisks{} + if currentDisks != nil { + tmpCurrentDisks = *currentDisks + } + diskMap := disks.mapToIntMap() + currentDiskMap := tmpCurrentDisks.mapToIntMap() + for i := range diskMap { + if diskMap[i] != nil && diskMap[i].Disk != nil && diskMap[i].Disk.Size%gibibyte != 0 && (currentDiskMap[i] == nil || currentDiskMap[i].Disk == nil || diskMap[i].Disk.Size < currentDiskMap[i].Disk.Size) { + resize = append(resize, qemuDiskResize{ + Id: QemuDiskId("virtio" + strconv.Itoa(int(i))), + SizeInKibibytes: diskMap[i].Disk.Size, + }) + } + } + return resize +} + func (disks QemuVirtIODisks) Validate() (err error) { _, err = disks.validate() return From 2dd9a878846485fe39a388c395ee13e532cbd226 Mon Sep 17 00:00:00 2001 From: Tinyblargon <76069640+Tinyblargon@users.noreply.github.com> Date: Wed, 31 Jan 2024 12:00:46 +0000 Subject: [PATCH 6/9] feat: resize disks that where created with 0 size --- proxmox/config_qemu.go | 7 +++++++ proxmox/config_qemu_disk.go | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/proxmox/config_qemu.go b/proxmox/config_qemu.go index 32876eaf..bed3f0b2 100644 --- a/proxmox/config_qemu.go +++ b/proxmox/config_qemu.go @@ -935,6 +935,10 @@ func (newConfig ConfigQemu) setAdvanced(currentConfig *ConfigQemu, rebootIfNeede } } + if err = resizeNewDisks(vmr, client, newConfig.Disks, currentConfig.Disks); err != nil { + return + } + if stopped { // start vm if it was stopped if rebootIfNeeded { if err = GuestStart(vmr, client); err != nil { @@ -964,6 +968,9 @@ func (newConfig ConfigQemu) setAdvanced(currentConfig *ConfigQemu, rebootIfNeede if err != nil { return false, fmt.Errorf("error creating VM: %v, error status: %s (params: %v)", err, exitStatus, params) } + if err = resizeNewDisks(vmr, client, newConfig.Disks, nil); err != nil { + return + } } _, err = client.UpdateVMHA(vmr, newConfig.HaState, newConfig.HaGroup) diff --git a/proxmox/config_qemu_disk.go b/proxmox/config_qemu_disk.go index c51e181f..24a67b1a 100644 --- a/proxmox/config_qemu_disk.go +++ b/proxmox/config_qemu_disk.go @@ -1203,3 +1203,17 @@ func resizeDisks(vmr *VmRef, client *Client, disks []qemuDiskResize) (err error) } return } + +// Resize newly created disks +func resizeNewDisks(vmr *VmRef, client *Client, newDisks, currentDisks *QemuStorages) (err error) { + if newDisks == nil { + return + } + resize := newDisks.selectInitialResize(currentDisks) + if len(resize) > 0 { + if err = resizeDisks(vmr, client, resize); err != nil { + return + } + } + return +} From 100a85b2a4d5dac50f260859c4ebd5018eef8b59 Mon Sep 17 00:00:00 2001 From: Tinyblargon <76069640+Tinyblargon@users.noreply.github.com> Date: Wed, 31 Jan 2024 12:09:54 +0000 Subject: [PATCH 7/9] refactor: rename `Size` to `SizeInKibibytes` --- proxmox/config_qemu_disk.go | 58 +- proxmox/config_qemu_disk_ide.go | 146 +- proxmox/config_qemu_disk_sata.go | 144 +- proxmox/config_qemu_disk_scsi.go | 166 +- proxmox/config_qemu_disk_test.go | 236 +-- proxmox/config_qemu_disk_virtio.go | 156 +- proxmox/config_qemu_test.go | 2356 ++++++++++++++-------------- 7 files changed, 1631 insertions(+), 1631 deletions(-) diff --git a/proxmox/config_qemu_disk.go b/proxmox/config_qemu_disk.go index 24a67b1a..ea0ea844 100644 --- a/proxmox/config_qemu_disk.go +++ b/proxmox/config_qemu_disk.go @@ -19,8 +19,8 @@ const ( type IsoFile struct { File string `json:"file"` Storage string `json:"storage"` - // Size can only be retrieved, setting it has no effect - Size string `json:"size"` + // SizeInKibibytes can only be retrieved, setting it has no effect + SizeInKibibytes string `json:"size"` } const ( @@ -62,9 +62,9 @@ func (QemuCdRom) mapToStruct(settings qemuCdRom) *QemuCdRom { if settings.File != "" { return &QemuCdRom{ Iso: &IsoFile{ - Storage: settings.Storage, - File: settings.File, - Size: settings.Size, + Storage: settings.Storage, + File: settings.File, + SizeInKibibytes: settings.SizeInKibibytes, }, } } @@ -87,11 +87,11 @@ func (cdRom QemuCdRom) Validate() error { type qemuCdRom struct { CdRom bool // "local:iso/debian-11.0.0-amd64-netinst.iso,media=cdrom,size=377M" - Passthrough bool - Storage string - Format QemuDiskFormat // Only set for Cloud-init drives - File string - Size string + Passthrough bool + Storage string + Format QemuDiskFormat // Only set for Cloud-init drives + File string + SizeInKibibytes string } func (qemuCdRom) mapToStruct(diskData string, settings map[string]interface{}) *qemuCdRom { @@ -125,10 +125,10 @@ func (qemuCdRom) mapToStruct(diskData string, settings map[string]interface{}) * if fileType == "iso" { if setting, isSet := settings["size"]; isSet { return &qemuCdRom{ - CdRom: true, - Storage: tmpStorage[0], - File: tmpFile[1], - Size: setting.(string), + CdRom: true, + Storage: tmpStorage[0], + File: tmpFile[1], + SizeInKibibytes: setting.(string), } } } else { @@ -191,16 +191,16 @@ type qemuDisk struct { Disk bool // true = disk, false = passthrough EmulateSSD bool // Only set for ide,sata,scsi // TODO custom type - File string // Only set for Passthrough. - fileSyntax diskSyntaxEnum // private enum to determine the syntax of the file path, as this changes depending on the type of backing storage. ie nfs, lvm, local, etc. - Format QemuDiskFormat // Only set for Disk - Id uint // Only set for Disk - IOThread bool // Only set for scsi,virtio - LinkedDiskId *uint // Only set for Disk - ReadOnly bool // Only set for scsi,virtio - Replicate bool - Serial QemuDiskSerial - Size uint + File string // Only set for Passthrough. + fileSyntax diskSyntaxEnum // private enum to determine the syntax of the file path, as this changes depending on the type of backing storage. ie nfs, lvm, local, etc. + Format QemuDiskFormat // Only set for Disk + Id uint // Only set for Disk + IOThread bool // Only set for scsi,virtio + LinkedDiskId *uint // Only set for Disk + ReadOnly bool // Only set for scsi,virtio + Replicate bool + Serial QemuDiskSerial + SizeInKibibytes uint // TODO custom type Storage string // Only set for Disk Type qemuDiskType @@ -253,8 +253,8 @@ func (disk qemuDisk) formatDisk(vmID, LinkedVmId uint, currentStorage string, cu func (disk qemuDisk) mapToApiValues(vmID, LinkedVmId uint, currentStorage string, currentFormat QemuDiskFormat, syntax diskSyntaxEnum, create bool) (settings string) { if disk.Storage != "" { if create { - if disk.Size%gibibyte == 0 { - settings = disk.Storage + ":" + strconv.FormatInt(int64(disk.Size/gibibyte), 10) + if disk.SizeInKibibytes%gibibyte == 0 { + settings = disk.Storage + ":" + strconv.FormatInt(int64(disk.SizeInKibibytes/gibibyte), 10) } else { settings = disk.Storage + ":0" } @@ -425,7 +425,7 @@ func (qemuDisk) mapToStruct(diskData string, settings map[string]interface{}, li disk.Serial = QemuDiskSerial(value.(string)) } if value, isSet := settings["size"]; isSet { - disk.Size = kibibyteParse(value.(string)) + disk.SizeInKibibytes = kibibyteParse(value.(string)) } if value, isSet := settings["ssd"]; isSet { disk.EmulateSSD, _ = strconv.ParseBool(value.(string)) @@ -527,7 +527,7 @@ func (disk *qemuDisk) validate() (err error) { if err = disk.Format.Validate(); err != nil { return } - if disk.Size == 0 { + if disk.SizeInKibibytes == 0 { return errors.New(Error_QemuDisk_Size) } if disk.Storage == "" { @@ -947,7 +947,7 @@ func (storage *qemuStorage) mapToApiValues(currentStorage *qemuStorage, vmID, li // Create params[string(id)] = storage.Disk.mapToApiValues(vmID, 0, "", "", false, true) } else { - if storage.Disk.Size >= currentStorage.Disk.Size { + if storage.Disk.SizeInKibibytes >= currentStorage.Disk.SizeInKibibytes { // Update storage.Disk.Id = currentStorage.Disk.Id storage.Disk.LinkedDiskId = currentStorage.Disk.LinkedDiskId diff --git a/proxmox/config_qemu_disk_ide.go b/proxmox/config_qemu_disk_ide.go index 1ca1c6d6..78c0c200 100644 --- a/proxmox/config_qemu_disk_ide.go +++ b/proxmox/config_qemu_disk_ide.go @@ -6,42 +6,42 @@ import ( ) type QemuIdeDisk struct { - AsyncIO QemuDiskAsyncIO `json:"asyncio,omitempty"` - Backup bool `json:"backup"` - Bandwidth QemuDiskBandwidth `json:"bandwidth,omitempty"` - Cache QemuDiskCache `json:"cache,omitempty"` - Discard bool `json:"discard"` - EmulateSSD bool `json:"emulatessd"` - Format QemuDiskFormat `json:"format"` - Id uint `json:"id"` //Id is only returned and setting it has no effect - LinkedDiskId *uint `json:"linked"` //LinkedClone is only returned and setting it has no effect - Replicate bool `json:"replicate"` - Serial QemuDiskSerial `json:"serial,omitempty"` - Size uint `json:"size"` - Storage string `json:"storage"` - syntax diskSyntaxEnum - WorldWideName QemuWorldWideName `json:"wwn"` + AsyncIO QemuDiskAsyncIO `json:"asyncio,omitempty"` + Backup bool `json:"backup"` + Bandwidth QemuDiskBandwidth `json:"bandwidth,omitempty"` + Cache QemuDiskCache `json:"cache,omitempty"` + Discard bool `json:"discard"` + EmulateSSD bool `json:"emulatessd"` + Format QemuDiskFormat `json:"format"` + Id uint `json:"id"` //Id is only returned and setting it has no effect + LinkedDiskId *uint `json:"linked"` //LinkedClone is only returned and setting it has no effect + Replicate bool `json:"replicate"` + Serial QemuDiskSerial `json:"serial,omitempty"` + SizeInKibibytes uint `json:"size"` + Storage string `json:"storage"` + syntax diskSyntaxEnum + WorldWideName QemuWorldWideName `json:"wwn"` } func (disk *QemuIdeDisk) convertDataStructure() *qemuDisk { return &qemuDisk{ - AsyncIO: disk.AsyncIO, - Backup: disk.Backup, - Bandwidth: disk.Bandwidth, - Cache: disk.Cache, - Discard: disk.Discard, - Disk: true, - EmulateSSD: disk.EmulateSSD, - fileSyntax: disk.syntax, - Format: disk.Format, - Id: disk.Id, - LinkedDiskId: disk.LinkedDiskId, - Replicate: disk.Replicate, - Serial: disk.Serial, - Size: disk.Size, - Storage: disk.Storage, - Type: ide, - WorldWideName: disk.WorldWideName, + AsyncIO: disk.AsyncIO, + Backup: disk.Backup, + Bandwidth: disk.Bandwidth, + Cache: disk.Cache, + Discard: disk.Discard, + Disk: true, + EmulateSSD: disk.EmulateSSD, + fileSyntax: disk.syntax, + Format: disk.Format, + Id: disk.Id, + LinkedDiskId: disk.LinkedDiskId, + Replicate: disk.Replicate, + Serial: disk.Serial, + SizeInKibibytes: disk.SizeInKibibytes, + Storage: disk.Storage, + Type: ide, + WorldWideName: disk.WorldWideName, } } @@ -133,12 +133,12 @@ func (disks QemuIdeDisks) selectInitialResize(currentDisks *QemuIdeDisks) (resiz diskMap := disks.mapToIntMap() currentDiskMap := tmpCurrentDisks.mapToIntMap() for i := range diskMap { - if diskMap[i] != nil && diskMap[i].Disk != nil && diskMap[i].Disk.Size%gibibyte != 0 && (currentDiskMap[i] == nil || currentDiskMap[i].Disk == nil || diskMap[i].Disk.Size < currentDiskMap[i].Disk.Size) { - aaa := diskMap[i].Disk.Size % gibibyte + if diskMap[i] != nil && diskMap[i].Disk != nil && diskMap[i].Disk.SizeInKibibytes%gibibyte != 0 && (currentDiskMap[i] == nil || currentDiskMap[i].Disk == nil || diskMap[i].Disk.SizeInKibibytes < currentDiskMap[i].Disk.SizeInKibibytes) { + aaa := diskMap[i].Disk.SizeInKibibytes % gibibyte _ = aaa resize = append(resize, qemuDiskResize{ Id: QemuDiskId("ide" + strconv.Itoa(int(i))), - SizeInKibibytes: diskMap[i].Disk.Size, + SizeInKibibytes: diskMap[i].Disk.SizeInKibibytes, }) } } @@ -169,17 +169,17 @@ func (disks QemuIdeDisks) validate() (numberOfCloudInitDevices uint8, err error) } type QemuIdePassthrough struct { - AsyncIO QemuDiskAsyncIO `json:"asyncio,omitempty"` - Backup bool `json:"backup"` - Bandwidth QemuDiskBandwidth `json:"bandwidth,omitempty"` - Cache QemuDiskCache `json:"cache,omitempty"` - Discard bool `json:"discard"` - EmulateSSD bool `json:"emulatessd"` - File string `json:"file"` - Replicate bool `json:"replicate"` - Serial QemuDiskSerial `json:"serial,omitempty"` - Size uint `json:"size"` //size is only returned and setting it has no effect - WorldWideName QemuWorldWideName `json:"wwn"` + AsyncIO QemuDiskAsyncIO `json:"asyncio,omitempty"` + Backup bool `json:"backup"` + Bandwidth QemuDiskBandwidth `json:"bandwidth,omitempty"` + Cache QemuDiskCache `json:"cache,omitempty"` + Discard bool `json:"discard"` + EmulateSSD bool `json:"emulatessd"` + File string `json:"file"` + Replicate bool `json:"replicate"` + Serial QemuDiskSerial `json:"serial,omitempty"` + SizeInKibibytes uint `json:"size"` //size is only returned and setting it has no effect + WorldWideName QemuWorldWideName `json:"wwn"` } func (passthrough *QemuIdePassthrough) convertDataStructure() *qemuDisk { @@ -235,7 +235,7 @@ func (storage *QemuIdeStorage) convertDataStructureMark() *qemuDiskMark { if storage.Disk != nil { return &qemuDiskMark{ Format: storage.Disk.Format, - Size: storage.Disk.Size, + Size: storage.Disk.SizeInKibibytes, Storage: storage.Disk.Storage, Type: ide, } @@ -261,35 +261,35 @@ func (QemuIdeStorage) mapToStruct(param string, LinkedVmId *uint) *QemuIdeStorag } if tmpDisk.File == "" { return &QemuIdeStorage{Disk: &QemuIdeDisk{ - AsyncIO: tmpDisk.AsyncIO, - Backup: tmpDisk.Backup, - Bandwidth: tmpDisk.Bandwidth, - Cache: tmpDisk.Cache, - Discard: tmpDisk.Discard, - EmulateSSD: tmpDisk.EmulateSSD, - Format: tmpDisk.Format, - Id: tmpDisk.Id, - LinkedDiskId: tmpDisk.LinkedDiskId, - Replicate: tmpDisk.Replicate, - Serial: tmpDisk.Serial, - Size: tmpDisk.Size, - Storage: tmpDisk.Storage, - syntax: tmpDisk.fileSyntax, - WorldWideName: tmpDisk.WorldWideName, + AsyncIO: tmpDisk.AsyncIO, + Backup: tmpDisk.Backup, + Bandwidth: tmpDisk.Bandwidth, + Cache: tmpDisk.Cache, + Discard: tmpDisk.Discard, + EmulateSSD: tmpDisk.EmulateSSD, + Format: tmpDisk.Format, + Id: tmpDisk.Id, + LinkedDiskId: tmpDisk.LinkedDiskId, + Replicate: tmpDisk.Replicate, + Serial: tmpDisk.Serial, + SizeInKibibytes: tmpDisk.SizeInKibibytes, + Storage: tmpDisk.Storage, + syntax: tmpDisk.fileSyntax, + WorldWideName: tmpDisk.WorldWideName, }} } return &QemuIdeStorage{Passthrough: &QemuIdePassthrough{ - AsyncIO: tmpDisk.AsyncIO, - Backup: tmpDisk.Backup, - Bandwidth: tmpDisk.Bandwidth, - Cache: tmpDisk.Cache, - Discard: tmpDisk.Discard, - EmulateSSD: tmpDisk.EmulateSSD, - File: tmpDisk.File, - Replicate: tmpDisk.Replicate, - Serial: tmpDisk.Serial, - Size: tmpDisk.Size, - WorldWideName: tmpDisk.WorldWideName, + AsyncIO: tmpDisk.AsyncIO, + Backup: tmpDisk.Backup, + Bandwidth: tmpDisk.Bandwidth, + Cache: tmpDisk.Cache, + Discard: tmpDisk.Discard, + EmulateSSD: tmpDisk.EmulateSSD, + File: tmpDisk.File, + Replicate: tmpDisk.Replicate, + Serial: tmpDisk.Serial, + SizeInKibibytes: tmpDisk.SizeInKibibytes, + WorldWideName: tmpDisk.WorldWideName, }} } diff --git a/proxmox/config_qemu_disk_sata.go b/proxmox/config_qemu_disk_sata.go index b11f0d9c..c09814ab 100644 --- a/proxmox/config_qemu_disk_sata.go +++ b/proxmox/config_qemu_disk_sata.go @@ -6,42 +6,42 @@ import ( ) type QemuSataDisk struct { - AsyncIO QemuDiskAsyncIO `json:"asyncio,omitempty"` - Backup bool `json:"backup"` - Bandwidth QemuDiskBandwidth `json:"bandwidth,omitempty"` - Cache QemuDiskCache `json:"cache,omitempty"` - Discard bool `json:"discard"` - EmulateSSD bool `json:"emulatessd"` - Format QemuDiskFormat `json:"format"` - Id uint `json:"id"` //Id is only returned and setting it has no effect - LinkedDiskId *uint `json:"linked"` //LinkedClone is only returned and setting it has no effect - Replicate bool `json:"replicate"` - Serial QemuDiskSerial `json:"serial,omitempty"` - Size uint `json:"size"` - Storage string `json:"storage"` - syntax diskSyntaxEnum - WorldWideName QemuWorldWideName `json:"wwn"` + AsyncIO QemuDiskAsyncIO `json:"asyncio,omitempty"` + Backup bool `json:"backup"` + Bandwidth QemuDiskBandwidth `json:"bandwidth,omitempty"` + Cache QemuDiskCache `json:"cache,omitempty"` + Discard bool `json:"discard"` + EmulateSSD bool `json:"emulatessd"` + Format QemuDiskFormat `json:"format"` + Id uint `json:"id"` //Id is only returned and setting it has no effect + LinkedDiskId *uint `json:"linked"` //LinkedClone is only returned and setting it has no effect + Replicate bool `json:"replicate"` + Serial QemuDiskSerial `json:"serial,omitempty"` + SizeInKibibytes uint `json:"size"` + Storage string `json:"storage"` + syntax diskSyntaxEnum + WorldWideName QemuWorldWideName `json:"wwn"` } func (disk *QemuSataDisk) convertDataStructure() *qemuDisk { return &qemuDisk{ - AsyncIO: disk.AsyncIO, - Backup: disk.Backup, - Bandwidth: disk.Bandwidth, - Cache: disk.Cache, - Discard: disk.Discard, - Disk: true, - EmulateSSD: disk.EmulateSSD, - fileSyntax: disk.syntax, - Format: disk.Format, - Id: disk.Id, - LinkedDiskId: disk.LinkedDiskId, - Replicate: disk.Replicate, - Serial: disk.Serial, - Size: disk.Size, - Storage: disk.Storage, - Type: sata, - WorldWideName: disk.WorldWideName, + AsyncIO: disk.AsyncIO, + Backup: disk.Backup, + Bandwidth: disk.Bandwidth, + Cache: disk.Cache, + Discard: disk.Discard, + Disk: true, + EmulateSSD: disk.EmulateSSD, + fileSyntax: disk.syntax, + Format: disk.Format, + Id: disk.Id, + LinkedDiskId: disk.LinkedDiskId, + Replicate: disk.Replicate, + Serial: disk.Serial, + SizeInKibibytes: disk.SizeInKibibytes, + Storage: disk.Storage, + Type: sata, + WorldWideName: disk.WorldWideName, } } @@ -145,10 +145,10 @@ func (disks QemuSataDisks) selectInitialResize(currentDisks *QemuSataDisks) (res diskMap := disks.mapToIntMap() currentDiskMap := tmpCurrentDisks.mapToIntMap() for i := range diskMap { - if diskMap[i] != nil && diskMap[i].Disk != nil && diskMap[i].Disk.Size%gibibyte != 0 && (currentDiskMap[i] == nil || currentDiskMap[i].Disk == nil || diskMap[i].Disk.Size < currentDiskMap[i].Disk.Size) { + if diskMap[i] != nil && diskMap[i].Disk != nil && diskMap[i].Disk.SizeInKibibytes%gibibyte != 0 && (currentDiskMap[i] == nil || currentDiskMap[i].Disk == nil || diskMap[i].Disk.SizeInKibibytes < currentDiskMap[i].Disk.SizeInKibibytes) { resize = append(resize, qemuDiskResize{ Id: QemuDiskId("sata" + strconv.Itoa(int(i))), - SizeInKibibytes: diskMap[i].Disk.Size, + SizeInKibibytes: diskMap[i].Disk.SizeInKibibytes, }) } } @@ -179,17 +179,17 @@ func (disks QemuSataDisks) validate() (numberOfCloudInitDevices uint8, err error } type QemuSataPassthrough struct { - AsyncIO QemuDiskAsyncIO `json:"asyncio,omitempty"` - Backup bool `json:"backup"` - Bandwidth QemuDiskBandwidth `json:"bandwidth,omitempty"` - Cache QemuDiskCache `json:"cache,omitempty"` - Discard bool `json:"discard"` - EmulateSSD bool `json:"emulatessd"` - File string `json:"file"` - Replicate bool `json:"replicate"` - Serial QemuDiskSerial `json:"serial,omitempty"` - Size uint `json:"size"` //size is only returned and setting it has no effect - WorldWideName QemuWorldWideName `json:"wwn"` + AsyncIO QemuDiskAsyncIO `json:"asyncio,omitempty"` + Backup bool `json:"backup"` + Bandwidth QemuDiskBandwidth `json:"bandwidth,omitempty"` + Cache QemuDiskCache `json:"cache,omitempty"` + Discard bool `json:"discard"` + EmulateSSD bool `json:"emulatessd"` + File string `json:"file"` + Replicate bool `json:"replicate"` + Serial QemuDiskSerial `json:"serial,omitempty"` + SizeInKibibytes uint `json:"size"` //size is only returned and setting it has no effect + WorldWideName QemuWorldWideName `json:"wwn"` } func (passthrough *QemuSataPassthrough) convertDataStructure() *qemuDisk { @@ -245,7 +245,7 @@ func (storage *QemuSataStorage) convertDataStructureMark() *qemuDiskMark { if storage.Disk != nil { return &qemuDiskMark{ Format: storage.Disk.Format, - Size: storage.Disk.Size, + Size: storage.Disk.SizeInKibibytes, Storage: storage.Disk.Storage, Type: ide, } @@ -271,35 +271,35 @@ func (QemuSataStorage) mapToStruct(param string, LinkedVmId *uint) *QemuSataStor } if tmpDisk.File == "" { return &QemuSataStorage{Disk: &QemuSataDisk{ - AsyncIO: tmpDisk.AsyncIO, - Backup: tmpDisk.Backup, - Bandwidth: tmpDisk.Bandwidth, - Cache: tmpDisk.Cache, - Discard: tmpDisk.Discard, - EmulateSSD: tmpDisk.EmulateSSD, - Format: tmpDisk.Format, - Id: tmpDisk.Id, - LinkedDiskId: tmpDisk.LinkedDiskId, - Replicate: tmpDisk.Replicate, - Serial: tmpDisk.Serial, - Size: tmpDisk.Size, - Storage: tmpDisk.Storage, - syntax: tmpDisk.fileSyntax, - WorldWideName: tmpDisk.WorldWideName, + AsyncIO: tmpDisk.AsyncIO, + Backup: tmpDisk.Backup, + Bandwidth: tmpDisk.Bandwidth, + Cache: tmpDisk.Cache, + Discard: tmpDisk.Discard, + EmulateSSD: tmpDisk.EmulateSSD, + Format: tmpDisk.Format, + Id: tmpDisk.Id, + LinkedDiskId: tmpDisk.LinkedDiskId, + Replicate: tmpDisk.Replicate, + Serial: tmpDisk.Serial, + SizeInKibibytes: tmpDisk.SizeInKibibytes, + Storage: tmpDisk.Storage, + syntax: tmpDisk.fileSyntax, + WorldWideName: tmpDisk.WorldWideName, }} } return &QemuSataStorage{Passthrough: &QemuSataPassthrough{ - AsyncIO: tmpDisk.AsyncIO, - Backup: tmpDisk.Backup, - Bandwidth: tmpDisk.Bandwidth, - Cache: tmpDisk.Cache, - Discard: tmpDisk.Discard, - EmulateSSD: tmpDisk.EmulateSSD, - File: tmpDisk.File, - Replicate: tmpDisk.Replicate, - Serial: tmpDisk.Serial, - Size: tmpDisk.Size, - WorldWideName: tmpDisk.WorldWideName, + AsyncIO: tmpDisk.AsyncIO, + Backup: tmpDisk.Backup, + Bandwidth: tmpDisk.Bandwidth, + Cache: tmpDisk.Cache, + Discard: tmpDisk.Discard, + EmulateSSD: tmpDisk.EmulateSSD, + File: tmpDisk.File, + Replicate: tmpDisk.Replicate, + Serial: tmpDisk.Serial, + SizeInKibibytes: tmpDisk.SizeInKibibytes, + WorldWideName: tmpDisk.WorldWideName, }} } diff --git a/proxmox/config_qemu_disk_scsi.go b/proxmox/config_qemu_disk_scsi.go index 4f470ccb..dee7e271 100644 --- a/proxmox/config_qemu_disk_scsi.go +++ b/proxmox/config_qemu_disk_scsi.go @@ -6,46 +6,46 @@ import ( ) type QemuScsiDisk struct { - AsyncIO QemuDiskAsyncIO `json:"asyncio,omitempty"` - Backup bool `json:"backup"` - Bandwidth QemuDiskBandwidth `json:"bandwidth,omitempty"` - Cache QemuDiskCache `json:"cache,omitempty"` - Discard bool `json:"discard"` - EmulateSSD bool `json:"emulatessd"` - Format QemuDiskFormat `json:"format"` - Id uint `json:"id"` //Id is only returned and setting it has no effect - IOThread bool `json:"iothread"` - LinkedDiskId *uint `json:"linked"` //LinkedCloneId is only returned and setting it has no effect - ReadOnly bool `json:"readonly"` - Replicate bool `json:"replicate"` - Serial QemuDiskSerial `json:"serial,omitempty"` - Size uint `json:"size"` - Storage string `json:"storage"` - syntax diskSyntaxEnum - WorldWideName QemuWorldWideName `json:"wwn"` + AsyncIO QemuDiskAsyncIO `json:"asyncio,omitempty"` + Backup bool `json:"backup"` + Bandwidth QemuDiskBandwidth `json:"bandwidth,omitempty"` + Cache QemuDiskCache `json:"cache,omitempty"` + Discard bool `json:"discard"` + EmulateSSD bool `json:"emulatessd"` + Format QemuDiskFormat `json:"format"` + Id uint `json:"id"` //Id is only returned and setting it has no effect + IOThread bool `json:"iothread"` + LinkedDiskId *uint `json:"linked"` //LinkedCloneId is only returned and setting it has no effect + ReadOnly bool `json:"readonly"` + Replicate bool `json:"replicate"` + Serial QemuDiskSerial `json:"serial,omitempty"` + SizeInKibibytes uint `json:"size"` + Storage string `json:"storage"` + syntax diskSyntaxEnum + WorldWideName QemuWorldWideName `json:"wwn"` } func (disk *QemuScsiDisk) convertDataStructure() *qemuDisk { return &qemuDisk{ - AsyncIO: disk.AsyncIO, - Backup: disk.Backup, - Bandwidth: disk.Bandwidth, - Cache: disk.Cache, - Discard: disk.Discard, - Disk: true, - EmulateSSD: disk.EmulateSSD, - Format: disk.Format, - Id: disk.Id, - IOThread: disk.IOThread, - LinkedDiskId: disk.LinkedDiskId, - ReadOnly: disk.ReadOnly, - Replicate: disk.Replicate, - Serial: disk.Serial, - Size: disk.Size, - Storage: disk.Storage, - fileSyntax: disk.syntax, - Type: scsi, - WorldWideName: disk.WorldWideName, + AsyncIO: disk.AsyncIO, + Backup: disk.Backup, + Bandwidth: disk.Bandwidth, + Cache: disk.Cache, + Discard: disk.Discard, + Disk: true, + EmulateSSD: disk.EmulateSSD, + Format: disk.Format, + Id: disk.Id, + IOThread: disk.IOThread, + LinkedDiskId: disk.LinkedDiskId, + ReadOnly: disk.ReadOnly, + Replicate: disk.Replicate, + Serial: disk.Serial, + SizeInKibibytes: disk.SizeInKibibytes, + Storage: disk.Storage, + fileSyntax: disk.syntax, + Type: scsi, + WorldWideName: disk.WorldWideName, } } @@ -299,10 +299,10 @@ func (disks QemuScsiDisks) selectInitialResize(currentDisks *QemuScsiDisks) (res diskMap := disks.mapToIntMap() currentDiskMap := tmpCurrentDisks.mapToIntMap() for i := range diskMap { - if diskMap[i] != nil && diskMap[i].Disk != nil && diskMap[i].Disk.Size%gibibyte != 0 && (currentDiskMap[i] == nil || currentDiskMap[i].Disk == nil || diskMap[i].Disk.Size < currentDiskMap[i].Disk.Size) { + if diskMap[i] != nil && diskMap[i].Disk != nil && diskMap[i].Disk.SizeInKibibytes%gibibyte != 0 && (currentDiskMap[i] == nil || currentDiskMap[i].Disk == nil || diskMap[i].Disk.SizeInKibibytes < currentDiskMap[i].Disk.SizeInKibibytes) { resize = append(resize, qemuDiskResize{ - Id: QemuDiskId("scsi" + strconv.Itoa(int(i))), - SizeInKibibytes: diskMap[i].Disk.Size, + Id: QemuDiskId("scsi" + strconv.Itoa(int(i))), + SizeInKibibytes: diskMap[i].Disk.SizeInKibibytes, }) } } @@ -333,19 +333,19 @@ func (disks QemuScsiDisks) validate() (numberOfCloudInitDevices uint8, err error } type QemuScsiPassthrough struct { - AsyncIO QemuDiskAsyncIO `json:"asyncio,omitempty"` - Backup bool `json:"backup"` - Bandwidth QemuDiskBandwidth `json:"bandwidth,omitempty"` - Cache QemuDiskCache `json:"cache,omitempty"` - Discard bool `json:"discard"` - EmulateSSD bool `json:"emulatessd"` - File string `json:"file"` - IOThread bool `json:"iothread"` - ReadOnly bool `json:"readonly"` - Replicate bool `json:"replicate"` - Serial QemuDiskSerial `json:"serial,omitempty"` - Size uint `json:"size"` //size is only returned and setting it has no effect - WorldWideName QemuWorldWideName `json:"wwn"` + AsyncIO QemuDiskAsyncIO `json:"asyncio,omitempty"` + Backup bool `json:"backup"` + Bandwidth QemuDiskBandwidth `json:"bandwidth,omitempty"` + Cache QemuDiskCache `json:"cache,omitempty"` + Discard bool `json:"discard"` + EmulateSSD bool `json:"emulatessd"` + File string `json:"file"` + IOThread bool `json:"iothread"` + ReadOnly bool `json:"readonly"` + Replicate bool `json:"replicate"` + Serial QemuDiskSerial `json:"serial,omitempty"` + SizeInKibibytes uint `json:"size"` //size is only returned and setting it has no effect + WorldWideName QemuWorldWideName `json:"wwn"` } func (passthrough *QemuScsiPassthrough) convertDataStructure() *qemuDisk { @@ -403,7 +403,7 @@ func (storage *QemuScsiStorage) convertDataStructureMark() *qemuDiskMark { if storage.Disk != nil { return &qemuDiskMark{ Format: storage.Disk.Format, - Size: storage.Disk.Size, + Size: storage.Disk.SizeInKibibytes, Storage: storage.Disk.Storage, Type: ide, } @@ -429,39 +429,39 @@ func (QemuScsiStorage) mapToStruct(param string, LinkedVmId *uint) *QemuScsiStor } if tmpDisk.File == "" { return &QemuScsiStorage{Disk: &QemuScsiDisk{ - AsyncIO: tmpDisk.AsyncIO, - Backup: tmpDisk.Backup, - Bandwidth: tmpDisk.Bandwidth, - Cache: tmpDisk.Cache, - Discard: tmpDisk.Discard, - EmulateSSD: tmpDisk.EmulateSSD, - Format: tmpDisk.Format, - Id: tmpDisk.Id, - IOThread: tmpDisk.IOThread, - LinkedDiskId: tmpDisk.LinkedDiskId, - ReadOnly: tmpDisk.ReadOnly, - Replicate: tmpDisk.Replicate, - Serial: tmpDisk.Serial, - Size: tmpDisk.Size, - Storage: tmpDisk.Storage, - syntax: tmpDisk.fileSyntax, - WorldWideName: tmpDisk.WorldWideName, + AsyncIO: tmpDisk.AsyncIO, + Backup: tmpDisk.Backup, + Bandwidth: tmpDisk.Bandwidth, + Cache: tmpDisk.Cache, + Discard: tmpDisk.Discard, + EmulateSSD: tmpDisk.EmulateSSD, + Format: tmpDisk.Format, + Id: tmpDisk.Id, + IOThread: tmpDisk.IOThread, + LinkedDiskId: tmpDisk.LinkedDiskId, + ReadOnly: tmpDisk.ReadOnly, + Replicate: tmpDisk.Replicate, + Serial: tmpDisk.Serial, + SizeInKibibytes: tmpDisk.SizeInKibibytes, + Storage: tmpDisk.Storage, + syntax: tmpDisk.fileSyntax, + WorldWideName: tmpDisk.WorldWideName, }} } return &QemuScsiStorage{Passthrough: &QemuScsiPassthrough{ - AsyncIO: tmpDisk.AsyncIO, - Backup: tmpDisk.Backup, - Bandwidth: tmpDisk.Bandwidth, - Cache: tmpDisk.Cache, - Discard: tmpDisk.Discard, - EmulateSSD: tmpDisk.EmulateSSD, - File: tmpDisk.File, - IOThread: tmpDisk.IOThread, - ReadOnly: tmpDisk.ReadOnly, - Replicate: tmpDisk.Replicate, - Serial: tmpDisk.Serial, - Size: tmpDisk.Size, - WorldWideName: tmpDisk.WorldWideName, + AsyncIO: tmpDisk.AsyncIO, + Backup: tmpDisk.Backup, + Bandwidth: tmpDisk.Bandwidth, + Cache: tmpDisk.Cache, + Discard: tmpDisk.Discard, + EmulateSSD: tmpDisk.EmulateSSD, + File: tmpDisk.File, + IOThread: tmpDisk.IOThread, + ReadOnly: tmpDisk.ReadOnly, + Replicate: tmpDisk.Replicate, + Serial: tmpDisk.Serial, + SizeInKibibytes: tmpDisk.SizeInKibibytes, + WorldWideName: tmpDisk.WorldWideName, }} } diff --git a/proxmox/config_qemu_disk_test.go b/proxmox/config_qemu_disk_test.go index 07c02678..a2c009b0 100644 --- a/proxmox/config_qemu_disk_test.go +++ b/proxmox/config_qemu_disk_test.go @@ -21,7 +21,7 @@ func Test_IsoFile_Validate(t *testing.T) { {name: "Invalid 00", input: IsoFile{}, err: errors.New(Error_IsoFile_File)}, {name: "Invalid 01", input: IsoFile{File: "anything"}, err: errors.New(Error_IsoFile_Storage)}, {name: "Invalid 02", input: IsoFile{Storage: "something"}, err: errors.New(Error_IsoFile_File)}, - {name: "Invalid 03", input: IsoFile{Size: "something"}, err: errors.New(Error_IsoFile_File)}, + {name: "Invalid 03", input: IsoFile{SizeInKibibytes: "something"}, err: errors.New(Error_IsoFile_File)}, } for _, test := range testData { t.Run(test.name, func(*testing.T) { @@ -48,7 +48,7 @@ func Test_QemuCdRom_Validate(t *testing.T) { {name: "Invalid 00", input: QemuCdRom{Iso: &IsoFile{}}, err: errors.New(Error_IsoFile_File)}, {name: "Invalid 01", input: QemuCdRom{Iso: &IsoFile{File: "anything"}}, err: errors.New(Error_IsoFile_Storage)}, {name: "Invalid 02", input: QemuCdRom{Iso: &IsoFile{Storage: "something"}}, err: errors.New(Error_IsoFile_File)}, - {name: "Invalid 03", input: QemuCdRom{Iso: &IsoFile{Size: "something"}}, err: errors.New(Error_IsoFile_File)}, + {name: "Invalid 03", input: QemuCdRom{Iso: &IsoFile{SizeInKibibytes: "something"}}, err: errors.New(Error_IsoFile_File)}, {name: "Invalid 04", input: QemuCdRom{Iso: &IsoFile{File: "anything", Storage: "something"}, Passthrough: true}, err: errors.New(Error_QemuCdRom_MutuallyExclusive)}, } for _, test := range testData { @@ -907,16 +907,16 @@ func Test_QemuStorages_markDiskChanges(t *testing.T) { }{ {name: "Disk CHANGE", storages: QemuStorages{ - Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: format_Raw, Size: 100, Storage: "NewStorage"}}}, - Sata: &QemuSataDisks{Disk_1: &QemuSataStorage{Disk: &QemuSataDisk{Format: format_Raw, Size: 50, Storage: "NewStorage"}}}, - Scsi: &QemuScsiDisks{Disk_2: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: format_Raw, Size: 33, Storage: "NewStorage"}}}, - VirtIO: &QemuVirtIODisks{Disk_3: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: format_Raw, Size: 99, Storage: "NewStorage"}}}, + Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: format_Raw, SizeInKibibytes: 100, Storage: "NewStorage"}}}, + Sata: &QemuSataDisks{Disk_1: &QemuSataStorage{Disk: &QemuSataDisk{Format: format_Raw, SizeInKibibytes: 50, Storage: "NewStorage"}}}, + Scsi: &QemuScsiDisks{Disk_2: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: format_Raw, SizeInKibibytes: 33, Storage: "NewStorage"}}}, + VirtIO: &QemuVirtIODisks{Disk_3: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: format_Raw, SizeInKibibytes: 99, Storage: "NewStorage"}}}, }, currentStorages: QemuStorages{ - Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Vmdk, Size: 32, Storage: "Test"}}}, - Sata: &QemuSataDisks{Disk_1: &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Vmdk, Size: 32, Storage: "Test"}}}, - Scsi: &QemuScsiDisks{Disk_2: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Vmdk, Size: 32, Storage: "Test"}}}, - VirtIO: &QemuVirtIODisks{Disk_3: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Vmdk, Size: 32, Storage: "Test"}}}, + Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Vmdk, SizeInKibibytes: 32, Storage: "Test"}}}, + Sata: &QemuSataDisks{Disk_1: &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Vmdk, SizeInKibibytes: 32, Storage: "Test"}}}, + Scsi: &QemuScsiDisks{Disk_2: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Vmdk, SizeInKibibytes: 32, Storage: "Test"}}}, + VirtIO: &QemuVirtIODisks{Disk_3: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Vmdk, SizeInKibibytes: 32, Storage: "Test"}}}, }, output: &qemuUpdateChanges{ Move: []qemuDiskMove{ @@ -935,46 +935,46 @@ func Test_QemuStorages_markDiskChanges(t *testing.T) { }, {name: "Disk NO CHANGE", storages: QemuStorages{ - Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: format_Raw, Size: 100, Storage: "NewStorage"}}}, - Sata: &QemuSataDisks{Disk_1: &QemuSataStorage{Disk: &QemuSataDisk{Format: format_Raw, Size: 50, Storage: "NewStorage"}}}, - Scsi: &QemuScsiDisks{Disk_2: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: format_Raw, Size: 33, Storage: "NewStorage"}}}, - VirtIO: &QemuVirtIODisks{Disk_3: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: format_Raw, Size: 99, Storage: "NewStorage"}}}, + Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: format_Raw, SizeInKibibytes: 100, Storage: "NewStorage"}}}, + Sata: &QemuSataDisks{Disk_1: &QemuSataStorage{Disk: &QemuSataDisk{Format: format_Raw, SizeInKibibytes: 50, Storage: "NewStorage"}}}, + Scsi: &QemuScsiDisks{Disk_2: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: format_Raw, SizeInKibibytes: 33, Storage: "NewStorage"}}}, + VirtIO: &QemuVirtIODisks{Disk_3: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: format_Raw, SizeInKibibytes: 99, Storage: "NewStorage"}}}, }, currentStorages: QemuStorages{ - Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Vmdk, Size: 32, Storage: "Test"}}}, - Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Vmdk, Size: 32, Storage: "Test"}}}, - Scsi: &QemuScsiDisks{Disk_6: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Vmdk, Size: 32, Storage: "Test"}}}, - VirtIO: &QemuVirtIODisks{Disk_8: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Vmdk, Size: 32, Storage: "Test"}}}, + Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Vmdk, SizeInKibibytes: 32, Storage: "Test"}}}, + Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Vmdk, SizeInKibibytes: 32, Storage: "Test"}}}, + Scsi: &QemuScsiDisks{Disk_6: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Vmdk, SizeInKibibytes: 32, Storage: "Test"}}}, + VirtIO: &QemuVirtIODisks{Disk_8: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Vmdk, SizeInKibibytes: 32, Storage: "Test"}}}, }, output: &qemuUpdateChanges{}, }, {name: "Disk_X.Disk SAME", storages: QemuStorages{ - Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, - Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, - Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, - VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "Test"}}}, + Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "Test"}}}, + Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "Test"}}}, + VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "Test"}}}, }, currentStorages: QemuStorages{ - Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, - Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, - Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, - VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "Test"}}}, + Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "Test"}}}, + Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "Test"}}}, + VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "Test"}}}, }, output: &qemuUpdateChanges{}, }, {name: "Disk_X.Disk.Format CHANGE", storages: QemuStorages{ - Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, - Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, - Scsi: &QemuScsiDisks{Disk_4: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, - VirtIO: &QemuVirtIODisks{Disk_5: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, + Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "Test"}}}, + Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "Test"}}}, + Scsi: &QemuScsiDisks{Disk_4: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "Test"}}}, + VirtIO: &QemuVirtIODisks{Disk_5: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "Test"}}}, }, currentStorages: QemuStorages{ - Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Vmdk, Size: 32, Storage: "Test"}}}, - Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Vmdk, Size: 32, Storage: "Test"}}}, - Scsi: &QemuScsiDisks{Disk_4: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Vmdk, Size: 32, Storage: "Test"}}}, - VirtIO: &QemuVirtIODisks{Disk_5: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Vmdk, Size: 32, Storage: "Test"}}}, + Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Vmdk, SizeInKibibytes: 32, Storage: "Test"}}}, + Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Vmdk, SizeInKibibytes: 32, Storage: "Test"}}}, + Scsi: &QemuScsiDisks{Disk_4: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Vmdk, SizeInKibibytes: 32, Storage: "Test"}}}, + VirtIO: &QemuVirtIODisks{Disk_5: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Vmdk, SizeInKibibytes: 32, Storage: "Test"}}}, }, output: &qemuUpdateChanges{Move: []qemuDiskMove{ {Format: &format_Raw, Id: "ide2", Storage: "Test"}, @@ -985,16 +985,16 @@ func Test_QemuStorages_markDiskChanges(t *testing.T) { }, {name: "Disk.Size BIGGER", storages: QemuStorages{ - Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Raw, Size: 90, Storage: "Test"}}}, - Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Raw, Size: 80, Storage: "Test"}}}, - Scsi: &QemuScsiDisks{Disk_5: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Raw, Size: 50, Storage: "Test"}}}, - VirtIO: &QemuVirtIODisks{Disk_6: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Raw, Size: 33, Storage: "Test"}}}, + Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 90, Storage: "Test"}}}, + Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 80, Storage: "Test"}}}, + Scsi: &QemuScsiDisks{Disk_5: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 50, Storage: "Test"}}}, + VirtIO: &QemuVirtIODisks{Disk_6: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 33, Storage: "Test"}}}, }, currentStorages: QemuStorages{ - Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, - Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, - Scsi: &QemuScsiDisks{Disk_5: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, - VirtIO: &QemuVirtIODisks{Disk_6: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, + Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "Test"}}}, + Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "Test"}}}, + Scsi: &QemuScsiDisks{Disk_5: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "Test"}}}, + VirtIO: &QemuVirtIODisks{Disk_6: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "Test"}}}, }, output: &qemuUpdateChanges{Resize: []qemuDiskResize{ {Id: "ide3", SizeInKibibytes: 90}, @@ -1005,31 +1005,31 @@ func Test_QemuStorages_markDiskChanges(t *testing.T) { }, {name: "Disk.Size SMALLER", storages: QemuStorages{ - Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Raw, Size: 1, Storage: "Test"}}}, - Sata: &QemuSataDisks{Disk_5: &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Raw, Size: 10, Storage: "Test"}}}, - Scsi: &QemuScsiDisks{Disk_6: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Raw, Size: 20, Storage: "Test"}}}, - VirtIO: &QemuVirtIODisks{Disk_7: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Raw, Size: 31, Storage: "Test"}}}, + Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 1, Storage: "Test"}}}, + Sata: &QemuSataDisks{Disk_5: &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 10, Storage: "Test"}}}, + Scsi: &QemuScsiDisks{Disk_6: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 20, Storage: "Test"}}}, + VirtIO: &QemuVirtIODisks{Disk_7: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 31, Storage: "Test"}}}, }, currentStorages: QemuStorages{ - Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, - Sata: &QemuSataDisks{Disk_5: &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, - Scsi: &QemuScsiDisks{Disk_6: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, - VirtIO: &QemuVirtIODisks{Disk_7: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, + Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "Test"}}}, + Sata: &QemuSataDisks{Disk_5: &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "Test"}}}, + Scsi: &QemuScsiDisks{Disk_6: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "Test"}}}, + VirtIO: &QemuVirtIODisks{Disk_7: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "Test"}}}, }, output: &qemuUpdateChanges{}, }, {name: "Disk.Storage CHANGE", storages: QemuStorages{ - Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "NewStorage"}}}, - Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "NewStorage"}}}, - Scsi: &QemuScsiDisks{Disk_7: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "NewStorage"}}}, - VirtIO: &QemuVirtIODisks{Disk_8: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "NewStorage"}}}, + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "NewStorage"}}}, + Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "NewStorage"}}}, + Scsi: &QemuScsiDisks{Disk_7: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "NewStorage"}}}, + VirtIO: &QemuVirtIODisks{Disk_8: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "NewStorage"}}}, }, currentStorages: QemuStorages{ - Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, - Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, - Scsi: &QemuScsiDisks{Disk_7: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, - VirtIO: &QemuVirtIODisks{Disk_8: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Raw, Size: 32, Storage: "Test"}}}, + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "Test"}}}, + Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "Test"}}}, + Scsi: &QemuScsiDisks{Disk_7: &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "Test"}}}, + VirtIO: &QemuVirtIODisks{Disk_8: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Raw, SizeInKibibytes: 32, Storage: "Test"}}}, }, output: &qemuUpdateChanges{Move: []qemuDiskMove{ {Id: "ide1", Storage: "NewStorage"}, @@ -1061,28 +1061,28 @@ func Test_QemuStorages_selectInitialResize(t *testing.T) { }{ {name: "Disks Resize Down Gibibytes", input: testInput{currentStorages: &QemuStorages{ - Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 10485761}}}, - Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Size: 1048577}}}, - Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 70254593}}}, - VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 872415233}}}, + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{SizeInKibibytes: 10485761}}}, + Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{SizeInKibibytes: 1048577}}}, + Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{SizeInKibibytes: 70254593}}}, + VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{SizeInKibibytes: 872415233}}}, }, newStorages: QemuStorages{ - Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 10485760}}}, - Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Size: 1048576}}}, - Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 70254592}}}, - VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 872415232}}}, + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{SizeInKibibytes: 10485760}}}, + Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{SizeInKibibytes: 1048576}}}, + Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{SizeInKibibytes: 70254592}}}, + VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{SizeInKibibytes: 872415232}}}, }}, }, {name: "Disks Resize Down Kibibytes", input: testInput{currentStorages: &QemuStorages{ - Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 94384}}}, - Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Size: 75}}}, - Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 8584654835893}}}, - VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 19695729}}}, + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{SizeInKibibytes: 94384}}}, + Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{SizeInKibibytes: 75}}}, + Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{SizeInKibibytes: 8584654835893}}}, + VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{SizeInKibibytes: 19695729}}}, }, newStorages: QemuStorages{ - Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 943}}}, - Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Size: 7}}}, - Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 8584654835}}}, - VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 19695}}}, + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{SizeInKibibytes: 943}}}, + Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{SizeInKibibytes: 7}}}, + Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{SizeInKibibytes: 8584654835}}}, + VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{SizeInKibibytes: 19695}}}, }}, output: []qemuDiskResize{ {Id: "ide1", SizeInKibibytes: 943}, @@ -1093,52 +1093,52 @@ func Test_QemuStorages_selectInitialResize(t *testing.T) { }, {name: "Disks Resize Up", input: testInput{currentStorages: &QemuStorages{ - Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 943}}}, - Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Size: 7}}}, - Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 8584654835}}}, - VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 19695}}}, + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{SizeInKibibytes: 943}}}, + Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{SizeInKibibytes: 7}}}, + Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{SizeInKibibytes: 8584654835}}}, + VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{SizeInKibibytes: 19695}}}, }, newStorages: QemuStorages{ - Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 94384}}}, - Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Size: 75}}}, - Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 8584654835893}}}, - VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 19695729}}}, + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{SizeInKibibytes: 94384}}}, + Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{SizeInKibibytes: 75}}}, + Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{SizeInKibibytes: 8584654835893}}}, + VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{SizeInKibibytes: 19695729}}}, }}, }, {name: "Disks Same", input: testInput{currentStorages: &QemuStorages{ - Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 94384}}}, - Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Size: 75}}}, - Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 8584654835893}}}, - VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 19695729}}}, + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{SizeInKibibytes: 94384}}}, + Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{SizeInKibibytes: 75}}}, + Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{SizeInKibibytes: 8584654835893}}}, + VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{SizeInKibibytes: 19695729}}}, }, newStorages: QemuStorages{ - Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 94384}}}, - Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Size: 75}}}, - Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 8584654835893}}}, - VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 19695729}}}, + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{SizeInKibibytes: 94384}}}, + Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{SizeInKibibytes: 75}}}, + Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{SizeInKibibytes: 8584654835893}}}, + VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{SizeInKibibytes: 19695729}}}, }}, }, {name: "Don't resize cause whole x gibibyte", input: testInput{currentStorages: nil, newStorages: QemuStorages{ - Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 1048576}}}, - Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Size: 10485760}}}, - Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 47185920}}}, - VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 480247808}}}, + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{SizeInKibibytes: 1048576}}}, + Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{SizeInKibibytes: 10485760}}}, + Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{SizeInKibibytes: 47185920}}}, + VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{SizeInKibibytes: 480247808}}}, }}, }, {name: "newStorages empty", input: testInput{currentStorages: &QemuStorages{ - Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 94384}}}, - Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Size: 75}}}, - Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 8584654835893}}}, - VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 19695729}}}, + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{SizeInKibibytes: 94384}}}, + Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{SizeInKibibytes: 75}}}, + Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{SizeInKibibytes: 8584654835893}}}, + VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{SizeInKibibytes: 19695729}}}, }, newStorages: QemuStorages{}}, }, {name: "No current disks 1 x kibibyte", input: testInput{currentStorages: nil, newStorages: QemuStorages{ - Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 7867}}}, - Sata: &QemuSataDisks{Disk_1: &QemuSataStorage{Disk: &QemuSataDisk{Size: 985947483}}}, - Scsi: &QemuScsiDisks{Disk_2: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 577564}}}, - VirtIO: &QemuVirtIODisks{Disk_3: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 323}}}, + Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{SizeInKibibytes: 7867}}}, + Sata: &QemuSataDisks{Disk_1: &QemuSataStorage{Disk: &QemuSataDisk{SizeInKibibytes: 985947483}}}, + Scsi: &QemuScsiDisks{Disk_2: &QemuScsiStorage{Disk: &QemuScsiDisk{SizeInKibibytes: 577564}}}, + VirtIO: &QemuVirtIODisks{Disk_3: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{SizeInKibibytes: 323}}}, }}, output: []qemuDiskResize{ {Id: "ide0", SizeInKibibytes: 7867}, @@ -1149,10 +1149,10 @@ func Test_QemuStorages_selectInitialResize(t *testing.T) { }, {name: "No current disks 2 x kibibyte", input: testInput{currentStorages: &QemuStorages{}, newStorages: QemuStorages{ - Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 7867}}}, - Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{Size: 985947483}}}, - Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 577564}}}, - VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 323}}}, + Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{SizeInKibibytes: 7867}}}, + Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{SizeInKibibytes: 985947483}}}, + Scsi: &QemuScsiDisks{Disk_3: &QemuScsiStorage{Disk: &QemuScsiDisk{SizeInKibibytes: 577564}}}, + VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{SizeInKibibytes: 323}}}, }}, output: []qemuDiskResize{ {Id: "ide1", SizeInKibibytes: 7867}, @@ -1168,10 +1168,10 @@ func Test_QemuStorages_selectInitialResize(t *testing.T) { Scsi: &QemuScsiDisks{}, VirtIO: &QemuVirtIODisks{}, }, newStorages: QemuStorages{ - Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 7867}}}, - Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{Size: 985947483}}}, - Scsi: &QemuScsiDisks{Disk_4: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 577564}}}, - VirtIO: &QemuVirtIODisks{Disk_5: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 323}}}, + Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{SizeInKibibytes: 7867}}}, + Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{SizeInKibibytes: 985947483}}}, + Scsi: &QemuScsiDisks{Disk_4: &QemuScsiStorage{Disk: &QemuScsiDisk{SizeInKibibytes: 577564}}}, + VirtIO: &QemuVirtIODisks{Disk_5: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{SizeInKibibytes: 323}}}, }}, output: []qemuDiskResize{ {Id: "ide2", SizeInKibibytes: 7867}, @@ -1187,10 +1187,10 @@ func Test_QemuStorages_selectInitialResize(t *testing.T) { Scsi: &QemuScsiDisks{Disk_5: &QemuScsiStorage{}}, VirtIO: &QemuVirtIODisks{Disk_6: &QemuVirtIOStorage{}}, }, newStorages: QemuStorages{ - Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 7867}}}, - Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Disk: &QemuSataDisk{Size: 985947483}}}, - Scsi: &QemuScsiDisks{Disk_5: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 577564}}}, - VirtIO: &QemuVirtIODisks{Disk_6: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 323}}}, + Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{SizeInKibibytes: 7867}}}, + Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Disk: &QemuSataDisk{SizeInKibibytes: 985947483}}}, + Scsi: &QemuScsiDisks{Disk_5: &QemuScsiStorage{Disk: &QemuScsiDisk{SizeInKibibytes: 577564}}}, + VirtIO: &QemuVirtIODisks{Disk_6: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{SizeInKibibytes: 323}}}, }}, output: []qemuDiskResize{ {Id: "ide3", SizeInKibibytes: 7867}, @@ -1206,10 +1206,10 @@ func Test_QemuStorages_selectInitialResize(t *testing.T) { Scsi: &QemuScsiDisks{Disk_6: &QemuScsiStorage{CloudInit: &QemuCloudInitDisk{}}}, VirtIO: &QemuVirtIODisks{Disk_7: &QemuVirtIOStorage{CdRom: &QemuCdRom{}}}, }, newStorages: QemuStorages{ - Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 7867}}}, - Sata: &QemuSataDisks{Disk_5: &QemuSataStorage{Disk: &QemuSataDisk{Size: 985947483}}}, - Scsi: &QemuScsiDisks{Disk_6: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 577564}}}, - VirtIO: &QemuVirtIODisks{Disk_7: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 323}}}, + Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{SizeInKibibytes: 7867}}}, + Sata: &QemuSataDisks{Disk_5: &QemuSataStorage{Disk: &QemuSataDisk{SizeInKibibytes: 985947483}}}, + Scsi: &QemuScsiDisks{Disk_6: &QemuScsiStorage{Disk: &QemuScsiDisk{SizeInKibibytes: 577564}}}, + VirtIO: &QemuVirtIODisks{Disk_7: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{SizeInKibibytes: 323}}}, }}, output: []qemuDiskResize{ {Id: "ide0", SizeInKibibytes: 7867}, diff --git a/proxmox/config_qemu_disk_virtio.go b/proxmox/config_qemu_disk_virtio.go index bdf53e20..d9bd7091 100644 --- a/proxmox/config_qemu_disk_virtio.go +++ b/proxmox/config_qemu_disk_virtio.go @@ -6,44 +6,44 @@ import ( ) type QemuVirtIODisk struct { - AsyncIO QemuDiskAsyncIO `json:"asyncio,omitempty"` - Backup bool `json:"backup"` - Bandwidth QemuDiskBandwidth `json:"bandwidth,omitempty"` - Cache QemuDiskCache `json:"cache,omitempty"` - Discard bool `json:"discard"` - Format QemuDiskFormat `json:"format"` - Id uint `json:"id"` //Id is only returned and setting it has no effect - IOThread bool `json:"iothread"` - LinkedDiskId *uint `json:"linked"` //LinkedCloneId is only returned and setting it has no effect - ReadOnly bool `json:"readonly"` - Replicate bool `json:"replicate"` - Serial QemuDiskSerial `json:"serial,omitempty"` - Size uint `json:"size"` - Storage string `json:"storage"` - syntax diskSyntaxEnum - WorldWideName QemuWorldWideName `json:"wwn"` + AsyncIO QemuDiskAsyncIO `json:"asyncio,omitempty"` + Backup bool `json:"backup"` + Bandwidth QemuDiskBandwidth `json:"bandwidth,omitempty"` + Cache QemuDiskCache `json:"cache,omitempty"` + Discard bool `json:"discard"` + Format QemuDiskFormat `json:"format"` + Id uint `json:"id"` //Id is only returned and setting it has no effect + IOThread bool `json:"iothread"` + LinkedDiskId *uint `json:"linked"` //LinkedCloneId is only returned and setting it has no effect + ReadOnly bool `json:"readonly"` + Replicate bool `json:"replicate"` + Serial QemuDiskSerial `json:"serial,omitempty"` + SizeInKibibytes uint `json:"size"` + Storage string `json:"storage"` + syntax diskSyntaxEnum + WorldWideName QemuWorldWideName `json:"wwn"` } func (disk *QemuVirtIODisk) convertDataStructure() *qemuDisk { return &qemuDisk{ - AsyncIO: disk.AsyncIO, - Backup: disk.Backup, - Bandwidth: disk.Bandwidth, - Cache: disk.Cache, - Discard: disk.Discard, - Disk: true, - fileSyntax: disk.syntax, - Format: disk.Format, - Id: disk.Id, - IOThread: disk.IOThread, - LinkedDiskId: disk.LinkedDiskId, - ReadOnly: disk.ReadOnly, - Replicate: disk.Replicate, - Serial: disk.Serial, - Size: disk.Size, - Storage: disk.Storage, - Type: virtIO, - WorldWideName: disk.WorldWideName, + AsyncIO: disk.AsyncIO, + Backup: disk.Backup, + Bandwidth: disk.Bandwidth, + Cache: disk.Cache, + Discard: disk.Discard, + Disk: true, + fileSyntax: disk.syntax, + Format: disk.Format, + Id: disk.Id, + IOThread: disk.IOThread, + LinkedDiskId: disk.LinkedDiskId, + ReadOnly: disk.ReadOnly, + Replicate: disk.Replicate, + Serial: disk.Serial, + SizeInKibibytes: disk.SizeInKibibytes, + Storage: disk.Storage, + Type: virtIO, + WorldWideName: disk.WorldWideName, } } @@ -207,10 +207,10 @@ func (disks QemuVirtIODisks) selectInitialResize(currentDisks *QemuVirtIODisks) diskMap := disks.mapToIntMap() currentDiskMap := tmpCurrentDisks.mapToIntMap() for i := range diskMap { - if diskMap[i] != nil && diskMap[i].Disk != nil && diskMap[i].Disk.Size%gibibyte != 0 && (currentDiskMap[i] == nil || currentDiskMap[i].Disk == nil || diskMap[i].Disk.Size < currentDiskMap[i].Disk.Size) { + if diskMap[i] != nil && diskMap[i].Disk != nil && diskMap[i].Disk.SizeInKibibytes%gibibyte != 0 && (currentDiskMap[i] == nil || currentDiskMap[i].Disk == nil || diskMap[i].Disk.SizeInKibibytes < currentDiskMap[i].Disk.SizeInKibibytes) { resize = append(resize, qemuDiskResize{ - Id: QemuDiskId("virtio" + strconv.Itoa(int(i))), - SizeInKibibytes: diskMap[i].Disk.Size, + Id: QemuDiskId("virtio" + strconv.Itoa(int(i))), + SizeInKibibytes: diskMap[i].Disk.SizeInKibibytes, }) } } @@ -241,18 +241,18 @@ func (disks QemuVirtIODisks) validate() (numberOfCloudInitDevices uint8, err err } type QemuVirtIOPassthrough struct { - AsyncIO QemuDiskAsyncIO `json:"asyncio,omitempty"` - Backup bool `json:"backup"` - Bandwidth QemuDiskBandwidth `json:"bandwidth,omitempty"` - Cache QemuDiskCache `json:"cache,omitempty"` - Discard bool `json:"discard"` - File string `json:"file"` - IOThread bool `json:"iothread"` - ReadOnly bool `json:"readonly"` - Replicate bool `json:"replicate"` - Serial QemuDiskSerial `json:"serial,omitempty"` - Size uint `json:"size"` //size is only returned and setting it has no effect - WorldWideName QemuWorldWideName `json:"wwn"` + AsyncIO QemuDiskAsyncIO `json:"asyncio,omitempty"` + Backup bool `json:"backup"` + Bandwidth QemuDiskBandwidth `json:"bandwidth,omitempty"` + Cache QemuDiskCache `json:"cache,omitempty"` + Discard bool `json:"discard"` + File string `json:"file"` + IOThread bool `json:"iothread"` + ReadOnly bool `json:"readonly"` + Replicate bool `json:"replicate"` + Serial QemuDiskSerial `json:"serial,omitempty"` + SizeInKibibytes uint `json:"size"` //size is only returned and setting it has no effect + WorldWideName QemuWorldWideName `json:"wwn"` } func (passthrough *QemuVirtIOPassthrough) convertDataStructure() *qemuDisk { @@ -309,7 +309,7 @@ func (storage *QemuVirtIOStorage) convertDataStructureMark() *qemuDiskMark { if storage.Disk != nil { return &qemuDiskMark{ Format: storage.Disk.Format, - Size: storage.Disk.Size, + Size: storage.Disk.SizeInKibibytes, Storage: storage.Disk.Storage, Type: ide, } @@ -335,37 +335,37 @@ func (QemuVirtIOStorage) mapToStruct(param string, LinkedVmId *uint) *QemuVirtIO } if tmpDisk.File == "" { return &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - AsyncIO: tmpDisk.AsyncIO, - Backup: tmpDisk.Backup, - Bandwidth: tmpDisk.Bandwidth, - Cache: tmpDisk.Cache, - Discard: tmpDisk.Discard, - Format: tmpDisk.Format, - Id: tmpDisk.Id, - IOThread: tmpDisk.IOThread, - LinkedDiskId: tmpDisk.LinkedDiskId, - ReadOnly: tmpDisk.ReadOnly, - Replicate: tmpDisk.Replicate, - Serial: tmpDisk.Serial, - Size: tmpDisk.Size, - Storage: tmpDisk.Storage, - syntax: tmpDisk.fileSyntax, - WorldWideName: tmpDisk.WorldWideName, + AsyncIO: tmpDisk.AsyncIO, + Backup: tmpDisk.Backup, + Bandwidth: tmpDisk.Bandwidth, + Cache: tmpDisk.Cache, + Discard: tmpDisk.Discard, + Format: tmpDisk.Format, + Id: tmpDisk.Id, + IOThread: tmpDisk.IOThread, + LinkedDiskId: tmpDisk.LinkedDiskId, + ReadOnly: tmpDisk.ReadOnly, + Replicate: tmpDisk.Replicate, + Serial: tmpDisk.Serial, + SizeInKibibytes: tmpDisk.SizeInKibibytes, + Storage: tmpDisk.Storage, + syntax: tmpDisk.fileSyntax, + WorldWideName: tmpDisk.WorldWideName, }} } return &QemuVirtIOStorage{Passthrough: &QemuVirtIOPassthrough{ - AsyncIO: tmpDisk.AsyncIO, - Backup: tmpDisk.Backup, - Bandwidth: tmpDisk.Bandwidth, - Cache: tmpDisk.Cache, - Discard: tmpDisk.Discard, - File: tmpDisk.File, - IOThread: tmpDisk.IOThread, - ReadOnly: tmpDisk.ReadOnly, - Replicate: tmpDisk.Replicate, - Serial: tmpDisk.Serial, - Size: tmpDisk.Size, - WorldWideName: tmpDisk.WorldWideName, + AsyncIO: tmpDisk.AsyncIO, + Backup: tmpDisk.Backup, + Bandwidth: tmpDisk.Bandwidth, + Cache: tmpDisk.Cache, + Discard: tmpDisk.Discard, + File: tmpDisk.File, + IOThread: tmpDisk.IOThread, + ReadOnly: tmpDisk.ReadOnly, + Replicate: tmpDisk.Replicate, + Serial: tmpDisk.Serial, + SizeInKibibytes: tmpDisk.SizeInKibibytes, + WorldWideName: tmpDisk.WorldWideName, }} } diff --git a/proxmox/config_qemu_test.go b/proxmox/config_qemu_test.go index b0dc24b7..d43f75a3 100644 --- a/proxmox/config_qemu_test.go +++ b/proxmox/config_qemu_test.go @@ -21,10 +21,10 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { uint78 := QemuDiskBandwidthIopsLimitBurst(78) uint89 := QemuDiskBandwidthIopsLimitBurst(89) update_CloudInit := &QemuCloudInitDisk{Format: QemuDiskFormat_Raw, Storage: "test"} - ideBase := &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Raw, Id: 23, Size: 10, Storage: "test"}} - sataBase := &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Raw, Id: 23, Size: 10, Storage: "test"}} - scsiBase := &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Raw, Id: 23, Size: 10, Storage: "test"}} - virtioBase := &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Raw, Id: 23, Size: 10, Storage: "test"}} + ideBase := &QemuIdeStorage{Disk: &QemuIdeDisk{Format: QemuDiskFormat_Raw, Id: 23, SizeInKibibytes: 10, Storage: "test"}} + sataBase := &QemuSataStorage{Disk: &QemuSataDisk{Format: QemuDiskFormat_Raw, Id: 23, SizeInKibibytes: 10, Storage: "test"}} + scsiBase := &QemuScsiStorage{Disk: &QemuScsiDisk{Format: QemuDiskFormat_Raw, Id: 23, SizeInKibibytes: 10, Storage: "test"}} + virtioBase := &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Format: QemuDiskFormat_Raw, Id: 23, SizeInKibibytes: 10, Storage: "test"}} tests := []struct { name string config *ConfigQemu @@ -67,29 +67,29 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { WriteLimit: QemuDiskBandwidthIopsLimit{Burst: uint89, BurstDuration: 4, Concurrent: uint23}, }, }, - Cache: QemuDiskCache_DirectSync, - Discard: true, - EmulateSSD: true, - Format: format_Raw, - Replicate: true, - Serial: "558485ef-478", - Size: 33554432, - Storage: "Test", - WorldWideName: "0x5000D31000C9876F", + Cache: QemuDiskCache_DirectSync, + Discard: true, + EmulateSSD: true, + Format: format_Raw, + Replicate: true, + Serial: "558485ef-478", + SizeInKibibytes: 33554432, + Storage: "Test", + WorldWideName: "0x5000D31000C9876F", }}}}}, output: map[string]interface{}{"ide0": "Test:32,aio=native,cache=directsync,discard=on,format=raw,iops_rd=34,iops_rd_max=78,iops_rd_max_length=3,iops_wr=23,iops_wr_max=89,iops_wr_max_length=4,mbps_rd=10.3,mbps_rd_max=99.2,mbps_wr=45.23,mbps_wr_max=79.23,serial=558485ef-478,ssd=1,wwn=0x5000D31000C9876F"}, }, {name: "Create Disks.Ide.Disk_X.Disk Create Gibibyte", config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Size: 33554432, - Storage: "Test", + SizeInKibibytes: 33554432, + Storage: "Test", }}}}}, output: map[string]interface{}{"ide0": "Test:32,backup=0,replicate=0"}, }, {name: "Create Disks.Ide.Disk_X.Disk Create Kibibyte", config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Size: 33554433, - Storage: "Test", + SizeInKibibytes: 33554433, + Storage: "Test", }}}}}, output: map[string]interface{}{"ide0": "Test:0,backup=0,replicate=0"}, }, @@ -194,7 +194,7 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { output: map[string]interface{}{"ide2": ",backup=0,replicate=0,serial=558485ef-478"}, }, {name: "Create Disks.Ide.Disk_X.Disk.Size", - config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{Size: 32}}}}}, + config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{SizeInKibibytes: 32}}}}}, output: map[string]interface{}{"ide3": ",backup=0,replicate=0"}, }, {name: "Create Disks.Ide.Disk_X.Disk.Storage", @@ -366,29 +366,29 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { WriteLimit: QemuDiskBandwidthIopsLimit{Burst: uint89, BurstDuration: 4, Concurrent: uint23}, }, }, - Cache: QemuDiskCache_Unsafe, - Discard: true, - EmulateSSD: true, - Format: QemuDiskFormat_Qcow2, - Replicate: true, - Serial: "ab_C-12_3", - Size: 16777216, - Storage: "Test", - WorldWideName: "0x5009876000A321DC", + Cache: QemuDiskCache_Unsafe, + Discard: true, + EmulateSSD: true, + Format: QemuDiskFormat_Qcow2, + Replicate: true, + Serial: "ab_C-12_3", + SizeInKibibytes: 16777216, + Storage: "Test", + WorldWideName: "0x5009876000A321DC", }}}}}, output: map[string]interface{}{"sata0": "Test:16,aio=native,cache=unsafe,discard=on,format=qcow2,iops_rd=34,iops_rd_max=78,iops_rd_max_length=3,iops_wr=23,iops_wr_max=89,iops_wr_max_length=4,mbps_rd=10.3,mbps_rd_max=99.2,mbps_wr=45.23,mbps_wr_max=79.23,serial=ab_C-12_3,ssd=1,wwn=0x5009876000A321DC"}, }, {name: "Create Disks.Sata.Disk_X.Disk Create Gibibyte", config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ - Size: 16777216, - Storage: "Test", + SizeInKibibytes: 16777216, + Storage: "Test", }}}}}, output: map[string]interface{}{"sata0": "Test:16,backup=0,replicate=0"}, }, {name: "Create Disks.Sata.Disk_X.Disk Create Kibibyte", config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ - Size: 16777217, - Storage: "Test", + SizeInKibibytes: 16777217, + Storage: "Test", }}}}}, output: map[string]interface{}{"sata0": "Test:0,backup=0,replicate=0"}, }, @@ -493,7 +493,7 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { output: map[string]interface{}{"sata3": ",backup=0,replicate=0,serial=558485ef-478"}, }, {name: "Create Disks.Sata.Disk_X.Disk.Size", - config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Disk: &QemuSataDisk{Size: 32}}}}}, + config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Disk: &QemuSataDisk{SizeInKibibytes: 32}}}}}, output: map[string]interface{}{"sata4": ",backup=0,replicate=0"}, }, {name: "Create Disks.Sata.Disk_X.Disk.Storage", @@ -665,31 +665,31 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { WriteLimit: QemuDiskBandwidthIopsLimit{Burst: uint89, BurstDuration: 4, Concurrent: uint23}, }, }, - Cache: QemuDiskCache_DirectSync, - Discard: true, - EmulateSSD: true, - Format: format_Raw, - IOThread: true, - ReadOnly: true, - Replicate: true, - Serial: "558485ef-478", - Size: 76546048, - Storage: "Test", - WorldWideName: "0x500D567800BAC321", + Cache: QemuDiskCache_DirectSync, + Discard: true, + EmulateSSD: true, + Format: format_Raw, + IOThread: true, + ReadOnly: true, + Replicate: true, + Serial: "558485ef-478", + SizeInKibibytes: 76546048, + Storage: "Test", + WorldWideName: "0x500D567800BAC321", }}}}}, output: map[string]interface{}{"scsi0": "Test:73,aio=native,cache=directsync,discard=on,format=raw,iops_rd=34,iops_rd_max=78,iops_rd_max_length=3,iops_wr=23,iops_wr_max=89,iops_wr_max_length=4,iothread=1,mbps_rd=10.3,mbps_rd_max=99.2,mbps_wr=45.23,mbps_wr_max=79.23,ro=1,serial=558485ef-478,ssd=1,wwn=0x500D567800BAC321"}, }, {name: "Create Disks.Scsi.Disk_X.Disk Create Gibibyte", config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_0: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Size: 76546048, - Storage: "Test", + SizeInKibibytes: 76546048, + Storage: "Test", }}}}}, output: map[string]interface{}{"scsi0": "Test:73,backup=0,replicate=0"}, }, {name: "Create Disks.Scsi.Disk_X.Disk Create Kibibyte", config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_0: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Size: 76546049, - Storage: "Test", + SizeInKibibytes: 76546049, + Storage: "Test", }}}}}, output: map[string]interface{}{"scsi0": "Test:0,backup=0,replicate=0"}, }, @@ -802,7 +802,7 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { output: map[string]interface{}{"scsi24": ",backup=0,replicate=0,serial=558485ef-478"}, }, {name: "Create Disks.Scsi.Disk_X.Disk.Size", - config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_25: &QemuScsiStorage{Disk: &QemuScsiDisk{Size: 32}}}}}, + config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_25: &QemuScsiStorage{Disk: &QemuScsiDisk{SizeInKibibytes: 32}}}}}, output: map[string]interface{}{"scsi25": ",backup=0,replicate=0"}, }, {name: "Create Disks.Scsi.Disk_X.Disk.Storage", @@ -984,30 +984,30 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { WriteLimit: QemuDiskBandwidthIopsLimit{Burst: uint89, BurstDuration: 4, Concurrent: uint23}, }, }, - Cache: QemuDiskCache_DirectSync, - Discard: true, - Format: format_Raw, - IOThread: true, - ReadOnly: true, - Replicate: true, - Serial: "558485ef-478", - Size: 8238661632, - Storage: "Test", - WorldWideName: "0x500A7B0800F345D2", + Cache: QemuDiskCache_DirectSync, + Discard: true, + Format: format_Raw, + IOThread: true, + ReadOnly: true, + Replicate: true, + Serial: "558485ef-478", + SizeInKibibytes: 8238661632, + Storage: "Test", + WorldWideName: "0x500A7B0800F345D2", }}}}}, output: map[string]interface{}{"virtio0": "Test:7857,aio=native,cache=directsync,discard=on,format=raw,iops_rd=34,iops_rd_max=78,iops_rd_max_length=3,iops_wr=23,iops_wr_max=89,iops_wr_max_length=4,iothread=1,mbps_rd=10.3,mbps_rd_max=99.2,mbps_wr=45.23,mbps_wr_max=79.23,ro=1,serial=558485ef-478,wwn=0x500A7B0800F345D2"}, }, {name: "Create Disks.VirtIO.Disk_X.Disk Create Gibibyte", config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_0: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Size: 8238661632, - Storage: "Test", + SizeInKibibytes: 8238661632, + Storage: "Test", }}}}}, output: map[string]interface{}{"virtio0": "Test:7857,backup=0,replicate=0"}, }, {name: "Create Disks.VirtIO.Disk_X.Disk Create Kibibyte", config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_0: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Size: 8238661633, - Storage: "Test", + SizeInKibibytes: 8238661633, + Storage: "Test", }}}}}, output: map[string]interface{}{"virtio0": "Test:0,backup=0,replicate=0"}, }, @@ -1124,7 +1124,7 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { output: map[string]interface{}{"virtio7": ",backup=0,replicate=0,serial=558485ef-478"}, }, {name: "Create Disks.VirtIO.Disk_X.Disk.Size", - config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_8: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{Size: 32}}}}}, + config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_8: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{SizeInKibibytes: 32}}}}}, output: map[string]interface{}{"virtio8": ",backup=0,replicate=0"}, }, {name: "Create Disks.VirtIO.Disk_X.Disk.Storage", @@ -1357,17 +1357,17 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { // Update Disk.Ide.Disk_X.Disk {name: "Update Disk.Ide.Disk_X.Disk CHANGE File", currentConfig: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{ - AsyncIO: QemuDiskAsyncIO_IOuring, - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 10, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_IOuring, + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{ - AsyncIO: QemuDiskAsyncIO_Native, - Format: QemuDiskFormat_Raw, - Size: 10, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_Native, + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{"ide3": "test:0/vm-0-disk-23.raw,aio=native,backup=0,replicate=0"}, }, @@ -1375,33 +1375,33 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{ - AsyncIO: QemuDiskAsyncIO_IOuring, - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_IOuring, + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{ - AsyncIO: QemuDiskAsyncIO_Native, - Format: QemuDiskFormat_Raw, - Size: 10, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_Native, + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{"ide3": "test:100/base-100-disk-1.raw/0/vm-0-disk-23.raw,aio=native,backup=0,replicate=0"}, }, {name: "Update Disk.Ide.Disk_X.Disk CHANGE Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{ - AsyncIO: QemuDiskAsyncIO_IOuring, - Id: 23, - Size: 10, - Storage: "test", - syntax: diskSyntaxVolume, + AsyncIO: QemuDiskAsyncIO_IOuring, + Id: 23, + SizeInKibibytes: 10, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{ - AsyncIO: QemuDiskAsyncIO_Native, - Size: 10, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_Native, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{"ide3": "test:vm-0-disk-23,aio=native,backup=0,replicate=0"}, }, @@ -1409,17 +1409,17 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{ - AsyncIO: QemuDiskAsyncIO_IOuring, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - syntax: diskSyntaxVolume, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_IOuring, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + syntax: diskSyntaxVolume, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{ - AsyncIO: QemuDiskAsyncIO_Native, - Size: 10, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_Native, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{"ide3": "test:base-100-disk-1/vm-0-disk-23,aio=native,backup=0,replicate=0"}, }, @@ -1430,15 +1430,15 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { }, {name: "Update Disk.Ide.Disk_X.Disk MIGRATE File", currentConfig: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 10, - Storage: "test1", + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 10, + Storage: "test1", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Size: 10, - Storage: "test2", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 10, + Storage: "test2", }}}}}, output: map[string]interface{}{"ide1": "test2:0/vm-0-disk-23.raw,backup=0,replicate=0"}, }, @@ -1446,29 +1446,29 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test1", + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test1", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Size: 10, - Storage: "test2", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 10, + Storage: "test2", }}}}}, output: map[string]interface{}{"ide1": "test2:0/vm-0-disk-23.raw,backup=0,replicate=0"}, }, {name: "Update Disk.Ide.Disk_X.Disk MIGRATE Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Id: 23, - Size: 10, - Storage: "test1", - syntax: diskSyntaxVolume, + Id: 23, + SizeInKibibytes: 10, + Storage: "test1", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Size: 10, - Storage: "test2", + SizeInKibibytes: 10, + Storage: "test2", }}}}}, output: map[string]interface{}{"ide1": "test2:vm-0-disk-23,backup=0,replicate=0"}, }, @@ -1476,29 +1476,29 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test1", - syntax: diskSyntaxVolume, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test1", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Size: 10, - Storage: "test2", + SizeInKibibytes: 10, + Storage: "test2", }}}}}, output: map[string]interface{}{"ide1": "test2:vm-0-disk-23,backup=0,replicate=0"}, }, {name: "Update Disk.Ide.Disk_X.Disk RESIZE DOWN Gibibyte File", currentConfig: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 9437185, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 9437185, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Size: 9437184, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437184, + Storage: "test", }}}}}, output: map[string]interface{}{"ide2": "test:9,backup=0,format=raw,replicate=0"}, }, @@ -1506,30 +1506,30 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 9437185, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 9437185, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Size: 9437184, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437184, + Storage: "test", }}}}}, output: map[string]interface{}{"ide2": "test:9,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.Ide.Disk_X.Disk RESIZE DOWN Gibibyte Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Id: 23, - Size: 9437185, - Storage: "test", - syntax: diskSyntaxVolume, + Id: 23, + SizeInKibibytes: 9437185, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Size: 9437184, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437184, + Storage: "test", }}}}}, output: map[string]interface{}{"ide2": "test:9,backup=0,format=raw,replicate=0"}, }, @@ -1537,30 +1537,30 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Id: 23, - LinkedDiskId: &uint1, - Size: 9437185, - Storage: "test", - syntax: diskSyntaxVolume, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 9437185, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Size: 9437184, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437184, + Storage: "test", }}}}}, output: map[string]interface{}{"ide2": "test:9,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.Ide.Disk_X.Disk RESIZE DOWN Kibibyte File", currentConfig: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 9437186, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 9437186, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Size: 9437185, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437185, + Storage: "test", }}}}}, output: map[string]interface{}{"ide2": "test:0,backup=0,format=raw,replicate=0"}, }, @@ -1568,30 +1568,30 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 9437186, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 9437186, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Size: 9437185, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437185, + Storage: "test", }}}}}, output: map[string]interface{}{"ide2": "test:0,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.Ide.Disk_X.Disk RESIZE DOWN Kibibyte Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Id: 23, - Size: 9437186, - Storage: "test", - syntax: diskSyntaxVolume, + Id: 23, + SizeInKibibytes: 9437186, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Size: 9437185, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437185, + Storage: "test", }}}}}, output: map[string]interface{}{"ide2": "test:0,backup=0,format=raw,replicate=0"}, }, @@ -1599,30 +1599,30 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Id: 23, - LinkedDiskId: &uint1, - Size: 9437186, - Storage: "test", - syntax: diskSyntaxVolume, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 9437186, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Size: 9437185, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437185, + Storage: "test", }}}}}, output: map[string]interface{}{"ide2": "test:0,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.Ide.Disk_X.Disk RESIZE UP File", currentConfig: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Size: 11, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 11, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, @@ -1630,29 +1630,29 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 110, Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Size: 11, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 11, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, {name: "Update Disk.Ide.Disk_X.Disk RESIZE UP Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Id: 23, - Size: 10, - Storage: "test", - syntax: diskSyntaxVolume, + Id: 23, + SizeInKibibytes: 10, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Size: 11, - Storage: "test", + SizeInKibibytes: 11, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, @@ -1660,38 +1660,38 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 110, Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test", - syntax: diskSyntaxVolume, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Size: 11, - Storage: "test", + SizeInKibibytes: 11, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, {name: "Update Disk.Ide.Disk_X.Disk SAME", currentConfig: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_0: ideBase}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, {name: "Update Disk.Ide.Disk_X.Disk.Format CHANGE File", currentConfig: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Qcow2, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Qcow2, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{"ide1": "test:0/vm-0-disk-23.qcow2,backup=0,replicate=0"}, }, @@ -1699,31 +1699,31 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Qcow2, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Qcow2, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{"ide1": "test:0/vm-0-disk-23.qcow2,backup=0,replicate=0"}, }, {name: "Update Disk.Ide.Disk_X.Disk.Format CHANGE Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 10, - Storage: "test", - syntax: diskSyntaxVolume, + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 10, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Qcow2, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Qcow2, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, @@ -1731,17 +1731,17 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test", - syntax: diskSyntaxVolume, + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Qcow2, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Qcow2, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, @@ -1846,17 +1846,17 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { // Update Disk.Sata.Disk_X.Disk {name: "Update Disk.Sata.Disk_X.Disk CHANGE File", currentConfig: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{ - AsyncIO: QemuDiskAsyncIO_IOuring, - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 10, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_IOuring, + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{ - AsyncIO: QemuDiskAsyncIO_Native, - Format: QemuDiskFormat_Raw, - Size: 10, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_Native, + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{"sata3": "test:0/vm-0-disk-23.raw,aio=native,backup=0,replicate=0"}, }, @@ -1864,33 +1864,33 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{ - AsyncIO: QemuDiskAsyncIO_IOuring, - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_IOuring, + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{ - AsyncIO: QemuDiskAsyncIO_Native, - Format: QemuDiskFormat_Raw, - Size: 10, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_Native, + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{"sata3": "test:100/base-100-disk-1.raw/0/vm-0-disk-23.raw,aio=native,backup=0,replicate=0"}, }, {name: "Update Disk.Sata.Disk_X.Disk CHANGE Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{ - AsyncIO: QemuDiskAsyncIO_IOuring, - Id: 23, - Size: 10, - Storage: "test", - syntax: diskSyntaxVolume, + AsyncIO: QemuDiskAsyncIO_IOuring, + Id: 23, + SizeInKibibytes: 10, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{ - AsyncIO: QemuDiskAsyncIO_Native, - Size: 10, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_Native, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{"sata3": "test:vm-0-disk-23,aio=native,backup=0,replicate=0"}, }, @@ -1898,17 +1898,17 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{ - AsyncIO: QemuDiskAsyncIO_IOuring, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test", - syntax: diskSyntaxVolume, + AsyncIO: QemuDiskAsyncIO_IOuring, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{ - AsyncIO: QemuDiskAsyncIO_Native, - Size: 10, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_Native, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{"sata3": "test:base-100-disk-1/vm-0-disk-23,aio=native,backup=0,replicate=0"}, }, @@ -1919,15 +1919,15 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { }, {name: "Update Disk.Sata.Disk_X.Disk MIGRATE File", currentConfig: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_5: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 10, - Storage: "test1", + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 10, + Storage: "test1", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_5: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Size: 10, - Storage: "test2", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 10, + Storage: "test2", }}}}}, output: map[string]interface{}{"sata5": "test2:0/vm-0-disk-23.raw,backup=0,replicate=0"}, }, @@ -1935,31 +1935,31 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_5: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test1", + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test1", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_5: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Size: 10, - Storage: "test2", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 10, + Storage: "test2", }}}}}, output: map[string]interface{}{"sata5": "test2:0/vm-0-disk-23.raw,backup=0,replicate=0"}, }, {name: "Update Disk.Sata.Disk_X.Disk MIGRATE Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_5: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 10, - Storage: "test1", - syntax: diskSyntaxVolume, + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 10, + Storage: "test1", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_5: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Size: 10, - Storage: "test2", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 10, + Storage: "test2", }}}}}, output: map[string]interface{}{"sata5": "test2:vm-0-disk-23,backup=0,replicate=0"}, }, @@ -1967,29 +1967,29 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_5: &QemuSataStorage{Disk: &QemuSataDisk{ - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test1", - syntax: diskSyntaxVolume, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test1", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_5: &QemuSataStorage{Disk: &QemuSataDisk{ - Size: 10, - Storage: "test2", + SizeInKibibytes: 10, + Storage: "test2", }}}}}, output: map[string]interface{}{"sata5": "test2:vm-0-disk-23,backup=0,replicate=0"}, }, {name: "Update Disk.Sata.Disk_X.Disk RESIZE DOWN Gibibyte File", currentConfig: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 9437185, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 9437185, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Size: 9437184, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437184, + Storage: "test", }}}}}, output: map[string]interface{}{"sata0": "test:9,backup=0,format=raw,replicate=0"}, }, @@ -1997,29 +1997,29 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 9437185, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 9437185, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Size: 9437184, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437184, + Storage: "test", }}}}}, output: map[string]interface{}{"sata0": "test:9,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.Sata.Disk_X.Disk RESIZE DOWN Gibibyte Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ - Id: 23, - Size: 9437185, - Storage: "test", - syntax: diskSyntaxVolume, + Id: 23, + SizeInKibibytes: 9437185, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ - Size: 9437184, - Storage: "test", + SizeInKibibytes: 9437184, + Storage: "test", }}}}}, output: map[string]interface{}{"sata0": "test:9,backup=0,replicate=0"}, }, @@ -2027,29 +2027,29 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ - Id: 23, - LinkedDiskId: &uint1, - Size: 9437185, - Storage: "test", - syntax: diskSyntaxVolume, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 9437185, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ - Size: 9437184, - Storage: "test", + SizeInKibibytes: 9437184, + Storage: "test", }}}}}, output: map[string]interface{}{"sata0": "test:9,backup=0,replicate=0"}, }, {name: "Update Disk.Sata.Disk_X.Disk RESIZE DOWN Kibibyte File", currentConfig: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 9437186, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 9437186, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Size: 9437185, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437185, + Storage: "test", }}}}}, output: map[string]interface{}{"sata0": "test:0,backup=0,format=raw,replicate=0"}, }, @@ -2057,29 +2057,29 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 9437186, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 9437186, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Size: 9437185, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437185, + Storage: "test", }}}}}, output: map[string]interface{}{"sata0": "test:0,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.Sata.Disk_X.Disk RESIZE DOWN Kibibyte Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ - Id: 23, - Size: 9437186, - Storage: "test", - syntax: diskSyntaxVolume, + Id: 23, + SizeInKibibytes: 9437186, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ - Size: 9437185, - Storage: "test", + SizeInKibibytes: 9437185, + Storage: "test", }}}}}, output: map[string]interface{}{"sata0": "test:0,backup=0,replicate=0"}, }, @@ -2087,29 +2087,29 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ - Id: 23, - LinkedDiskId: &uint1, - Size: 9437186, - Storage: "test", - syntax: diskSyntaxVolume, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 9437186, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ - Size: 9437185, - Storage: "test", + SizeInKibibytes: 9437185, + Storage: "test", }}}}}, output: map[string]interface{}{"sata0": "test:0,backup=0,replicate=0"}, }, {name: "Update Disk.Sata.Disk_X.Disk RESIZE UP File", currentConfig: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_1: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_1: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Size: 11, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 11, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, @@ -2117,28 +2117,28 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_1: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_1: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Size: 11, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 11, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, {name: "Update Disk.Sata.Disk_X.Disk RESIZE UP Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_1: &QemuSataStorage{Disk: &QemuSataDisk{ - Id: 23, - Size: 10, - Storage: "test", + Id: 23, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_1: &QemuSataStorage{Disk: &QemuSataDisk{ - Size: 11, - Storage: "test", + SizeInKibibytes: 11, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, @@ -2146,37 +2146,37 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_1: &QemuSataStorage{Disk: &QemuSataDisk{ - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test", + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_1: &QemuSataStorage{Disk: &QemuSataDisk{ - Size: 11, - Storage: "test", + SizeInKibibytes: 11, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, {name: "Update Disk.Sata.Disk_X.Disk SAME", currentConfig: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_2: sataBase}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, {name: "Update Disk.Sata.Disk_X.Disk.Format CHANGE File", currentConfig: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Qcow2, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Qcow2, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{"sata3": "test:0/vm-0-disk-23.qcow2,backup=0,replicate=0"}, }, @@ -2184,31 +2184,31 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Qcow2, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Qcow2, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{"sata3": "test:0/vm-0-disk-23.qcow2,backup=0,replicate=0"}, }, {name: "Update Disk.Sata.Disk_X.Disk.Format CHANGE Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 10, - Storage: "test", - syntax: diskSyntaxVolume, + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 10, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Qcow2, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Qcow2, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, @@ -2216,17 +2216,17 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test", - syntax: diskSyntaxVolume, + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Qcow2, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Qcow2, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, @@ -2331,17 +2331,17 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { // Update Disk.Scsi.Disk_X.Disk {name: "Update Disk.Scsi.Disk_X.Disk CHANGE File", currentConfig: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_15: &QemuScsiStorage{Disk: &QemuScsiDisk{ - AsyncIO: QemuDiskAsyncIO_IOuring, - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 10, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_IOuring, + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_15: &QemuScsiStorage{Disk: &QemuScsiDisk{ - AsyncIO: QemuDiskAsyncIO_Native, - Format: QemuDiskFormat_Raw, - Size: 10, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_Native, + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{"scsi15": "test:0/vm-0-disk-23.raw,aio=native,backup=0,replicate=0"}, }, @@ -2349,33 +2349,33 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_15: &QemuScsiStorage{Disk: &QemuScsiDisk{ - AsyncIO: QemuDiskAsyncIO_IOuring, - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_IOuring, + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_15: &QemuScsiStorage{Disk: &QemuScsiDisk{ - AsyncIO: QemuDiskAsyncIO_Native, - Format: QemuDiskFormat_Raw, - Size: 10, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_Native, + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{"scsi15": "test:100/base-100-disk-1.raw/0/vm-0-disk-23.raw,aio=native,backup=0,replicate=0"}, }, {name: "Update Disk.Scsi.Disk_X.Disk CHANGE Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_15: &QemuScsiStorage{Disk: &QemuScsiDisk{ - AsyncIO: QemuDiskAsyncIO_IOuring, - Id: 23, - Size: 10, - Storage: "test", - syntax: diskSyntaxVolume, + AsyncIO: QemuDiskAsyncIO_IOuring, + Id: 23, + SizeInKibibytes: 10, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_15: &QemuScsiStorage{Disk: &QemuScsiDisk{ - AsyncIO: QemuDiskAsyncIO_Native, - Size: 10, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_Native, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{"scsi15": "test:vm-0-disk-23,aio=native,backup=0,replicate=0"}, }, @@ -2383,17 +2383,17 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_15: &QemuScsiStorage{Disk: &QemuScsiDisk{ - AsyncIO: QemuDiskAsyncIO_IOuring, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test", - syntax: diskSyntaxVolume, + AsyncIO: QemuDiskAsyncIO_IOuring, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_15: &QemuScsiStorage{Disk: &QemuScsiDisk{ - AsyncIO: QemuDiskAsyncIO_Native, - Size: 10, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_Native, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{"scsi15": "test:base-100-disk-1/vm-0-disk-23,aio=native,backup=0,replicate=0"}, }, @@ -2404,15 +2404,15 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { }, {name: "Update Disk.Scsi.Disk_X.Disk MIGRATE File", currentConfig: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_17: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 10, - Storage: "test1", + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 10, + Storage: "test1", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_17: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Size: 10, - Storage: "test2", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 10, + Storage: "test2", }}}}}, output: map[string]interface{}{"scsi17": "test2:0/vm-0-disk-23.raw,backup=0,replicate=0"}, }, @@ -2420,29 +2420,29 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_17: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test1", + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test1", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_17: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Size: 10, - Storage: "test2", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 10, + Storage: "test2", }}}}}, output: map[string]interface{}{"scsi17": "test2:0/vm-0-disk-23.raw,backup=0,replicate=0"}, }, {name: "Update Disk.Scsi.Disk_X.Disk MIGRATE Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_17: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Id: 23, - Size: 10, - Storage: "test1", - syntax: diskSyntaxVolume, + Id: 23, + SizeInKibibytes: 10, + Storage: "test1", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_17: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Size: 10, - Storage: "test2", + SizeInKibibytes: 10, + Storage: "test2", }}}}}, output: map[string]interface{}{"scsi17": "test2:vm-0-disk-23,backup=0,replicate=0"}, }, @@ -2450,29 +2450,29 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_17: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test1", - syntax: diskSyntaxVolume, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test1", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_17: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Size: 10, - Storage: "test2", + SizeInKibibytes: 10, + Storage: "test2", }}}}}, output: map[string]interface{}{"scsi17": "test2:vm-0-disk-23,backup=0,replicate=0"}, }, {name: "Update Disk.Scsi.Disk_X.Disk RESIZE DOWN Gibibyte File", currentConfig: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 9437185, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 9437185, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Size: 9437184, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437184, + Storage: "test", }}}}}, output: map[string]interface{}{"scsi18": "test:9,backup=0,format=raw,replicate=0"}, }, @@ -2480,30 +2480,30 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 9437185, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 9437185, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Size: 9437184, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437184, + Storage: "test", }}}}}, output: map[string]interface{}{"scsi18": "test:9,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.Scsi.Disk_X.Disk RESIZE DOWN Gibibyte Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Id: 23, - Size: 9437185, - Storage: "test", - syntax: diskSyntaxVolume, + Id: 23, + SizeInKibibytes: 9437185, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Size: 9437184, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437184, + Storage: "test", }}}}}, output: map[string]interface{}{"scsi18": "test:9,backup=0,format=raw,replicate=0"}, }, @@ -2511,30 +2511,30 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Id: 23, - LinkedDiskId: &uint1, - Size: 9437185, - Storage: "test", - syntax: diskSyntaxVolume, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 9437185, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Size: 9437184, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437184, + Storage: "test", }}}}}, output: map[string]interface{}{"scsi18": "test:9,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.Scsi.Disk_X.Disk RESIZE DOWN Kibibyte File", currentConfig: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 9437186, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 9437186, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Size: 9437185, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437185, + Storage: "test", }}}}}, output: map[string]interface{}{"scsi18": "test:0,backup=0,format=raw,replicate=0"}, }, @@ -2542,30 +2542,30 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 9437186, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 9437186, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Size: 9437185, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437185, + Storage: "test", }}}}}, output: map[string]interface{}{"scsi18": "test:0,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.Scsi.Disk_X.Disk RESIZE DOWN Kibibyte Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Id: 23, - Size: 9437186, - Storage: "test", - syntax: diskSyntaxVolume, + Id: 23, + SizeInKibibytes: 9437186, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Size: 9437185, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437185, + Storage: "test", }}}}}, output: map[string]interface{}{"scsi18": "test:0,backup=0,format=raw,replicate=0"}, }, @@ -2573,30 +2573,30 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Id: 23, - LinkedDiskId: &uint1, - Size: 9437186, - Storage: "test", - syntax: diskSyntaxVolume, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 9437186, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Size: 9437185, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437185, + Storage: "test", }}}}}, output: map[string]interface{}{"scsi18": "test:0,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.Scsi.Disk_X.Disk RESIZE UP File", currentConfig: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_19: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_19: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Size: 11, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 11, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, @@ -2604,31 +2604,31 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_19: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_19: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Size: 11, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 11, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, {name: "Update Disk.Scsi.Disk_X.Disk RESIZE UP Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_19: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 10, - Storage: "test", - syntax: diskSyntaxVolume, + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 10, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_19: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Size: 11, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 11, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, @@ -2636,40 +2636,40 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_19: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test", - syntax: diskSyntaxVolume, + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_19: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Size: 11, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 11, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, {name: "Update Disk.Scsi.Disk_X.Disk SAME", currentConfig: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_20: scsiBase}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_20: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, {name: "Update Disk.Scsi.Disk_X.Disk.Format CHANGE File", currentConfig: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_21: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_21: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Qcow2, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Qcow2, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{"scsi21": "test:0/vm-0-disk-23.qcow2,backup=0,replicate=0"}, }, @@ -2677,31 +2677,31 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_21: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_21: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Qcow2, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Qcow2, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{"scsi21": "test:0/vm-0-disk-23.qcow2,backup=0,replicate=0"}, }, {name: "Update Disk.Scsi.Disk_X.Disk.Format CHANGE Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_21: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 10, - Storage: "test", - syntax: diskSyntaxVolume, + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 10, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_21: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Qcow2, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Qcow2, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, @@ -2709,17 +2709,17 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_21: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test", - syntax: diskSyntaxVolume, + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_21: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Qcow2, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Qcow2, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, @@ -2824,17 +2824,17 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { // Update Disk.VirtIO.Disk_X.Disk {name: "Update Disk.VirtIO.Disk_X.Disk CHANGE File", currentConfig: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_15: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - AsyncIO: QemuDiskAsyncIO_IOuring, - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 10, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_IOuring, + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_15: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - AsyncIO: QemuDiskAsyncIO_Native, - Format: QemuDiskFormat_Raw, - Size: 10, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_Native, + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{"virtio15": "test:0/vm-0-disk-23.raw,aio=native,backup=0,replicate=0"}, }, @@ -2842,33 +2842,33 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_15: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - AsyncIO: QemuDiskAsyncIO_IOuring, - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_IOuring, + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_15: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - AsyncIO: QemuDiskAsyncIO_Native, - Format: QemuDiskFormat_Raw, - Size: 10, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_Native, + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{"virtio15": "test:100/base-100-disk-1.raw/0/vm-0-disk-23.raw,aio=native,backup=0,replicate=0"}, }, {name: "Update Disk.VirtIO.Disk_X.Disk CHANGE Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_15: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - AsyncIO: QemuDiskAsyncIO_IOuring, - Id: 23, - Size: 10, - Storage: "test", - syntax: diskSyntaxVolume, + AsyncIO: QemuDiskAsyncIO_IOuring, + Id: 23, + SizeInKibibytes: 10, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_15: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - AsyncIO: QemuDiskAsyncIO_Native, - Size: 10, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_Native, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{"virtio15": "test:vm-0-disk-23,aio=native,backup=0,replicate=0"}, }, @@ -2876,17 +2876,17 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_15: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - AsyncIO: QemuDiskAsyncIO_IOuring, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test", - syntax: diskSyntaxVolume, + AsyncIO: QemuDiskAsyncIO_IOuring, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_15: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - AsyncIO: QemuDiskAsyncIO_Native, - Size: 10, - Storage: "test", + AsyncIO: QemuDiskAsyncIO_Native, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{"virtio15": "test:base-100-disk-1/vm-0-disk-23,aio=native,backup=0,replicate=0"}, }, @@ -2897,15 +2897,15 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { }, {name: "Update Disk.VirtIO.Disk_X.Disk MIGRATE File", currentConfig: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_1: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 10, - Storage: "test1", + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 10, + Storage: "test1", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_1: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Size: 10, - Storage: "test2", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 10, + Storage: "test2", }}}}}, output: map[string]interface{}{"virtio1": "test2:0/vm-0-disk-23.raw,backup=0,replicate=0"}, }, @@ -2913,29 +2913,29 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_1: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test1", + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test1", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_1: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Size: 10, - Storage: "test2", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 10, + Storage: "test2", }}}}}, output: map[string]interface{}{"virtio1": "test2:0/vm-0-disk-23.raw,backup=0,replicate=0"}, }, {name: "Update Disk.VirtIO.Disk_X.Disk MIGRATE Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_1: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Id: 23, - Size: 10, - Storage: "test1", - syntax: diskSyntaxVolume, + Id: 23, + SizeInKibibytes: 10, + Storage: "test1", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_1: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Size: 10, - Storage: "test2", + SizeInKibibytes: 10, + Storage: "test2", }}}}}, output: map[string]interface{}{"virtio1": "test2:vm-0-disk-23,backup=0,replicate=0"}, }, @@ -2943,29 +2943,29 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_1: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test1", - syntax: diskSyntaxVolume, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test1", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_1: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Size: 10, - Storage: "test2", + SizeInKibibytes: 10, + Storage: "test2", }}}}}, output: map[string]interface{}{"virtio1": "test2:vm-0-disk-23,backup=0,replicate=0"}, }, {name: "Update Disk.VirtIO.Disk_X.Disk RESIZE DOWN Gibibyte File", currentConfig: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 9437185, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 9437185, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Size: 9437184, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437184, + Storage: "test", }}}}}, output: map[string]interface{}{"virtio2": "test:9,backup=0,format=raw,replicate=0"}, }, @@ -2973,30 +2973,30 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 9437185, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 9437185, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Size: 9437184, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437184, + Storage: "test", }}}}}, output: map[string]interface{}{"virtio2": "test:9,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.VirtIO.Disk_X.Disk RESIZE DOWN Gibibyte Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Id: 23, - Size: 9437185, - Storage: "test", - syntax: diskSyntaxVolume, + Id: 23, + SizeInKibibytes: 9437185, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Size: 9437184, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437184, + Storage: "test", }}}}}, output: map[string]interface{}{"virtio2": "test:9,backup=0,format=raw,replicate=0"}, }, @@ -3004,30 +3004,30 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Id: 23, - LinkedDiskId: &uint1, - Size: 9437185, - Storage: "test", - syntax: diskSyntaxVolume, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 9437185, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Size: 9437184, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437184, + Storage: "test", }}}}}, output: map[string]interface{}{"virtio2": "test:9,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.VirtIO.Disk_X.Disk RESIZE DOWN Kibibyte File", currentConfig: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 9437186, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 9437186, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Size: 9437185, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437185, + Storage: "test", }}}}}, output: map[string]interface{}{"virtio2": "test:0,backup=0,format=raw,replicate=0"}, }, @@ -3035,30 +3035,30 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 9437186, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 9437186, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Size: 9437185, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437185, + Storage: "test", }}}}}, output: map[string]interface{}{"virtio2": "test:0,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.VirtIO.Disk_X.Disk RESIZE DOWN Kibibyte Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Id: 23, - Size: 9437186, - Storage: "test", - syntax: diskSyntaxVolume, + Id: 23, + SizeInKibibytes: 9437186, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Size: 9437185, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437185, + Storage: "test", }}}}}, output: map[string]interface{}{"virtio2": "test:0,backup=0,format=raw,replicate=0"}, }, @@ -3066,30 +3066,30 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Id: 23, - LinkedDiskId: &uint1, - Size: 9437186, - Storage: "test", - syntax: diskSyntaxVolume, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 9437186, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Size: 9437185, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 9437185, + Storage: "test", }}}}}, output: map[string]interface{}{"virtio2": "test:0,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.VirtIO.Disk_X.Disk RESIZE UP File", currentConfig: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_3: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_3: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Size: 11, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 11, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, @@ -3097,29 +3097,29 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_3: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_3: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Size: 11, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 11, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, {name: "Update Disk.VirtIO.Disk_X.Disk RESIZE UP Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_3: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Id: 23, - Size: 10, - Storage: "test", - syntax: diskSyntaxVolume, + Id: 23, + SizeInKibibytes: 10, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_3: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Size: 11, - Storage: "test", + SizeInKibibytes: 11, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, @@ -3127,38 +3127,38 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_3: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test", - syntax: diskSyntaxVolume, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_3: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Size: 11, - Storage: "test", + SizeInKibibytes: 11, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, {name: "Update Disk.VirtIO.Disk_X.Disk SAME", currentConfig: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_4: virtioBase}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_4: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, {name: "Update Disk.VirtIO.Disk_X.Disk.Format CHANGE File", currentConfig: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_5: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_5: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Qcow2, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Qcow2, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{"virtio5": "test:0/vm-0-disk-23.qcow2,backup=0,replicate=0"}, }, @@ -3166,31 +3166,31 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_5: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test", }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_5: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Qcow2, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Qcow2, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{"virtio5": "test:0/vm-0-disk-23.qcow2,backup=0,replicate=0"}, }, {name: "Update Disk.VirtIO.Disk_X.Disk.Format CHANGE Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_5: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - Size: 10, - Storage: "test", - syntax: diskSyntaxVolume, + Format: QemuDiskFormat_Raw, + Id: 23, + SizeInKibibytes: 10, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_5: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Qcow2, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Qcow2, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, @@ -3198,17 +3198,17 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { currentConfig: ConfigQemu{ LinkedVmId: 100, Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_5: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Id: 23, - LinkedDiskId: &uint1, - Size: 10, - Storage: "test", - syntax: diskSyntaxVolume, + Format: QemuDiskFormat_Raw, + Id: 23, + LinkedDiskId: &uint1, + SizeInKibibytes: 10, + Storage: "test", + syntax: diskSyntaxVolume, }}}}}, config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_5: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Qcow2, - Size: 10, - Storage: "test", + Format: QemuDiskFormat_Qcow2, + SizeInKibibytes: 10, + Storage: "test", }}}}}, output: map[string]interface{}{}, }, @@ -3289,9 +3289,9 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { {name: "Disks Ide CdRom iso", input: map[string]interface{}{"ide3": "local:iso/debian-11.0.0-amd64-netinst.iso,media=cdrom,size=377M"}, output: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{CdRom: &QemuCdRom{Iso: &IsoFile{ - File: "debian-11.0.0-amd64-netinst.iso", - Storage: "local", - Size: "377M", + File: "debian-11.0.0-amd64-netinst.iso", + Storage: "local", + SizeInKibibytes: "377M", }}}}}}, }, // Disks Ide CloudInit @@ -3335,16 +3335,16 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { WriteLimit: QemuDiskBandwidthIopsLimit{Burst: 14, BurstDuration: 5, Concurrent: 15}, }, }, - Cache: QemuDiskCache_WriteThrough, - Discard: true, - EmulateSSD: true, - Format: QemuDiskFormat_Qcow2, - Id: uint53, - Replicate: false, - Serial: "disk-9763", - Size: 1082130432, - Storage: "test2", - WorldWideName: "0x500F753600A987E1", + Cache: QemuDiskCache_WriteThrough, + Discard: true, + EmulateSSD: true, + Format: QemuDiskFormat_Qcow2, + Id: uint53, + Replicate: false, + Serial: "disk-9763", + SizeInKibibytes: 1082130432, + Storage: "test2", + WorldWideName: "0x500F753600A987E1", }}}}}, }, {name: "Disks Ide Disk ALL LinkedClone", @@ -3364,17 +3364,17 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { WriteLimit: QemuDiskBandwidthIopsLimit{Burst: 14, BurstDuration: 5, Concurrent: 15}, }, }, - Cache: QemuDiskCache_WriteThrough, - Discard: true, - EmulateSSD: true, - Format: QemuDiskFormat_Qcow2, - Id: uint53, - LinkedDiskId: &uint1, - Replicate: false, - Serial: "disk-9763", - Size: 1082130432, - Storage: "test2", - WorldWideName: "0x500679CE00B1DAF4", + Cache: QemuDiskCache_WriteThrough, + Discard: true, + EmulateSSD: true, + Format: QemuDiskFormat_Qcow2, + Id: uint53, + LinkedDiskId: &uint1, + Replicate: false, + Serial: "disk-9763", + SizeInKibibytes: 1082130432, + Storage: "test2", + WorldWideName: "0x500679CE00B1DAF4", }}}}}, }, {name: "Disks Ide Disk aio", @@ -3554,45 +3554,45 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { {name: "Disks Ide Disk size G", input: map[string]interface{}{"ide0": "test2:100/vm-100-disk-53.qcow2,size=1032G"}, output: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Backup: true, - Format: QemuDiskFormat_Qcow2, - Id: uint53, - Replicate: true, - Size: 1082130432, - Storage: "test2", + Backup: true, + Format: QemuDiskFormat_Qcow2, + Id: uint53, + Replicate: true, + SizeInKibibytes: 1082130432, + Storage: "test2", }}}}}, }, {name: "Disks Ide Disk size K", input: map[string]interface{}{"ide0": "test2:100/vm-100-disk-53.qcow2,size=1032K"}, output: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Backup: true, - Format: QemuDiskFormat_Qcow2, - Id: uint53, - Replicate: true, - Size: 1032, - Storage: "test2", + Backup: true, + Format: QemuDiskFormat_Qcow2, + Id: uint53, + Replicate: true, + SizeInKibibytes: 1032, + Storage: "test2", }}}}}, }, {name: "Disks Ide Disk size M", input: map[string]interface{}{"ide0": "test2:100/vm-100-disk-53.qcow2,size=1032M"}, output: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Backup: true, - Format: QemuDiskFormat_Qcow2, - Id: uint53, - Replicate: true, - Size: 1056768, - Storage: "test2", + Backup: true, + Format: QemuDiskFormat_Qcow2, + Id: uint53, + Replicate: true, + SizeInKibibytes: 1056768, + Storage: "test2", }}}}}, }, {name: "Disks Ide Disk size T", input: map[string]interface{}{"ide0": "test2:100/vm-100-disk-53.qcow2,size=2T"}, output: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Backup: true, - Format: QemuDiskFormat_Qcow2, - Id: uint53, - Replicate: true, - Size: 2147483648, - Storage: "test2", + Backup: true, + Format: QemuDiskFormat_Qcow2, + Id: uint53, + Replicate: true, + SizeInKibibytes: 2147483648, + Storage: "test2", }}}}}, }, {name: "Disks Ide Disk ssd", @@ -3666,14 +3666,14 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { WriteLimit: QemuDiskBandwidthIopsLimit{Burst: 13, BurstDuration: 5, Concurrent: 11}, }, }, - Cache: QemuDiskCache_Unsafe, - Discard: true, - EmulateSSD: true, - File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", - Replicate: false, - Serial: "disk-9763", - Size: 1048576, - WorldWideName: "0x500CBE4300D978A6", + Cache: QemuDiskCache_Unsafe, + Discard: true, + EmulateSSD: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: false, + Serial: "disk-9763", + SizeInKibibytes: 1048576, + WorldWideName: "0x500CBE4300D978A6", }}}}}, }, {name: "Disks Ide Passthrough aio", @@ -3821,37 +3821,37 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { {name: "Disks Ide Passthrough size G", input: map[string]interface{}{"ide0": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=10G"}, output: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Passthrough: &QemuIdePassthrough{ - Backup: true, - File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", - Replicate: true, - Size: 10485760, + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + SizeInKibibytes: 10485760, }}}}}, }, {name: "Disks Ide Passthrough size K", input: map[string]interface{}{"ide0": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=10K"}, output: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Passthrough: &QemuIdePassthrough{ - Backup: true, - File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", - Replicate: true, - Size: 10, + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + SizeInKibibytes: 10, }}}}}, }, {name: "Disks Ide Passthrough size M", input: map[string]interface{}{"ide0": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=10M"}, output: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Passthrough: &QemuIdePassthrough{ - Backup: true, - File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", - Replicate: true, - Size: 10240, + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + SizeInKibibytes: 10240, }}}}}, }, {name: "Disks Ide Passthrough size T", input: map[string]interface{}{"ide0": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=10T"}, output: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Passthrough: &QemuIdePassthrough{ - Backup: true, - File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", - Replicate: true, - Size: 10737418240, + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + SizeInKibibytes: 10737418240, }}}}}, }, {name: "Disks Ide Passthrough ssd", @@ -3884,9 +3884,9 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { {name: "Disks Sata CdRom iso", input: map[string]interface{}{"sata3": "local:iso/debian-11.0.0-amd64-netinst.iso,media=cdrom,size=377M"}, output: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{CdRom: &QemuCdRom{Iso: &IsoFile{ - File: "debian-11.0.0-amd64-netinst.iso", - Storage: "local", - Size: "377M", + File: "debian-11.0.0-amd64-netinst.iso", + Storage: "local", + SizeInKibibytes: "377M", }}}}}}, }, // Disks Sata CloudInit @@ -3930,16 +3930,16 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { WriteLimit: QemuDiskBandwidthIopsLimit{Burst: 13, BurstDuration: 5, Concurrent: 11}, }, }, - Cache: QemuDiskCache_None, - Discard: true, - EmulateSSD: true, - Format: QemuDiskFormat_Qcow2, - Id: uint47, - Replicate: false, - Serial: "disk-9763", - Size: 33554432, - Storage: "test2", - WorldWideName: "0x500DFA8900E3C641", + Cache: QemuDiskCache_None, + Discard: true, + EmulateSSD: true, + Format: QemuDiskFormat_Qcow2, + Id: uint47, + Replicate: false, + Serial: "disk-9763", + SizeInKibibytes: 33554432, + Storage: "test2", + WorldWideName: "0x500DFA8900E3C641", }}}}}, }, {name: "Disks Sata Disk ALL LinkedClone", @@ -3959,17 +3959,17 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { WriteLimit: QemuDiskBandwidthIopsLimit{Burst: 13, BurstDuration: 5, Concurrent: 11}, }, }, - Cache: QemuDiskCache_None, - Discard: true, - EmulateSSD: true, - Format: QemuDiskFormat_Qcow2, - Id: uint47, - LinkedDiskId: &uint1, - Replicate: false, - Serial: "disk-9763", - Size: 33554432, - Storage: "test2", - WorldWideName: "0x5003B97600A8F2D4", + Cache: QemuDiskCache_None, + Discard: true, + EmulateSSD: true, + Format: QemuDiskFormat_Qcow2, + Id: uint47, + LinkedDiskId: &uint1, + Replicate: false, + Serial: "disk-9763", + SizeInKibibytes: 33554432, + Storage: "test2", + WorldWideName: "0x5003B97600A8F2D4", }}}}}, }, {name: "Disks Sata Disk aio", @@ -4153,45 +4153,45 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { {name: "Disks Sata Disk size G", input: map[string]interface{}{"sata4": "test2:100/vm-100-disk-47.qcow2,size=32G"}, output: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Disk: &QemuSataDisk{ - Backup: true, - Format: QemuDiskFormat_Qcow2, - Id: uint47, - Replicate: true, - Size: 33554432, - Storage: "test2", + Backup: true, + Format: QemuDiskFormat_Qcow2, + Id: uint47, + Replicate: true, + SizeInKibibytes: 33554432, + Storage: "test2", }}}}}, }, {name: "Disks Sata Disk size K", input: map[string]interface{}{"sata4": "test2:100/vm-100-disk-47.qcow2,size=32K"}, output: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Disk: &QemuSataDisk{ - Backup: true, - Format: QemuDiskFormat_Qcow2, - Id: uint47, - Replicate: true, - Size: 32, - Storage: "test2", + Backup: true, + Format: QemuDiskFormat_Qcow2, + Id: uint47, + Replicate: true, + SizeInKibibytes: 32, + Storage: "test2", }}}}}, }, {name: "Disks Sata Disk size M", input: map[string]interface{}{"sata4": "test2:100/vm-100-disk-47.qcow2,size=32M"}, output: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Disk: &QemuSataDisk{ - Backup: true, - Format: QemuDiskFormat_Qcow2, - Id: uint47, - Replicate: true, - Size: 32768, - Storage: "test2", + Backup: true, + Format: QemuDiskFormat_Qcow2, + Id: uint47, + Replicate: true, + SizeInKibibytes: 32768, + Storage: "test2", }}}}}, }, {name: "Disks Sata Disk size T", input: map[string]interface{}{"sata4": "test2:100/vm-100-disk-47.qcow2,size=3T"}, output: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Disk: &QemuSataDisk{ - Backup: true, - Format: QemuDiskFormat_Qcow2, - Id: uint47, - Replicate: true, - Size: 3221225472, - Storage: "test2", + Backup: true, + Format: QemuDiskFormat_Qcow2, + Id: uint47, + Replicate: true, + SizeInKibibytes: 3221225472, + Storage: "test2", }}}}}, }, {name: "Disks Sata Disk ssd", @@ -4265,14 +4265,14 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { WriteLimit: QemuDiskBandwidthIopsLimit{Burst: 13, BurstDuration: 4, Concurrent: 11}, }, }, - Cache: QemuDiskCache_DirectSync, - Discard: true, - EmulateSSD: true, - File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", - Replicate: false, - Serial: "disk-9763", - Size: 1048576, - WorldWideName: "500E9FBC00F2A6D3", + Cache: QemuDiskCache_DirectSync, + Discard: true, + EmulateSSD: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: false, + Serial: "disk-9763", + SizeInKibibytes: 1048576, + WorldWideName: "500E9FBC00F2A6D3", }}}}}, }, {name: "Disks Sata Passthrough aio", @@ -4420,37 +4420,37 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { {name: "Disks Sata Passthrough size G", input: map[string]interface{}{"sata4": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=3G"}, output: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Passthrough: &QemuSataPassthrough{ - Backup: true, - File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", - Replicate: true, - Size: 3145728, + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + SizeInKibibytes: 3145728, }}}}}, }, {name: "Disks Sata Passthrough size K", input: map[string]interface{}{"sata4": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=5789K"}, output: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Passthrough: &QemuSataPassthrough{ - Backup: true, - File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", - Replicate: true, - Size: 5789, + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + SizeInKibibytes: 5789, }}}}}, }, {name: "Disks Sata Passthrough size M", input: map[string]interface{}{"sata4": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=45M"}, output: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Passthrough: &QemuSataPassthrough{ - Backup: true, - File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", - Replicate: true, - Size: 46080, + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + SizeInKibibytes: 46080, }}}}}, }, {name: "Disks Sata Passthrough size T", input: map[string]interface{}{"sata4": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=7T"}, output: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_4: &QemuSataStorage{Passthrough: &QemuSataPassthrough{ - Backup: true, - File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", - Replicate: true, - Size: 7516192768, + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + SizeInKibibytes: 7516192768, }}}}}, }, {name: "Disks Sata Passthrough ssd", @@ -4483,9 +4483,9 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { {name: "Disks Scsi CdRom iso", input: map[string]interface{}{"scsi28": "local:iso/debian-11.0.0-amd64-netinst.iso,media=cdrom,size=377M"}, output: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_28: &QemuScsiStorage{CdRom: &QemuCdRom{Iso: &IsoFile{ - File: "debian-11.0.0-amd64-netinst.iso", - Storage: "local", - Size: "377M", + File: "debian-11.0.0-amd64-netinst.iso", + Storage: "local", + SizeInKibibytes: "377M", }}}}}}, }, // Disks Scsi CloudInit @@ -4529,18 +4529,18 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { WriteLimit: QemuDiskBandwidthIopsLimit{Burst: 13, BurstDuration: 5, Concurrent: 11}, }, }, - Cache: QemuDiskCache_WriteBack, - Discard: true, - EmulateSSD: true, - Format: QemuDiskFormat_Qcow2, - Id: uint2, - IOThread: true, - ReadOnly: true, - Replicate: false, - Serial: "disk-9763", - Size: 33554432, - Storage: "test", - WorldWideName: "0x500AF18700E9CD25", + Cache: QemuDiskCache_WriteBack, + Discard: true, + EmulateSSD: true, + Format: QemuDiskFormat_Qcow2, + Id: uint2, + IOThread: true, + ReadOnly: true, + Replicate: false, + Serial: "disk-9763", + SizeInKibibytes: 33554432, + Storage: "test", + WorldWideName: "0x500AF18700E9CD25", }}}}}, }, {name: "Disks Scsi Disk ALL LinkedClone", @@ -4560,19 +4560,19 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { WriteLimit: QemuDiskBandwidthIopsLimit{Burst: 13, BurstDuration: 5, Concurrent: 11}, }, }, - Cache: QemuDiskCache_WriteBack, - Discard: true, - EmulateSSD: true, - Format: QemuDiskFormat_Qcow2, - Id: uint2, - IOThread: true, - LinkedDiskId: &uint1, - ReadOnly: true, - Replicate: false, - Serial: "disk-9763", - Size: 33554432, - Storage: "test", - WorldWideName: "0x500879DC00F3BE6A", + Cache: QemuDiskCache_WriteBack, + Discard: true, + EmulateSSD: true, + Format: QemuDiskFormat_Qcow2, + Id: uint2, + IOThread: true, + LinkedDiskId: &uint1, + ReadOnly: true, + Replicate: false, + Serial: "disk-9763", + SizeInKibibytes: 33554432, + Storage: "test", + WorldWideName: "0x500879DC00F3BE6A", }}}}}, }, {name: "Disks Scsi Disk aio", @@ -4774,45 +4774,45 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { {name: "Disks Scsi Disk size G", input: map[string]interface{}{"scsi18": "test:100/vm-100-disk-2.qcow2,size=32G"}, output: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Backup: true, - Format: QemuDiskFormat_Qcow2, - Id: uint2, - Replicate: true, - Size: 33554432, - Storage: "test", + Backup: true, + Format: QemuDiskFormat_Qcow2, + Id: uint2, + Replicate: true, + SizeInKibibytes: 33554432, + Storage: "test", }}}}}, }, {name: "Disks Scsi Disk size K", input: map[string]interface{}{"scsi18": "test:100/vm-100-disk-2.qcow2,size=32K"}, output: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Backup: true, - Format: QemuDiskFormat_Qcow2, - Id: uint2, - Replicate: true, - Size: 32, - Storage: "test", + Backup: true, + Format: QemuDiskFormat_Qcow2, + Id: uint2, + Replicate: true, + SizeInKibibytes: 32, + Storage: "test", }}}}}, }, {name: "Disks Scsi Disk size M", input: map[string]interface{}{"scsi18": "test:100/vm-100-disk-2.qcow2,size=32M"}, output: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Backup: true, - Format: QemuDiskFormat_Qcow2, - Id: uint2, - Replicate: true, - Size: 32768, - Storage: "test", + Backup: true, + Format: QemuDiskFormat_Qcow2, + Id: uint2, + Replicate: true, + SizeInKibibytes: 32768, + Storage: "test", }}}}}, }, {name: "Disks Scsi Disk size T", input: map[string]interface{}{"scsi18": "test:100/vm-100-disk-2.qcow2,size=4T"}, output: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Backup: true, - Format: QemuDiskFormat_Qcow2, - Id: uint2, - Replicate: true, - Size: 4294967296, - Storage: "test", + Backup: true, + Format: QemuDiskFormat_Qcow2, + Id: uint2, + Replicate: true, + SizeInKibibytes: 4294967296, + Storage: "test", }}}}}, }, {name: "Disks Scsi Disk ssd", @@ -4886,16 +4886,16 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { WriteLimit: QemuDiskBandwidthIopsLimit{Burst: 13, BurstDuration: 5, Concurrent: 11}, }, }, - Cache: QemuDiskCache_None, - Discard: true, - EmulateSSD: true, - File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", - IOThread: true, - ReadOnly: true, - Replicate: false, - Serial: "disk-9763", - Size: 1048576, - WorldWideName: "500CB15600D8FE32", + Cache: QemuDiskCache_None, + Discard: true, + EmulateSSD: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + IOThread: true, + ReadOnly: true, + Replicate: false, + Serial: "disk-9763", + SizeInKibibytes: 1048576, + WorldWideName: "500CB15600D8FE32", }}}}}, }, {name: "Disks Scsi Passthrough aio", @@ -5061,37 +5061,37 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { {name: "Disks Scsi Passthrough size G", input: map[string]interface{}{"scsi18": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=1G"}, output: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Passthrough: &QemuScsiPassthrough{ - Backup: true, - File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", - Replicate: true, - Size: 1048576, + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + SizeInKibibytes: 1048576, }}}}}, }, {name: "Disks Scsi Passthrough size K", input: map[string]interface{}{"scsi18": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=1K"}, output: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Passthrough: &QemuScsiPassthrough{ - Backup: true, - File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", - Replicate: true, - Size: 1, + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + SizeInKibibytes: 1, }}}}}, }, {name: "Disks Scsi Passthrough size M", input: map[string]interface{}{"scsi18": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=1M"}, output: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Passthrough: &QemuScsiPassthrough{ - Backup: true, - File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", - Replicate: true, - Size: 1024, + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + SizeInKibibytes: 1024, }}}}}, }, {name: "Disks Scsi Passthrough size T", input: map[string]interface{}{"scsi18": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=1T"}, output: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Passthrough: &QemuScsiPassthrough{ - Backup: true, - File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", - Replicate: true, - Size: 1073741824, + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + SizeInKibibytes: 1073741824, }}}}}, }, {name: "Disks Scsi Passthrough ssd", @@ -5124,9 +5124,9 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { {name: "Disks VirtIO CdRom iso", input: map[string]interface{}{"virtio9": "local:iso/debian-11.0.0-amd64-netinst.iso,media=cdrom,size=377M"}, output: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_9: &QemuVirtIOStorage{CdRom: &QemuCdRom{Iso: &IsoFile{ - File: "debian-11.0.0-amd64-netinst.iso", - Storage: "local", - Size: "377M", + File: "debian-11.0.0-amd64-netinst.iso", + Storage: "local", + SizeInKibibytes: "377M", }}}}}}, }, // Disks VirtIO CloudInit @@ -5170,17 +5170,17 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { WriteLimit: QemuDiskBandwidthIopsLimit{Burst: 13, BurstDuration: 3, Concurrent: 11}, }, }, - Cache: QemuDiskCache_DirectSync, - Discard: true, - Format: QemuDiskFormat_Qcow2, - Id: uint31, - IOThread: true, - ReadOnly: true, - Replicate: false, - Serial: "disk-9763", - Size: 33554432, - Storage: "test2", - WorldWideName: "0x50015B3900F8EAD2", + Cache: QemuDiskCache_DirectSync, + Discard: true, + Format: QemuDiskFormat_Qcow2, + Id: uint31, + IOThread: true, + ReadOnly: true, + Replicate: false, + Serial: "disk-9763", + SizeInKibibytes: 33554432, + Storage: "test2", + WorldWideName: "0x50015B3900F8EAD2", }}}}}, }, {name: "Disks VirtIO Disk ALL LinkedClone", @@ -5200,18 +5200,18 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { WriteLimit: QemuDiskBandwidthIopsLimit{Burst: 13, BurstDuration: 3, Concurrent: 11}, }, }, - Cache: QemuDiskCache_DirectSync, - Discard: true, - Format: QemuDiskFormat_Qcow2, - Id: uint31, - IOThread: true, - LinkedDiskId: &uint1, - ReadOnly: true, - Replicate: false, - Serial: "disk-9763", - Size: 33554432, - Storage: "test2", - WorldWideName: "0x500FA2D000C69587", + Cache: QemuDiskCache_DirectSync, + Discard: true, + Format: QemuDiskFormat_Qcow2, + Id: uint31, + IOThread: true, + LinkedDiskId: &uint1, + ReadOnly: true, + Replicate: false, + Serial: "disk-9763", + SizeInKibibytes: 33554432, + Storage: "test2", + WorldWideName: "0x500FA2D000C69587", }}}}}, }, {name: "Disks VirtIO Disk aio", @@ -5417,45 +5417,45 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { {name: "Disks VirtIO Disk size G", input: map[string]interface{}{"virtio2": "test2:100/vm-100-disk-31.qcow2,size=32G"}, output: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Backup: true, - Format: QemuDiskFormat_Qcow2, - Id: uint31, - Replicate: true, - Size: 33554432, - Storage: "test2", + Backup: true, + Format: QemuDiskFormat_Qcow2, + Id: uint31, + Replicate: true, + SizeInKibibytes: 33554432, + Storage: "test2", }}}}}, }, {name: "Disks VirtIO Disk size K", input: map[string]interface{}{"virtio2": "test2:100/vm-100-disk-31.qcow2,size=32K"}, output: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Backup: true, - Format: QemuDiskFormat_Qcow2, - Id: uint31, - Replicate: true, - Size: 32, - Storage: "test2", + Backup: true, + Format: QemuDiskFormat_Qcow2, + Id: uint31, + Replicate: true, + SizeInKibibytes: 32, + Storage: "test2", }}}}}, }, {name: "Disks VirtIO Disk size M", input: map[string]interface{}{"virtio2": "test2:100/vm-100-disk-31.qcow2,size=32M"}, output: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Backup: true, - Format: QemuDiskFormat_Qcow2, - Id: uint31, - Replicate: true, - Size: 32768, - Storage: "test2", + Backup: true, + Format: QemuDiskFormat_Qcow2, + Id: uint31, + Replicate: true, + SizeInKibibytes: 32768, + Storage: "test2", }}}}}, }, {name: "Disks VirtIO Disk size T", input: map[string]interface{}{"virtio2": "test2:100/vm-100-disk-31.qcow2,size=5T"}, output: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Backup: true, - Format: QemuDiskFormat_Qcow2, - Id: uint31, - Replicate: true, - Size: 5368709120, - Storage: "test2", + Backup: true, + Format: QemuDiskFormat_Qcow2, + Id: uint31, + Replicate: true, + SizeInKibibytes: 5368709120, + Storage: "test2", }}}}}, }, {name: "Disks VirtIO Disk syntax fileSyntaxVolume", @@ -5518,15 +5518,15 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { WriteLimit: QemuDiskBandwidthIopsLimit{Burst: 13, BurstDuration: 5, Concurrent: 11}, }, }, - Cache: QemuDiskCache_Unsafe, - Discard: true, - File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", - IOThread: true, - ReadOnly: true, - Replicate: false, - Serial: "disk-9763", - Size: 1048576, - WorldWideName: "0x500B6ED600F1C945", + Cache: QemuDiskCache_Unsafe, + Discard: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + IOThread: true, + ReadOnly: true, + Replicate: false, + Serial: "disk-9763", + SizeInKibibytes: 1048576, + WorldWideName: "0x500B6ED600F1C945", }}}}}, }, {name: "Disks VirtIO Passthrough aio", @@ -5692,37 +5692,37 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { {name: "Disks VirtIO Passthrough size G", input: map[string]interface{}{"virtio2": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=1G"}, output: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Passthrough: &QemuVirtIOPassthrough{ - Backup: true, - File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", - Replicate: true, - Size: 1048576, + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + SizeInKibibytes: 1048576, }}}}}, }, {name: "Disks VirtIO Passthrough size K", input: map[string]interface{}{"virtio2": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=1K"}, output: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Passthrough: &QemuVirtIOPassthrough{ - Backup: true, - File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", - Replicate: true, - Size: 1, + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + SizeInKibibytes: 1, }}}}}, }, {name: "Disks VirtIO Passthrough size M", input: map[string]interface{}{"virtio2": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=1M"}, output: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Passthrough: &QemuVirtIOPassthrough{ - Backup: true, - File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", - Replicate: true, - Size: 1024, + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + SizeInKibibytes: 1024, }}}}}, }, {name: "Disks VirtIO Passthrough size T", input: map[string]interface{}{"virtio2": "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8,size=1T"}, output: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Passthrough: &QemuVirtIOPassthrough{ - Backup: true, - File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", - Replicate: true, - Size: 1073741824, + Backup: true, + File: "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi8", + Replicate: true, + SizeInKibibytes: 1073741824, }}}}}, }, {name: "Disks VirtIO Passthrough wwn", @@ -5739,15 +5739,15 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { input: map[string]interface{}{"ide2": "local:iso/debian-11.0.0-amd64-netinst.iso,media=cdrom,size=377M"}, output: &ConfigQemu{ Iso: &IsoFile{ - File: "debian-11.0.0-amd64-netinst.iso", - Storage: "local", - Size: "377M", + File: "debian-11.0.0-amd64-netinst.iso", + Storage: "local", + SizeInKibibytes: "377M", }, Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{CdRom: &QemuCdRom{ Iso: &IsoFile{ - File: "debian-11.0.0-amd64-netinst.iso", - Storage: "local", - Size: "377M", + File: "debian-11.0.0-amd64-netinst.iso", + Storage: "local", + SizeInKibibytes: "377M", }, }}}}, }, @@ -5945,40 +5945,40 @@ func Test_ConfigQemu_Validate(t *testing.T) { {name: "Valid Disks Disk", input: ConfigQemu{Disks: &QemuStorages{ Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{ - AsyncIO: QemuDiskAsyncIO_IOuring, - Bandwidth: BandwidthValid0, - Cache: QemuDiskCache_DirectSync, - Format: QemuDiskFormat_Raw, - Size: 32, - Storage: "test", - WorldWideName: "0x500A1B2C3D4E5F60", + AsyncIO: QemuDiskAsyncIO_IOuring, + Bandwidth: BandwidthValid0, + Cache: QemuDiskCache_DirectSync, + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 32, + Storage: "test", + WorldWideName: "0x500A1B2C3D4E5F60", }}}, Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ - AsyncIO: QemuDiskAsyncIO_Native, - Bandwidth: BandwidthValid1, - Cache: QemuDiskCache_None, - Format: QemuDiskFormat_Cow, - Size: 1, - Storage: "test", - WorldWideName: "0x500F123456789ABC", + AsyncIO: QemuDiskAsyncIO_Native, + Bandwidth: BandwidthValid1, + Cache: QemuDiskCache_None, + Format: QemuDiskFormat_Cow, + SizeInKibibytes: 1, + Storage: "test", + WorldWideName: "0x500F123456789ABC", }}}, Scsi: &QemuScsiDisks{Disk_0: &QemuScsiStorage{Disk: &QemuScsiDisk{ - AsyncIO: QemuDiskAsyncIO_Threads, - Bandwidth: BandwidthValid2, - Cache: QemuDiskCache_WriteBack, - Format: QemuDiskFormat_Qcow2, - Size: 10, - Storage: "test", - WorldWideName: "0x5009876543210DEF", + AsyncIO: QemuDiskAsyncIO_Threads, + Bandwidth: BandwidthValid2, + Cache: QemuDiskCache_WriteBack, + Format: QemuDiskFormat_Qcow2, + SizeInKibibytes: 10, + Storage: "test", + WorldWideName: "0x5009876543210DEF", }}}, VirtIO: &QemuVirtIODisks{Disk_0: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - AsyncIO: "", - Bandwidth: BandwidthValid3, - Cache: "", - Format: QemuDiskFormat_Vmdk, - Size: 1024, - Storage: "test", - WorldWideName: "0x500C0D0E0F101112", + AsyncIO: "", + Bandwidth: BandwidthValid3, + Cache: "", + Format: QemuDiskFormat_Vmdk, + SizeInKibibytes: 1024, + Storage: "test", + WorldWideName: "0x500C0D0E0F101112", }}}, }}, }, @@ -6583,25 +6583,25 @@ func Test_ConfigQemu_Validate(t *testing.T) { }, {name: `Invalid Disks Disk Ide errors.New(Error_QemuDisk_Size)`, input: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Size: 0, + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 0, }}}}}, err: errors.New(Error_QemuDisk_Size), }, {name: `Invalid Disks Disk Ide errors.New(Error_QemuDisk_Storage)`, input: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Size: 32, - Storage: "", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 32, + Storage: "", }}}}}, err: errors.New(Error_QemuDisk_Storage), }, {name: `Invalid Disks Disk Ide errors.New(Error_QemuWorldWideName_Invalid)`, input: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_0: &QemuIdeStorage{Disk: &QemuIdeDisk{ - Format: QemuDiskFormat_Raw, - Size: 32, - Storage: "Test", - WorldWideName: "0xG123456789ABCDE", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 32, + Storage: "Test", + WorldWideName: "0xG123456789ABCDE", }}}}}, err: errors.New(Error_QemuWorldWideName_Invalid), }, @@ -6670,25 +6670,25 @@ func Test_ConfigQemu_Validate(t *testing.T) { }, {name: `Invalid Disks Disk Sata errors.New(Error_QemuDisk_Size)`, input: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Size: 0, + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 0, }}}}}, err: errors.New(Error_QemuDisk_Size), }, {name: `Invalid Disks Disk Sata errors.New(Error_QemuDisk_Storage)`, input: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Size: 32, - Storage: "", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 32, + Storage: "", }}}}}, err: errors.New(Error_QemuDisk_Storage), }, {name: `Invalid Disks Disk Sata errors.New(Error_QemuWorldWideName_Invalid)`, input: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ - Format: QemuDiskFormat_Raw, - Size: 32, - Storage: "Test", - WorldWideName: "500A1B2C3D4E5F60", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 32, + Storage: "Test", + WorldWideName: "500A1B2C3D4E5F60", }}}}}, err: errors.New(Error_QemuWorldWideName_Invalid), }, @@ -6757,25 +6757,25 @@ func Test_ConfigQemu_Validate(t *testing.T) { }, {name: `Invalid Disks Disk Scsi errors.New(Error_QemuDisk_Size)`, input: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_14: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Size: 0, + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 0, }}}}}, err: errors.New(Error_QemuDisk_Size), }, {name: `Invalid Disks Disk Scsi errors.New(Error_QemuDisk_Storage)`, input: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_15: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Size: 32, - Storage: "", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 32, + Storage: "", }}}}}, err: errors.New(Error_QemuDisk_Storage), }, {name: `Invalid Disks Disk Scsi errors.New(Error_QemuWorldWideName_Invalid)`, input: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_16: &QemuScsiStorage{Disk: &QemuScsiDisk{ - Format: QemuDiskFormat_Raw, - Size: 32, - Storage: "Test", - WorldWideName: "0x5009876543210DEFG", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 32, + Storage: "Test", + WorldWideName: "0x5009876543210DEFG", }}}}}, err: errors.New(Error_QemuWorldWideName_Invalid), }, @@ -6844,25 +6844,25 @@ func Test_ConfigQemu_Validate(t *testing.T) { }, {name: `Invalid Disks Disk VirtIO errors.New(Error_QemuDisk_Size)`, input: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_14: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Size: 0, + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 0, }}}}}, err: errors.New(Error_QemuDisk_Size), }, {name: `Invalid Disks Disk VirtIO errors.New(Error_QemuDisk_Storage)`, input: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_15: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Size: 32, - Storage: "", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 32, + Storage: "", }}}}}, err: errors.New(Error_QemuDisk_Storage), }, {name: `Invalid Disks Disk VirtIO errors.New(Error_QemuWorldWideName_Invalid)`, input: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_0: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ - Format: QemuDiskFormat_Raw, - Size: 32, - Storage: "Test", - WorldWideName: "500C0D0E0F10111", + Format: QemuDiskFormat_Raw, + SizeInKibibytes: 32, + Storage: "Test", + WorldWideName: "500C0D0E0F10111", }}}}}, err: errors.New(Error_QemuWorldWideName_Invalid), }, From f32d3029f037b6c20a30e758bc603e9093dfc200 Mon Sep 17 00:00:00 2001 From: Tinyblargon <76069640+Tinyblargon@users.noreply.github.com> Date: Thu, 1 Feb 2024 09:22:17 +0000 Subject: [PATCH 8/9] fix: disk value may not be `0` --- proxmox/config_qemu_disk.go | 2 +- proxmox/config_qemu_test.go | 40 ++++++++++++++++++------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/proxmox/config_qemu_disk.go b/proxmox/config_qemu_disk.go index ea0ea844..90a861b0 100644 --- a/proxmox/config_qemu_disk.go +++ b/proxmox/config_qemu_disk.go @@ -256,7 +256,7 @@ func (disk qemuDisk) mapToApiValues(vmID, LinkedVmId uint, currentStorage string if disk.SizeInKibibytes%gibibyte == 0 { settings = disk.Storage + ":" + strconv.FormatInt(int64(disk.SizeInKibibytes/gibibyte), 10) } else { - settings = disk.Storage + ":0" + settings = disk.Storage + ":0.001" } } else { settings = disk.formatDisk(vmID, LinkedVmId, currentStorage, currentFormat, syntax) diff --git a/proxmox/config_qemu_test.go b/proxmox/config_qemu_test.go index d43f75a3..819a1f06 100644 --- a/proxmox/config_qemu_test.go +++ b/proxmox/config_qemu_test.go @@ -91,7 +91,7 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { SizeInKibibytes: 33554433, Storage: "Test", }}}}}, - output: map[string]interface{}{"ide0": "Test:0,backup=0,replicate=0"}, + output: map[string]interface{}{"ide0": "Test:0.001,backup=0,replicate=0"}, }, {name: "Create Disks.Ide.Disk_X.Disk.AsyncIO", config: &ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_1: &QemuIdeStorage{Disk: &QemuIdeDisk{AsyncIO: QemuDiskAsyncIO_Native}}}}}, @@ -390,7 +390,7 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { SizeInKibibytes: 16777217, Storage: "Test", }}}}}, - output: map[string]interface{}{"sata0": "Test:0,backup=0,replicate=0"}, + output: map[string]interface{}{"sata0": "Test:0.001,backup=0,replicate=0"}, }, {name: "Create Disks.Sata.Disk_X.Disk.AsyncIO", config: &ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{AsyncIO: QemuDiskAsyncIO_Native}}}}}, @@ -691,7 +691,7 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { SizeInKibibytes: 76546049, Storage: "Test", }}}}}, - output: map[string]interface{}{"scsi0": "Test:0,backup=0,replicate=0"}, + output: map[string]interface{}{"scsi0": "Test:0.001,backup=0,replicate=0"}, }, {name: "Create Disks.Scsi.Disk_X.Disk.AsyncIO", config: &ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_1: &QemuScsiStorage{Disk: &QemuScsiDisk{AsyncIO: QemuDiskAsyncIO_Native}}}}}, @@ -1009,7 +1009,7 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { SizeInKibibytes: 8238661633, Storage: "Test", }}}}}, - output: map[string]interface{}{"virtio0": "Test:0,backup=0,replicate=0"}, + output: map[string]interface{}{"virtio0": "Test:0.001,backup=0,replicate=0"}, }, {name: "Create Disks.VirtIO.Disk_X.Disk.AsyncIO", config: &ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_1: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{AsyncIO: QemuDiskAsyncIO_Native}}}}}, @@ -1562,7 +1562,7 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { SizeInKibibytes: 9437185, Storage: "test", }}}}}, - output: map[string]interface{}{"ide2": "test:0,backup=0,format=raw,replicate=0"}, + output: map[string]interface{}{"ide2": "test:0.001,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.Ide.Disk_X.Disk RESIZE DOWN Kibibyte File LinkedClone", currentConfig: ConfigQemu{ @@ -1579,7 +1579,7 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { SizeInKibibytes: 9437185, Storage: "test", }}}}}, - output: map[string]interface{}{"ide2": "test:0,backup=0,format=raw,replicate=0"}, + output: map[string]interface{}{"ide2": "test:0.001,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.Ide.Disk_X.Disk RESIZE DOWN Kibibyte Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ @@ -1593,7 +1593,7 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { SizeInKibibytes: 9437185, Storage: "test", }}}}}, - output: map[string]interface{}{"ide2": "test:0,backup=0,format=raw,replicate=0"}, + output: map[string]interface{}{"ide2": "test:0.001,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.Ide.Disk_X.Disk RESIZE DOWN Kibibyte Volume LinkedClone", currentConfig: ConfigQemu{ @@ -1610,7 +1610,7 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { SizeInKibibytes: 9437185, Storage: "test", }}}}}, - output: map[string]interface{}{"ide2": "test:0,backup=0,format=raw,replicate=0"}, + output: map[string]interface{}{"ide2": "test:0.001,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.Ide.Disk_X.Disk RESIZE UP File", currentConfig: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{ @@ -2051,7 +2051,7 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { SizeInKibibytes: 9437185, Storage: "test", }}}}}, - output: map[string]interface{}{"sata0": "test:0,backup=0,format=raw,replicate=0"}, + output: map[string]interface{}{"sata0": "test:0.001,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.Sata.Disk_X.Disk RESIZE DOWN Kibibyte File LinkedClone", currentConfig: ConfigQemu{ @@ -2068,7 +2068,7 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { SizeInKibibytes: 9437185, Storage: "test", }}}}}, - output: map[string]interface{}{"sata0": "test:0,backup=0,format=raw,replicate=0"}, + output: map[string]interface{}{"sata0": "test:0.001,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.Sata.Disk_X.Disk RESIZE DOWN Kibibyte Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_0: &QemuSataStorage{Disk: &QemuSataDisk{ @@ -2081,7 +2081,7 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { SizeInKibibytes: 9437185, Storage: "test", }}}}}, - output: map[string]interface{}{"sata0": "test:0,backup=0,replicate=0"}, + output: map[string]interface{}{"sata0": "test:0.001,backup=0,replicate=0"}, }, {name: "Update Disk.Sata.Disk_X.Disk RESIZE DOWN Kibibyte Volume LinkedClone", currentConfig: ConfigQemu{ @@ -2097,7 +2097,7 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { SizeInKibibytes: 9437185, Storage: "test", }}}}}, - output: map[string]interface{}{"sata0": "test:0,backup=0,replicate=0"}, + output: map[string]interface{}{"sata0": "test:0.001,backup=0,replicate=0"}, }, {name: "Update Disk.Sata.Disk_X.Disk RESIZE UP File", currentConfig: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_1: &QemuSataStorage{Disk: &QemuSataDisk{ @@ -2536,7 +2536,7 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { SizeInKibibytes: 9437185, Storage: "test", }}}}}, - output: map[string]interface{}{"scsi18": "test:0,backup=0,format=raw,replicate=0"}, + output: map[string]interface{}{"scsi18": "test:0.001,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.Scsi.Disk_X.Disk RESIZE DOWN Kibibyte File LinkedClone", currentConfig: ConfigQemu{ @@ -2553,7 +2553,7 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { SizeInKibibytes: 9437185, Storage: "test", }}}}}, - output: map[string]interface{}{"scsi18": "test:0,backup=0,format=raw,replicate=0"}, + output: map[string]interface{}{"scsi18": "test:0.001,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.Scsi.Disk_X.Disk RESIZE DOWN Kibibyte Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_18: &QemuScsiStorage{Disk: &QemuScsiDisk{ @@ -2567,7 +2567,7 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { SizeInKibibytes: 9437185, Storage: "test", }}}}}, - output: map[string]interface{}{"scsi18": "test:0,backup=0,format=raw,replicate=0"}, + output: map[string]interface{}{"scsi18": "test:0.001,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.Scsi.Disk_X.Disk RESIZE DOWN Kibibyte Volume LinkedClone", currentConfig: ConfigQemu{ @@ -2584,7 +2584,7 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { SizeInKibibytes: 9437185, Storage: "test", }}}}}, - output: map[string]interface{}{"scsi18": "test:0,backup=0,format=raw,replicate=0"}, + output: map[string]interface{}{"scsi18": "test:0.001,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.Scsi.Disk_X.Disk RESIZE UP File", currentConfig: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_19: &QemuScsiStorage{Disk: &QemuScsiDisk{ @@ -3029,7 +3029,7 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { SizeInKibibytes: 9437185, Storage: "test", }}}}}, - output: map[string]interface{}{"virtio2": "test:0,backup=0,format=raw,replicate=0"}, + output: map[string]interface{}{"virtio2": "test:0.001,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.VirtIO.Disk_X.Disk RESIZE DOWN Kibibyte File LinkedClone", currentConfig: ConfigQemu{ @@ -3046,7 +3046,7 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { SizeInKibibytes: 9437185, Storage: "test", }}}}}, - output: map[string]interface{}{"virtio2": "test:0,backup=0,format=raw,replicate=0"}, + output: map[string]interface{}{"virtio2": "test:0.001,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.VirtIO.Disk_X.Disk RESIZE DOWN Kibibyte Volume", currentConfig: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_2: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ @@ -3060,7 +3060,7 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { SizeInKibibytes: 9437185, Storage: "test", }}}}}, - output: map[string]interface{}{"virtio2": "test:0,backup=0,format=raw,replicate=0"}, + output: map[string]interface{}{"virtio2": "test:0.001,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.VirtIO.Disk_X.Disk RESIZE DOWN Kibibyte Volume LinkedClone", currentConfig: ConfigQemu{ @@ -3077,7 +3077,7 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { SizeInKibibytes: 9437185, Storage: "test", }}}}}, - output: map[string]interface{}{"virtio2": "test:0,backup=0,format=raw,replicate=0"}, + output: map[string]interface{}{"virtio2": "test:0.001,backup=0,format=raw,replicate=0"}, }, {name: "Update Disk.VirtIO.Disk_X.Disk RESIZE UP File", currentConfig: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_3: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ From 917baef1800c9e5d3e8f9c97e5aa50cd1523e2bd Mon Sep 17 00:00:00 2001 From: Tinyblargon <76069640+Tinyblargon@users.noreply.github.com> Date: Thu, 1 Feb 2024 09:29:32 +0000 Subject: [PATCH 9/9] feat: type `QemuDiskSize` --- proxmox/config_qemu_disk.go | 47 +++++++++++++++++++++++++----- proxmox/config_qemu_disk_ide.go | 4 +-- proxmox/config_qemu_disk_sata.go | 4 +-- proxmox/config_qemu_disk_scsi.go | 4 +-- proxmox/config_qemu_disk_virtio.go | 4 +-- proxmox/config_qemu_test.go | 38 ++++++++++++------------ proxmox/constants.go | 9 ------ proxmox/util.go | 15 ---------- 8 files changed, 67 insertions(+), 58 deletions(-) delete mode 100644 proxmox/constants.go diff --git a/proxmox/config_qemu_disk.go b/proxmox/config_qemu_disk.go index 90a861b0..5063787f 100644 --- a/proxmox/config_qemu_disk.go +++ b/proxmox/config_qemu_disk.go @@ -200,7 +200,7 @@ type qemuDisk struct { ReadOnly bool // Only set for scsi,virtio Replicate bool Serial QemuDiskSerial - SizeInKibibytes uint + SizeInKibibytes QemuDiskSize // TODO custom type Storage string // Only set for Disk Type qemuDiskType @@ -210,7 +210,6 @@ type qemuDisk struct { const ( Error_QemuDisk_File string = "file may not be empty" Error_QemuDisk_MutuallyExclusive string = "settings cdrom,cloudinit,disk,passthrough are mutually exclusive" - Error_QemuDisk_Size string = "size must be greater then 0" Error_QemuDisk_Storage string = "storage may not be empty" ) @@ -425,7 +424,7 @@ func (qemuDisk) mapToStruct(diskData string, settings map[string]interface{}, li disk.Serial = QemuDiskSerial(value.(string)) } if value, isSet := settings["size"]; isSet { - disk.SizeInKibibytes = kibibyteParse(value.(string)) + disk.SizeInKibibytes = QemuDiskSize(0).parse(value.(string)) } if value, isSet := settings["ssd"]; isSet { disk.EmulateSSD, _ = strconv.ParseBool(value.(string)) @@ -527,8 +526,8 @@ func (disk *qemuDisk) validate() (err error) { if err = disk.Format.Validate(); err != nil { return } - if disk.SizeInKibibytes == 0 { - return errors.New(Error_QemuDisk_Size) + if err = disk.SizeInKibibytes.Validate(); err != nil { + return } if disk.Storage == "" { return errors.New(Error_QemuDisk_Storage) @@ -790,7 +789,7 @@ func (id QemuDiskId) Validate() error { type qemuDiskMark struct { Format QemuDiskFormat Id QemuDiskId - Size uint + Size QemuDiskSize Storage string Type qemuDiskType } @@ -843,9 +842,43 @@ func (serial QemuDiskSerial) Validate() error { return nil } +// Amount of Kibibytes the disk should be. +// Disk size must be greater then 4096. +type QemuDiskSize uint + +const ( + QemuDiskSize_Error_Minimum string = "disk size must be greater then 4096" + qemuDiskSize_Minimum QemuDiskSize = 4097 + mebibyte QemuDiskSize = 1024 + gibibyte QemuDiskSize = 1048576 + tebibyte QemuDiskSize = 1073741824 +) + +func (QemuDiskSize) parse(rawSize string) (size QemuDiskSize) { + tmpSize, _ := strconv.ParseInt(rawSize[:len(rawSize)-1], 10, 0) + switch rawSize[len(rawSize)-1:] { + case "T": + size = QemuDiskSize(tmpSize) * tebibyte + case "G": + size = QemuDiskSize(tmpSize) * gibibyte + case "M": + size = QemuDiskSize(tmpSize) * mebibyte + case "K": + size = QemuDiskSize(tmpSize) + } + return +} + +func (size QemuDiskSize) Validate() error { + if size < qemuDiskSize_Minimum { + return errors.New(QemuDiskSize_Error_Minimum) + } + return nil +} + type qemuDiskResize struct { Id QemuDiskId - SizeInKibibytes uint + SizeInKibibytes QemuDiskSize } // Increase the disk size to the specified amount in gigabytes diff --git a/proxmox/config_qemu_disk_ide.go b/proxmox/config_qemu_disk_ide.go index 78c0c200..5c7541e9 100644 --- a/proxmox/config_qemu_disk_ide.go +++ b/proxmox/config_qemu_disk_ide.go @@ -17,7 +17,7 @@ type QemuIdeDisk struct { LinkedDiskId *uint `json:"linked"` //LinkedClone is only returned and setting it has no effect Replicate bool `json:"replicate"` Serial QemuDiskSerial `json:"serial,omitempty"` - SizeInKibibytes uint `json:"size"` + SizeInKibibytes QemuDiskSize `json:"size"` Storage string `json:"storage"` syntax diskSyntaxEnum WorldWideName QemuWorldWideName `json:"wwn"` @@ -178,7 +178,7 @@ type QemuIdePassthrough struct { File string `json:"file"` Replicate bool `json:"replicate"` Serial QemuDiskSerial `json:"serial,omitempty"` - SizeInKibibytes uint `json:"size"` //size is only returned and setting it has no effect + SizeInKibibytes QemuDiskSize `json:"size"` //size is only returned and setting it has no effect WorldWideName QemuWorldWideName `json:"wwn"` } diff --git a/proxmox/config_qemu_disk_sata.go b/proxmox/config_qemu_disk_sata.go index c09814ab..bc2473d1 100644 --- a/proxmox/config_qemu_disk_sata.go +++ b/proxmox/config_qemu_disk_sata.go @@ -17,7 +17,7 @@ type QemuSataDisk struct { LinkedDiskId *uint `json:"linked"` //LinkedClone is only returned and setting it has no effect Replicate bool `json:"replicate"` Serial QemuDiskSerial `json:"serial,omitempty"` - SizeInKibibytes uint `json:"size"` + SizeInKibibytes QemuDiskSize `json:"size"` Storage string `json:"storage"` syntax diskSyntaxEnum WorldWideName QemuWorldWideName `json:"wwn"` @@ -188,7 +188,7 @@ type QemuSataPassthrough struct { File string `json:"file"` Replicate bool `json:"replicate"` Serial QemuDiskSerial `json:"serial,omitempty"` - SizeInKibibytes uint `json:"size"` //size is only returned and setting it has no effect + SizeInKibibytes QemuDiskSize `json:"size"` //size is only returned and setting it has no effect WorldWideName QemuWorldWideName `json:"wwn"` } diff --git a/proxmox/config_qemu_disk_scsi.go b/proxmox/config_qemu_disk_scsi.go index dee7e271..f694f3fa 100644 --- a/proxmox/config_qemu_disk_scsi.go +++ b/proxmox/config_qemu_disk_scsi.go @@ -19,7 +19,7 @@ type QemuScsiDisk struct { ReadOnly bool `json:"readonly"` Replicate bool `json:"replicate"` Serial QemuDiskSerial `json:"serial,omitempty"` - SizeInKibibytes uint `json:"size"` + SizeInKibibytes QemuDiskSize `json:"size"` Storage string `json:"storage"` syntax diskSyntaxEnum WorldWideName QemuWorldWideName `json:"wwn"` @@ -344,7 +344,7 @@ type QemuScsiPassthrough struct { ReadOnly bool `json:"readonly"` Replicate bool `json:"replicate"` Serial QemuDiskSerial `json:"serial,omitempty"` - SizeInKibibytes uint `json:"size"` //size is only returned and setting it has no effect + SizeInKibibytes QemuDiskSize `json:"size"` //size is only returned and setting it has no effect WorldWideName QemuWorldWideName `json:"wwn"` } diff --git a/proxmox/config_qemu_disk_virtio.go b/proxmox/config_qemu_disk_virtio.go index d9bd7091..c86ea8cd 100644 --- a/proxmox/config_qemu_disk_virtio.go +++ b/proxmox/config_qemu_disk_virtio.go @@ -18,7 +18,7 @@ type QemuVirtIODisk struct { ReadOnly bool `json:"readonly"` Replicate bool `json:"replicate"` Serial QemuDiskSerial `json:"serial,omitempty"` - SizeInKibibytes uint `json:"size"` + SizeInKibibytes QemuDiskSize `json:"size"` Storage string `json:"storage"` syntax diskSyntaxEnum WorldWideName QemuWorldWideName `json:"wwn"` @@ -251,7 +251,7 @@ type QemuVirtIOPassthrough struct { ReadOnly bool `json:"readonly"` Replicate bool `json:"replicate"` Serial QemuDiskSerial `json:"serial,omitempty"` - SizeInKibibytes uint `json:"size"` //size is only returned and setting it has no effect + SizeInKibibytes QemuDiskSize `json:"size"` //size is only returned and setting it has no effect WorldWideName QemuWorldWideName `json:"wwn"` } diff --git a/proxmox/config_qemu_test.go b/proxmox/config_qemu_test.go index 819a1f06..886643fe 100644 --- a/proxmox/config_qemu_test.go +++ b/proxmox/config_qemu_test.go @@ -5949,7 +5949,7 @@ func Test_ConfigQemu_Validate(t *testing.T) { Bandwidth: BandwidthValid0, Cache: QemuDiskCache_DirectSync, Format: QemuDiskFormat_Raw, - SizeInKibibytes: 32, + SizeInKibibytes: 5748543, Storage: "test", WorldWideName: "0x500A1B2C3D4E5F60", }}}, @@ -5958,7 +5958,7 @@ func Test_ConfigQemu_Validate(t *testing.T) { Bandwidth: BandwidthValid1, Cache: QemuDiskCache_None, Format: QemuDiskFormat_Cow, - SizeInKibibytes: 1, + SizeInKibibytes: 4097, Storage: "test", WorldWideName: "0x500F123456789ABC", }}}, @@ -5967,7 +5967,7 @@ func Test_ConfigQemu_Validate(t *testing.T) { Bandwidth: BandwidthValid2, Cache: QemuDiskCache_WriteBack, Format: QemuDiskFormat_Qcow2, - SizeInKibibytes: 10, + SizeInKibibytes: 9475478, Storage: "test", WorldWideName: "0x5009876543210DEF", }}}, @@ -5976,7 +5976,7 @@ func Test_ConfigQemu_Validate(t *testing.T) { Bandwidth: BandwidthValid3, Cache: "", Format: QemuDiskFormat_Vmdk, - SizeInKibibytes: 1024, + SizeInKibibytes: 18742, Storage: "test", WorldWideName: "0x500C0D0E0F101112", }}}, @@ -6581,17 +6581,17 @@ func Test_ConfigQemu_Validate(t *testing.T) { }}}}}, err: errors.New(Error_QemuDiskSerial_IllegalLength), }, - {name: `Invalid Disks Disk Ide errors.New(Error_QemuDisk_Size)`, + {name: `Invalid Disks Disk Ide errors.New(QemuDiskSize_Error_Minimum)`, input: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_2: &QemuIdeStorage{Disk: &QemuIdeDisk{ Format: QemuDiskFormat_Raw, - SizeInKibibytes: 0, + SizeInKibibytes: 4096, }}}}}, - err: errors.New(Error_QemuDisk_Size), + err: errors.New(QemuDiskSize_Error_Minimum), }, {name: `Invalid Disks Disk Ide errors.New(Error_QemuDisk_Storage)`, input: ConfigQemu{Disks: &QemuStorages{Ide: &QemuIdeDisks{Disk_3: &QemuIdeStorage{Disk: &QemuIdeDisk{ Format: QemuDiskFormat_Raw, - SizeInKibibytes: 32, + SizeInKibibytes: qemuDiskSize_Minimum, Storage: "", }}}}}, err: errors.New(Error_QemuDisk_Storage), @@ -6668,17 +6668,17 @@ func Test_ConfigQemu_Validate(t *testing.T) { }}}}}, err: errors.New(Error_QemuDiskSerial_IllegalLength), }, - {name: `Invalid Disks Disk Sata errors.New(Error_QemuDisk_Size)`, + {name: `Invalid Disks Disk Sata errors.New(QemuDiskSize_Error_Minimum)`, input: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_2: &QemuSataStorage{Disk: &QemuSataDisk{ Format: QemuDiskFormat_Raw, - SizeInKibibytes: 0, + SizeInKibibytes: 4096, }}}}}, - err: errors.New(Error_QemuDisk_Size), + err: errors.New(QemuDiskSize_Error_Minimum), }, {name: `Invalid Disks Disk Sata errors.New(Error_QemuDisk_Storage)`, input: ConfigQemu{Disks: &QemuStorages{Sata: &QemuSataDisks{Disk_3: &QemuSataStorage{Disk: &QemuSataDisk{ Format: QemuDiskFormat_Raw, - SizeInKibibytes: 32, + SizeInKibibytes: qemuDiskSize_Minimum, Storage: "", }}}}}, err: errors.New(Error_QemuDisk_Storage), @@ -6755,17 +6755,17 @@ func Test_ConfigQemu_Validate(t *testing.T) { }}}}}, err: errors.New(Error_QemuDiskSerial_IllegalLength), }, - {name: `Invalid Disks Disk Scsi errors.New(Error_QemuDisk_Size)`, + {name: `Invalid Disks Disk Scsi errors.New(QemuDiskSize_Error_Minimum)`, input: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_14: &QemuScsiStorage{Disk: &QemuScsiDisk{ Format: QemuDiskFormat_Raw, SizeInKibibytes: 0, }}}}}, - err: errors.New(Error_QemuDisk_Size), + err: errors.New(QemuDiskSize_Error_Minimum), }, {name: `Invalid Disks Disk Scsi errors.New(Error_QemuDisk_Storage)`, input: ConfigQemu{Disks: &QemuStorages{Scsi: &QemuScsiDisks{Disk_15: &QemuScsiStorage{Disk: &QemuScsiDisk{ Format: QemuDiskFormat_Raw, - SizeInKibibytes: 32, + SizeInKibibytes: qemuDiskSize_Minimum, Storage: "", }}}}}, err: errors.New(Error_QemuDisk_Storage), @@ -6842,17 +6842,17 @@ func Test_ConfigQemu_Validate(t *testing.T) { }}}}}, err: errors.New(Error_QemuDiskSerial_IllegalLength), }, - {name: `Invalid Disks Disk VirtIO errors.New(Error_QemuDisk_Size)`, + {name: `Invalid Disks Disk VirtIO errors.New(QemuDiskSize_Error_Minimum)`, input: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_14: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ Format: QemuDiskFormat_Raw, - SizeInKibibytes: 0, + SizeInKibibytes: 1024, }}}}}, - err: errors.New(Error_QemuDisk_Size), + err: errors.New(QemuDiskSize_Error_Minimum), }, {name: `Invalid Disks Disk VirtIO errors.New(Error_QemuDisk_Storage)`, input: ConfigQemu{Disks: &QemuStorages{VirtIO: &QemuVirtIODisks{Disk_15: &QemuVirtIOStorage{Disk: &QemuVirtIODisk{ Format: QemuDiskFormat_Raw, - SizeInKibibytes: 32, + SizeInKibibytes: qemuDiskSize_Minimum, Storage: "", }}}}}, err: errors.New(Error_QemuDisk_Storage), diff --git a/proxmox/constants.go b/proxmox/constants.go deleted file mode 100644 index 1c334f69..00000000 --- a/proxmox/constants.go +++ /dev/null @@ -1,9 +0,0 @@ -package proxmox - -// Constants that are not explicitly related to a specific type go here. - -const ( - mebibyte uint = 1024 - gibibyte uint = 1048576 - tebibyte uint = 1073741824 -) diff --git a/proxmox/util.go b/proxmox/util.go index 106a4f34..e39fefe8 100644 --- a/proxmox/util.go +++ b/proxmox/util.go @@ -234,21 +234,6 @@ func floatToTrimmedString(f float64, maxDecimals uint8) (s string) { return } -func kibibyteParse(rawSize string) (size uint) { - tmpSize, _ := strconv.ParseInt(rawSize[:len(rawSize)-1], 10, 0) - switch rawSize[len(rawSize)-1:] { - case "T": - size = uint(tmpSize) * tebibyte - case "G": - size = uint(tmpSize) * gibibyte - case "M": - size = uint(tmpSize) * mebibyte - case "K": - size = uint(tmpSize) - } - return -} - func splitStringOfSettings(settings string) map[string]interface{} { settingValuePairs := strings.Split(settings, ",") settingMap := map[string]interface{}{}