One thought in comparing MHVTL device assignment to real libraries - With a real library, one tape device is always the master and it uses a serial connection (ADI) to connect the library as a LUN. This means that the master, or 0th tape device in the library will always be first device, LUN 0 and the library head will be the same pSCSI/SAS/FC device, but assigned to LUN 1. If you partition the library, the 0th drive assigned to the partition takes on that same role.
Currently in MHVTL, things are reversed. The library head is getting the LUN 0 assignment and the 0th tape drive is getting the LUN 1 assignment. While this is not a disaster, it is odd if you are working with a diagnostic tool that expects the live order.
I've looked at the generators and can't see a way to set the order of the devices generated when the target is enabled and started. Is this possible there, or do we need a core code change?
It appears that the old pSCSI rule of higher ID = higher priority is still being observed in the Linux kernel.
Therefore, Your should order the ID field by the order in which you want to virtual drives assigned in the kernel.
Therefore, to force the "lower," or management drive to be ST0, be sure to set it and the library to a higher ID than the second and later drives. Notice belowe that the drive at TARGET: 07 will be /dev/nst0 and the drive at TARGET: 00 will be /dev/nst1: