diff --git a/src/PVE/API2/Disks/ZFS.pm b/src/PVE/API2/Disks/ZFS.pm index b26805a..2215dd6 100644 --- a/src/PVE/API2/Disks/ZFS.pm +++ b/src/PVE/API2/Disks/ZFS.pm @@ -245,7 +245,7 @@ __PACKAGE__->register_method({ $config = 1; } elsif ( $config - && $line =~ m/^(\s+)(\S+)\s*(\S+)?(?:\s+(\S+)\s+(\S+)\s+(\S+))?\s*(.*)$/ + && $line =~ m/^(\s+)(\S+)\s*(\S+)?(?:\s+(\d+)\s+(\d+)\s+(\d+))?\s*(.*)$/ ) { my ($space, $name, $state, $read, $write, $cksum, $msg) = ($1, $2, $3, $4, $5, $6, $7); diff --git a/src/test/zfs_pool_detail_test.pm b/src/test/zfs_pool_detail_test.pm index 00d666a..bcca5ae 100644 --- a/src/test/zfs_pool_detail_test.pm +++ b/src/test/zfs_pool_detail_test.pm @@ -225,6 +225,109 @@ EOF ], }, }, + { + description => 'hot spare in use', + status => <<"EOF", + pool: tank + state: ONLINE + scan: resilvered 725M in 00:00:00 with 0 errors on Mon May 12 16:50:25 2025 +config: + +\tNAME STATE READ WRITE CKSUM +\ttank ONLINE 0 0 0 +\t mirror-0 ONLINE 0 0 0 +\t spare-0 ONLINE 0 0 0 +\t /dev/disk/by-id/ata-DISK_A-part1 ONLINE 0 0 0 +\t /dev/disk/by-id/ata-DISK_C-part1 ONLINE 0 0 0 +\t /dev/disk/by-id/ata-DISK_B-part1 ONLINE 0 0 0 +\tspares +\t /dev/disk/by-id/ata-DISK_C-part1 INUSE currently in use + +errors: No known data errors +EOF + expected => { + name => 'tank', + state => 'ONLINE', + scan => 'resilvered 725M in 00:00:00 with 0 errors on Mon May 12 16:50:25 2025', + errors => 'No known data errors', + leaf => 0, + children => [ + { + name => 'tank', + state => 'ONLINE', + read => 0, + write => 0, + cksum => 0, + msg => '', + leaf => 0, + children => [ + { + name => 'mirror-0', + state => 'ONLINE', + read => 0, + write => 0, + cksum => 0, + msg => '', + leaf => 0, + children => [ + { + name => 'spare-0', + state => 'ONLINE', + read => 0, + write => 0, + cksum => 0, + msg => '', + leaf => 0, + children => [ + { + name => '/dev/disk/by-id/ata-DISK_A-part1', + state => 'ONLINE', + read => 0, + write => 0, + cksum => 0, + msg => '', + leaf => 1, + }, + { + name => '/dev/disk/by-id/ata-DISK_C-part1', + state => 'ONLINE', + read => 0, + write => 0, + cksum => 0, + msg => '', + leaf => 1, + }, + ], + }, + { + name => '/dev/disk/by-id/ata-DISK_B-part1', + state => 'ONLINE', + read => 0, + write => 0, + cksum => 0, + msg => '', + leaf => 1, + }, + ], + }, + ], + }, + { + name => 'spares', + msg => '', + leaf => 0, + children => [ + { + name => '/dev/disk/by-id/ata-DISK_C-part1', + state => 'INUSE', + msg => 'currently in use', + leaf => 1, + }, + ], + }, + ], + }, + }, ]; plan tests => scalar @$tests;