[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v5 13/27] qemu-io: Add "-L" option for BDRV_O_NO_LOC
From: |
Fam Zheng |
Subject: |
[Qemu-devel] [PATCH v5 13/27] qemu-io: Add "-L" option for BDRV_O_NO_LOCK |
Date: |
Tue, 17 May 2016 15:35:22 +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 5ef3ef7..4291cb7 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -107,6 +107,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 lock\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"
@@ -123,7 +124,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,
};
@@ -142,12 +143,13 @@ static int open_f(BlockBackend *blk, int argc, char
**argv)
{
int flags = BDRV_O_UNMAP;
int readonly = 0;
+ int nolock = 0;
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;
@@ -176,6 +178,9 @@ static int open_f(BlockBackend *blk, int argc, char **argv)
return 0;
}
break;
+ case 'L':
+ nolock = 1;
+ break;
case 'o':
if (imageOpts) {
printf("--image-opts and 'open -o' are mutually exclusive\n");
@@ -197,6 +202,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);
@@ -433,13 +442,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:";
+ int nolock = 0;
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' },
@@ -499,6 +510,9 @@ int main(int argc, char **argv)
case 'r':
readonly = 1;
break;
+ case 'L':
+ nolock = 1;
+ break;
case 'm':
qemuio_misalign = true;
break;
@@ -579,6 +593,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.8.2
- [Qemu-devel] [PATCH v5 11/27] raw-posix: Implement .bdrv_lockf, (continued)
- [Qemu-devel] [PATCH v5 11/27] raw-posix: Implement .bdrv_lockf, Fam Zheng, 2016/05/17
- [Qemu-devel] [PATCH v5 10/27] raw-posix: Use qemu_dup, Fam Zheng, 2016/05/17
- [Qemu-devel] [PATCH v5 16/27] qemu-nbd: Add "--no-lock/-L" option, Fam Zheng, 2016/05/17
- [Qemu-devel] [PATCH v5 15/27] qemu-img: Update documentation of "-L" option, Fam Zheng, 2016/05/17
- [Qemu-devel] [PATCH v5 14/27] qemu-img: Add "-L" option to sub commands, Fam Zheng, 2016/05/17
- [Qemu-devel] [PATCH v5 13/27] qemu-io: Add "-L" option for BDRV_O_NO_LOCK,
Fam Zheng <=
- [Qemu-devel] [PATCH v5 17/27] block: Don't lock drive-backup target image in none mode, Fam Zheng, 2016/05/17
- [Qemu-devel] [PATCH v5 18/27] mirror: Disable image locking on target backing chain, Fam Zheng, 2016/05/17
- [Qemu-devel] [PATCH v5 19/27] qemu-iotests: 140: Disable image lock for qemu-io access, Fam Zheng, 2016/05/17
- [Qemu-devel] [PATCH v5 21/27] qemu-iotests: Wait for QEMU processes before checking image in 091, Fam Zheng, 2016/05/17
- [Qemu-devel] [PATCH v5 20/27] qemu-iotests: 046: Move version detection out from verify_io, Fam Zheng, 2016/05/17