qemu-commits
[Top][All Lists]
Advanced

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

[Qemu-commits] [qemu/qemu] 2d853c: qemu.py: Pylint/style fixes


From: GitHub
Subject: [Qemu-commits] [qemu/qemu] 2d853c: qemu.py: Pylint/style fixes
Date: Sat, 16 Sep 2017 07:25:07 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 2d853c70a25a2c4b812eadd304c9e35882eb2e0e
      
https://github.com/qemu/qemu/commit/2d853c70a25a2c4b812eadd304c9e35882eb2e0e
  Author: Lukáš Doktor <address@hidden>
  Date:   2017-09-15 (Fri, 15 Sep 2017)

  Changed paths:
    M scripts/qemu.py

  Log Message:
  -----------
  qemu.py: Pylint/style fixes

No actual code changes, just several pylint/style fixes and docstring
clarifications.

Signed-off-by: Lukáš Doktor <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Cleber Rosa <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: 2782fc517d6720dbec24b4dfa08aa4606c72c76d
      
https://github.com/qemu/qemu/commit/2782fc517d6720dbec24b4dfa08aa4606c72c76d
  Author: Lukáš Doktor <address@hidden>
  Date:   2017-09-15 (Fri, 15 Sep 2017)

  Changed paths:
    M scripts/qemu.py
    M scripts/qtest.py

  Log Message:
  -----------
  qemu|qtest: Avoid dangerous arguments

The list object is mutable in python and potentially might modify other
object's arguments when used as default argument. Reproducer:

    >>> vm1 = QEMUMachine("qemu")
    >>> vm2 = QEMUMachine("qemu")
    >>> vm1._wrapper.append("foo")
    >>> print vm2._wrapper
    ['foo']

In this case the `args` is actually copied so it would be safe to keep
it, but it's not a good practice to keep it. The same issue applies in
inherited qtest module.

Signed-off-by: Lukáš Doktor <address@hidden>
Reviewed-by: Eduardo Habkost <address@hidden>
Reviewed-by: John Snow <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Cleber Rosa <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: 7f33ca7878e3414f779a5d89f04c68c0438c3dc7
      
https://github.com/qemu/qemu/commit/7f33ca7878e3414f779a5d89f04c68c0438c3dc7
  Author: Lukáš Doktor <address@hidden>
  Date:   2017-09-15 (Fri, 15 Sep 2017)

  Changed paths:
    M scripts/qemu.py

  Log Message:
  -----------
  qemu.py: Use iteritems rather than keys()

Let's avoid creating an in-memory list of keys and query for each value
and use `iteritems` which is an iterator of key-value pairs.

Signed-off-by: Lukáš Doktor <address@hidden>
Reviewed-by: Eduardo Habkost <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Cleber Rosa <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: 41f714b190ffff7fefb3ad090bc02d089e4c7bda
      
https://github.com/qemu/qemu/commit/41f714b190ffff7fefb3ad090bc02d089e4c7bda
  Author: Lukáš Doktor <address@hidden>
  Date:   2017-09-15 (Fri, 15 Sep 2017)

  Changed paths:
    M scripts/qemu.py

  Log Message:
  -----------
  qemu.py: Simplify QMP key-conversion

The QMP key conversion consist of '_'s to be replaced with '-'s, which
can easily be done by a single `str.replace` method which is faster and
does not require `string` module import.

Signed-off-by: Lukáš Doktor <address@hidden>
Reviewed-by: Eduardo Habkost <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Cleber Rosa <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: a004e249f035f8a0c859d1700abb4081c86f8c1f
      
https://github.com/qemu/qemu/commit/a004e249f035f8a0c859d1700abb4081c86f8c1f
  Author: Lukáš Doktor <address@hidden>
  Date:   2017-09-15 (Fri, 15 Sep 2017)

  Changed paths:
    M scripts/qemu.py

  Log Message:
  -----------
  qemu.py: Use custom exceptions rather than Exception

The naked Exception should not be widely used. It makes sense to be a
bit more specific and use better-suited custom exceptions. As a benefit
we can store the full reply in the exception in case someone needs it
when catching the exception.

Signed-off-by: Lukáš Doktor <address@hidden>
Reviewed-by: Eduardo Habkost <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: 9d47f6de10e36c988e935069bf288d39bdcc1126
      
https://github.com/qemu/qemu/commit/9d47f6de10e36c988e935069bf288d39bdcc1126
  Author: Lukáš Doktor <address@hidden>
  Date:   2017-09-15 (Fri, 15 Sep 2017)

  Changed paths:
    M scripts/qmp/qmp.py

  Log Message:
  -----------
  qmp.py: Couple of pylint/style fixes

No actual code changes, just initializing attributes earlier to avoid
AttributeError on early introspection, a few pylint/style fixes and
docstring clarifications.

Signed-off-by: Lukáš Doktor <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: 3dd29b4133e4f6ad595bcd835fc0b3302a3304fe
      
https://github.com/qemu/qemu/commit/3dd29b4133e4f6ad595bcd835fc0b3302a3304fe
  Author: Lukáš Doktor <address@hidden>
  Date:   2017-09-15 (Fri, 15 Sep 2017)

  Changed paths:
    M scripts/qmp/qmp-shell
    M scripts/qmp/qmp.py

  Log Message:
  -----------
  qmp.py: Use object-based class for QEMUMonitorProtocol

There is no need to define QEMUMonitorProtocol as old-style class.

Signed-off-by: Lukáš Doktor <address@hidden>
Reviewed-by: Eduardo Habkost <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: 2cb05a3f3613f633b916b854cfaf04c663ccc953
      
https://github.com/qemu/qemu/commit/2cb05a3f3613f633b916b854cfaf04c663ccc953
  Author: Lukáš Doktor <address@hidden>
  Date:   2017-09-15 (Fri, 15 Sep 2017)

  Changed paths:
    M scripts/qmp/qmp.py

  Log Message:
  -----------
  qmp.py: Avoid "has_key" usage

The "has_key" is deprecated in favor of "__in__" operator.

Signed-off-by: Lukáš Doktor <address@hidden>
Reviewed-by: Eduardo Habkost <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: 7b6b9dbb3c4cb7eac4c847d601735da9b1d150ce
      
https://github.com/qemu/qemu/commit/7b6b9dbb3c4cb7eac4c847d601735da9b1d150ce
  Author: Lukáš Doktor <address@hidden>
  Date:   2017-09-15 (Fri, 15 Sep 2017)

  Changed paths:
    M scripts/qmp/qmp.py

  Log Message:
  -----------
  qmp.py: Avoid overriding a builtin object

The "id" is a builtin method to get object's identity and should not be
overridden. This might bring some issues in case someone was directly
calling "cmd(..., id=id)" but I haven't found such usage on brief search
for "cmd\(.*id=".

Signed-off-by: Lukáš Doktor <address@hidden>
Reviewed-by: Eduardo Habkost <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: 4d9342977a2e8b195609d332fcd64a93a48c158b
      
https://github.com/qemu/qemu/commit/4d9342977a2e8b195609d332fcd64a93a48c158b
  Author: Lukáš Doktor <address@hidden>
  Date:   2017-09-15 (Fri, 15 Sep 2017)

  Changed paths:
    M scripts/qtest.py

  Log Message:
  -----------
  qtest.py: Few pylint/style fixes

No actual code changes, just few pylint/style fixes.

Signed-off-by: Lukáš Doktor <address@hidden>
Reviewed-by: John Snow <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: f6cf7f5a227ca0c8cc540d78d4f0f943c51ea8d1
      
https://github.com/qemu/qemu/commit/f6cf7f5a227ca0c8cc540d78d4f0f943c51ea8d1
  Author: Amador Pahim <address@hidden>
  Date:   2017-09-15 (Fri, 15 Sep 2017)

  Changed paths:
    M scripts/qemu.py

  Log Message:
  -----------
  qemu.py: fix is_running() return before first launch()

is_running() returns None when called before the first time we
call launch():

    >>> import qemu
    >>> vm = qemu.QEMUMachine('qemu-system-x86_64')
    >>> vm.is_running()
    >>>

It should return False instead. This patch fixes that.

For consistence, this patch removes the parenthesis from the
second clause as it's not really needed.

Signed-off-by: Amador Pahim <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: 4738b0a85a0c2031fddc71b51cccebce0c4ba6b1
      
https://github.com/qemu/qemu/commit/4738b0a85a0c2031fddc71b51cccebce0c4ba6b1
  Author: Amador Pahim <address@hidden>
  Date:   2017-09-15 (Fri, 15 Sep 2017)

  Changed paths:
    M scripts/qemu.py

  Log Message:
  -----------
  qemu.py: avoid writing to stdout/stderr

This module should not write directly to stdout/stderr. Instead, it
should either raise exceptions or just log the messages and let the
callers handle them and decide what to do. For example, scripts could
choose to send the log messages stderr or/and write them to a file if
verbose or debugging mode is enabled.

This patch replaces the writes to stderr by an exception in the
send_fd_scm() when _socket_scm_helper is not set or not present. In the
same method, the subprocess Popen will now redirect the stdout/stderr to
logging.debug instead of writing to system stderr. As consequence, since
the Popen.communicate() is now used (in order to get the stdout), the
further call to wait() became redundant and was replaced by
Popen.returncode.

The shutdown() message on negative exit code will now be logged
to logging.warn instead of written to system stderr.

Signed-off-by: Amador Pahim <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: 63e0ba55222476c8b96d8c45131c830e00a80eaa
      
https://github.com/qemu/qemu/commit/63e0ba55222476c8b96d8c45131c830e00a80eaa
  Author: Amador Pahim <address@hidden>
  Date:   2017-09-15 (Fri, 15 Sep 2017)

  Changed paths:
    M scripts/qemu.py

  Log Message:
  -----------
  qemu.py: use os.path.null instead of /dev/null

For increased portability, let's use os.path.devnull.

Signed-off-by: Amador Pahim <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: dab91d9aa00e41ee680524e4f6e99a1e7fe12eb2
      
https://github.com/qemu/qemu/commit/dab91d9aa00e41ee680524e4f6e99a1e7fe12eb2
  Author: Amador Pahim <address@hidden>
  Date:   2017-09-15 (Fri, 15 Sep 2017)

  Changed paths:
    M scripts/qemu.py

  Log Message:
  -----------
  qemu.py: improve message on negative exit code

The current message shows 'self._args', which contains only part of the
options used in the Qemu command line.

This patch makes the qemu full args list an instance variable and then
uses it in the negative exit code message.

Message was moved outside the 'if is_running' block to make sure it will
be logged if the VM finishes before the call to shutdown().

Signed-off-by: Amador Pahim <address@hidden>
Message-Id: <address@hidden>
[ehabkost: removed superfluous parenthesis]
Reviewed-by: Fam Zheng <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: b92a0011b1220aff549ae82c6104014d25e339ef
      
https://github.com/qemu/qemu/commit/b92a0011b1220aff549ae82c6104014d25e339ef
  Author: Amador Pahim <address@hidden>
  Date:   2017-09-15 (Fri, 15 Sep 2017)

  Changed paths:
    M scripts/qemu.py

  Log Message:
  -----------
  qemu.py: include debug information on launch error

When launching a VM, if an exception happens and the VM is not
initiated, it might be useful to see the qemu command line and
the qemu command output.

This patch creates that message. Notice that self._iolog needs to be
cleaned up in the beginning of the launch() to make sure we will not
expose the qemu log from a previous launch if the current one fails.

Signed-off-by: Amador Pahim <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>


  Commit: 5ee53d1593dfc071275b13b1228c70bb88f4aaee
      
https://github.com/qemu/qemu/commit/5ee53d1593dfc071275b13b1228c70bb88f4aaee
  Author: Peter Maydell <address@hidden>
  Date:   2017-09-16 (Sat, 16 Sep 2017)

  Changed paths:
    M scripts/qemu.py
    M scripts/qmp/qmp-shell
    M scripts/qmp/qmp.py
    M scripts/qtest.py

  Log Message:
  -----------
  Merge remote-tracking branch 'remotes/ehabkost/tags/python-next-pull-request' 
into staging

Python queue, 2017-09-15

# gpg: Signature made Sat 16 Sep 2017 00:14:01 BST
# gpg:                using RSA key 0x2807936F984DC5A6
# gpg: Good signature from "Eduardo Habkost <address@hidden>"
# Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF  D1AA 2807 936F 984D C5A6

* remotes/ehabkost/tags/python-next-pull-request:
  qemu.py: include debug information on launch error
  qemu.py: improve message on negative exit code
  qemu.py: use os.path.null instead of /dev/null
  qemu.py: avoid writing to stdout/stderr
  qemu.py: fix is_running() return before first launch()
  qtest.py: Few pylint/style fixes
  qmp.py: Avoid overriding a builtin object
  qmp.py: Avoid "has_key" usage
  qmp.py: Use object-based class for QEMUMonitorProtocol
  qmp.py: Couple of pylint/style fixes
  qemu.py: Use custom exceptions rather than Exception
  qemu.py: Simplify QMP key-conversion
  qemu.py: Use iteritems rather than keys()
  qemu|qtest: Avoid dangerous arguments
  qemu.py: Pylint/style fixes

Signed-off-by: Peter Maydell <address@hidden>


Compare: https://github.com/qemu/qemu/compare/d8782a113a5f...5ee53d1593df

reply via email to

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