[PATCH 2/2] qemu_block: add locking option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There is a case that locking hits a bug and users wants to disable
locking like bug in Linux kernel.

This commit adds actual qemu option to the domain conf added in previous
commit.

Signed-off-by: Hiroki Narukawa <hnarukaw@xxxxxxxxxxxxx>
---
 src/qemu/qemu_block.c                         |  7 ++++++
 tests/qemublocktest.c                         |  1 +
 ...le-raw-aio_native-locking-off-srconly.json | 10 ++++++++
 .../file-raw-aio_native-locking-off.json      | 23 +++++++++++++++++++
 .../file-raw-aio_native-locking-off.xml       | 12 ++++++++++
 5 files changed, 53 insertions(+)
 create mode 100644 tests/qemublocktestdata/xml2json/file-raw-aio_native-locking-off-srconly.json
 create mode 100644 tests/qemublocktestdata/xml2json/file-raw-aio_native-locking-off.json
 create mode 100644 tests/qemublocktestdata/xml2json/file-raw-aio_native-locking-off.xml

diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 738b72d7ea..5905898b38 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -852,6 +852,13 @@ qemuBlockStorageSourceGetFileProps(virStorageSource *src,
                                        "S:aio", iomode,
                                        "S:pr-manager", prManagerAlias,
                                        NULL) < 0);
+
+    if (src->locking) {
+        const char *lockingStr = virTristateSwitchTypeToString(src->locking);
+        if (virJSONValueObjectAdd(&ret, "S:locking", lockingStr, NULL) < 0)
+            return NULL;
+    }
+
     return ret;
 }
 
diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
index c581bd1748..3b005cb475 100644
--- a/tests/qemublocktest.c
+++ b/tests/qemublocktest.c
@@ -1116,6 +1116,7 @@ mymain(void)
     TEST_DISK_TO_JSON("dir-fat-readonly");
     TEST_DISK_TO_JSON("dir-fat-floppy");
     TEST_DISK_TO_JSON("file-raw-aio_native");
+    TEST_DISK_TO_JSON("file-raw-aio_native-locking-off");
     TEST_DISK_TO_JSON("file-backing_basic-aio_threads");
     TEST_DISK_TO_JSON("file-backing_basic-aio_io_uring");
     TEST_DISK_TO_JSON("file-raw-luks");
diff --git a/tests/qemublocktestdata/xml2json/file-raw-aio_native-locking-off-srconly.json b/tests/qemublocktestdata/xml2json/file-raw-aio_native-locking-off-srconly.json
new file mode 100644
index 0000000000..88c9970ccf
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-raw-aio_native-locking-off-srconly.json
@@ -0,0 +1,10 @@
+(
+  source only properties:
+  {
+    "driver": "file",
+    "filename": "/path/to/i.img",
+    "locking": "off"
+  }
+  backing store string:
+  /path/to/i.img
+)
diff --git a/tests/qemublocktestdata/xml2json/file-raw-aio_native-locking-off.json b/tests/qemublocktestdata/xml2json/file-raw-aio_native-locking-off.json
new file mode 100644
index 0000000000..aeb483e4b4
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-raw-aio_native-locking-off.json
@@ -0,0 +1,23 @@
+{
+  "node-name": "test1",
+  "read-only": false,
+  "cache": {
+    "direct": true,
+    "no-flush": false
+  },
+  "driver": "raw",
+  "file": "test2"
+}
+{
+  "driver": "file",
+  "filename": "/path/to/i.img",
+  "aio": "native",
+  "locking": "off",
+  "node-name": "test2",
+  "auto-read-only": true,
+  "discard": "unmap",
+  "cache": {
+    "direct": true,
+    "no-flush": false
+  }
+}
diff --git a/tests/qemublocktestdata/xml2json/file-raw-aio_native-locking-off.xml b/tests/qemublocktestdata/xml2json/file-raw-aio_native-locking-off.xml
new file mode 100644
index 0000000000..9e6a9d26bc
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-raw-aio_native-locking-off.xml
@@ -0,0 +1,12 @@
+<disk device='disk'>
+  <driver name='qemu' type='raw' io='native' cache='none'/>
+  <source file='/path/to/i.img' locking='off'>
+    <privateData>
+      <nodenames>
+        <nodename type='storage' name='test2'/>
+        <nodename type='format' name='test1'/>
+      </nodenames>
+    </privateData>
+  </source>
+  <target dev='vda'/>
+</disk>
-- 
2.25.1
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux