Commit Graph
5 Commits
Author SHA1 Message Date
dualfroz 467e6d641e fix #6389: api: disks: zfs: parse the message of hot spares in use
Hot spares have no error counters in the output of 'zpool status', so a
spare that is in use only has a message after its state:

  nvme10n1      INUSE     currently in use

The parser took the three words of that message as READ, WRITE and
CKSUM counters, so the API returned zero for all of them and lost the
message, while logging warnings like:

  Argument "currently" isn't numeric in addition (+)

As 'zpool status' is called with '-p', the counters are always plain
numbers, so only accept digits for them. This way, the message of a
spare in use ends up in 'msg', like for any other vdev.

Signed-off-by: Michal Fox <me@dualfroz.com>
2026-10-02 16:17:54 +02:00
dualfroz 6320a3a111 fix #6640, #6938: api: disks: zfs: return exact error counters
Without '-p', 'zpool status' shortens the READ, WRITE and CKSUM counters
of a vdev to a value with a unit suffix once they reach 1024, for
example 1130 read errors are shown as '1.10K'. The parser just adds
zero to those values, so the API returned 1.1 read errors in that case
and logged a warning like:

  Argument "1.10K" isn't numeric in addition (+)

Request exact values with '-p'. For the non-JSON output of 'zpool
status' it only affects those counters, the sizes in the scan line stay
human readable.

Signed-off-by: Michal Fox <me@dualfroz.com>
2026-10-02 16:15:39 +02:00
dualfroz ab748c8530 test: add tests for zpool status parsing of the ZFS disk API
The detail call of the ZFS disk API parses the output of 'zpool status'
into the vdev tree of a pool. Add a test for it, which mocks the zpool
command and checks the result for a healthy pool with log, cache and
spare devices, so that fixes for the parser can extend it with their
cases.

Signed-off-by: Michal Fox <me@dualfroz.com>
2026-10-02 16:14:52 +02:00
dualfroz 9f20cd4f75 fix #5998: import: avoid duplicate disk keys with multiple controllers
The disk key is built from the controller type and the address of the
disk on that controller. The address is only unique per controller, so
with more than one controller of the same type, like a VM with more than
16 disks spread over two SCSI controllers, several disks got the same
key. 'qm importovf' then failed with "cowardly refusing to overwrite
existing entry: scsi0", and the import wizard silently dropped all but
one of those disks, as they are stored in a hash by key.

Keep the address for the first disk using it and move any further disk
with the same address to the lowest address of that bus that is not
used by any other disk.

Add a test manifest with a second SCSI controller.

Signed-off-by: Michal Fox <me@dualfroz.com>
2026-09-25 11:38:19 +02:00
dualfroz 43d4bbbdb2 fix #6969: plugin: keep content directory when freeing its last file
After removing a volume, free_image tries to remove the parent
directory, so that no empty per-guest directories are left behind once
all images of a guest are gone. This was done unconditionally, so
deleting the last ISO, container template, snippet or import file also
removed the shared content directory like 'snippets' or 'template/iso'.

The directory gets re-created shortly after by pvestatd, but as
root:root with default permissions, losing any ownership or mode that
the admin set up, for example to allow a non-root user to upload
snippets.

Only clean up the parent directory for guest images, which are the only
volumes stored in per-guest directories.

Signed-off-by: Michal Fox <me@dualfroz.com>
2026-09-25 11:30:43 +02:00