From: Masayoshi Mizuma
Add a unit test for transient option for qcow2 file.
Signed-off-by: Masayoshi Mizuma
---
tests/qemublocktest.c | 10 ++
.../xml2json/qcow2-transient-srconly.json | 9 +
.../qemublocktestdata/xml2json/qcow2-transient.json | 13 +
.../qemublocktestdata/xml2json/qcow2-transient.xml | 13 +
4 files changed, 45 insertions(+)
create mode 100644
tests/qemublocktestdata/xml2json/qcow2-transient-srconly.json
create mode 100644 tests/qemublocktestdata/xml2json/qcow2-transient.json
create mode 100644 tests/qemublocktestdata/xml2json/qcow2-transient.xml
diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
index 0cdedb9..1294c18 100644
--- a/tests/qemublocktest.c
+++ b/tests/qemublocktest.c
@@ -266,6 +266,7 @@ testQemuDiskXMLToProps(const void *opaque)
g_autoptr(virJSONValue) formatProps = NULL;
g_autoptr(virJSONValue) storageProps = NULL;
g_autoptr(virJSONValue) storageSrcOnlyProps = NULL;
+qemuDomainObjPrivate priv;
g_autofree char *xmlpath = NULL;
g_autofree char *xmlstr = NULL;
@@ -288,6 +289,13 @@ testQemuDiskXMLToProps(const void *opaque)
return -1;
}
+if (disk->transient) {
+priv.driver = data->driver;
+if (qemuBlockCreateTransientDisk(disk->src, &priv) < 0)
+return EXIT_AM_SKIP;
+unlink(disk->src->path);
+}
+
for (n = disk->src; virStorageSourceIsBacking(n); n = n->backingStore) {
g_autofree char *backingstore = NULL;
@@ -1226,6 +1234,8 @@ mymain(void)
TEST_DISK_TO_JSON("nvme-raw-noopts");
+TEST_DISK_TO_JSON("qcow2-transient");
+
#define TEST_JSON_TO_JSON(nme) \
do { \
jsontojsondata.name = nme; \
diff --git a/tests/qemublocktestdata/xml2json/qcow2-transient-srconly.json
b/tests/qemublocktestdata/xml2json/qcow2-transient-srconly.json
new file mode 100644
index 000..3c2de91
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/qcow2-transient-srconly.json
@@ -0,0 +1,9 @@
+(
+ source only properties:
+ {
+"driver": "file",
+"filename": "/var/lib/libvirt/images/transient.qcow2.TRANSIENT"
+ }
+ backing store string:
+ /var/lib/libvirt/images/transient.qcow2.TRANSIENT
+)
diff --git a/tests/qemublocktestdata/xml2json/qcow2-transient.json
b/tests/qemublocktestdata/xml2json/qcow2-transient.json
new file mode 100644
index 000..57463e1
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/qcow2-transient.json
@@ -0,0 +1,13 @@
+{
+ "node-name": "1234567890",
+ "read-only": false,
+ "driver": "qcow2",
+ "file": "1234567890"
+}
+{
+ "driver": "file",
+ "filename": "/var/lib/libvirt/images/transient.qcow2.TRANSIENT",
+ "node-name": "1234567890",
+ "auto-read-only": true,
+ "discard": "unmap"
+}
diff --git a/tests/qemublocktestdata/xml2json/qcow2-transient.xml
b/tests/qemublocktestdata/xml2json/qcow2-transient.xml
new file mode 100644
index 000..d2e3919
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/qcow2-transient.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
--
2.27.0