On Fri, Apr 08, 2022 at 05:00:07PM +0200, Laszlo Ersek wrote:
On 04/08/22 13:11, Richard W.M. Jones wrote:
> +(* Find all NVMe hard disks.
> + *
> + * In the VMX file:
> + * nvme0.pcislotnumber = "192"
> + * nvme0:0.fileName = "guest.vmdk"
> + *)
> +and find_nvme_disks vmx vmx_source =
> + let get_nvme_controller_target ns =
> + sscanf ns "nvme%d:%d" (fun c t -> c, t)
Did we just get lucky here that the NVMe naming scheme (device,
namespace) happens to map quite cleanly to our internal (controller,
target) scheme?
I mean if there weren't namespaces, we could still use
sscanf ns "nvme%d" (fun c -> c, 0)
buf if there were *more* than two components in the NVMe identifier,
we'd be in some trouble, would we not?
(Now I think I understand we don't actually map the "target" we parse
here back to a namespace, near the top of the patch; just asking about
the internal tuple structure the existing disk collection code expects.
... More precisely, I think the namespace information is lost when we
sort and renumber near the end of "find_hdds".)
I only have an example of a guest with a single NVMe drive, so I've no
idea how the second one would be named. But if it's the same as the
SCSI examples then it'll be "nvme0:0", "nvme0:1", through
"nvme0:15",
then "nvme1:0", "nvme1:1", etc. I don't know what the numbers
precisely mean.
The only thing we use the 'c' and 't' numbers for is to order the
disks, since the entries do not appear in order in the .vmx file.
So really we don't care what the numbers are (but we do need to parse
them as simple string sorting wouldn't work, because "scsi10:0" <
"scsi1:0"). We only need the number of disks and their original
order. The original namespace info is indeed lost.
We will create the same number of virtio-blk devices on the target,
and copy them in the same order.
There's probably a lot of room for improvement here ...
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v