[libvirt] [PATCH 6/7] util: storage: Fix check for empty storage device

Peter Krempa pkrempa at redhat.com
Thu Mar 12 17:09:58 UTC 2015


If the storage device type is parsed as network our parser still allows
it to omit the <source> element. The empty drive check would not trigger
on such device as it expects that every network storage source is valid.

Use VIR_STORAGE_NET_PROTOCOL_NONE as a marker that the storage source is
empty.
---
 src/util/virstoragefile.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 78a7a9f..96be02e 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1989,6 +1989,10 @@ virStorageSourceIsEmpty(virStorageSourcePtr src)
     if (src->type == VIR_STORAGE_TYPE_NONE)
         return true;

+    if (src->type == VIR_STORAGE_TYPE_NETWORK &&
+        src->protocol == VIR_STORAGE_NET_PROTOCOL_NONE)
+        return true;
+
     return false;
 }

-- 
2.2.2




More information about the libvir-list mailing list