[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v7 07/20] qemu-io: Add "-L" option for BDRV_O_NO_LOC
From: |
Fam Zheng |
Subject: |
[Qemu-devel] [PATCH v7 07/20] qemu-io: Add "-L" option for BDRV_O_NO_LOCK |
Date: |
Mon, 8 Aug 2016 21:13:20 +0800 |
Signed-off-by: Fam Zheng <address@hidden>
---
qemu-io.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/qemu-io.c b/qemu-io.c
index db129ea..5c14eba 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -108,6 +108,7 @@ static void open_help(void)
" -r, -- open file read-only\n"
" -s, -- use snapshot file\n"
" -n, -- disable host cache, short for -t none\n"
+" -L, -- disable image locking\n"
" -k, -- use kernel AIO implementation (on Linux only)\n"
" -t, -- use the given cache mode for the image\n"
" -d, -- use the given discard mode for the image\n"
@@ -124,7 +125,7 @@ static const cmdinfo_t open_cmd = {
.argmin = 1,
.argmax = -1,
.flags = CMD_NOFILE_OK,
- .args = "[-rsnk] [-t cache] [-d discard] [-o options] [path]",
+ .args = "[-rsnLk] [-t cache] [-d discard] [-o options] [path]",
.oneline = "open the file specified by path",
.help = open_help,
};
@@ -143,12 +144,13 @@ static int open_f(BlockBackend *blk, int argc, char
**argv)
{
int flags = BDRV_O_UNMAP;
int readonly = 0;
+ bool nolock = false;
bool writethrough = true;
int c;
QemuOpts *qopts;
QDict *opts;
- while ((c = getopt(argc, argv, "snro:kt:d:")) != -1) {
+ while ((c = getopt(argc, argv, "snrLo:kt:d:")) != -1) {
switch (c) {
case 's':
flags |= BDRV_O_SNAPSHOT;
@@ -177,6 +179,9 @@ static int open_f(BlockBackend *blk, int argc, char **argv)
return 0;
}
break;
+ case 'L':
+ nolock = true;
+ break;
case 'o':
if (imageOpts) {
printf("--image-opts and 'open -o' are mutually exclusive\n");
@@ -198,6 +203,10 @@ static int open_f(BlockBackend *blk, int argc, char **argv)
flags |= BDRV_O_RDWR;
}
+ if (nolock) {
+ flags |= BDRV_O_NO_LOCK;
+ }
+
if (imageOpts && (optind == argc - 1)) {
if (!qemu_opts_parse_noisily(&empty_opts, argv[optind], false)) {
qemu_opts_reset(&empty_opts);
@@ -436,13 +445,15 @@ static QemuOptsList file_opts = {
int main(int argc, char **argv)
{
int readonly = 0;
- const char *sopt = "hVc:d:f:rsnmkt:T:";
+ const char *sopt = "hVc:d:f:rLsnmkt:T:";
+ bool nolock = false;
const struct option lopt[] = {
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
{ "cmd", required_argument, NULL, 'c' },
{ "format", required_argument, NULL, 'f' },
{ "read-only", no_argument, NULL, 'r' },
+ { "no-lock", no_argument, NULL, 'L' },
{ "snapshot", no_argument, NULL, 's' },
{ "nocache", no_argument, NULL, 'n' },
{ "misalign", no_argument, NULL, 'm' },
@@ -501,6 +512,9 @@ int main(int argc, char **argv)
case 'r':
readonly = 1;
break;
+ case 'L':
+ nolock = true;
+ break;
case 'm':
qemuio_misalign = true;
break;
@@ -586,6 +600,10 @@ int main(int argc, char **argv)
flags |= BDRV_O_RDWR;
}
+ if (nolock) {
+ flags |= BDRV_O_NO_LOCK;
+ }
+
if ((argc - optind) == 1) {
if (imageOpts) {
QemuOpts *qopts = NULL;
--
2.7.4
- [Qemu-devel] [PATCH v7 00/20] block: Image locking series for 2.8, Fam Zheng, 2016/08/08
- [Qemu-devel] [PATCH v7 01/20] block: Add flag bits for image locking, Fam Zheng, 2016/08/08
- [Qemu-devel] [PATCH v7 02/20] qapi: Add lock-mode in blockdev-add options, Fam Zheng, 2016/08/08
- [Qemu-devel] [PATCH v7 03/20] block: Add and parse "lock-mode" option for image locking, Fam Zheng, 2016/08/08
- [Qemu-devel] [PATCH v7 04/20] block: Introduce image file locking, Fam Zheng, 2016/08/08
- [Qemu-devel] [PATCH v7 05/20] osdep: Add qemu_lock_fd and qemu_unlock_fd, Fam Zheng, 2016/08/08
- [Qemu-devel] [PATCH v7 07/20] qemu-io: Add "-L" option for BDRV_O_NO_LOCK,
Fam Zheng <=
- [Qemu-devel] [PATCH v7 06/20] raw-posix: Add image locking support, Fam Zheng, 2016/08/08
- [Qemu-devel] [PATCH v7 08/20] qemu-img: Add "-L" option to sub commands, Fam Zheng, 2016/08/08
- [Qemu-devel] [PATCH v7 09/20] qemu-img: Update documentation of "-L" option, Fam Zheng, 2016/08/08
- [Qemu-devel] [PATCH v7 10/20] qemu-nbd: Add "--no-lock/-L" option, Fam Zheng, 2016/08/08
- [Qemu-devel] [PATCH v7 11/20] block: Don't lock drive-backup target image in none mode, Fam Zheng, 2016/08/08
- [Qemu-devel] [PATCH v7 12/20] qemu-iotests: 046: Move version detection out from verify_io, Fam Zheng, 2016/08/08
- [Qemu-devel] [PATCH v7 13/20] qemu-iotests: Wait for QEMU processes before checking image in 091, Fam Zheng, 2016/08/08
- [Qemu-devel] [PATCH v7 15/20] iotests: 087: Disable image locking in cases where file is shared, Fam Zheng, 2016/08/08
- [Qemu-devel] [PATCH v7 16/20] iotests: 130: Check image info locklessly, Fam Zheng, 2016/08/08
- [Qemu-devel] [PATCH v7 19/20] block: Turn on image locking by default, Fam Zheng, 2016/08/08