common/options: Change drv struct to store drive index instead of device name.

The device name is only used by guestfish (when using the -N option to
prepare drives).  We constructed the device name very naively,
basically ‘sprintf ("/dev/sd%c", next_drive)’.

This stores the device index instead, and only constructs the device
name in guestfish.  Also the device name is constructed properly using
guestfs_int_drive_name so it can cope with #drives > 26.

As a side effect of this change we can remove the extra parameter of
the add_drives macro.

Thanks: Pino Toscano
This commit is contained in:
Richard W.M. Jones
2017-04-28 09:59:23 +01:00
parent b168147834
commit 8c9a4bc84f
17 changed files with 42 additions and 51 deletions

View File

@@ -249,7 +249,7 @@ main (int argc, char *argv[])
const char *wipefs[] = { "wipefs", NULL };
/* Add domains/drives from the command line (for a single guest). */
add_drives (drvs, 'a');
add_drives (drvs);
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);