mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-13 17:18:01 +03:00
conf: domain: Convert virDomainDiskDef's 'bus' to virDomainDiskBus
Use the appropriate type for the variable and refactor the XML parser to parse it correctly using virXMLPropEnum. Changes to other places using switch statements were required. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
1db5a84bdc
commit
0d7f0fe81a
@ -309,6 +309,15 @@ bhyveBuildDiskArgStr(const virDomainDef *def,
|
||||
if (bhyveBuildVirtIODiskArgStr(def, disk, cmd) < 0)
|
||||
return -1;
|
||||
break;
|
||||
case VIR_DOMAIN_DISK_BUS_SCSI:
|
||||
case VIR_DOMAIN_DISK_BUS_IDE:
|
||||
case VIR_DOMAIN_DISK_BUS_FDC:
|
||||
case VIR_DOMAIN_DISK_BUS_NONE:
|
||||
case VIR_DOMAIN_DISK_BUS_XEN:
|
||||
case VIR_DOMAIN_DISK_BUS_USB:
|
||||
case VIR_DOMAIN_DISK_BUS_UML:
|
||||
case VIR_DOMAIN_DISK_BUS_SD:
|
||||
case VIR_DOMAIN_DISK_BUS_LAST:
|
||||
default:
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("unsupported disk device"));
|
||||
|
@ -133,6 +133,18 @@ bhyveDomainDiskDefAssignAddress(struct _bhyveConn *driver,
|
||||
|
||||
def->info.addr.drive.bus = 0;
|
||||
break;
|
||||
case VIR_DOMAIN_DISK_BUS_SCSI:
|
||||
case VIR_DOMAIN_DISK_BUS_IDE:
|
||||
case VIR_DOMAIN_DISK_BUS_FDC:
|
||||
case VIR_DOMAIN_DISK_BUS_NONE:
|
||||
case VIR_DOMAIN_DISK_BUS_VIRTIO:
|
||||
case VIR_DOMAIN_DISK_BUS_XEN:
|
||||
case VIR_DOMAIN_DISK_BUS_USB:
|
||||
case VIR_DOMAIN_DISK_BUS_UML:
|
||||
case VIR_DOMAIN_DISK_BUS_SD:
|
||||
case VIR_DOMAIN_DISK_BUS_LAST:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -7874,6 +7874,13 @@ virDomainDiskDefAssignAddress(virDomainXMLOption *xmlopt,
|
||||
def->info.addr.drive.unit = idx % 2;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DISK_BUS_NONE:
|
||||
case VIR_DOMAIN_DISK_BUS_VIRTIO:
|
||||
case VIR_DOMAIN_DISK_BUS_XEN:
|
||||
case VIR_DOMAIN_DISK_BUS_USB:
|
||||
case VIR_DOMAIN_DISK_BUS_UML:
|
||||
case VIR_DOMAIN_DISK_BUS_SD:
|
||||
case VIR_DOMAIN_DISK_BUS_LAST:
|
||||
default:
|
||||
/* Other disk bus's aren't controller based */
|
||||
break;
|
||||
@ -9314,7 +9321,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
|
||||
bool source = false;
|
||||
g_autofree char *tmp = NULL;
|
||||
g_autofree char *target = NULL;
|
||||
g_autofree char *bus = NULL;
|
||||
g_autofree char *serial = NULL;
|
||||
g_autofree char *logical_block_size = NULL;
|
||||
g_autofree char *physical_block_size = NULL;
|
||||
@ -9375,7 +9381,11 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
|
||||
} else if (!target &&
|
||||
virXMLNodeNameEqual(cur, "target")) {
|
||||
target = virXMLPropString(cur, "dev");
|
||||
bus = virXMLPropString(cur, "bus");
|
||||
if (virXMLPropEnum(cur, "bus",
|
||||
virDomainDiskBusTypeFromString,
|
||||
VIR_XML_PROP_OPTIONAL | VIR_XML_PROP_NONZERO,
|
||||
&def->bus) < 0)
|
||||
return NULL;
|
||||
if (virXMLPropEnum(cur, "tray", virDomainDiskTrayTypeFromString,
|
||||
VIR_XML_PROP_OPTIONAL, &def->tray_status) < 0)
|
||||
return NULL;
|
||||
@ -9462,14 +9472,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
|
||||
}
|
||||
}
|
||||
|
||||
if (bus) {
|
||||
if ((def->bus = virDomainDiskBusTypeFromString(bus)) <= 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("unknown disk bus type '%s'"), bus);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (rotation_rate &&
|
||||
virStrToLong_ui(rotation_rate, NULL, 10, &def->rotation_rate) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
@ -30042,6 +30044,10 @@ virDiskNameToBusDeviceIndex(virDomainDiskDef *disk,
|
||||
case VIR_DOMAIN_DISK_BUS_VIRTIO:
|
||||
case VIR_DOMAIN_DISK_BUS_XEN:
|
||||
case VIR_DOMAIN_DISK_BUS_SD:
|
||||
case VIR_DOMAIN_DISK_BUS_NONE:
|
||||
case VIR_DOMAIN_DISK_BUS_SATA:
|
||||
case VIR_DOMAIN_DISK_BUS_UML:
|
||||
case VIR_DOMAIN_DISK_BUS_LAST:
|
||||
default:
|
||||
*busIdx = 0;
|
||||
*devIdx = idx;
|
||||
|
@ -536,7 +536,7 @@ struct _virDomainDiskDef {
|
||||
virObject *privateData;
|
||||
|
||||
int device; /* enum virDomainDiskDevice */
|
||||
int bus; /* enum virDomainDiskBus */
|
||||
virDomainDiskBus bus;
|
||||
char *dst;
|
||||
virDomainDiskTray tray_status;
|
||||
virTristateSwitch removable;
|
||||
|
@ -961,6 +961,14 @@ hypervDomainAttachStorage(virDomainPtr domain, virDomainDef *def, const char *ho
|
||||
if (hypervDomainAttachFloppy(domain, def->disks[i], floppySettings, hostname) < 0)
|
||||
return -1;
|
||||
break;
|
||||
case VIR_DOMAIN_DISK_BUS_NONE:
|
||||
case VIR_DOMAIN_DISK_BUS_VIRTIO:
|
||||
case VIR_DOMAIN_DISK_BUS_XEN:
|
||||
case VIR_DOMAIN_DISK_BUS_USB:
|
||||
case VIR_DOMAIN_DISK_BUS_UML:
|
||||
case VIR_DOMAIN_DISK_BUS_SATA:
|
||||
case VIR_DOMAIN_DISK_BUS_SD:
|
||||
case VIR_DOMAIN_DISK_BUS_LAST:
|
||||
default:
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unsupported controller type"));
|
||||
return -1;
|
||||
@ -3108,6 +3116,14 @@ hypervDomainAttachDeviceFlags(virDomainPtr domain, const char *xml, unsigned int
|
||||
if (!entry)
|
||||
return -1;
|
||||
break;
|
||||
case VIR_DOMAIN_DISK_BUS_NONE:
|
||||
case VIR_DOMAIN_DISK_BUS_VIRTIO:
|
||||
case VIR_DOMAIN_DISK_BUS_XEN:
|
||||
case VIR_DOMAIN_DISK_BUS_USB:
|
||||
case VIR_DOMAIN_DISK_BUS_UML:
|
||||
case VIR_DOMAIN_DISK_BUS_SATA:
|
||||
case VIR_DOMAIN_DISK_BUS_SD:
|
||||
case VIR_DOMAIN_DISK_BUS_LAST:
|
||||
default:
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid disk bus in definition"));
|
||||
return -1;
|
||||
|
@ -2755,6 +2755,9 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDomainDiskDef *disk,
|
||||
|
||||
case VIR_DOMAIN_DISK_BUS_XEN:
|
||||
case VIR_DOMAIN_DISK_BUS_SD:
|
||||
case VIR_DOMAIN_DISK_BUS_NONE:
|
||||
case VIR_DOMAIN_DISK_BUS_UML:
|
||||
case VIR_DOMAIN_DISK_BUS_LAST:
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -595,7 +595,7 @@ prlsdkAddDomainVideoInfoVm(PRL_HANDLE sdkdom, virDomainDef *def)
|
||||
}
|
||||
|
||||
static int
|
||||
prlsdkGetDiskId(PRL_HANDLE disk, int *bus, char **dst)
|
||||
prlsdkGetDiskId(PRL_HANDLE disk, virDomainDiskBus *bus, char **dst)
|
||||
{
|
||||
PRL_RESULT pret;
|
||||
PRL_UINT32 pos, ifType;
|
||||
@ -1624,7 +1624,7 @@ prlsdkBootOrderCheck(PRL_HANDLE sdkdom, PRL_DEVICE_TYPE sdkType, int sdkIndex,
|
||||
PRL_HANDLE dev = PRL_INVALID_HANDLE;
|
||||
virDomainDiskDef *disk;
|
||||
virDomainDiskDevice device;
|
||||
int bus;
|
||||
virDomainDiskBus bus;
|
||||
char *dst = NULL;
|
||||
int ret = -1;
|
||||
|
||||
@ -3462,6 +3462,14 @@ static int prlsdkConfigureDisk(struct _vzDriver *driver,
|
||||
sdkbus = PMS_SATA_DEVICE;
|
||||
idx = drive->unit;
|
||||
break;
|
||||
case VIR_DOMAIN_DISK_BUS_FDC:
|
||||
case VIR_DOMAIN_DISK_BUS_NONE:
|
||||
case VIR_DOMAIN_DISK_BUS_VIRTIO:
|
||||
case VIR_DOMAIN_DISK_BUS_XEN:
|
||||
case VIR_DOMAIN_DISK_BUS_USB:
|
||||
case VIR_DOMAIN_DISK_BUS_UML:
|
||||
case VIR_DOMAIN_DISK_BUS_SD:
|
||||
case VIR_DOMAIN_DISK_BUS_LAST:
|
||||
default:
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("Specified disk bus is not "
|
||||
@ -3500,7 +3508,7 @@ prlsdkGetDisk(PRL_HANDLE sdkdom, virDomainDiskDef *disk)
|
||||
PRL_UINT32 num;
|
||||
size_t i;
|
||||
PRL_HANDLE sdkdisk = PRL_INVALID_HANDLE;
|
||||
int bus;
|
||||
virDomainDiskBus bus;
|
||||
char *dst = NULL;
|
||||
PRL_DEVICE_TYPE devType;
|
||||
|
||||
@ -4339,6 +4347,14 @@ prlsdkGetBlockStats(PRL_HANDLE sdkstats,
|
||||
prefix = "scsi";
|
||||
idx = address->unit;
|
||||
break;
|
||||
case VIR_DOMAIN_DISK_BUS_FDC:
|
||||
case VIR_DOMAIN_DISK_BUS_NONE:
|
||||
case VIR_DOMAIN_DISK_BUS_VIRTIO:
|
||||
case VIR_DOMAIN_DISK_BUS_XEN:
|
||||
case VIR_DOMAIN_DISK_BUS_USB:
|
||||
case VIR_DOMAIN_DISK_BUS_UML:
|
||||
case VIR_DOMAIN_DISK_BUS_SD:
|
||||
case VIR_DOMAIN_DISK_BUS_LAST:
|
||||
default:
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Unknown disk bus: %X"), disk->bus);
|
||||
|
@ -237,6 +237,14 @@ vzCheckDiskAddressDriveUnsupportedParams(virDomainDiskDef *disk)
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case VIR_DOMAIN_DISK_BUS_FDC:
|
||||
case VIR_DOMAIN_DISK_BUS_NONE:
|
||||
case VIR_DOMAIN_DISK_BUS_VIRTIO:
|
||||
case VIR_DOMAIN_DISK_BUS_XEN:
|
||||
case VIR_DOMAIN_DISK_BUS_USB:
|
||||
case VIR_DOMAIN_DISK_BUS_UML:
|
||||
case VIR_DOMAIN_DISK_BUS_SD:
|
||||
case VIR_DOMAIN_DISK_BUS_LAST:
|
||||
default:
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("Specified disk bus is not supported by vz driver."));
|
||||
|
Loading…
Reference in New Issue
Block a user