[libvirt] [PATCH] Improve invalid argument checks for the public API
Eric Blake
eblake at redhat.com
Tue May 17 15:46:34 UTC 2011
On 05/17/2011 07:14 AM, Daniel Veillard wrote:
> On Tue, May 17, 2011 at 02:45:44PM +0200, Matthias Bolte wrote:
>> ---
>> src/libvirt.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
>> 1 files changed, 94 insertions(+), 6 deletions(-)
>
>> @@ -5040,6 +5045,12 @@ virDomainGetSchedulerParameters(virDomainPtr domain,
>> virDispatchError(NULL);
>> return -1;
>> }
>> +
>> + if (params == NULL || nparams == NULL) {
>> + virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
>> + goto error;
>> + }
>
> I was just wondering here if params being NULL couldn't be used to
> find out the correct value for nparams, but looking at least at the
> qemu driver code we really expect the array there.
Let's fix that as a separate patch.
>
>> conn = domain->conn;
>>
>> if (conn->driver->domainGetSchedulerParameters) {
>> @@ -5084,6 +5095,12 @@ virDomainSetSchedulerParameters(virDomainPtr domain,
>> virDispatchError(NULL);
>> return -1;
>> }
>> +
>> + if (params == NULL) {
>> + virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
>> + goto error;
>> + }
Hmm, here we document that nparams can be <= the value returned by
virDomainGetSchedulerType; which means it can be 0, which means that
params can be NULL. I think we should change this to allow NULL,0 in
input as a way of querying the proper nparams size on output.
This affects Hu's patch series, where we are adding
virDomainSetSchedulerParametersFlags, which should have the same semantics.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110517/e66f845c/attachment-0001.sig>
More information about the libvir-list
mailing list