Skip to contentSkip to conversation

qemu.py: Fix error message when qemu dies from signal

PATCH In review Eric Blake 2 participants 4 messages Jan 11, 2019 – Jan 14, 2019

lore
Share & tools
lore

Eric Blake

author
#0 lore raw

PATCH 1/1 qemu.py: Fix error message when qemu dies from signal

When qemu dies from a signal, the python code gets a negative value for exitcode; but signal numbers are positive. Copy the pattern used in qemu-iotests/iotests.py for reporting a positive value.

---
 scripts/qemu.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/qemu.py +1 -1
index 6e3b0e67719..0a5e02eb56e 100644
@@ -351,7 +351,7 @@ class QEMUMachine(object):
                 command = ' '.join(self._qemu_full_args)
             else:
                 command = ''
-            LOG.warn(msg, exitcode, command)
+            LOG.warn(msg, -exitcode, command)
 
         self._launched = False
 
Signature · 1 line
2.20.1
#1 lore raw

Hi Eric,

Quoted 16 lines · Eric Blake

When qemu dies from a signal, the python code gets a negative value for exitcode; but signal numbers are positive. Copy the pattern used in qemu-iotests/iotests.py for reporting a positive value.

---
 scripts/qemu.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/qemu.py +0 -0
index 6e3b0e67719..0a5e02eb56e 100644

scripts/qemu.py class QEMUMachine(object): · line 354

Quoted 5 lines
scripts/qemu.py +1 -1
@@ -351,7 +351,7 @@ class QEMUMachine(object):
                 command = ' '.join(self._qemu_full_args)
             else:
                 command = ''
-            LOG.warn(msg, exitcode, command)
+            LOG.warn(msg, -exitcode, command)

What about displaying signal name directly?

import signal

...

msg = 'qemu received %s: %s'
...

LOG.warn(msg, signal.Signals(-exitcode).name, command)

Quoted 3 lines
scripts/qemu.py +0 -0
         self._launched = False
 
author
#2 lore raw
Quoted 14 lines · Philippe Mathieu-Daudé

Hi Eric,

Quoted 11 lines · Eric Blake

When qemu dies from a signal, the python code gets a negative value for exitcode; but signal numbers are positive. Copy the pattern used in qemu-iotests/iotests.py for reporting a positive value.

---
 scripts/qemu.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

scripts/qemu.py class QEMUMachine(object): · line 354

Quoted 10 lines
scripts/qemu.py +1 -1
index 6e3b0e67719..0a5e02eb56e 100644
@@ -351,7 +351,7 @@ class QEMUMachine(object):
                 command = ' '.join(self._qemu_full_args)
             else:
                 command = ''
-            LOG.warn(msg, exitcode, command)
+            LOG.warn(msg, -exitcode, command)

What about displaying signal name directly?

If you want to do that, it should be a separate patch, and fix iotests.py at the same time.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#3 lore raw
Quoted 28 lines · Eric Blake
Quoted 14 lines · Philippe Mathieu-Daudé

Hi Eric,

Quoted 11 lines · Eric Blake

When qemu dies from a signal, the python code gets a negative value for exitcode; but signal numbers are positive. Copy the pattern used in qemu-iotests/iotests.py for reporting a positive value.

---
 scripts/qemu.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

scripts/qemu.py class QEMUMachine(object): · line 354

Quoted 10 lines
scripts/qemu.py +1 -1
index 6e3b0e67719..0a5e02eb56e 100644
@@ -351,7 +351,7 @@ class QEMUMachine(object):
                 command = ' '.join(self._qemu_full_args)
             else:
                 command = ''
-            LOG.warn(msg, exitcode, command)
+            LOG.warn(msg, -exitcode, command)

What about displaying signal name directly?

Quoted 2 lines

If you want to do that, it should be a separate patch, and fix iotests.py at the same time.

Fair enough :)