mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
conf: Rework and rename virDomainDeviceFindControllerModel
As it turns out virDomainDeviceFindControllerModel was only ever called for SCSI controllers using VIR_DOMAIN_CONTROLLER_TYPE_SCSI as a parameter. So rename to virDomainDeviceFindSCSIController and rather than return a model, let's return a virDomainControllerDefPtr to let the caller reference whatever it wants.
This commit is contained in:
parent
e37540f459
commit
932862b8bf
@ -7821,21 +7821,20 @@ virDomainHostdevDefParseXMLCaps(xmlNodePtr node ATTRIBUTE_UNUSED,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
virDomainDeviceFindControllerModel(const virDomainDef *def,
|
virDomainControllerDefPtr
|
||||||
virDomainDeviceInfoPtr info,
|
virDomainDeviceFindSCSIController(const virDomainDef *def,
|
||||||
int controllerType)
|
virDomainDeviceInfoPtr info)
|
||||||
{
|
{
|
||||||
int model = -1;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < def->ncontrollers; i++) {
|
for (i = 0; i < def->ncontrollers; i++) {
|
||||||
if (def->controllers[i]->type == controllerType &&
|
if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI &&
|
||||||
def->controllers[i]->idx == info->addr.drive.controller)
|
def->controllers[i]->idx == info->addr.drive.controller)
|
||||||
model = def->controllers[i]->model;
|
return def->controllers[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return model;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
virDomainDiskDefPtr
|
virDomainDiskDefPtr
|
||||||
@ -17804,17 +17803,16 @@ virDomainDefMaybeAddHostdevSCSIcontroller(virDomainDefPtr def)
|
|||||||
hostdev = def->hostdevs[i];
|
hostdev = def->hostdevs[i];
|
||||||
if (virHostdevIsSCSIDevice(hostdev) &&
|
if (virHostdevIsSCSIDevice(hostdev) &&
|
||||||
(int)hostdev->info->addr.drive.controller > maxController) {
|
(int)hostdev->info->addr.drive.controller > maxController) {
|
||||||
int model = -1;
|
virDomainControllerDefPtr cont;
|
||||||
|
|
||||||
maxController = hostdev->info->addr.drive.controller;
|
maxController = hostdev->info->addr.drive.controller;
|
||||||
/* We may be creating a new controller because this one is full.
|
/* We may be creating a new controller because this one is full.
|
||||||
* So let's grab the model from it and update the model we're
|
* So let's grab the model from it and update the model we're
|
||||||
* going to add as long as this one isn't undefined. The premise
|
* going to add as long as this one isn't undefined. The premise
|
||||||
* being keeping the same controller model for all SCSI hostdevs. */
|
* being keeping the same controller model for all SCSI hostdevs. */
|
||||||
model = virDomainDeviceFindControllerModel(def, hostdev->info,
|
cont = virDomainDeviceFindSCSIController(def, hostdev->info);
|
||||||
VIR_DOMAIN_CONTROLLER_TYPE_SCSI);
|
if (cont && cont->model != -1)
|
||||||
if (model != -1)
|
newModel = cont->model;
|
||||||
newModel = model;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2759,9 +2759,9 @@ int virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name)
|
|||||||
ATTRIBUTE_RETURN_CHECK;
|
ATTRIBUTE_RETURN_CHECK;
|
||||||
int virDomainDiskGetFormat(virDomainDiskDefPtr def);
|
int virDomainDiskGetFormat(virDomainDiskDefPtr def);
|
||||||
void virDomainDiskSetFormat(virDomainDiskDefPtr def, int format);
|
void virDomainDiskSetFormat(virDomainDiskDefPtr def, int format);
|
||||||
int virDomainDeviceFindControllerModel(const virDomainDef *def,
|
virDomainControllerDefPtr
|
||||||
virDomainDeviceInfoPtr info,
|
virDomainDeviceFindSCSIController(const virDomainDef *def,
|
||||||
int controllerType);
|
virDomainDeviceInfoPtr info);
|
||||||
virDomainDiskDefPtr virDomainDiskFindByBusAndDst(virDomainDefPtr def,
|
virDomainDiskDefPtr virDomainDiskFindByBusAndDst(virDomainDefPtr def,
|
||||||
int bus,
|
int bus,
|
||||||
char *dst);
|
char *dst);
|
||||||
|
@ -298,7 +298,7 @@ virDomainDeviceAliasIsUserAlias;
|
|||||||
virDomainDeviceDefCopy;
|
virDomainDeviceDefCopy;
|
||||||
virDomainDeviceDefFree;
|
virDomainDeviceDefFree;
|
||||||
virDomainDeviceDefParse;
|
virDomainDeviceDefParse;
|
||||||
virDomainDeviceFindControllerModel;
|
virDomainDeviceFindSCSIController;
|
||||||
virDomainDeviceGetInfo;
|
virDomainDeviceGetInfo;
|
||||||
virDomainDeviceInfoIterate;
|
virDomainDeviceInfoIterate;
|
||||||
virDomainDeviceTypeToString;
|
virDomainDeviceTypeToString;
|
||||||
|
@ -190,9 +190,11 @@ qemuAssignDeviceDiskAlias(virDomainDefPtr def,
|
|||||||
|
|
||||||
if (disk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) {
|
if (disk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) {
|
||||||
if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI) {
|
if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI) {
|
||||||
controllerModel =
|
virDomainControllerDefPtr cont;
|
||||||
virDomainDeviceFindControllerModel(def, &disk->info,
|
|
||||||
VIR_DOMAIN_CONTROLLER_TYPE_SCSI);
|
cont = virDomainDeviceFindSCSIController(def, &disk->info);
|
||||||
|
if (cont)
|
||||||
|
controllerModel = cont->model;
|
||||||
|
|
||||||
if ((qemuDomainSetSCSIControllerModel(def, qemuCaps,
|
if ((qemuDomainSetSCSIControllerModel(def, qemuCaps,
|
||||||
&controllerModel)) < 0)
|
&controllerModel)) < 0)
|
||||||
|
@ -1957,6 +1957,7 @@ qemuBuildDriveDevStr(const virDomainDef *def,
|
|||||||
virQEMUCapsPtr qemuCaps)
|
virQEMUCapsPtr qemuCaps)
|
||||||
{
|
{
|
||||||
virBuffer opt = VIR_BUFFER_INITIALIZER;
|
virBuffer opt = VIR_BUFFER_INITIALIZER;
|
||||||
|
virDomainControllerDefPtr cont;
|
||||||
const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus);
|
const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus);
|
||||||
const char *contAlias;
|
const char *contAlias;
|
||||||
char *drivealias;
|
char *drivealias;
|
||||||
@ -2042,9 +2043,9 @@ qemuBuildDriveDevStr(const virDomainDef *def,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
controllerModel =
|
cont = virDomainDeviceFindSCSIController(def, &disk->info);
|
||||||
virDomainDeviceFindControllerModel(def, &disk->info,
|
if (cont)
|
||||||
VIR_DOMAIN_CONTROLLER_TYPE_SCSI);
|
controllerModel = cont->model;
|
||||||
if ((qemuDomainSetSCSIControllerModel(def, qemuCaps,
|
if ((qemuDomainSetSCSIControllerModel(def, qemuCaps,
|
||||||
&controllerModel)) < 0)
|
&controllerModel)) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
@ -5142,12 +5143,14 @@ qemuBuildSCSIHostdevDevStr(const virDomainDef *def,
|
|||||||
virQEMUCapsPtr qemuCaps)
|
virQEMUCapsPtr qemuCaps)
|
||||||
{
|
{
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
|
virDomainControllerDefPtr cont;
|
||||||
int model = -1;
|
int model = -1;
|
||||||
char *driveAlias;
|
char *driveAlias;
|
||||||
const char *contAlias;
|
const char *contAlias;
|
||||||
|
|
||||||
model = virDomainDeviceFindControllerModel(def, dev->info,
|
cont = virDomainDeviceFindSCSIController(def, dev->info);
|
||||||
VIR_DOMAIN_CONTROLLER_TYPE_SCSI);
|
if (cont)
|
||||||
|
model = cont->model;
|
||||||
|
|
||||||
if (qemuDomainSetSCSIControllerModel(def, qemuCaps, &model) < 0)
|
if (qemuDomainSetSCSIControllerModel(def, qemuCaps, &model) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -1047,10 +1047,11 @@ static int
|
|||||||
vboxAttachDrives(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine)
|
vboxAttachDrives(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
int type, ret = 0, model = -1;
|
int type, ret = 0;
|
||||||
const char *src = NULL;
|
const char *src = NULL;
|
||||||
nsresult rc = 0;
|
nsresult rc = 0;
|
||||||
virDomainDiskDefPtr disk = NULL;
|
virDomainDiskDefPtr disk = NULL;
|
||||||
|
virDomainControllerDefPtr cont;
|
||||||
PRUnichar *storageCtlName = NULL;
|
PRUnichar *storageCtlName = NULL;
|
||||||
char *controllerName = NULL;
|
char *controllerName = NULL;
|
||||||
IMedium *medium = NULL;
|
IMedium *medium = NULL;
|
||||||
@ -1126,9 +1127,8 @@ vboxAttachDrives(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine)
|
|||||||
case VIR_DOMAIN_DISK_BUS_SCSI:
|
case VIR_DOMAIN_DISK_BUS_SCSI:
|
||||||
VBOX_UTF8_TO_UTF16(VBOX_CONTROLLER_SCSI_NAME, &storageCtlName);
|
VBOX_UTF8_TO_UTF16(VBOX_CONTROLLER_SCSI_NAME, &storageCtlName);
|
||||||
|
|
||||||
model = virDomainDeviceFindControllerModel(def, &disk->info,
|
cont = virDomainDeviceFindSCSIController(def, &disk->info);
|
||||||
VIR_DOMAIN_CONTROLLER_TYPE_SCSI);
|
if (cont && cont->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068) {
|
||||||
if (model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068) {
|
|
||||||
VBOX_UTF16_FREE(storageCtlName);
|
VBOX_UTF16_FREE(storageCtlName);
|
||||||
VBOX_UTF8_TO_UTF16(VBOX_CONTROLLER_SAS_NAME, &storageCtlName);
|
VBOX_UTF8_TO_UTF16(VBOX_CONTROLLER_SAS_NAME, &storageCtlName);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user