提交 07beea6c 编写于 作者: J John Ferlan

qemu: Use same model when adding hostdev SCSI controller

When qemuDomainFindOrCreateSCSIDiskController adds a controller,
let's use the same model as a currently found controller under the
assumption that the reason to add the controller in hotplug is
because virDomainHostdevAssignAddress determined that there were
too many devices on the existing controller, but only assigned a
new controller index and did not add a new controller and we
desire to use the same controller model as any existing controller
and not take a chance that qemuDomainSetSCSIControllerModel would
use a default that may be incompatible.
上级 fae22fce
...@@ -587,6 +587,7 @@ qemuDomainFindOrCreateSCSIDiskController(virQEMUDriverPtr driver, ...@@ -587,6 +587,7 @@ qemuDomainFindOrCreateSCSIDiskController(virQEMUDriverPtr driver,
{ {
size_t i; size_t i;
virDomainControllerDefPtr cont; virDomainControllerDefPtr cont;
int model = -1;
for (i = 0; i < vm->def->ncontrollers; i++) { for (i = 0; i < vm->def->ncontrollers; i++) {
cont = vm->def->controllers[i]; cont = vm->def->controllers[i];
...@@ -596,6 +597,16 @@ qemuDomainFindOrCreateSCSIDiskController(virQEMUDriverPtr driver, ...@@ -596,6 +597,16 @@ qemuDomainFindOrCreateSCSIDiskController(virQEMUDriverPtr driver,
if (cont->idx == controller) if (cont->idx == controller)
return cont; 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 /* No SCSI controller present, for backward compatibility we
...@@ -604,11 +615,11 @@ qemuDomainFindOrCreateSCSIDiskController(virQEMUDriverPtr driver, ...@@ -604,11 +615,11 @@ qemuDomainFindOrCreateSCSIDiskController(virQEMUDriverPtr driver,
return NULL; return NULL;
cont->type = VIR_DOMAIN_CONTROLLER_TYPE_SCSI; cont->type = VIR_DOMAIN_CONTROLLER_TYPE_SCSI;
cont->idx = controller; cont->idx = controller;
cont->model = -1; cont->model = model;
VIR_INFO("No SCSI controller present, hotplugging one"); VIR_INFO("No SCSI controller present, hotplugging one model=%s",
if (qemuDomainAttachControllerDevice(driver, virDomainControllerModelSCSITypeToString(model));
vm, cont) < 0) { if (qemuDomainAttachControllerDevice(driver, vm, cont) < 0) {
VIR_FREE(cont); VIR_FREE(cont);
return NULL; return NULL;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册