render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
fbe740
From eb4cd7cd29f434bae7279b3166aac9f7eb2c2436 Mon Sep 17 00:00:00 2001
fbe740
Message-Id: <eb4cd7cd29f434bae7279b3166aac9f7eb2c2436@dist-git>
fbe740
From: Michal Privoznik <mprivozn@redhat.com>
fbe740
Date: Thu, 19 Mar 2020 19:46:43 +0100
fbe740
Subject: [PATCH] qemu: Don't crash when getting targets for a multipath
fbe740
MIME-Version: 1.0
fbe740
Content-Type: text/plain; charset=UTF-8
fbe740
Content-Transfer-Encoding: 8bit
fbe740
fbe740
In one of my previous commits I've introduced code that creates
fbe740
all devices for given (possible) multipath target. But I've made
fbe740
a mistake there - the code accesses 'next->path' without checking
fbe740
if the disk source is local. Note that the 'next->path' is
fbe740
NULL/doesn't make sense for VIR_STORAGE_TYPE_NVME.
fbe740
fbe740
Fixes: a30078cb832646177defd256e77c632905f1e6d0
fbe740
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1814947
fbe740
fbe740
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
fbe740
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
fbe740
Reviewed-by: Ján Tomko <jtomko@redhat.com>
fbe740
(cherry picked from commit aeb909bf9b4c3fa48d017475545df94f7c5d3b3a)
fbe740
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
fbe740
Message-Id: <3f21a46399486a42b8dd0fbbac25b75f4f6ac80a.1584643597.git.mprivozn@redhat.com>
fbe740
Reviewed-by: Ján Tomko <jtomko@redhat.com>
fbe740
---
fbe740
 src/qemu/qemu_domain.c | 23 ++++++++++++-----------
fbe740
 1 file changed, 12 insertions(+), 11 deletions(-)
fbe740
fbe740
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
fbe740
index 36a63449b2..3d31e176d1 100644
fbe740
--- a/src/qemu/qemu_domain.c
fbe740
+++ b/src/qemu/qemu_domain.c
fbe740
@@ -15932,7 +15932,6 @@ qemuDomainNamespaceSetupDisk(virDomainObjPtr vm,
fbe740
     bool hasNVMe = false;
fbe740
 
fbe740
     for (next = src; virStorageSourceIsBacking(next); next = next->backingStore) {
fbe740
-        VIR_AUTOSTRINGLIST targetPaths = NULL;
fbe740
         g_autofree char *tmpPath = NULL;
fbe740
 
fbe740
         if (next->type == VIR_STORAGE_TYPE_NVME) {
fbe740
@@ -15941,6 +15940,8 @@ qemuDomainNamespaceSetupDisk(virDomainObjPtr vm,
fbe740
             if (!(tmpPath = virPCIDeviceAddressGetIOMMUGroupDev(&next->nvme->pciAddr)))
fbe740
                 return -1;
fbe740
         } else {
fbe740
+            VIR_AUTOSTRINGLIST targetPaths = NULL;
fbe740
+
fbe740
             if (virStorageSourceIsEmpty(next) ||
fbe740
                 !virStorageSourceIsLocalStorage(next)) {
fbe740
                 /* Not creating device. Just continue. */
fbe740
@@ -15948,20 +15949,20 @@ qemuDomainNamespaceSetupDisk(virDomainObjPtr vm,
fbe740
             }
fbe740
 
fbe740
             tmpPath = g_strdup(next->path);
fbe740
-        }
fbe740
 
fbe740
-        if (virStringListAdd(&paths, tmpPath) < 0)
fbe740
-            return -1;
fbe740
+            if (virDevMapperGetTargets(next->path, &targetPaths) < 0 &&
fbe740
+                errno != ENOSYS && errno != EBADF) {
fbe740
+                virReportSystemError(errno,
fbe740
+                                     _("Unable to get devmapper targets for %s"),
fbe740
+                                     next->path);
fbe740
+                return -1;
fbe740
+            }
fbe740
 
fbe740
-        if (virDevMapperGetTargets(next->path, &targetPaths) < 0 &&
fbe740
-            errno != ENOSYS && errno != EBADF) {
fbe740
-            virReportSystemError(errno,
fbe740
-                                 _("Unable to get devmapper targets for %s"),
fbe740
-                                 next->path);
fbe740
-            return -1;
fbe740
+            if (virStringListMerge(&paths, &targetPaths) < 0)
fbe740
+                return -1;
fbe740
         }
fbe740
 
fbe740
-        if (virStringListMerge(&paths, &targetPaths) < 0)
fbe740
+        if (virStringListAdd(&paths, tmpPath) < 0)
fbe740
             return -1;
fbe740
     }
fbe740
 
fbe740
-- 
fbe740
2.25.1
fbe740