]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuDomainNamespaceSetupDisk: Simplify disk check
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 3 Feb 2017 16:23:10 +0000 (17:23 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 8 Feb 2017 14:56:21 +0000 (15:56 +0100)
Firstly, instead of checking for next->path the
virStorageSourceIsEmpty() function should be used which also
takes disk type into account.
Secondly, not every disk source passed has the correct type set
(due to our laziness). Therefore, instead of checking for
virStorageSourceIsBlockLocal() and also S_ISBLK() the former can
be refined to just virStorageSourceIsLocalStorage().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_domain.c

index 9e34d73be87213c41151963556c649d3fc2f571a..d3f765605a37ceb864c8333deda0a91a0545daee 100644 (file)
@@ -7912,7 +7912,8 @@ qemuDomainNamespaceSetupDisk(virQEMUDriverPtr driver,
         return 0;
 
     for (next = src; next; next = next->backingStore) {
-        if (!next->path || !virStorageSourceIsBlockLocal(src)) {
+        if (virStorageSourceIsEmpty(next) ||
+            !virStorageSourceIsLocalStorage(next)) {
             /* Not creating device. Just continue. */
             continue;
         }
@@ -7923,12 +7924,8 @@ qemuDomainNamespaceSetupDisk(virQEMUDriverPtr driver,
             goto cleanup;
         }
 
-        if (!S_ISBLK(sb.st_mode)) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("Disk source %s must be a block device"),
-                           next->path);
-            goto cleanup;
-        }
+        if (!S_ISBLK(sb.st_mode))
+            continue;
 
         if (qemuDomainAttachDeviceMknod(driver,
                                         vm,