* Re: [Qemu-devel] fixing qemu busy wait
[not found] ` <CAHXCByTwZN6oLPFQM50u5srL-f94TsnwMuCtvZO75L+=V9=Vow@mail.gmail.com>
@ 2013-04-18 18:47 ` Orr Dvory
2013-05-31 14:17 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Orr Dvory @ 2013-04-18 18:47 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 3923 bytes --]
is this better?
diff -uprN qemu-1.4.1/gdbstub.c qemu-1.4.1-fix/gdbstub.c
--- qemu-1.4.1/gdbstub.c 2013-04-15 23:25:18.000000000 +0300
+++ qemu-1.4.1-fix/gdbstub.c 2013-04-18 21:35:00.000000000 +0300
@@ -379,17 +379,22 @@ static void put_buffer(GDBState *s, cons
{
#ifdef CONFIG_USER_ONLY
int ret;
-
+ int fd_flags = fcntl (s->fd, F_GETFL, 0);
+ fcntl (s->fd, F_SETFL, fd_flags & ~O_NONBLOCK);
while (len > 0) {
ret = send(s->fd, buf, len, 0);
if (ret < 0) {
if (errno != EINTR && errno != EAGAIN)
+ {
+ fcntl (s->fd, F_SETFL, fd_flags);
return;
+ }
} else {
buf += ret;
len -= ret;
}
}
+ fcntl (s->fd, F_SETFL, fd_flags);
#else
qemu_chr_fe_write(s->chr, buf, len);
#endif
@@ -2775,6 +2780,7 @@ gdb_handlesig (CPUArchState *env, int si
GDBState *s;
char buf[256];
int n;
+ int fd_flags;
s = gdbserver_state;
if (gdbserver_fd < 0 || s->fd < 0)
@@ -2793,7 +2799,8 @@ gdb_handlesig (CPUArchState *env, int si
connection. */
if (s->fd < 0)
return sig;
-
+ fd_flags = fcntl (s->fd, F_GETFL, 0);
+ fcntl (s->fd, F_SETFL, fd_flags & ~O_NONBLOCK);
sig = 0;
s->state = RS_IDLE;
s->running_state = 0;
@@ -2810,9 +2817,11 @@ gdb_handlesig (CPUArchState *env, int si
{
/* XXX: Connection closed. Should probably wait for another
connection before continuing. */
+ fcntl (s->fd, F_SETFL, fd_flags);
return sig;
}
}
+ fcntl (s->fd, F_SETFL, fd_flags);
sig = s->signal;
s->signal = 0;
return sig;
On Thu, Apr 18, 2013 at 9:46 PM, Orr Dvory <gidesa@gmail.com> wrote:
> is this better?
>
> diff -uprN qemu-1.4.1/gdbstub.c qemu-1.4.1-fix/gdbstub.c
> --- qemu-1.4.1/gdbstub.c 2013-04-15 23:25:18.000000000 +0300
> +++ qemu-1.4.1-fix/gdbstub.c 2013-04-18 21:35:00.000000000 +0300
> @@ -379,17 +379,22 @@ static void put_buffer(GDBState *s, cons
> {
> #ifdef CONFIG_USER_ONLY
> int ret;
> -
> + int fd_flags = fcntl (s->fd, F_GETFL, 0);
> + fcntl (s->fd, F_SETFL, fd_flags & ~O_NONBLOCK);
> while (len > 0) {
> ret = send(s->fd, buf, len, 0);
> if (ret < 0) {
>
> if (errno != EINTR && errno != EAGAIN)
> + {
> + fcntl (s->fd, F_SETFL, fd_flags);
> return;
> + }
> } else {
> buf += ret;
> len -= ret;
> }
> }
> + fcntl (s->fd, F_SETFL, fd_flags);
> #else
> qemu_chr_fe_write(s->chr, buf, len);
> #endif
> @@ -2775,6 +2780,7 @@ gdb_handlesig (CPUArchState *env, int si
> GDBState *s;
> char buf[256];
> int n;
> + int fd_flags;
>
> s = gdbserver_state;
> if (gdbserver_fd < 0 || s->fd < 0)
> @@ -2793,7 +2799,8 @@ gdb_handlesig (CPUArchState *env, int si
> connection. */
> if (s->fd < 0)
> return sig;
> -
> + fd_flags = fcntl (s->fd, F_GETFL, 0);
> + fcntl (s->fd, F_SETFL, fd_flags & ~O_NONBLOCK);
> sig = 0;
> s->state = RS_IDLE;
> s->running_state = 0;
> @@ -2810,9 +2817,11 @@ gdb_handlesig (CPUArchState *env, int si
> {
> /* XXX: Connection closed. Should probably wait for another
> connection before continuing. */
> + fcntl (s->fd, F_SETFL, fd_flags);
> return sig;
> }
> }
> + fcntl (s->fd, F_SETFL, fd_flags);
> sig = s->signal;
> s->signal = 0;
> return sig;
>
>
> On Wed, Feb 20, 2013 at 10:38 PM, Paolo Bonzini <pbonzini@redhat.com>wrote:
>
>> Il 20/02/2013 20:39, Orr Dvory ha scritto:
>> > if (errno != EINTR && errno != EAGAIN)
>> > + /* there's no need to restore the
>> > + O_NONBLOCK option. */
>> > return;
>> > +
>>
>> But it's cleaner to do it anyway. :)
>>
>> Paolo
>>
>
>
[-- Attachment #2: Type: text/html, Size: 5153 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] fixing qemu busy wait
2013-04-18 18:47 ` [Qemu-devel] fixing qemu busy wait Orr Dvory
@ 2013-05-31 14:17 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2013-05-31 14:17 UTC (permalink / raw)
To: Orr Dvory; +Cc: qemu-devel
Il 18/04/2013 20:47, Orr Dvory ha scritto:
> is this better?
Yes -- but I don't remember if this was fixed elsewhere. Can you
reproduce the problem in 1.5.0? If so, please send the patch according
to the guidelines at http://wiki.qemu.org/Contribute/SubmitAPatch.
Paolo
> diff -uprN qemu-1.4.1/gdbstub.c qemu-1.4.1-fix/gdbstub.c
> --- qemu-1.4.1/gdbstub.c 2013-04-15 23:25:18.000000000 +0300
> +++ qemu-1.4.1-fix/gdbstub.c 2013-04-18 21:35:00.000000000 +0300
> @@ -379,17 +379,22 @@ static void put_buffer(GDBState *s, cons
> {
> #ifdef CONFIG_USER_ONLY
> int ret;
> -
> + int fd_flags = fcntl (s->fd, F_GETFL, 0);
> + fcntl (s->fd, F_SETFL, fd_flags & ~O_NONBLOCK);
> while (len > 0) {
> ret = send(s->fd, buf, len, 0);
> if (ret < 0) {
>
> if (errno != EINTR && errno != EAGAIN)
> + {
> + fcntl (s->fd, F_SETFL, fd_flags);
> return;
> + }
> } else {
> buf += ret;
> len -= ret;
> }
> }
> + fcntl (s->fd, F_SETFL, fd_flags);
> #else
> qemu_chr_fe_write(s->chr, buf, len);
> #endif
> @@ -2775,6 +2780,7 @@ gdb_handlesig (CPUArchState *env, int si
> GDBState *s;
> char buf[256];
> int n;
> + int fd_flags;
>
> s = gdbserver_state;
> if (gdbserver_fd < 0 || s->fd < 0)
> @@ -2793,7 +2799,8 @@ gdb_handlesig (CPUArchState *env, int si
> connection. */
> if (s->fd < 0)
> return sig;
> -
> + fd_flags = fcntl (s->fd, F_GETFL, 0);
> + fcntl (s->fd, F_SETFL, fd_flags & ~O_NONBLOCK);
> sig = 0;
> s->state = RS_IDLE;
> s->running_state = 0;
> @@ -2810,9 +2817,11 @@ gdb_handlesig (CPUArchState *env, int si
> {
> /* XXX: Connection closed. Should probably wait for another
> connection before continuing. */
> + fcntl (s->fd, F_SETFL, fd_flags);
> return sig;
> }
> }
> + fcntl (s->fd, F_SETFL, fd_flags);
> sig = s->signal;
> s->signal = 0;
> return sig;
>
>
> On Thu, Apr 18, 2013 at 9:46 PM, Orr Dvory <gidesa@gmail.com
> <mailto:gidesa@gmail.com>> wrote:
>
> is this better?
>
> diff -uprN qemu-1.4.1/gdbstub.c qemu-1.4.1-fix/gdbstub.c
> --- qemu-1.4.1/gdbstub.c 2013-04-15 23:25:18.000000000 +0300
> +++ qemu-1.4.1-fix/gdbstub.c 2013-04-18 21:35:00.000000000 +0300
> @@ -379,17 +379,22 @@ static void put_buffer(GDBState *s, cons
> {
> #ifdef CONFIG_USER_ONLY
> int ret;
> -
> + int fd_flags = fcntl (s->fd, F_GETFL, 0);
> + fcntl (s->fd, F_SETFL, fd_flags & ~O_NONBLOCK);
> while (len > 0) {
> ret = send(s->fd, buf, len, 0);
> if (ret < 0) {
>
> if (errno != EINTR && errno != EAGAIN)
> + {
> + fcntl (s->fd, F_SETFL, fd_flags);
> return;
> + }
> } else {
> buf += ret;
> len -= ret;
> }
> }
> + fcntl (s->fd, F_SETFL, fd_flags);
> #else
> qemu_chr_fe_write(s->chr, buf, len);
> #endif
> @@ -2775,6 +2780,7 @@ gdb_handlesig (CPUArchState *env, int si
> GDBState *s;
> char buf[256];
> int n;
> + int fd_flags;
>
> s = gdbserver_state;
> if (gdbserver_fd < 0 || s->fd < 0)
> @@ -2793,7 +2799,8 @@ gdb_handlesig (CPUArchState *env, int si
> connection. */
> if (s->fd < 0)
> return sig;
> -
> + fd_flags = fcntl (s->fd, F_GETFL, 0);
> + fcntl (s->fd, F_SETFL, fd_flags & ~O_NONBLOCK);
> sig = 0;
> s->state = RS_IDLE;
> s->running_state = 0;
> @@ -2810,9 +2817,11 @@ gdb_handlesig (CPUArchState *env, int si
> {
> /* XXX: Connection closed. Should probably wait for another
> connection before continuing. */
> + fcntl (s->fd, F_SETFL, fd_flags);
> return sig;
> }
> }
> + fcntl (s->fd, F_SETFL, fd_flags);
> sig = s->signal;
> s->signal = 0;
> return sig;
>
>
> On Wed, Feb 20, 2013 at 10:38 PM, Paolo Bonzini <pbonzini@redhat.com
> <mailto:pbonzini@redhat.com>> wrote:
>
> Il 20/02/2013 20:39, Orr Dvory ha scritto:
> > if (errno != EINTR && errno != EAGAIN)
> > + /* there's no need to restore the
> > + O_NONBLOCK option. */
> > return;
> > +
>
> But it's cleaner to do it anyway. :)
>
> Paolo
>
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-05-31 14:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CAHXCByREfdGsVntX4ojv9BAEVD5TA0-8eiya5ky2onVBcuEv+Q@mail.gmail.com>
[not found] ` <512002D7.4090906@twiddle.net>
[not found] ` <CAHXCByQQ2Yd7yCiXzfH=5iw4UAAYCxyorawmy8ZnDCHe-6zjYA@mail.gmail.com>
[not found] ` <CAHXCByRaXWMpyuOAixm+PzVoM4DfoK+HaLDkofd1j3h3Wo3Bng@mail.gmail.com>
[not found] ` <5125343F.9090302@redhat.com>
[not found] ` <CAHXCByTwZN6oLPFQM50u5srL-f94TsnwMuCtvZO75L+=V9=Vow@mail.gmail.com>
2013-04-18 18:47 ` [Qemu-devel] fixing qemu busy wait Orr Dvory
2013-05-31 14:17 ` Paolo Bonzini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.