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.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/qemu/qemu_command.c | 3 ++-
src/qemu/qemu_domain_address.c | 51 +++++++++++++++++++-----------------------
src/qemu/qemu_domain_address.h | 6 ++---
3 files changed, 28 insertions(+), 32 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 32ff385cf..1142f302a 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -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))
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 74f7df205..5211b4f8a 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -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 (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 (cont->model > 0)
+ return cont->model;
- return 0;
+ 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;
+
+ 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;
}
diff --git a/src/qemu/qemu_domain_address.h b/src/qemu/qemu_domain_address.h
index 8a4346892..209b59e0d 100644
--- a/src/qemu/qemu_domain_address.h
+++ b/src/qemu/qemu_domain_address.h
@@ -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,
--
2.13.6