vmspawn: use qemu_device_driver_to_string() in resolve_disk_driver
Drop the inline DiskType → QEMU device driver switch and call the shared helper instead. serial_max and the CD-ROM read-only flag stay inline since they are vmspawn-local. Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
This commit is contained in:
@@ -2273,7 +2273,6 @@ static int qemu_config_add_qmp_monitor(FILE *config_file, int bridge_fds[2], int
|
||||
}
|
||||
|
||||
static int resolve_disk_driver(DiskType dt, const char *filename, DriveInfo *info) {
|
||||
const char *driver;
|
||||
size_t serial_max;
|
||||
int r;
|
||||
|
||||
@@ -2282,19 +2281,15 @@ static int resolve_disk_driver(DiskType dt, const char *filename, DriveInfo *inf
|
||||
|
||||
switch (dt) {
|
||||
case DISK_TYPE_VIRTIO_BLK:
|
||||
driver = "virtio-blk-pci";
|
||||
serial_max = DISK_SERIAL_MAX_LEN_VIRTIO_BLK;
|
||||
break;
|
||||
case DISK_TYPE_VIRTIO_SCSI:
|
||||
driver = "scsi-hd";
|
||||
serial_max = DISK_SERIAL_MAX_LEN_SCSI;
|
||||
break;
|
||||
case DISK_TYPE_NVME:
|
||||
driver = "nvme";
|
||||
serial_max = DISK_SERIAL_MAX_LEN_NVME;
|
||||
break;
|
||||
case DISK_TYPE_VIRTIO_SCSI_CDROM:
|
||||
driver = "scsi-cd";
|
||||
serial_max = DISK_SERIAL_MAX_LEN_SCSI;
|
||||
info->flags |= QMP_DRIVE_READ_ONLY;
|
||||
break;
|
||||
@@ -2302,7 +2297,7 @@ static int resolve_disk_driver(DiskType dt, const char *filename, DriveInfo *inf
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
info->disk_driver = strdup(driver);
|
||||
info->disk_driver = strdup(ASSERT_PTR(qemu_device_driver_to_string(dt)));
|
||||
if (!info->disk_driver)
|
||||
return log_oom();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user