[libvirt] [PATCH 11/11] qemuDomainNamespaceSetupDisk: Simplify disk check

Michal Privoznik posted 11 patches 9 years ago
[libvirt] [PATCH 11/11] qemuDomainNamespaceSetupDisk: Simplify disk check
Posted by Michal Privoznik 9 years ago
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 | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index a4ee652db..7c696963e 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -7911,7 +7911,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;
         }
@@ -7922,12 +7923,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,
-- 
2.11.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 11/11] qemuDomainNamespaceSetupDisk: Simplify disk check
Posted by Peter Krempa 9 years ago
On Wed, Feb 08, 2017 at 11:37:14 +0100, Michal Privoznik wrote:
> 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 | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)

ACK
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list