[libvirt] RFC: add new API to known if domain has been updated

Osier Yang jyang at redhat.com
Thu Nov 18 10:36:22 UTC 2010


于 2010年11月18日 17:44, Daniel P. Berrange 写道:
> On Mon, Nov 15, 2010 at 02:02:28PM +0800, Osier Yang wrote:
>> 于 2010年11月15日 18:56, Daniel P. Berrange 写道:
>>> On Mon, Nov 15, 2010 at 10:26:22AM +0800, Osier Yang wrote:
>>>> Hi, all
>>>>
>>>> Suppose that one updated a domain, and want to restart the
>>>> domain with original configuration.
>>>>
>>>> However, currently, unless shutdown the domain first, and then
>>>> restart or reload libvirtd, otherwise domain will still be started
>>>> with changed configuration. e.g.
>>>>
>>>> # virsh list --all
>>>>   Id Name                 State
>>>> ----------------------------------
>>>>    1 f14                  running
>>>>
>>>> # virsh dumpxml f14 | grep -A 7 cdrom
>>>>      <disk type='file' device='cdrom'>
>>>>        <driver name='qemu' type='raw'/>
>>>>        <source file='/var/lib/libvirt/images/cd1.iso'/>
>>>>        <target dev='hdc' bus='ide'/>
>>>>        <readonly/>
>>>>        <alias name='ide0-1-0'/>
>>>>        <address type='drive' controller='0' bus='1' unit='0'/>
>>>>      </disk>
>>>>
>>>> # virsh update-device f14 cd2.xml
>>>>
>>>> # virsh dumpxml f14 | grep -A 7 cdrom
>>>>      <disk type='file' device='cdrom'>
>>>>        <driver name='qemu' type='raw'/>
>>>>        <source file='/var/lib/libvirt/images/cd2.iso'/>
>>>>        <target dev='hdc' bus='ide'/>
>>>>        <readonly/>
>>>>        <alias name='ide0-1-0'/>
>>>>        <address type='drive' controller='0' bus='1' unit='0'/>
>>>>      </disk>
>>>>
>>>> # virsh destroy f14
>>>> # virsh start f14
>>>>
>>>> # virsh dumpxml f14 | grep -A 7 cdrom
>>>>      <disk type='file' device='cdrom'>
>>>>        <driver name='qemu' type='raw'/>
>>>>        <source file='/var/lib/libvirt/images/cd2.iso'/>
>>>>        <target dev='hdc' bus='ide'/>
>>>>        <readonly/>
>>>>        <alias name='ide0-1-0'/>
>>>>        <address type='drive' controller='0' bus='1' unit='0'/>
>>>>      </disk>
>>>>
>>>> it's caused by libvirtd doesn't known if a domain is updated or not,
>>>> it updated the domain configuration in memory, but client could
>>>> not known about it.
>>>>
>>>> As a result, one wants to start the domain with original configuration,
>>>> he has to shutdown the domain first, and then restart libvirt.
>>>
>>> This is a bug. libvirt should save a copy of the original configuration
>>> at the time the guest starts, so any live changes only remain for the
>>> duration of that boot and automatically revert at shutdown.
>>
>> yeah, I'm tring to fix it.. :-)
>>
>> IMHO it's waste of some memory to let libvirtd save a copy of the
>> original domain configuration, though it could just save the
>> copy only when updating happens.
>
> Yep, that would be ideal.
>
>> The diffrence with your thought is that it will really relys
>> on client, reducing the work load of libvirt, but all the
>> clients that using libvirt should be updated with the new APIs
>> to fix the bug then, so, not sure if it's fine.
>
> We can fix this entirely in the server side so we can avoid every single
> client having to be aware of it.
>

yep, I'm changing to fix it like so.

> Even though I don't think this API is the solution to the problem you
> describe, I think this API is still useful. There are a couple of
> further enhancements I'd like to see. First add implementation sof
> it to all the hypervisor drivers - it should be pretty trivial to
> do - the UML/LXC drivers will just be like the QEMU impl. The other
> drivers will all just return 0, because they don't have the separate
> config in memory vs on disk.

okay, will do it.

- Osier
>
> Regards,
> Daniel




More information about the libvir-list mailing list