]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_alias: Be more tolerant if alias don't follow our format
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 20 Oct 2017 11:24:41 +0000 (13:24 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Sun, 22 Oct 2017 11:49:46 +0000 (13:49 +0200)
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@redhat.com>
src/qemu/qemu_alias.c

index d06a3d63e67bd75d8aae7f5df27434dd8d919639..37fe2aa8025f55037a12af9b89bbac7a0244892c 100644 (file)
@@ -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;