From: luzhipeng <luzhipeng@cestc.cn>
To: qemu-devel <qemu-devel@nongnu.org>
Cc: Eric Blake <eblake@redhat.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>,
qemu-block@nongnu.org, lu zhipeng <luzhipeng@cestc.cn>
Subject: [PATCH] qemu-nbd: set timeout to qemu-nbd socket
Date: Sun, 25 Sep 2022 21:53:08 +0800 [thread overview]
Message-ID: <20220925135308.481-1-luzhipeng@cestc.cn> (raw)
From: lu zhipeng <luzhipeng@cestc.cn>
Prevent the NBD socket stuck all the time, So
set timeout.
Signed-off-by: lu zhipeng <luzhipeng@cestc.cn>
---
nbd/client.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/nbd/client.c b/nbd/client.c
index 30d5383cb1..89dde53a0f 100644
--- a/nbd/client.c
+++ b/nbd/client.c
@@ -24,6 +24,8 @@
#include "nbd-internal.h"
#include "qemu/cutils.h"
+#define NBD_DEFAULT_TIMEOUT 30
+
/* Definitions for opaque data types */
static QTAILQ_HEAD(, NBDExport) exports = QTAILQ_HEAD_INITIALIZER(exports);
@@ -1301,6 +1303,12 @@ int nbd_init(int fd, QIOChannelSocket *sioc, NBDExportInfo *info,
}
}
+ if (ioctl(fd, NBD_SET_TIMEOUT, NBD_DEFAULT_TIMEOUT) < 0) {
+ int serrno = errno;
+ error_setg(errp, "Failed setting timeout");
+ return -serrno;
+ }
+
trace_nbd_init_finish();
return 0;
--
2.31.1
next reply other threads:[~2022-09-25 13:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-25 13:53 luzhipeng [this message]
2022-09-26 10:05 ` [PATCH] qemu-nbd: set timeout to qemu-nbd socket Vladimir Sementsov-Ogievskiy
2022-09-26 11:34 ` Denis V. Lunev
2022-09-26 12:44 ` Vladimir Sementsov-Ogievskiy
2022-09-27 3:20 ` luzhipeng
2022-09-27 6:16 ` luzhipeng
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=20220925135308.481-1-luzhipeng@cestc.cn \
--to=luzhipeng@cestc.cn \
--cc=eblake@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@yandex-team.ru \
/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).