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