mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
qemu: Introduce qemuDomainGetSCSIControllerModel
Rename and rework qemuDomainSetSCSIControllerModel since we're really not setting the SCSI controller model. Instead the code is either returning the existing SCSI controller model value, the default value based on the capabilities, or -1 with the error set.
This commit is contained in:
parent
6ae6ffd88e
commit
fadfb4f9b3
@ -2723,7 +2723,8 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
|
||||
*devstr = NULL;
|
||||
|
||||
if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) {
|
||||
if ((qemuDomainSetSCSIControllerModel(domainDef, qemuCaps, &model)) < 0)
|
||||
model = qemuDomainGetSCSIControllerModel(domainDef, def, qemuCaps);
|
||||
if (model < 0)
|
||||
return -1;
|
||||
|
||||
if (!qemuBuildCheckSCSIControllerModel(qemuCaps, model))
|
||||
|
@ -42,35 +42,33 @@ VIR_LOG_INIT("qemu.qemu_domain_address");
|
||||
|
||||
/**
|
||||
* @def: Domain definition
|
||||
* @cont: Domain controller def
|
||||
* @qemuCaps: qemu capabilities
|
||||
* @model: model to either return or adjust
|
||||
*
|
||||
* If the @model is already defined, return it immediately; otherwise,
|
||||
* based on the @qemuCaps set the @model value to the default value.
|
||||
* If the controller model is already defined, return it immediately;
|
||||
* otherwise, based on the @qemuCaps return a default model value.
|
||||
*
|
||||
* Returns @model on success, -1 on failure with error set.
|
||||
* Returns model on success, -1 on failure with error set.
|
||||
*/
|
||||
int
|
||||
qemuDomainSetSCSIControllerModel(const virDomainDef *def,
|
||||
virQEMUCapsPtr qemuCaps,
|
||||
int *model)
|
||||
qemuDomainGetSCSIControllerModel(const virDomainDef *def,
|
||||
const virDomainControllerDef *cont,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
if (*model > 0)
|
||||
return 0;
|
||||
if (cont->model > 0)
|
||||
return cont->model;
|
||||
|
||||
if (qemuDomainIsPSeries(def)) {
|
||||
*model = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI;
|
||||
} else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_LSI)) {
|
||||
*model = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC;
|
||||
} else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_SCSI)) {
|
||||
*model = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI;
|
||||
} else {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Unable to determine model for scsi controller"));
|
||||
return -1;
|
||||
}
|
||||
if (qemuDomainIsPSeries(def))
|
||||
return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI;
|
||||
else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_LSI))
|
||||
return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC;
|
||||
else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_SCSI))
|
||||
return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI;
|
||||
|
||||
return 0;
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Unable to determine model for SCSI controller idx=%d"),
|
||||
cont->idx);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@ -90,7 +88,6 @@ qemuDomainFindSCSIControllerModel(const virDomainDef *def,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
virDomainControllerDefPtr cont;
|
||||
int model;
|
||||
|
||||
if (!(cont = virDomainDeviceFindSCSIController(def, info))) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
@ -99,9 +96,7 @@ qemuDomainFindSCSIControllerModel(const virDomainDef *def,
|
||||
return -1;
|
||||
}
|
||||
|
||||
model = cont->model;
|
||||
ignore_value(qemuDomainSetSCSIControllerModel(def, qemuCaps, &model));
|
||||
return model;
|
||||
return qemuDomainGetSCSIControllerModel(def, cont, qemuCaps);
|
||||
}
|
||||
|
||||
|
||||
@ -227,9 +222,9 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def,
|
||||
for (i = 0; i < def->ncontrollers; i++) {
|
||||
virDomainControllerDefPtr cont = def->controllers[i];
|
||||
|
||||
model = cont->model;
|
||||
if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) {
|
||||
if (qemuDomainSetSCSIControllerModel(def, qemuCaps, &model) < 0)
|
||||
model = qemuDomainGetSCSIControllerModel(def, cont, qemuCaps);
|
||||
if (model < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -28,9 +28,9 @@
|
||||
# include "qemu_conf.h"
|
||||
# include "qemu_capabilities.h"
|
||||
|
||||
int qemuDomainSetSCSIControllerModel(const virDomainDef *def,
|
||||
virQEMUCapsPtr qemuCaps,
|
||||
int *model);
|
||||
int qemuDomainGetSCSIControllerModel(const virDomainDef *def,
|
||||
const virDomainControllerDef *cont,
|
||||
virQEMUCapsPtr qemuCaps);
|
||||
|
||||
int qemuDomainFindSCSIControllerModel(const virDomainDef *def,
|
||||
virDomainDeviceInfoPtr info,
|
||||
|
Loading…
x
Reference in New Issue
Block a user