于 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.
My thought is to export APIs to work around it, the patches is
to export API "virDomainIsUpdated", however, think also need
another API, which is to update the hash entry of the domain
configuration, need to invoke "virHashUpdateEntry". This API
could be invoked when starting a updated domain. It reloads the
persistent domain configuration and updates the updated domain
configuration maintained by libvirtd. How about naming it as
"virDomainUpdateConfig"?
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.
Thanks
- Osier
Regards,
Daniel