qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [Qemu-block] [PATCH 6/7] qcow2: aio support for compres


From: Vladimir Sementsov-Ogievskiy
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 6/7] qcow2: aio support for compressed cluster read
Date: Tue, 6 Nov 2018 16:24:36 +0000

06.11.2018 18:30, Alberto Garcia wrote:
> On Tue 06 Nov 2018 04:13:58 PM CET, Vladimir Sementsov-Ogievskiy wrote:
>> 06.11.2018 18:06, Alberto Garcia wrote:
>>> On Thu 01 Nov 2018 07:27:37 PM CET, Vladimir Sementsov-Ogievskiy wrote:
>>>
>>>> +    buf = g_try_malloc(csize);
>>>> +    if (!buf) {
>>>> +        return -ENOMEM;
>>>> +    }
>>>> +    iov.iov_base = buf;
>>>> +    iov.iov_len = csize;
>>>> +    qemu_iovec_init_external(&local_qiov, &iov, 1);
>>>>    
>>>> -        iov.iov_base = s->cluster_data;
>>>> -        iov.iov_len = csize;
>>>> -        qemu_iovec_init_external(&local_qiov, &iov, 1);
>>>> +    out_buf = qemu_blockalign(bs, s->cluster_size);
>>> You should also check whether out_buf is NULL, shouldn't you?
>> No, it will abort on fail. qemu_try_blockalign result should be
>> checked.
> Is there any reason why some parts of the QEMU code use qemu_blockalign
> and others qemu_try_blockalign() ? From what I can see it seems to be up
> to whoever wrote it...
>
> Berto

As I understand, the good reason to use _try_ versions, is when we are 
allocating some size, taken from user input, so it may be unpredictable 
large (hm, or just any really large allocation), so, I use try_malloc 
for compressed size, which may be very large in somehow corrupted image. 
And it looks a common practice to use not-failing (aborting) allocation 
functions for cluster_size allocations in qcow2.c

-- 
Best regards,
Vladimir


reply via email to

[Prev in Thread] Current Thread [Next in Thread]