qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 10/10] qemu-iotests/118: Test media change with


From: Sascha Silbe
Subject: Re: [Qemu-devel] [PATCH 10/10] qemu-iotests/118: Test media change with qdev name
Date: Thu, 15 Sep 2016 19:57:41 +0200
User-agent: Notmuch/0.22.1~rc0 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu)

Dear Eric,

Eric Blake <address@hidden> writes:

> arglist = (all other parameters)
> if self.device_name:
>     arglist.append(id=self.device_name)
> else:
>     arglist.append(device='drive0')
> invoke(self.vm.qmp, arglist)

That would be:

        qmp_args = {'cmd': 'blockdev-change-medium', 'filename': new_img,
                    'format': iotests.imgfmt}
        if self.device_name is not None:
            qmp_args['id'] = self.device_name
        else:
            qmp_args['device'] = 'drive0'
        result = self.vm.qmp(**qmp_args)

Or:

        qmp_args = {'filename': new_img, 'format': iotests.imgfmt}
        if self.device_name is not None:
            qmp_args['id'] = self.device_name
        else:
            qmp_args['device'] = 'drive0'
        result = self.vm.qmp('blockdev-change-medium', **qmp_args)


FWIW these days I tend to use Python magics (like *args / **kwargs) only
if there's a _significant_ improvement in either functionality or
readability; especially for code bases that are being worked on by
developers who don't speak Python "natively". Using magics sparingly
also makes it easier for static analysis tools like pylint.

Sascha
-- 
Softwareentwicklung Sascha Silbe, Niederhofenstraße 5/1, 71229 Leonberg
https://se-silbe.de/
USt-IdNr. DE281696641




reply via email to

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