When assigning alias to a device we usually iterate over other
devices of its kind trying to find next index. We do this by
stripping down the prefix and then parsing number at the end,
Usually, if the prefix doesn't match the one we are expecting, we
just continue with next iteration. Except for couple of
functions: qemuGetNextChrDevIndex(),
qemuAssignDeviceRedirdevAlias() and qemuAssignDeviceShmemAlias().
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_alias.c | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c
index d06a3d63e..37fe2aa80 100644
--- a/src/qemu/qemu_alias.c
+++ b/src/qemu/qemu_alias.c
@@ -73,11 +73,8 @@ qemuGetNextChrDevIndex(virDomainDefPtr def,
ssize_t thisidx;
if (((thisidx = qemuDomainDeviceAliasIndex(&arrPtr[i]->info, prefix)) <
0) &&
(prefix2 &&
- (thisidx = qemuDomainDeviceAliasIndex(&arrPtr[i]->info, prefix2))
< 0)) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Unable to determine device index for character
device"));
- return -1;
- }
+ (thisidx = qemuDomainDeviceAliasIndex(&arrPtr[i]->info, prefix2))
< 0))
+ continue;
if (thisidx >= idx)
idx = thisidx + 1;
}
@@ -391,11 +388,8 @@ qemuAssignDeviceRedirdevAlias(virDomainDefPtr def,
idx = 0;
for (i = 0; i < def->nredirdevs; i++) {
int thisidx;
- if ((thisidx = qemuDomainDeviceAliasIndex(&def->redirdevs[i]->info,
"redir")) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Unable to determine device index for redirected
device"));
- return -1;
- }
+ if ((thisidx = qemuDomainDeviceAliasIndex(&def->redirdevs[i]->info,
"redir")) < 0)
+ continue;
if (thisidx >= idx)
idx = thisidx + 1;
}
@@ -491,12 +485,8 @@ qemuAssignDeviceShmemAlias(virDomainDefPtr def,
int thisidx;
if ((thisidx = qemuDomainDeviceAliasIndex(&def->shmems[i]->info,
- "shmem")) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Unable to determine device index "
- "for shmem device"));
- return -1;
- }
+ "shmem")) < 0)
+ continue;
if (thisidx >= idx)
idx = thisidx + 1;
--
2.13.6