[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] Don't allow NULL paths for BlockStats and InterfaceStats



Do the check in libvirt.c, to save drivers from the burden. This changes
behavior slightly in the qemu driver: we no longer explictly error if
passed an empty string. An error will still be thrown when the device
lookup fails.
---
 src/libvirt.c     |    4 ++--
 src/qemu_driver.c |    6 ------
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index 0e6d88f..d086052 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -3578,7 +3578,7 @@ virDomainBlockStats (virDomainPtr dom, const char *path,
         virLibDomainError (NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
         return -1;
     }
-    if (!stats || size > sizeof stats2) {
+    if (!path || !stats || size > sizeof stats2) {
         virLibDomainError (dom, VIR_ERR_INVALID_ARG, __FUNCTION__);
         goto error;
     }
@@ -3636,7 +3636,7 @@ virDomainInterfaceStats (virDomainPtr dom, const char *path,
         virLibDomainError (NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
         return -1;
     }
-    if (!stats || size > sizeof stats2) {
+    if (!path || !stats || size > sizeof stats2) {
         virLibDomainError (dom, VIR_ERR_INVALID_ARG, __FUNCTION__);
         goto error;
     }
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index c4683ae..c8f451d 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -5329,12 +5329,6 @@ qemudDomainInterfaceStats (virDomainPtr dom,
         goto cleanup;
     }
 
-    if (!path || path[0] == '\0') {
-        qemudReportError(dom->conn, dom, NULL, VIR_ERR_INVALID_ARG,
-                         "%s", _("NULL or empty path"));
-        goto cleanup;
-    }
-
     /* Check the path is one of the domain's network interfaces. */
     for (i = 0 ; i < vm->def->nnets ; i++) {
         if (vm->def->nets[i]->ifname &&
-- 
1.6.0.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]