On 28/03/2015 19:54, Michael S. Tsirkin wrote:
> This API is pretty easy to misuse, and return
> value is completely undocumented. In fact, if I see
> "is" I assume a boolean return type.
> 
> As you are touching all users anyway, how about
> wrappers that answer specific questions:
> memory_region_is_logging_dirty_memory_vga
> memory_region_is_logging_dirty_memory_migration
> memory_region_is_logging_dirty_memory_except_migration
> ?

The full return value is used later in the series.

I'll add a "client" argument to memory_region_is_logging (so that the
compiler will catch anything I forger) and add
memory_region_get_dirty_log_mask for the other users.

Regarding memory_region_is_logging_dirty_memory_except_migration, it
will go away once migration stops being special cased via
log_global_start/log_global_stop.

Paolo

> As a bonus, compiler will catch you if you forget to
> change some caller.
> 
>> diff --git a/xen-hvm.c b/xen-hvm.c
>> index 315864c..acd89c8 100644
>> --- a/xen-hvm.c
>> +++ b/xen-hvm.c
>> @@ -488,7 +488,8 @@ static void xen_set_memory(struct MemoryListener 
>> *listener,
>>      XenIOState *state = container_of(listener, XenIOState, memory_listener);
>>      hwaddr start_addr = section->offset_within_address_space;
>>      ram_addr_t size = int128_get64(section->size);
>> -    bool log_dirty = memory_region_is_logging(section->mr);
>> +    bool log_dirty =
>> +        memory_region_is_logging(section->mr) & ~(1 << 
>> DIRTY_MEMORY_MIGRATION);
>>      hvmmem_type_t mem_type;
>>  
>>      if (section->mr == &ram_memory) {
>> -- 
>> 2.3.3
>>
> 
> 


Reply via email to