qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 0/3] iotests: clean up resources using context m


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH 0/3] iotests: clean up resources using context managers
Date: Thu, 31 Aug 2017 12:26:57 +0100
User-agent: Mutt/1.8.3 (2017-05-23)

On Thu, Aug 24, 2017 at 08:21:59AM +0100, Stefan Hajnoczi wrote:
> This series introduces context managers for the two most commonly used
> resources: files and VMs.  Context managers eliminate the need to call a
> cleanup function explicitly.
> 
> Tests should declare resources upfront in a with statement.  Resources are
> automatically cleaned up whether the test passes or fails:
> 
>   with FilePath('test.img') as img_path,
>        VM() as vm:
>       ...test...
>   # img_path is deleted and vm is shut down automatically
> 
> The final patch converts 194 to use context managers instead of
> atexit.register().  This makes the code shorter and easier to read.
> 
> Stefan Hajnoczi (3):
>   qemu.py: make VM() a context manager
>   iotests.py: add FilePath context manager
>   qemu-iotests: use context managers for resource cleanup in 194
> 
>  scripts/qemu.py               | 16 ++++++++-
>  tests/qemu-iotests/194        | 83 
> +++++++++++++++++++++----------------------
>  tests/qemu-iotests/iotests.py | 26 ++++++++++++++
>  3 files changed, 82 insertions(+), 43 deletions(-)
> 
> -- 
> 2.13.5
> 

Thanks, applied to my block-next tree:
https://github.com/stefanha/qemu/commits/block-next

Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]