diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
index b15d90b614..09fef8f2a9 100644
--- a/tests/qemublocktest.c
+++ b/tests/qemublocktest.c
@@ -471,6 +471,14 @@ mymain(void)
TEST_DISK_TO_JSON("file-backing_basic-unmap-ignore");
TEST_DISK_TO_JSON("file-backing_basic-detect");
+ TEST_DISK_TO_JSON("file-backing_basic-cache-none");
+ TEST_DISK_TO_JSON("file-backing_basic-cache-writethrough");
+ TEST_DISK_TO_JSON("file-backing_basic-cache-writeback");
+ TEST_DISK_TO_JSON("file-backing_basic-cache-directsync");
+ TEST_DISK_TO_JSON("file-backing_basic-cache-unsafe");
+ TEST_DISK_TO_JSON("network-qcow2-backing-chain-cache-unsafe");
+ TEST_DISK_TO_JSON("dir-fat-cache");
+
cleanup:
virHashFree(diskxmljsondata.schema);
qemuTestDriverFree(&driver);
diff --git a/tests/qemublocktestdata/xml2json/dir-fat-cache.json b/tests/qemublocktestdata/xml2json/dir-fat-cache.json
new file mode 100644
index 0000000000..8c0a045ed5
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/dir-fat-cache.json
@@ -0,0 +1,22 @@
+{
+ "node-name": "node-f",
+ "read-only": true,
+ "cache": {
+ "direct": true,
+ "no-flush": false
+ },
+ "driver": "raw",
+ "file": {
+ "driver": "vvfat",
+ "dir": "/var/somefiles",
+ "floppy": false,
+ "rw": false,
+ "node-name": "node-s",
+ "cache": {
+ "direct": true,
+ "no-flush": false
+ },
+ "read-only": true,
+ "discard": "unmap"
+ }
+}
diff --git a/tests/qemublocktestdata/xml2json/dir-fat-cache.xml b/tests/qemublocktestdata/xml2json/dir-fat-cache.xml
new file mode 100644
index 0000000000..18e652a45f
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/dir-fat-cache.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-directsync.json b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-directsync.json
new file mode 100644
index 0000000000..023caf013f
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-directsync.json
@@ -0,0 +1,91 @@
+{
+ "node-name": "node-a-f",
+ "read-only": false,
+ "cache": {
+ "direct": true,
+ "no-flush": false
+ },
+ "driver": "qcow2",
+ "file": {
+ "driver": "file",
+ "filename": "/var/lib/libvirt/images/a",
+ "node-name": "node-a-s",
+ "cache": {
+ "direct": true,
+ "no-flush": false
+ },
+ "read-only": false,
+ "discard": "unmap"
+ },
+ "backing": "node-b-f"
+}
+{
+ "node-name": "node-b-f",
+ "read-only": true,
+ "cache": {
+ "direct": true,
+ "no-flush": false
+ },
+ "driver": "qcow2",
+ "file": {
+ "driver": "file",
+ "filename": "/var/lib/libvirt/images/b",
+ "node-name": "node-b-s",
+ "cache": {
+ "direct": true,
+ "no-flush": false
+ },
+ "read-only": true,
+ "discard": "unmap"
+ },
+ "backing": "node-c-f"
+}
+{
+ "node-name": "node-c-f",
+ "read-only": true,
+ "cache": {
+ "direct": true,
+ "no-flush": false
+ },
+ "driver": "qcow2",
+ "file": {
+ "driver": "gluster",
+ "volume": "images",
+ "path": "c",
+ "server": [
+ {
+ "type": "inet",
+ "host": "test.org",
+ "port": "24007"
+ }
+ ],
+ "node-name": "node-c-s",
+ "cache": {
+ "direct": true,
+ "no-flush": false
+ },
+ "read-only": true,
+ "discard": "unmap"
+ },
+ "backing": "node-d-f"
+}
+{
+ "node-name": "node-d-f",
+ "read-only": true,
+ "cache": {
+ "direct": true,
+ "no-flush": false
+ },
+ "driver": "raw",
+ "file": {
+ "driver": "file",
+ "filename": "/var/lib/libvirt/images/d",
+ "node-name": "node-d-s",
+ "cache": {
+ "direct": true,
+ "no-flush": false
+ },
+ "read-only": true,
+ "discard": "unmap"
+ }
+}
diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-directsync.xml b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-directsync.xml
new file mode 100644
index 0000000000..cf4197ea86
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-directsync.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-none.json b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-none.json
new file mode 100644
index 0000000000..023caf013f
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-none.json
@@ -0,0 +1,91 @@
+{
+ "node-name": "node-a-f",
+ "read-only": false,
+ "cache": {
+ "direct": true,
+ "no-flush": false
+ },
+ "driver": "qcow2",
+ "file": {
+ "driver": "file",
+ "filename": "/var/lib/libvirt/images/a",
+ "node-name": "node-a-s",
+ "cache": {
+ "direct": true,
+ "no-flush": false
+ },
+ "read-only": false,
+ "discard": "unmap"
+ },
+ "backing": "node-b-f"
+}
+{
+ "node-name": "node-b-f",
+ "read-only": true,
+ "cache": {
+ "direct": true,
+ "no-flush": false
+ },
+ "driver": "qcow2",
+ "file": {
+ "driver": "file",
+ "filename": "/var/lib/libvirt/images/b",
+ "node-name": "node-b-s",
+ "cache": {
+ "direct": true,
+ "no-flush": false
+ },
+ "read-only": true,
+ "discard": "unmap"
+ },
+ "backing": "node-c-f"
+}
+{
+ "node-name": "node-c-f",
+ "read-only": true,
+ "cache": {
+ "direct": true,
+ "no-flush": false
+ },
+ "driver": "qcow2",
+ "file": {
+ "driver": "gluster",
+ "volume": "images",
+ "path": "c",
+ "server": [
+ {
+ "type": "inet",
+ "host": "test.org",
+ "port": "24007"
+ }
+ ],
+ "node-name": "node-c-s",
+ "cache": {
+ "direct": true,
+ "no-flush": false
+ },
+ "read-only": true,
+ "discard": "unmap"
+ },
+ "backing": "node-d-f"
+}
+{
+ "node-name": "node-d-f",
+ "read-only": true,
+ "cache": {
+ "direct": true,
+ "no-flush": false
+ },
+ "driver": "raw",
+ "file": {
+ "driver": "file",
+ "filename": "/var/lib/libvirt/images/d",
+ "node-name": "node-d-s",
+ "cache": {
+ "direct": true,
+ "no-flush": false
+ },
+ "read-only": true,
+ "discard": "unmap"
+ }
+}
diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-none.xml b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-none.xml
new file mode 100644
index 0000000000..240afa85d2
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-none.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-unsafe.json b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-unsafe.json
new file mode 100644
index 0000000000..5f6b94a9d5
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-unsafe.json
@@ -0,0 +1,91 @@
+{
+ "node-name": "node-a-f",
+ "read-only": false,
+ "cache": {
+ "direct": false,
+ "no-flush": true
+ },
+ "driver": "qcow2",
+ "file": {
+ "driver": "file",
+ "filename": "/var/lib/libvirt/images/a",
+ "node-name": "node-a-s",
+ "cache": {
+ "direct": false,
+ "no-flush": true
+ },
+ "read-only": false,
+ "discard": "unmap"
+ },
+ "backing": "node-b-f"
+}
+{
+ "node-name": "node-b-f",
+ "read-only": true,
+ "cache": {
+ "direct": false,
+ "no-flush": true
+ },
+ "driver": "qcow2",
+ "file": {
+ "driver": "file",
+ "filename": "/var/lib/libvirt/images/b",
+ "node-name": "node-b-s",
+ "cache": {
+ "direct": false,
+ "no-flush": true
+ },
+ "read-only": true,
+ "discard": "unmap"
+ },
+ "backing": "node-c-f"
+}
+{
+ "node-name": "node-c-f",
+ "read-only": true,
+ "cache": {
+ "direct": false,
+ "no-flush": true
+ },
+ "driver": "qcow2",
+ "file": {
+ "driver": "gluster",
+ "volume": "images",
+ "path": "c",
+ "server": [
+ {
+ "type": "inet",
+ "host": "test.org",
+ "port": "24007"
+ }
+ ],
+ "node-name": "node-c-s",
+ "cache": {
+ "direct": false,
+ "no-flush": true
+ },
+ "read-only": true,
+ "discard": "unmap"
+ },
+ "backing": "node-d-f"
+}
+{
+ "node-name": "node-d-f",
+ "read-only": true,
+ "cache": {
+ "direct": false,
+ "no-flush": true
+ },
+ "driver": "raw",
+ "file": {
+ "driver": "file",
+ "filename": "/var/lib/libvirt/images/d",
+ "node-name": "node-d-s",
+ "cache": {
+ "direct": false,
+ "no-flush": true
+ },
+ "read-only": true,
+ "discard": "unmap"
+ }
+}
diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-unsafe.xml b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-unsafe.xml
new file mode 100644
index 0000000000..e18d33ce3c
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-unsafe.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writeback.json b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writeback.json
new file mode 100644
index 0000000000..9dc7d38850
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writeback.json
@@ -0,0 +1,91 @@
+{
+ "node-name": "node-a-f",
+ "read-only": false,
+ "cache": {
+ "direct": false,
+ "no-flush": false
+ },
+ "driver": "qcow2",
+ "file": {
+ "driver": "file",
+ "filename": "/var/lib/libvirt/images/a",
+ "node-name": "node-a-s",
+ "cache": {
+ "direct": false,
+ "no-flush": false
+ },
+ "read-only": false,
+ "discard": "unmap"
+ },
+ "backing": "node-b-f"
+}
+{
+ "node-name": "node-b-f",
+ "read-only": true,
+ "cache": {
+ "direct": false,
+ "no-flush": false
+ },
+ "driver": "qcow2",
+ "file": {
+ "driver": "file",
+ "filename": "/var/lib/libvirt/images/b",
+ "node-name": "node-b-s",
+ "cache": {
+ "direct": false,
+ "no-flush": false
+ },
+ "read-only": true,
+ "discard": "unmap"
+ },
+ "backing": "node-c-f"
+}
+{
+ "node-name": "node-c-f",
+ "read-only": true,
+ "cache": {
+ "direct": false,
+ "no-flush": false
+ },
+ "driver": "qcow2",
+ "file": {
+ "driver": "gluster",
+ "volume": "images",
+ "path": "c",
+ "server": [
+ {
+ "type": "inet",
+ "host": "test.org",
+ "port": "24007"
+ }
+ ],
+ "node-name": "node-c-s",
+ "cache": {
+ "direct": false,
+ "no-flush": false
+ },
+ "read-only": true,
+ "discard": "unmap"
+ },
+ "backing": "node-d-f"
+}
+{
+ "node-name": "node-d-f",
+ "read-only": true,
+ "cache": {
+ "direct": false,
+ "no-flush": false
+ },
+ "driver": "raw",
+ "file": {
+ "driver": "file",
+ "filename": "/var/lib/libvirt/images/d",
+ "node-name": "node-d-s",
+ "cache": {
+ "direct": false,
+ "no-flush": false
+ },
+ "read-only": true,
+ "discard": "unmap"
+ }
+}
diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writeback.xml b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writeback.xml
new file mode 100644
index 0000000000..7040388040
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writeback.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writethrough.json b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writethrough.json
new file mode 100644
index 0000000000..9dc7d38850
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writethrough.json
@@ -0,0 +1,91 @@
+{
+ "node-name": "node-a-f",
+ "read-only": false,
+ "cache": {
+ "direct": false,
+ "no-flush": false
+ },
+ "driver": "qcow2",
+ "file": {
+ "driver": "file",
+ "filename": "/var/lib/libvirt/images/a",
+ "node-name": "node-a-s",
+ "cache": {
+ "direct": false,
+ "no-flush": false
+ },
+ "read-only": false,
+ "discard": "unmap"
+ },
+ "backing": "node-b-f"
+}
+{
+ "node-name": "node-b-f",
+ "read-only": true,
+ "cache": {
+ "direct": false,
+ "no-flush": false
+ },
+ "driver": "qcow2",
+ "file": {
+ "driver": "file",
+ "filename": "/var/lib/libvirt/images/b",
+ "node-name": "node-b-s",
+ "cache": {
+ "direct": false,
+ "no-flush": false
+ },
+ "read-only": true,
+ "discard": "unmap"
+ },
+ "backing": "node-c-f"
+}
+{
+ "node-name": "node-c-f",
+ "read-only": true,
+ "cache": {
+ "direct": false,
+ "no-flush": false
+ },
+ "driver": "qcow2",
+ "file": {
+ "driver": "gluster",
+ "volume": "images",
+ "path": "c",
+ "server": [
+ {
+ "type": "inet",
+ "host": "test.org",
+ "port": "24007"
+ }
+ ],
+ "node-name": "node-c-s",
+ "cache": {
+ "direct": false,
+ "no-flush": false
+ },
+ "read-only": true,
+ "discard": "unmap"
+ },
+ "backing": "node-d-f"
+}
+{
+ "node-name": "node-d-f",
+ "read-only": true,
+ "cache": {
+ "direct": false,
+ "no-flush": false
+ },
+ "driver": "raw",
+ "file": {
+ "driver": "file",
+ "filename": "/var/lib/libvirt/images/d",
+ "node-name": "node-d-s",
+ "cache": {
+ "direct": false,
+ "no-flush": false
+ },
+ "read-only": true,
+ "discard": "unmap"
+ }
+}
diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writethrough.xml b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writethrough.xml
new file mode 100644
index 0000000000..d2fe1b780b
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writethrough.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-cache-unsafe.json b/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-cache-unsafe.json
new file mode 100644
index 0000000000..6161f3375d
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-cache-unsafe.json
@@ -0,0 +1,57 @@
+{
+ "node-name": "node-b-f",
+ "read-only": false,
+ "cache": {
+ "direct": false,
+ "no-flush": true
+ },
+ "driver": "qcow2",
+ "file": {
+ "driver": "rbd",
+ "pool": "rbdpool",
+ "image": "rbdimg",
+ "server": [
+ {
+ "host": "host1.example.com",
+ "port": "0"
+ },
+ {
+ "host": "host2.example.com",
+ "port": "0"
+ }
+ ],
+ "user": "testuser-rbd",
+ "node-name": "node-a-s",
+ "cache": {
+ "direct": false,
+ "no-flush": true
+ },
+ "read-only": false,
+ "discard": "unmap"
+ },
+ "backing": "node-b-f"
+}
+{
+ "node-name": "node-b-f",
+ "read-only": true,
+ "cache": {
+ "direct": false,
+ "no-flush": true
+ },
+ "driver": "qcow2",
+ "file": {
+ "driver": "iscsi",
+ "portal": "example.org:3260",
+ "target": "iscsitarget",
+ "lun": 1,
+ "transport": "tcp",
+ "node-name": "node-b-s",
+ "cache": {
+ "direct": false,
+ "no-flush": true
+ },
+ "read-only": true,
+ "discard": "unmap"
+ },
+ "backing": null
+}
diff --git a/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-cache-unsafe.xml b/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-cache-unsafe.xml
new file mode 100644
index 0000000000..a51e6a4b5d
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-cache-unsafe.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+