qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: qemu-stable@nongnu.org
Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 19/43] nbd: fixes to read-only handling
Date: Mon,  3 Dec 2012 16:08:43 -0600	[thread overview]
Message-ID: <1354572547-21271-20-git-send-email-mdroth@linux.vnet.ibm.com> (raw)
In-Reply-To: <1354572547-21271-1-git-send-email-mdroth@linux.vnet.ibm.com>

From: Paolo Bonzini <pbonzini@redhat.com>

We do not need BLKROSET if the kernel supports setting flags.
Also, always do BLKROSET even for a read-write export, otherwise
the read-only state remains "sticky" after the invocation of
"qemu-nbd -r".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit c8969eded252058e90e91f12f75f32aceae46ec9)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 nbd.c |   25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/nbd.c b/nbd.c
index 206f75c..19f6cd8 100644
--- a/nbd.c
+++ b/nbd.c
@@ -399,24 +399,23 @@ int nbd_init(int fd, int csock, uint32_t flags, off_t size, size_t blocksize)
         return -serrno;
     }
 
-    if (flags & NBD_FLAG_READ_ONLY) {
-        int read_only = 1;
-        TRACE("Setting readonly attribute");
-
-        if (ioctl(fd, BLKROSET, (unsigned long) &read_only) < 0) {
+    if (ioctl(fd, NBD_SET_FLAGS, flags) < 0) {
+        if (errno == ENOTTY) {
+            int read_only = (flags & NBD_FLAG_READ_ONLY) != 0;
+            TRACE("Setting readonly attribute");
+
+            if (ioctl(fd, BLKROSET, (unsigned long) &read_only) < 0) {
+                int serrno = errno;
+                LOG("Failed setting read-only attribute");
+                return -serrno;
+            }
+        } else {
             int serrno = errno;
-            LOG("Failed setting read-only attribute");
+            LOG("Failed setting flags");
             return -serrno;
         }
     }
 
-    if (ioctl(fd, NBD_SET_FLAGS, flags) < 0
-        && errno != ENOTTY) {
-        int serrno = errno;
-        LOG("Failed setting flags");
-        return -serrno;
-    }
-
     TRACE("Negotiation ended");
 
     return 0;
-- 
1.7.9.5

  parent reply	other threads:[~2012-12-03 22:15 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-03 22:08 [Qemu-devel] Patch Round-up for stable 1.2.2, freeze Wednesday Michael Roth
2012-12-03 22:08 ` [Qemu-devel] [PATCH 01/43] configure: Fix CONFIG_QEMU_HELPERDIR generation Michael Roth
2012-12-03 22:08 ` [Qemu-devel] [PATCH 02/43] fix CONFIG_QEMU_HELPERDIR generation again Michael Roth
2012-12-03 22:08 ` [Qemu-devel] [PATCH 03/43] ui/vnc: Only report/use TIGHT_PNG encoding if enabled Michael Roth
2012-12-03 22:08 ` [Qemu-devel] [PATCH 04/43] vnc: fix "info vnc" with "-vnc ..., reverse=on" Michael Roth
2012-12-03 22:08 ` [Qemu-devel] [PATCH 05/43] uhci: Raise interrupt when requested even for non active tds Michael Roth
2012-12-03 22:08 ` [Qemu-devel] [PATCH 06/43] hw/qxl: qxl_dirty_surfaces: use uintptr_t Michael Roth
2012-12-03 22:08 ` [Qemu-devel] [PATCH 07/43] qxl: always update displaysurface on resize Michael Roth
2012-12-03 22:08 ` [Qemu-devel] [PATCH 08/43] rtc: fix overflow in mktimegm Michael Roth
2012-12-03 22:08 ` [Qemu-devel] [PATCH 09/43] hw: Fix return value check for bdrv_read, bdrv_write Michael Roth
2012-12-03 22:08 ` [Qemu-devel] [PATCH 10/43] target-i386: Allow tsc-frequency to be larger then 2.147G Michael Roth
2012-12-03 22:08 ` [Qemu-devel] [PATCH 11/43] e1000: drop check_rxov, always treat RX ring with RDH == RDT as empty Michael Roth
2012-12-03 22:08 ` [Qemu-devel] [PATCH 12/43] memory: fix rendering of a region obscured by another Michael Roth
2012-12-03 22:08 ` [Qemu-devel] [PATCH 13/43] s390x: fix -initrd in virtio machine Michael Roth
2012-12-03 22:08 ` [Qemu-devel] [PATCH 14/43] PPC: Bamboo: Fix memory size DT property Michael Roth
2012-12-03 22:08 ` [Qemu-devel] [PATCH 15/43] target-sparc64: disable VGA cirrus Michael Roth
2012-12-03 22:08 ` [Qemu-devel] [PATCH 16/43] xhci: fix usb name in caps Michael Roth
2012-12-03 22:08 ` [Qemu-devel] [PATCH 17/43] tools: initialize main loop before block layer Michael Roth
2012-12-03 22:08 ` [Qemu-devel] [PATCH 18/43] m68k: Return semihosting errno values correctly Michael Roth
2012-12-03 22:08 ` Michael Roth [this message]
2012-12-03 22:08 ` [Qemu-devel] [PATCH 20/43] mips/malta: fix CBUS UART interrupt pin Michael Roth
2012-12-03 22:08 ` [Qemu-devel] [PATCH 21/43] target-mips: fix wrong microMIPS opcode encoding Michael Roth
2012-12-03 22:08 ` [Qemu-devel] [PATCH 22/43] tcg/arm: fix TLB access in qemu-ld/st ops Michael Roth
2013-01-17 16:55   ` Peter Maydell
2012-12-03 22:08 ` [Qemu-devel] [PATCH 23/43] tcg/arm: fix cross-endian qemu_st16 Michael Roth
2012-12-03 22:08 ` [Qemu-devel] [PATCH 24/43] target-openrisc: remove conflicting definitions from cpu.h Michael Roth
2012-12-03 22:08 ` [Qemu-devel] [PATCH 25/43] configure: avoid compiler warning in pipe2 detection Michael Roth
2012-12-03 22:08 ` [Qemu-devel] [PATCH 26/43] qcow2: Fix refcount table size calculation Michael Roth
2012-12-03 22:08 ` [Qemu-devel] [PATCH 27/43] tci: Fix type of tci_read_label Michael Roth
2012-12-03 22:25 ` [Qemu-devel] [PATCH 28/43] block: Fix regression for MinGW (assertion caused by short string) Michael Roth
2012-12-03 22:25   ` [Qemu-devel] [PATCH 29/43] qom: dynamic_cast of NULL is always NULL Michael Roth
2012-12-03 22:25   ` [Qemu-devel] [PATCH 30/43] hmp: do not crash on invalid SCSI hotplug Michael Roth
2012-12-03 22:25   ` [Qemu-devel] [PATCH 31/43] PPC: Fix missing TRACE exception Michael Roth
2012-12-03 22:25   ` [Qemu-devel] [PATCH 32/43] qom: fix refcount of non-heap-allocated objects Michael Roth
2012-12-03 22:44 ` [Qemu-devel] [PATCH 33/43] qapi: handle visitor->type_size() in QapiDeallocVisitor Michael Roth
2012-12-03 22:44 ` [Qemu-devel] [PATCH 34/43] qapi: fix qapi_dealloc_type_size parameter type Michael Roth
2012-12-03 22:44 ` [Qemu-devel] [PATCH 35/43] iscsi: fix segfault in url parsing Michael Roth
2012-12-03 22:44 ` [Qemu-devel] [PATCH 36/43] iscsi: fix deadlock during login Michael Roth
2012-12-03 22:44 ` [Qemu-devel] [PATCH 37/43] iscsi: do not assume device is zero initialized Michael Roth
2012-12-03 22:44 ` [Qemu-devel] [PATCH 38/43] virtio-scsi: Fix some endian bugs with virtio-scsi Michael Roth
2012-12-03 22:44 ` [Qemu-devel] [PATCH 39/43] virtio-scsi: Fix subtle (guest) endian bug Michael Roth
2012-12-03 22:44 ` [Qemu-devel] [PATCH 40/43] qxl: reload memslots after migration, when qxl is in UNDEFINED mode Michael Roth
2012-12-03 22:44 ` [Qemu-devel] [PATCH 41/43] usb: fail usbdevice_create() when there is no USB bus Michael Roth
2012-12-03 22:44 ` [Qemu-devel] [PATCH 42/43] stream: fix ratelimit_set_speed Michael Roth
2012-12-03 22:44 ` [Qemu-devel] [PATCH 43/43] e1000: Discard packets that are too long if !SBP and !LPE Michael Roth

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=1354572547-21271-20-git-send-email-mdroth@linux.vnet.ibm.com \
    --to=mdroth@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@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).