The OVF parser only looks at disk drives, so the CD drives of a guest
are dropped on import. Appliances shipped as OVA sometimes come with
an ISO image in a CD drive, for example to install the guest on first
boot. Such a guest then does not boot after the import, and the user
is not told about the image at all.
Add the CD drives of the manifest as empty drives on their controller,
after the disks in the boot order, like the ESXi import does. As CD
images cannot be imported, report a referenced image with the existing
'cdrom-image-ignored' warning, so that the import wizard tells the user
to configure the drive in the 'Advanced' tab.
As the address only takes the position on the controller into account,
a CD drive can end up with the address of a disk, for example with a
disk on the first IDE controller and the CD drive on the second one.
Such a CD drive gets the next free address on its bus.
Signed-off-by: Michal Fox <me@dualfroz.com>
In its brief output format, smartctl prints the attribute flags as six
characters, followed by a seventh one which is a '+' if any other flag
bits are set and a space otherwise, for example:
5 Reallocated_Sector_Ct ------+ 100 100 050 - 0
The regex for the ATA attributes only accepted exactly six non-space
characters for the flags, so such attribute lines were skipped. For
drives that set those other bits on all attributes, like the SATA SSD
from the bug report, no SMART attributes showed up at all and the
wearout could not be determined either.
Accept an optional '+' after the flags and add the output from the
bug report as test case.
Signed-off-by: Michal Fox <me@dualfroz.com>
Cloning a template with a disk image that is neither raw nor a
subvolume, for example a qcow2 image, failed on a BTRFS storage with:
clone failed: Undefined subroutine &PVE::Storage::DirPlugin::clone_image called
For such images, the BTRFS plugin forwards the call to the DirPlugin.
But the DirPlugin does not implement clone_image itself, it inherits it
from the base plugin, and calling it as a plain function does not go
through the inheritance.
Call the implementation of the base plugin directly instead, like it is
already done for create_base.
Fixes: af50c2e ("add BTRFS storage plugin")
Signed-off-by: Michal Fox <me@dualfroz.com>
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>
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>
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>
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>
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>