[GH-ISSUE #380] Re-implement: Qemu Unused Disks #96

Open
opened 2026-02-28 00:40:33 +03:00 by kerem · 2 comments
Owner

Originally created by @Tinyblargon on GitHub (Nov 24, 2024).
Original GitHub issue: https://github.com/Telmate/proxmox-api-go/issues/380

Requirements:

  • UnusedDisks should use the structure specified below (some deviations might be needed).
  • When the disk is missing no action will be taken for it.
  • When all properties of the disk are nil or delete = false no action will be taken
  • Deleting a disks that do not exists should be ignored.
  • Updating disks that do not exist should return an error during the Validation phase.
  • Delete takes precedence over the other settings.

Some known unknowns about the implementation:

  • Can we ignore unused disks during initial vm creation?
  • Can we ignore unused disks after a clone, will unused disks get cloned?

The UnusedDisks structure:

type QemuUnusedDisks map[QemuUnusedDiskID]QemuUnusedDisk

func (config QemuUnusedDisks) mapToApi(current QemuUnusedDisk, params map[string]any) { }

func (config QemuUnusedDisks) Validate() error {
// calls QemuUnusedDiskID.Validate() for every item
// calls QemuUnusedDisk.Validate() for every item
}

type QemuUnusedDisk struct {
	Delete  bool            `json:"delete"`
	Storage *string         `json:"storage,omitempty"` // Changing migrates the disk to a different storage
	Format  *QemuDiskFormat `json:"format,omitempty"`  // Changing the format of the disk
}

func (config QemuUnusedDisk) Validate() error { }

// specify valid range of the id
type QemuUnusedDiskID uint8

func (id QemuUnusedDiskID) Validate() error { }
Originally created by @Tinyblargon on GitHub (Nov 24, 2024). Original GitHub issue: https://github.com/Telmate/proxmox-api-go/issues/380 Requirements: - `UnusedDisks` should use the structure specified below (some deviations might be needed). - When the disk is missing no action will be taken for it. - When all properties of the disk are `nil` or `delete = false` no action will be taken - Deleting a disks that do not exists should be ignored. - Updating disks that do not exist should return an error during the Validation phase. - Delete takes precedence over the other settings. Some known unknowns about the implementation: - Can we ignore unused disks during initial vm creation? - Can we ignore unused disks after a clone, will unused disks get cloned? The `UnusedDisks` structure: ```go type QemuUnusedDisks map[QemuUnusedDiskID]QemuUnusedDisk func (config QemuUnusedDisks) mapToApi(current QemuUnusedDisk, params map[string]any) { } func (config QemuUnusedDisks) Validate() error { // calls QemuUnusedDiskID.Validate() for every item // calls QemuUnusedDisk.Validate() for every item } type QemuUnusedDisk struct { Delete bool `json:"delete"` Storage *string `json:"storage,omitempty"` // Changing migrates the disk to a different storage Format *QemuDiskFormat `json:"format,omitempty"` // Changing the format of the disk } func (config QemuUnusedDisk) Validate() error { } // specify valid range of the id type QemuUnusedDiskID uint8 func (id QemuUnusedDiskID) Validate() error { } ```
Author
Owner

@angyaljanos commented on GitHub (Jun 24, 2025):

Hello @Tinyblargon!
If this issue is still open i would like to start work on it.
Can you explain the fields in a little more detail? The current version separates the the volume name, the file of the unused disk and the numerical id of the unused disk, if get that correct.

finalDiskConfMap["slot"] = diskID
finalDiskConfMap["storage"] = storage
NamefinalDiskConfMap["file"] = fileName

Also do you know why is the following line repeated 3 times:

config.QemuUnusedDisks[diskID] = finalDiskConfMap
<!-- gh-comment-id:3000686014 --> @angyaljanos commented on GitHub (Jun 24, 2025): Hello @Tinyblargon! If this issue is still open i would like to start work on it. Can you explain the fields in a little more detail? The current version separates the the volume name, the file of the unused disk and the numerical id of the unused disk, if get that correct. ```go finalDiskConfMap["slot"] = diskID finalDiskConfMap["storage"] = storage NamefinalDiskConfMap["file"] = fileName ``` Also do you know why is the following line repeated 3 times: ```go config.QemuUnusedDisks[diskID] = finalDiskConfMap ```
Author
Owner

@Tinyblargon commented on GitHub (Jun 24, 2025):

@angyaljanos It's still open.
Honestly I'm not too sure about the current implementation.

The current version forces the user to know these "slot", "storage", "file". The idea is to put them in an object instead.
It exposes the finalDiskConfMap to the user of this library, which is bad.
The current implementation is also missing tests.

The idea is that the new version will be a map indexed by the disks numerical id/slot. The index type will have a comment explaining it's range.

I'll update the original post with a better picture of the requirements.

<!-- gh-comment-id:3000904156 --> @Tinyblargon commented on GitHub (Jun 24, 2025): @angyaljanos It's still open. Honestly I'm not too sure about the current implementation. The current version forces the user to know these `"slot"`, `"storage"`, `"file"`. The idea is to put them in an object instead. It exposes the `finalDiskConfMap` to the user of this library, which is bad. The current implementation is also missing tests. The idea is that the new version will be a map indexed by the disks numerical id/slot. The index type will have a comment explaining it's range. I'll update the original post with a better picture of the requirements.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/proxmox-api-go#96
No description provided.