{
size_t i;
virDomainControllerDefPtr cont;
+ int model = -1;
for (i = 0; i < vm->def->ncontrollers; i++) {
cont = vm->def->controllers[i];
if (cont->idx == controller)
return cont;
+
+ /* Because virDomainHostdevAssignAddress called during
+ * virDomainHostdevDefPostParse cannot add a new controller
+ * it will assign a controller index to a controller that doesn't
+ * exist leaving this code to perform the magic of adding the
+ * controller. Because that code would be attempting to add a
+ * SCSI disk to an existing controller, let's save the model
+ * of the "last" SCSI controller we find so that if we end up
+ * creating a controller below it uses the same controller model. */
+ model = cont->model;
}
/* No SCSI controller present, for backward compatibility we
return NULL;
cont->type = VIR_DOMAIN_CONTROLLER_TYPE_SCSI;
cont->idx = controller;
- cont->model = -1;
+ cont->model = model;
- VIR_INFO("No SCSI controller present, hotplugging one");
- if (qemuDomainAttachControllerDevice(driver,
- vm, cont) < 0) {
+ VIR_INFO("No SCSI controller present, hotplugging one model=%s",
+ virDomainControllerModelSCSITypeToString(model));
+ if (qemuDomainAttachControllerDevice(driver, vm, cont) < 0) {
VIR_FREE(cont);
return NULL;
}