qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v1 02/12] vhost: Return number of free memslots


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v1 02/12] vhost: Return number of free memslots
Date: Wed, 27 Oct 2021 18:11:42 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0

On 10/27/21 17:45, David Hildenbrand wrote:
> On 27.10.21 17:33, Michael S. Tsirkin wrote:
>> On Wed, Oct 27, 2021 at 04:11:38PM +0200, Philippe Mathieu-Daudé wrote:
>>> On 10/27/21 16:04, David Hildenbrand wrote:
>>>> On 27.10.21 15:36, Philippe Mathieu-Daudé wrote:
>>>>> On 10/27/21 14:45, David Hildenbrand wrote:
>>>>>> Let's return the number of free slots instead of only checking if there
>>>>>> is a free slot. Required to support memory devices that consume multiple
>>>>>> memslots.
>>>>>>
>>>>>> Signed-off-by: David Hildenbrand <david@redhat.com>
>>>>>> ---
>>>>>>  hw/mem/memory-device.c    | 2 +-
>>>>>>  hw/virtio/vhost-stub.c    | 2 +-
>>>>>>  hw/virtio/vhost.c         | 4 ++--
>>>>>>  include/hw/virtio/vhost.h | 2 +-
>>>>>>  4 files changed, 5 insertions(+), 5 deletions(-)
>>>
>>>>>> -bool vhost_has_free_slot(void)
>>>>>> +unsigned int vhost_get_free_memslots(void)
>>>>>>  {
>>>>>>      return true;
>>>>>
>>>>>        return 0;
>>>>
>>>> Oh wait, no. This actually has to be
>>>>
>>>> "return ~0U;" (see real vhost_get_free_memslots())
>>>>
>>>> ... because there is no vhost and consequently no limit applies.
>>>
>>> Indeed.
>>>
>>> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>
>> confused. are you acking the theoretical patch with ~0 here?
>>
> 
> That's how I interpreted it.

~0U doesn't seem harmful when comparing. However I haven't tested
nor looked at the big picture. I wonder if vhost_has_free_slot()
shouldn't take the Error* as argument and each implementation set
the error message ("virtio/vhost support disabled" would be more
explicit in the stub case). But I still don't understand why when
built without virtio/vhost we return vhost_get_free_memslots() > 0.




reply via email to

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