[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 19/43] nbd: fixes to read-only handling
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 19/43] nbd: fixes to read-only handling |
Date: |
Mon, 3 Dec 2012 16:08:43 -0600 |
From: Paolo Bonzini <address@hidden>
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 <address@hidden>
(cherry picked from commit c8969eded252058e90e91f12f75f32aceae46ec9)
Signed-off-by: Michael Roth <address@hidden>
---
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
- [Qemu-devel] [PATCH 08/43] rtc: fix overflow in mktimegm, (continued)
- [Qemu-devel] [PATCH 08/43] rtc: fix overflow in mktimegm, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 10/43] target-i386: Allow tsc-frequency to be larger then 2.147G, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 09/43] hw: Fix return value check for bdrv_read, bdrv_write, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 12/43] memory: fix rendering of a region obscured by another, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 13/43] s390x: fix -initrd in virtio machine, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 11/43] e1000: drop check_rxov, always treat RX ring with RDH == RDT as empty, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 15/43] target-sparc64: disable VGA cirrus, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 16/43] xhci: fix usb name in caps, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 14/43] PPC: Bamboo: Fix memory size DT property, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 17/43] tools: initialize main loop before block layer, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 19/43] nbd: fixes to read-only handling,
Michael Roth <=
- [Qemu-devel] [PATCH 18/43] m68k: Return semihosting errno values correctly, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 20/43] mips/malta: fix CBUS UART interrupt pin, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 21/43] target-mips: fix wrong microMIPS opcode encoding, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 23/43] tcg/arm: fix cross-endian qemu_st16, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 22/43] tcg/arm: fix TLB access in qemu-ld/st ops, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 28/43] block: Fix regression for MinGW (assertion caused by short string), Michael Roth, 2012/12/03