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.
This commit is contained in:
Cole Robinson 2009-07-24 11:05:28 -04:00
parent 3c2051f86a
commit 13f3d40cbf
2 changed files with 2 additions and 8 deletions

View File

@ -3599,7 +3599,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;
}
@ -3657,7 +3657,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;
}

View File

@ -5704,12 +5704,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 &&