[virt-tools-list] [PATCH] virtinst: refresh pools status before fetch_pools

Cole Robinson crobinso at redhat.com
Fri Dec 5 13:54:15 UTC 2014


On 12/05/2014 03:40 AM, Chunyan Liu wrote:
> Currently, when connecting to hypervisor, if there are pools active
> but in fact target path already deleted (or for other reasons the
> pool is not working), libvirtd not refresh status yet, fetch_pools
> will fail, that will cause "connecting to hypervisor" process
> reporting error and exit. The whole connection work failed.
>
> With the patch, always refresh pool status before fetch pools. Let
> the libvirtd pool status reflect the reality, avoid the non-synced
> status affects the hypervisor connection.
>
> Signed-off-by: Chunyan Liu <cyliu at suse.com>
> ---
>   virtinst/pollhelpers.py | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
>
> diff --git a/virtinst/pollhelpers.py b/virtinst/pollhelpers.py
> index a9b1527..e8702f0 100644
> --- a/virtinst/pollhelpers.py
> +++ b/virtinst/pollhelpers.py
> @@ -133,6 +133,19 @@ def fetch_pools(backend, origmap, build_func):
>
>       if backend.check_support(
>           backend.SUPPORT_CONN_LISTALLSTORAGEPOOLS) and not _force_old_poll:
> +
> +        # Refresh pools before poll_helper. For those
> +        # 'active' but target path not exist (or other reasons
> +        # causing the pool not working), but libvirtd not
> +        # refresh the status, this will make it refreshed
> +        # and mark that pool as 'inactive'.
> +        objs = backend.listAllStoragePools()
> +        for obj in objs:
> +            try:
> +                obj.refresh(0)
> +            except Exception, e:
> +                pass
> +
>           return _new_poll_helper(origmap, name,
>                                   backend.listAllStoragePools, build_func)
>       else:
>

This is a very heavy hammer, refresh is a potentially long running operation 
so this could cause decent slowdown in some scenarios.

IMO this is essentially a libvirt bug, for pools with target directories (dir, 
fs, netfs), libvirt should be periodically checking the directory ctime and 
doing the pool refresh for us. And if the target has disappeared, it shuts 
down the pool (like shutting down a VM if it crashes).

We have so many hacks sprinkled around in virtinst/virt-manager dealing with 
the fallout of this lacking libvirt feature. Really wish I had implemented it 
years ago. But I'd rather focus on that then adding yet more hacks.

If there's a specific issue you're hitting that's manifesting itself elsewhere 
in the app, let us know and maybe there's a way to mitigate it in the interim

- Cole




More information about the virt-tools-list mailing list