mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
domain-conf: cleanup controller insert function
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
a9a583d6df
commit
6fdbdafcd7
@ -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,
|
|||||||
* 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user