提交 932862b8 编写于 作者: J John Ferlan

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.
上级 e37540f4
......@@ -7821,21 +7821,20 @@ virDomainHostdevDefParseXMLCaps(xmlNodePtr node ATTRIBUTE_UNUSED,
return ret;
}
int
virDomainDeviceFindControllerModel(const virDomainDef *def,
virDomainDeviceInfoPtr info,
int controllerType)
virDomainControllerDefPtr
virDomainDeviceFindSCSIController(const virDomainDef *def,
virDomainDeviceInfoPtr info)
{
int model = -1;
size_t 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)
model = def->controllers[i]->model;
return def->controllers[i];
}
return model;
return NULL;
}
virDomainDiskDefPtr
......@@ -17804,17 +17803,16 @@ virDomainDefMaybeAddHostdevSCSIcontroller(virDomainDefPtr def)
hostdev = def->hostdevs[i];
if (virHostdevIsSCSIDevice(hostdev) &&
(int)hostdev->info->addr.drive.controller > maxController) {
int model = -1;
virDomainControllerDefPtr cont;
maxController = hostdev->info->addr.drive.controller;
/* 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
* going to add as long as this one isn't undefined. The premise
* being keeping the same controller model for all SCSI hostdevs. */
model = virDomainDeviceFindControllerModel(def, hostdev->info,
VIR_DOMAIN_CONTROLLER_TYPE_SCSI);
if (model != -1)
newModel = model;
cont = virDomainDeviceFindSCSIController(def, hostdev->info);
if (cont && cont->model != -1)
newModel = cont->model;
}
}
......
......@@ -2759,9 +2759,9 @@ int virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name)
ATTRIBUTE_RETURN_CHECK;
int virDomainDiskGetFormat(virDomainDiskDefPtr def);
void virDomainDiskSetFormat(virDomainDiskDefPtr def, int format);
int virDomainDeviceFindControllerModel(const virDomainDef *def,
virDomainDeviceInfoPtr info,
int controllerType);
virDomainControllerDefPtr
virDomainDeviceFindSCSIController(const virDomainDef *def,
virDomainDeviceInfoPtr info);
virDomainDiskDefPtr virDomainDiskFindByBusAndDst(virDomainDefPtr def,
int bus,
char *dst);
......
......@@ -298,7 +298,7 @@ virDomainDeviceAliasIsUserAlias;
virDomainDeviceDefCopy;
virDomainDeviceDefFree;
virDomainDeviceDefParse;
virDomainDeviceFindControllerModel;
virDomainDeviceFindSCSIController;
virDomainDeviceGetInfo;
virDomainDeviceInfoIterate;
virDomainDeviceTypeToString;
......
......@@ -190,9 +190,11 @@ qemuAssignDeviceDiskAlias(virDomainDefPtr def,
if (disk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) {
if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI) {
controllerModel =
virDomainDeviceFindControllerModel(def, &disk->info,
VIR_DOMAIN_CONTROLLER_TYPE_SCSI);
virDomainControllerDefPtr cont;
cont = virDomainDeviceFindSCSIController(def, &disk->info);
if (cont)
controllerModel = cont->model;
if ((qemuDomainSetSCSIControllerModel(def, qemuCaps,
&controllerModel)) < 0)
......
......@@ -1957,6 +1957,7 @@ qemuBuildDriveDevStr(const virDomainDef *def,
virQEMUCapsPtr qemuCaps)
{
virBuffer opt = VIR_BUFFER_INITIALIZER;
virDomainControllerDefPtr cont;
const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus);
const char *contAlias;
char *drivealias;
......@@ -2042,9 +2043,9 @@ qemuBuildDriveDevStr(const virDomainDef *def,
goto error;
}
controllerModel =
virDomainDeviceFindControllerModel(def, &disk->info,
VIR_DOMAIN_CONTROLLER_TYPE_SCSI);
cont = virDomainDeviceFindSCSIController(def, &disk->info);
if (cont)
controllerModel = cont->model;
if ((qemuDomainSetSCSIControllerModel(def, qemuCaps,
&controllerModel)) < 0)
goto error;
......@@ -5142,12 +5143,14 @@ qemuBuildSCSIHostdevDevStr(const virDomainDef *def,
virQEMUCapsPtr qemuCaps)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
virDomainControllerDefPtr cont;
int model = -1;
char *driveAlias;
const char *contAlias;
model = virDomainDeviceFindControllerModel(def, dev->info,
VIR_DOMAIN_CONTROLLER_TYPE_SCSI);
cont = virDomainDeviceFindSCSIController(def, dev->info);
if (cont)
model = cont->model;
if (qemuDomainSetSCSIControllerModel(def, qemuCaps, &model) < 0)
goto error;
......
......@@ -1047,10 +1047,11 @@ static int
vboxAttachDrives(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine)
{
size_t i;
int type, ret = 0, model = -1;
int type, ret = 0;
const char *src = NULL;
nsresult rc = 0;
virDomainDiskDefPtr disk = NULL;
virDomainControllerDefPtr cont;
PRUnichar *storageCtlName = NULL;
char *controllerName = NULL;
IMedium *medium = NULL;
......@@ -1126,9 +1127,8 @@ vboxAttachDrives(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine)
case VIR_DOMAIN_DISK_BUS_SCSI:
VBOX_UTF8_TO_UTF16(VBOX_CONTROLLER_SCSI_NAME, &storageCtlName);
model = virDomainDeviceFindControllerModel(def, &disk->info,
VIR_DOMAIN_CONTROLLER_TYPE_SCSI);
if (model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068) {
cont = virDomainDeviceFindSCSIController(def, &disk->info);
if (cont && cont->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068) {
VBOX_UTF16_FREE(storageCtlName);
VBOX_UTF8_TO_UTF16(VBOX_CONTROLLER_SAS_NAME, &storageCtlName);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册