qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] qemu-nbd: set timeout to qemu-nbd socket


From: Denis V. Lunev
Subject: Re: [PATCH] qemu-nbd: set timeout to qemu-nbd socket
Date: Mon, 26 Sep 2022 13:34:42 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

On 9/26/22 12:05, Vladimir Sementsov-Ogievskiy wrote:
[+ Den]

On 9/25/22 16:53, luzhipeng wrote:
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;


Personally, I don't see a problem in enabling timeout by default.. But probably we need a new option instead?


I believe that this should be the same story as we have had with
KEEPALIVE. This should be set as an option and downstream
will change its default when necessary.

Den



reply via email to

[Prev in Thread] Current Thread [Next in Thread]