提交 6fdbdafc 编写于 作者: P Pavel Hrdina

domain-conf: cleanup controller insert function

Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 a9a583d6
......@@ -13397,6 +13397,7 @@ void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
int idx;
/* Tenatively plan to insert controller at the end. */
int insertAt = -1;
virDomainControllerDefPtr current = NULL;
/* Then work backwards looking for controllers of
* the same type. If we find a controller with a
......@@ -13404,17 +13405,19 @@ void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
* that position
*/
for (idx = (def->ncontrollers - 1); idx >= 0; idx--) {
/* If bus matches and current controller is after
* new controller, then new controller should go here */
if (def->controllers[idx]->type == controller->type &&
def->controllers[idx]->idx > controller->idx) {
insertAt = idx;
} else if (def->controllers[idx]->type == controller->type &&
insertAt == -1) {
/* Last controller with match bus is before the
* new controller, then put new controller just after
*/
insertAt = idx + 1;
current = def->controllers[idx];
if (current->type == controller->type) {
if (current->idx > controller->idx) {
/* If bus matches and current controller is after
* new controller, then new controller should go here
* */
insertAt = idx;
} else if (insertAt == -1) {
/* Last controller with match bus is before the
* new controller, then put new controller just after
*/
insertAt = idx + 1;
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册