Message ID | f231c9abc706f5825e41c0fbaa4fc82de1121435.1586370737.git.lukasstraub2@web.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | colo-compare bugfixes | expand |
Hi On Wed, Apr 8, 2020 at 8:37 PM Lukas Straub <lukasstraub2@web.de> wrote: > > This will be needed in the next patch. > > Signed-off-by: Lukas Straub <lukasstraub2@web.de> > --- > chardev/char.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/chardev/char.c b/chardev/char.c > index 04075389bf..51ad0dc6b3 100644 > --- a/chardev/char.c > +++ b/chardev/char.c > @@ -38,6 +38,7 @@ > #include "qemu/module.h" > #include "qemu/option.h" > #include "qemu/id.h" > +#include "qemu/coroutine.h" > > #include "chardev/char-mux.h" > > @@ -119,7 +120,11 @@ static int qemu_chr_write_buffer(Chardev *s, > retry: > res = cc->chr_write(s, buf + *offset, len - *offset); > if (res < 0 && errno == EAGAIN && write_all) { > - g_usleep(100); > + if (qemu_in_coroutine()) { > + qemu_co_sleep_ns(QEMU_CLOCK_REALTIME, 100000); > + } else { > + g_usleep(100); > + } > goto retry; Although we don't have any coroutine code in chardev/, it dos this kind of coroutine handling indirectly through qio. Thus it should be fine too here. Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> > } > > -- > 2.20.1 >
> -----Original Message----- > From: Lukas Straub <lukasstraub2@web.de> > Sent: Thursday, April 9, 2020 2:34 AM > To: qemu-devel <qemu-devel@nongnu.org> > Cc: Zhang, Chen <chen.zhang@intel.com>; Li Zhijian > <lizhijian@cn.fujitsu.com>; Jason Wang <jasowang@redhat.com>; Marc- > André Lureau <marcandre.lureau@redhat.com>; Paolo Bonzini > <pbonzini@redhat.com> > Subject: [PATCH 2/3] chardev/char.c: Use qemu_co_sleep_ns if in coroutine > > This will be needed in the next patch. > > Signed-off-by: Lukas Straub <lukasstraub2@web.de> Reviewed-by: Zhang Chen <chen.zhang@intel.com> > --- > chardev/char.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/chardev/char.c b/chardev/char.c index 04075389bf..51ad0dc6b3 > 100644 > --- a/chardev/char.c > +++ b/chardev/char.c > @@ -38,6 +38,7 @@ > #include "qemu/module.h" > #include "qemu/option.h" > #include "qemu/id.h" > +#include "qemu/coroutine.h" > > #include "chardev/char-mux.h" > > @@ -119,7 +120,11 @@ static int qemu_chr_write_buffer(Chardev *s, > retry: > res = cc->chr_write(s, buf + *offset, len - *offset); > if (res < 0 && errno == EAGAIN && write_all) { > - g_usleep(100); > + if (qemu_in_coroutine()) { > + qemu_co_sleep_ns(QEMU_CLOCK_REALTIME, 100000); > + } else { > + g_usleep(100); > + } > goto retry; > } > > -- > 2.20.1
diff --git a/chardev/char.c b/chardev/char.c index 04075389bf..51ad0dc6b3 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -38,6 +38,7 @@ #include "qemu/module.h" #include "qemu/option.h" #include "qemu/id.h" +#include "qemu/coroutine.h" #include "chardev/char-mux.h" @@ -119,7 +120,11 @@ static int qemu_chr_write_buffer(Chardev *s, retry: res = cc->chr_write(s, buf + *offset, len - *offset); if (res < 0 && errno == EAGAIN && write_all) { - g_usleep(100); + if (qemu_in_coroutine()) { + qemu_co_sleep_ns(QEMU_CLOCK_REALTIME, 100000); + } else { + g_usleep(100); + } goto retry; }
This will be needed in the next patch. Signed-off-by: Lukas Straub <lukasstraub2@web.de> --- chardev/char.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)