Re: [Qemu-devel] Re: [PATCH 3/3] Add KVM support to QEMU

Anthony Liguori
2008-10-29T13:08:03Z

Avi Kivity wrote:
> Anthony Liguori wrote:
>> Another place "hook" is updating a slot's dirty bitmap. Right now,
>> with my patchset we don't have live migration or the VGA RAM
>> optimization. There's nothing about the VGA RAM optimization that
>> wouldn't work for QEMU. I'm not sure that it really is an
>> optimization in the context of TCG, but I certainly don't think it's
>> any worse. The only thing you really need is to query the KVM dirty
>> bitmap when it comes time to enable start over querying the VGA dirty
>> bits.
>
> I don't understand this. The VGA optimization really is qemu's, the
> kvm modifications only cater to the different way of getting the dirty
> bits.

Right. I'm just not sure that it's going to be as much of an
optimization for TCG as it is for KVM.

>> The same is needed for live migration, so I think what we really need
>> is to change the memory dirty bit tracking API to have a concept of
>> refresh that we can use to hook for KVM.
>>
>
> Can you elaborate on this refresh?

Right now, in QEMU, code looks like this:

for (i = 0; i < addr; i += TARGET_PAGE_SIZE) {
if (cpu_p_m_g_dirty(i, DIRTY_FLAG)) {
cpu_p_m_r_dirty(i, i + TARGET_PAGE_SIZE, DIRTY_FLAG);

// do something with dirty memory
}

All we need to do is add another cpu_physical_memory_sync_dirty(i, i +
REGION_SIZE, DIRTY_FLAG); that would go at the start of this. For QEMU,
this is a nop since dirty bits are updated as soon as they are reset.
For KVM, this would update the entire set of dirty bits for the given
memory region.

We also need something to enable dirty tracking for a particular
region. We already have something for migration, we could perhaps
extend that API (cpu_p_m_s_dirty_tracking).

Regards,

Anthony Liguori