qemu: Reduce need to call qemuDomainGetSCSIControllerModel

Now that post parse processing handles setting the SCSI controller
model, there's no need to call qemuDomainGetSCSIControllerModel to
get the "default controller" when building the command line controller
string or when assigning the spaprvio address since the controller
model value will already be filled in.
This commit is contained in:
John Ferlan 2018-01-30 16:12:31 -05:00
parent d1b59c6214
commit de8fac5f21
2 changed files with 6 additions and 19 deletions

View File

@ -2717,22 +2717,17 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
int *nusbcontroller) int *nusbcontroller)
{ {
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
int model = def->model;
const char *modelName = NULL; const char *modelName = NULL;
*devstr = NULL; *devstr = NULL;
if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) { if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) {
model = qemuDomainGetSCSIControllerModel(domainDef, def, qemuCaps); if (!qemuBuildCheckSCSIControllerModel(qemuCaps, def->model))
if (model < 0)
return -1;
if (!qemuBuildCheckSCSIControllerModel(qemuCaps, model))
return -1; return -1;
} }
if (!(def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI && if (!(def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI &&
model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI)) { def->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI)) {
if (def->queues) { if (def->queues) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("'queues' is only supported by virtio-scsi controller")); _("'queues' is only supported by virtio-scsi controller"));
@ -2757,7 +2752,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
switch ((virDomainControllerType) def->type) { switch ((virDomainControllerType) def->type) {
case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
switch (model) { switch (def->model) {
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI:
if (def->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { if (def->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
virBufferAddLit(&buf, "virtio-scsi-ccw"); virBufferAddLit(&buf, "virtio-scsi-ccw");

View File

@ -225,12 +225,10 @@ qemuDomainAssignSpaprVIOAddress(virDomainDefPtr def,
static int static int
qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def, qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def)
virQEMUCapsPtr qemuCaps)
{ {
size_t i; size_t i;
int ret = -1; int ret = -1;
int model;
/* Default values match QEMU. See spapr_(llan|vscsi|vty).c */ /* Default values match QEMU. See spapr_(llan|vscsi|vty).c */
@ -249,13 +247,7 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def,
for (i = 0; i < def->ncontrollers; i++) { for (i = 0; i < def->ncontrollers; i++) {
virDomainControllerDefPtr cont = def->controllers[i]; virDomainControllerDefPtr cont = def->controllers[i];
if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) { if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI &&
model = qemuDomainGetSCSIControllerModel(def, cont, qemuCaps);
if (model < 0)
goto cleanup;
}
if (model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI &&
cont->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) { cont->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) {
cont->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO; cont->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
} }
@ -2864,7 +2856,7 @@ qemuDomainAssignAddresses(virDomainDefPtr def,
if (qemuDomainAssignVirtioSerialAddresses(def) < 0) if (qemuDomainAssignVirtioSerialAddresses(def) < 0)
return -1; return -1;
if (qemuDomainAssignSpaprVIOAddresses(def, qemuCaps) < 0) if (qemuDomainAssignSpaprVIOAddresses(def) < 0)
return -1; return -1;
if (qemuDomainAssignS390Addresses(def, qemuCaps) < 0) if (qemuDomainAssignS390Addresses(def, qemuCaps) < 0)