qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Chunyan Liu <cyliu@suse.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH V3 1/2] Update ioctl order in nbd_init to detect -EBUSY
Date: Wed, 23 Nov 2011 18:14:49 +0800	[thread overview]
Message-ID: <1322043290-20349-1-git-send-email-cyliu@suse.com> (raw)

Remove NBD_CLEAR_SOCK from nbd_init and adjust NBD_SET_SOCK ioctl before other
ioctl(s) in nbd_init so that it can detect -EBUSY properly.
 
Signed-off-by: Chunyan Liu <cyliu@suse.com>
---
 nbd.c |   27 +++++++++------------------
 1 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/nbd.c b/nbd.c
index e6c931c..4184614 100644
--- a/nbd.c
+++ b/nbd.c
@@ -348,6 +348,15 @@ int nbd_receive_negotiate(int csock, const char *name, uint32_t *flags,
 #ifdef __linux__
 int nbd_init(int fd, int csock, uint32_t flags, off_t size, size_t blocksize)
 {
+    TRACE("Setting NBD socket");
+
+    if (ioctl(fd, NBD_SET_SOCK, csock) == -1) {
+        int serrno = errno;
+        LOG("Failed to set NBD socket");
+        errno = serrno;
+        return -1;
+    }
+
     TRACE("Setting block size to %lu", (unsigned long)blocksize);
 
     if (ioctl(fd, NBD_SET_BLKSIZE, blocksize) == -1) {
@@ -386,24 +395,6 @@ int nbd_init(int fd, int csock, uint32_t flags, off_t size, size_t blocksize)
         return -1;
     }
 
-    TRACE("Clearing NBD socket");
-
-    if (ioctl(fd, NBD_CLEAR_SOCK) == -1) {
-        int serrno = errno;
-        LOG("Failed clearing NBD socket");
-        errno = serrno;
-        return -1;
-    }
-
-    TRACE("Setting NBD socket");
-
-    if (ioctl(fd, NBD_SET_SOCK, csock) == -1) {
-        int serrno = errno;
-        LOG("Failed to set NBD socket");
-        errno = serrno;
-        return -1;
-    }
-
     TRACE("Negotiation ended");
 
     return 0;
-- 
1.7.3.4

             reply	other threads:[~2011-11-23 10:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-23 10:14 Chunyan Liu [this message]
2011-11-23 10:14 ` [Qemu-devel] [PATCH V3 2/2] Add -f option to qemu-nbd Chunyan Liu
2011-11-23 10:56   ` Stefan Hajnoczi
2011-11-23 10:58     ` Stefan Hajnoczi
2011-11-24  3:38     ` Chunyan Liu
2011-11-24  8:59       ` Stefan Hajnoczi
2011-11-25 10:19         ` Chunyan Liu
2011-11-29 10:52           ` Stefan Hajnoczi
2011-12-02 15:31             ` Chunyan Liu

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=1322043290-20349-1-git-send-email-cyliu@suse.com \
    --to=cyliu@suse.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).