From: David Hildenbrand <david@redhat.com>
To: Philipp Reisner <philipp.reisner@linbit.com>, qemu-devel@nongnu.org
Cc: Fabiano Rosas <farosas@suse.de>, Peter Xu <peterx@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH] util: retry open() when it gets interrupted by a signal
Date: Wed, 31 Jul 2024 16:00:49 +0200 [thread overview]
Message-ID: <25fb9291-6b2e-45ab-812c-028f88de0dbb@redhat.com> (raw)
In-Reply-To: <20240731132524.308273-1-philipp.reisner@linbit.com>
On 31.07.24 15:25, Philipp Reisner wrote:
> As with many syscalls, open() might be interrupted by a signal.
>
> The experienced logfile entry is:
>
> qemu-system-x86_64: -device virtio-blk-pci,bus=pci.0,addr=0x7,drive=libvirt-2-format,id=virtio-disk0,bootindex=2,write-cache=on,serial=1b990c4d13b74a4e90ea: Could not open '/dev/drbd1003': Interrupted system call
>
> Retry it until it is not interrupted by a signal.
> FYI, dd has the same kind of loop aroud open().
> https://github.com/coreutils/coreutils/blob/1ae98dbda7322427e8226356fd110d2553f5fac9/src/dd.c#L1294-L1299
>
> Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
> ---
> util/osdep.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/util/osdep.c b/util/osdep.c
> index 770369831b..a1269d9345 100644
> --- a/util/osdep.c
> +++ b/util/osdep.c
> @@ -294,14 +294,17 @@ bool qemu_has_direct_io(void)
> static int qemu_open_cloexec(const char *name, int flags, mode_t mode)
> {
> int ret;
> + do {
> #ifdef O_CLOEXEC
> - ret = open(name, flags | O_CLOEXEC, mode);
> + ret = open(name, flags | O_CLOEXEC, mode);
> #else
> - ret = open(name, flags, mode);
> - if (ret >= 0) {
> - qemu_set_cloexec(ret);
> - }
> + ret = open(name, flags, mode);
> + if (ret >= 0) {
> + qemu_set_cloexec(ret);
> + }
> #endif
> + } while (ret == -1 && errno == EINTR);
> +
> return ret;
> }
>
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2024-07-31 14:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-31 13:25 [PATCH] util: retry open() when it gets interrupted by a signal Philipp Reisner
2024-07-31 14:00 ` David Hildenbrand [this message]
2024-07-31 14:10 ` Daniel P. Berrangé
2024-07-31 14:32 ` Peter Maydell
2024-07-31 14:49 ` Philipp Reisner
2024-07-31 15:17 ` [PATCH] util: use RETRY_ON_EINTR() on open() more consistently Philipp Reisner
2024-08-01 12:48 ` [PATCH v3] " Philippe Mathieu-Daudé
2024-08-02 7:26 ` Philipp Reisner
2024-07-31 15:21 ` [PATCH] util: retry open() when it gets interrupted by a signal Daniel P. Berrangé
2024-07-31 15:24 ` Peter Maydell
2024-07-31 15:34 ` Daniel P. Berrangé
2024-07-31 15:34 ` Philipp Reisner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=25fb9291-6b2e-45ab-812c-028f88de0dbb@redhat.com \
--to=david@redhat.com \
--cc=farosas@suse.de \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philipp.reisner@linbit.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).