On 08/04/2021 21:03, Paolo Bonzini wrote:


Il gio 8 apr 2021, 18:06 Emanuele Giuseppe Esposito <eespo...@redhat.com <mailto:eespo...@redhat.com>> ha scritto:



    On 08/04/2021 17:40, Paolo Bonzini wrote:
     > On 07/04/21 15:50, Emanuele Giuseppe Esposito wrote:
     >>       def get_qmp_events_filtered(self, wait=60.0):
     >>           result = []
     >> -        for ev in self.get_qmp_events(wait=wait):
     >> +        qmp_wait = wait
     >> +        if qemu_gdb:
     >> +            qmp_wait = 0.0
     >> +        for ev in self.get_qmp_events(wait=qmp_wait):
     >>               result.append(filter_qmp_event(ev))
     >>           return result
     >
     > Should this be handled in get_qmp_events instead, since you're
    basically
     > changing all the callers?

    get_qmp_events is in python/machine.py, which as I understand might be
    used also by some other scripts, so I want to keep the changes there to
    the minimum. Also, machine.py has no access to qemu_gdb or
    qemu_valgrind, so passing a boolean or something to delay the timer
    would still require to add a similar check in all sections.

    Or do you have a cleaner way to do this?


Maybe a subclass IotestsMachine?


I actually figured that I could override get_qmp_events and put the check there. Something like (simplified):

class VM(qtest.QEMUQtestMachine):

        ...

        def get_qmp_events(self, wait)
                if qemu_gdb or qemu_valgrind:
                        wait = 0.0
                return super().get_qmp_events(wait)

Emanuele


Reply via email to