On 04/14/22 17:40, Richard W.M. Jones wrote:
> On Thu, Apr 14, 2022 at 05:07:29PM +0200, Laszlo Ersek wrote:

>> +    let add_virtio_blk disk_id frontend_ctr =
>> +      (* Create a "virtio-blk-pci" device (front-end), together with its 
>> drive
>> +       * (back-end). The disk identifier is mandatory.
>> +       *)
>> +      let backend_name = sprintf "drive-vblk-%d" frontend_ctr in
> 
> If you just need a source of unique numbers you can use “unique ()”
> (from Std_utils).  A possible issue with this is that you won't get
> the same output on every run, especially if something unrelated inside
> virt-v2v changes, but that probably doesn't matter here.  Especially
> since we are printing the process ID in the output already, so that
> ship has sailed.
> 
> This means you wouldn't need to call Array.iteri below.

I prefer sticking with Array.iteri: "frontend_ctr" is used in various
front-end properties, such as the primary/secondary master/slave
placement on (i440fx) IDE, the (q35) SATA port selection, the LUNs for
scsi-cd / scsi-hd, the unit number for floppies; so "frontend_ctr"
should iterate over consecutive, and small, integers.

Thanks!
Laszlo
_______________________________________________
Libguestfs mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/libguestfs

Reply via email to