]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: qemublock: Add testing of 'blockdev-create' generators
authorPeter Krempa <pkrempa@redhat.com>
Tue, 4 Sep 2018 11:40:01 +0000 (13:40 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 18 Jul 2019 15:59:34 +0000 (17:59 +0200)
Test the output against the schema and also against what we expect.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
31 files changed:
tests/qemublocktest.c
tests/qemublocktestdata/imagecreate/luks-encopts.json [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/luks-encopts.xml [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/luks-noopts.json [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/luks-noopts.xml [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/network-gluster-qcow2.json [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/network-gluster-qcow2.xml [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/network-rbd-qcow2.json [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/network-rbd-qcow2.xml [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/network-sheepdog-qcow2.json [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/network-sheepdog-qcow2.xml [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/network-ssh-qcow2.json [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/network-ssh-qcow2.xml [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/qcow2-backing-luks.json [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/qcow2-backing-luks.xml [new symlink]
tests/qemublocktestdata/imagecreate/qcow2-backing-raw-nbd.json [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/qcow2-backing-raw-nbd.xml [new symlink]
tests/qemublocktestdata/imagecreate/qcow2-backing-raw.json [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/qcow2-backing-raw.xml [new symlink]
tests/qemublocktestdata/imagecreate/qcow2-luks-encopts-backing.json [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/qcow2-luks-encopts-backing.xml [new symlink]
tests/qemublocktestdata/imagecreate/qcow2-luks-encopts.json [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/qcow2-luks-encopts.xml [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/qcow2-luks-noopts.json [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/qcow2-luks-noopts.xml [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/qcow2.json [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/qcow2.xml [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/raw-nbd.json [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/raw-nbd.xml [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/raw.json [new file with mode: 0644]
tests/qemublocktestdata/imagecreate/raw.xml [new file with mode: 0644]

index e0b60bbec83943e7ede5c8d7c6d7239cc0ed155a..9321531f6ce729cc02937fde139df08503418062 100644 (file)
@@ -30,6 +30,9 @@
 
 # include "qemu/qemu_command.h"
 
+# define LIBVIRT_SNAPSHOT_CONF_PRIV_H_ALLOW
+# include "conf/snapshot_conf_priv.h"
+
 # define VIR_FROM_THIS VIR_FROM_NONE
 
 VIR_LOG_INIT("tests.storagetest");
@@ -342,6 +345,138 @@ testQemuDiskXMLToPropsValidateFile(const void *opaque)
 }
 
 
+struct testQemuImageCreateData {
+    const char *name;
+    const char *backingname;
+    virHashTablePtr schema;
+    virJSONValuePtr schemaroot;
+    virQEMUDriverPtr driver;
+    virQEMUCapsPtr qemuCaps;
+};
+
+static const char *testQemuImageCreatePath = abs_srcdir "/qemublocktestdata/imagecreate/";
+
+static virStorageSourcePtr
+testQemuImageCreateLoadDiskXML(const char *name,
+                               virDomainXMLOptionPtr xmlopt)
+
+{
+    virDomainSnapshotDiskDefPtr diskdef = NULL;
+    VIR_AUTOPTR(xmlDoc) doc = NULL;
+    VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
+    xmlNodePtr node;
+    VIR_AUTOFREE(char *) xmlpath = NULL;
+    virStorageSourcePtr ret = NULL;
+
+    if (virAsprintf(&xmlpath, "%s%s.xml",
+                    testQemuImageCreatePath, name) < 0)
+        return NULL;
+
+    if (!(doc = virXMLParseFileCtxt(xmlpath, &ctxt)))
+        return NULL;
+
+    if (!(node = virXPathNode("//disk", ctxt))) {
+        VIR_TEST_VERBOSE("failed to find <source> element\n");
+        return NULL;
+    }
+
+    if (VIR_ALLOC(diskdef) < 0)
+        return NULL;
+
+    if (virDomainSnapshotDiskDefParseXML(node, ctxt, diskdef,
+                                         VIR_DOMAIN_DEF_PARSE_STATUS,
+                                         xmlopt) == 0)
+        VIR_STEAL_PTR(ret, diskdef->src);
+
+    virDomainSnapshotDiskDefFree(diskdef);
+    return ret;
+}
+
+
+static int
+testQemuImageCreate(const void *opaque)
+{
+    struct testQemuImageCreateData *data = (void *) opaque;
+    VIR_AUTOPTR(virJSONValue) protocolprops = NULL;
+    VIR_AUTOPTR(virJSONValue) formatprops = NULL;
+    VIR_AUTOUNREF(virStorageSourcePtr) src = NULL;
+    VIR_AUTOCLEAN(virBuffer) debug = VIR_BUFFER_INITIALIZER;
+    VIR_AUTOCLEAN(virBuffer) actualbuf = VIR_BUFFER_INITIALIZER;
+    VIR_AUTOFREE(char *) jsonprotocol = NULL;
+    VIR_AUTOFREE(char *) jsonformat = NULL;
+    VIR_AUTOFREE(char *) actual = NULL;
+    VIR_AUTOFREE(char *) jsonpath = NULL;
+
+    if (!(src = testQemuImageCreateLoadDiskXML(data->name, data->driver->xmlopt)))
+        return -1;
+
+    if (data->backingname &&
+        !(src->backingStore = testQemuImageCreateLoadDiskXML(data->backingname,
+                                                             data->driver->xmlopt)))
+        return -1;
+
+    if (testQemuDiskXMLToJSONFakeSecrets(src) < 0)
+        return -1;
+
+    /* fake some sizes */
+    src->capacity = 1337;
+    src->physical = 42;
+
+    if (qemuDomainValidateStorageSource(src, data->qemuCaps) < 0)
+        return -1;
+
+    if (qemuBlockStorageSourceCreateGetStorageProps(src, &protocolprops) < 0)
+        return -1;
+
+    if (qemuBlockStorageSourceCreateGetFormatProps(src, src->backingStore, &formatprops) < 0)
+        return -1;
+
+    if (formatprops) {
+        if (!(jsonformat = virJSONValueToString(formatprops, true)))
+            return -1;
+
+        if (testQEMUSchemaValidate(formatprops, data->schemaroot, data->schema,
+                                   &debug) < 0) {
+            VIR_AUTOFREE(char *) debugmsg = virBufferContentAndReset(&debug);
+            VIR_TEST_VERBOSE("blockdev-create format json does not conform to QAPI schema");
+            VIR_TEST_DEBUG("json:\n%s\ndoes not match schema. Debug output:\n %s",
+                           jsonformat, NULLSTR(debugmsg));
+            return -1;
+        }
+        virBufferFreeAndReset(&debug);
+    }
+
+    if (protocolprops) {
+        if (!(jsonprotocol = virJSONValueToString(protocolprops, true)))
+            return -1;
+
+        if (testQEMUSchemaValidate(protocolprops, data->schemaroot, data->schema,
+                                   &debug) < 0) {
+            VIR_AUTOFREE(char *) debugmsg = virBufferContentAndReset(&debug);
+            VIR_TEST_VERBOSE("blockdev-create protocol json does not conform to QAPI schema");
+            VIR_TEST_DEBUG("json:\n%s\ndoes not match schema. Debug output:\n %s",
+                           jsonprotocol, NULLSTR(debugmsg));
+            return -1;
+        }
+        virBufferFreeAndReset(&debug);
+    }
+
+    virBufferStrcat(&actualbuf, "protocol:\n", NULLSTR(jsonprotocol),
+                    "\nformat:\n", NULLSTR(jsonformat), NULL);
+    virBufferTrim(&actualbuf, "\n", -1);
+    virBufferAddLit(&actualbuf, "\n");
+
+    if (virAsprintf(&jsonpath, "%s%s.json",
+                    testQemuImageCreatePath, data->name) < 0)
+        return -1;
+
+    if (!(actual = virBufferContentAndReset(&actualbuf)))
+        return -1;
+
+    return virTestCompareToFile(actual, jsonpath);
+}
+
+
 static int
 testQemuDiskXMLToPropsValidateFileSrcOnly(const void *opaque)
 {
@@ -383,6 +518,7 @@ mymain(void)
     virQEMUDriver driver;
     struct testBackingXMLjsonXMLdata xmljsonxmldata;
     struct testQemuDiskXMLToJSONData diskxmljsondata;
+    struct testQemuImageCreateData imagecreatedata;
     char *capslatest_x86_64 = NULL;
     virQEMUCapsPtr caps_x86_64 = NULL;
 
@@ -390,6 +526,7 @@ mymain(void)
         return EXIT_FAILURE;
 
     diskxmljsondata.driver = &driver;
+    imagecreatedata.driver = &driver;
 
     if (!(capslatest_x86_64 = testQemuGetLatestCapsForArch("x86_64", "xml")))
         return EXIT_FAILURE;
@@ -401,6 +538,7 @@ mymain(void)
         return EXIT_FAILURE;
 
     diskxmljsondata.qemuCaps = caps_x86_64;
+    imagecreatedata.qemuCaps = caps_x86_64;
 
     virTestCounterReset("qemu storage source xml->json->xml ");
 
@@ -548,6 +686,41 @@ mymain(void)
     TEST_DISK_TO_JSON("block-raw-noopts");
     TEST_DISK_TO_JSON("block-raw-reservations");
 
+# define TEST_IMAGE_CREATE(testname, testbacking) \
+    do { \
+        imagecreatedata.name = testname; \
+        imagecreatedata.backingname = testbacking; \
+        if (virTestRun("image create xml to props " testname, testQemuImageCreate, \
+                       &imagecreatedata) < 0) \
+            ret = -1; \
+    } while (0)
+    imagecreatedata.schema = diskxmljsondata.schema;
+    if (virQEMUQAPISchemaPathGet("blockdev-create/arg-type/options",
+                                 imagecreatedata.schema,
+                                 &imagecreatedata.schemaroot) < 0 ||
+        !imagecreatedata.schemaroot) {
+        VIR_TEST_VERBOSE("failed to find schema entry for blockdev-create\n");
+        ret = -1;
+        goto cleanup;
+    }
+
+    TEST_IMAGE_CREATE("raw", NULL);
+    TEST_IMAGE_CREATE("raw-nbd", NULL);
+    TEST_IMAGE_CREATE("luks-noopts", NULL);
+    TEST_IMAGE_CREATE("luks-encopts", NULL);
+    TEST_IMAGE_CREATE("qcow2", NULL);
+    TEST_IMAGE_CREATE("qcow2-luks-noopts", NULL);
+    TEST_IMAGE_CREATE("qcow2-luks-encopts", NULL);
+    TEST_IMAGE_CREATE("qcow2-backing-raw", "raw");
+    TEST_IMAGE_CREATE("qcow2-backing-raw-nbd", "raw-nbd");
+    TEST_IMAGE_CREATE("qcow2-backing-luks", "luks-noopts");
+    TEST_IMAGE_CREATE("qcow2-luks-encopts-backing", "qcow2");
+
+    TEST_IMAGE_CREATE("network-gluster-qcow2", NULL);
+    TEST_IMAGE_CREATE("network-rbd-qcow2", NULL);
+    TEST_IMAGE_CREATE("network-ssh-qcow2", NULL);
+    TEST_IMAGE_CREATE("network-sheepdog-qcow2", NULL);
+
  cleanup:
     virHashFree(diskxmljsondata.schema);
     qemuTestDriverFree(&driver);
diff --git a/tests/qemublocktestdata/imagecreate/luks-encopts.json b/tests/qemublocktestdata/imagecreate/luks-encopts.json
new file mode 100644 (file)
index 0000000..f065ad8
--- /dev/null
@@ -0,0 +1,19 @@
+protocol:
+{
+  "driver": "file",
+  "filename": "/var/lib/libvirt/images/i.img",
+  "size": 42
+}
+
+format:
+{
+  "key-secret": "0123456789ABCDEF0123456789ABCDE-encalias",
+  "cipher-alg": "serpent-256",
+  "cipher-mode": "cbc",
+  "hash-alg": "sha256",
+  "ivgen-alg": "plain64",
+  "ivgen-hash-alg": "sha256",
+  "driver": "luks",
+  "file": "0123456789ABCDEF0123456789ABCDE",
+  "size": 1337
+}
diff --git a/tests/qemublocktestdata/imagecreate/luks-encopts.xml b/tests/qemublocktestdata/imagecreate/luks-encopts.xml
new file mode 100644 (file)
index 0000000..bb0ee54
--- /dev/null
@@ -0,0 +1,16 @@
+<disk device='disk' name='vda'>
+  <driver type='raw'/>
+  <source file='/var/lib/libvirt/images/i.img'>
+    <privateData>
+      <nodenames>
+        <nodename type='storage' name='0123456789ABCDEF0123456789ABCDE'/>
+        <nodename type='format' name='0123456789ABCDEF0123456789ABCDE'/>
+      </nodenames>
+    </privateData>
+    <encryption format='luks'>
+      <secret type='passphrase' uuid='f52a81b2-424e-490c-823d-6bd4235bc572'/>
+      <cipher name='serpent' size='256' mode='cbc' hash='sha256'/>
+      <ivgen name='plain64' hash='sha256'/>
+    </encryption>
+  </source>
+</disk>
diff --git a/tests/qemublocktestdata/imagecreate/luks-noopts.json b/tests/qemublocktestdata/imagecreate/luks-noopts.json
new file mode 100644 (file)
index 0000000..1ea1948
--- /dev/null
@@ -0,0 +1,14 @@
+protocol:
+{
+  "driver": "file",
+  "filename": "/var/lib/libvirt/images/i.img",
+  "size": 42
+}
+
+format:
+{
+  "key-secret": "0123456789ABCDEF0123456789ABCDE-encalias",
+  "driver": "luks",
+  "file": "0123456789ABCDEF0123456789ABCDE",
+  "size": 1337
+}
diff --git a/tests/qemublocktestdata/imagecreate/luks-noopts.xml b/tests/qemublocktestdata/imagecreate/luks-noopts.xml
new file mode 100644 (file)
index 0000000..ac224b0
--- /dev/null
@@ -0,0 +1,14 @@
+<disk device='disk' name='vda'>
+  <driver type='raw'/>
+  <source file='/var/lib/libvirt/images/i.img'>
+    <privateData>
+      <nodenames>
+        <nodename type='storage' name='0123456789ABCDEF0123456789ABCDE'/>
+        <nodename type='format' name='0123456789ABCDEF0123456789ABCDE'/>
+      </nodenames>
+    </privateData>
+    <encryption format='luks'>
+      <secret type='passphrase' uuid='f52a81b2-424e-490c-823d-6bd4235bc572'/>
+    </encryption>
+  </source>
+</disk>
diff --git a/tests/qemublocktestdata/imagecreate/network-gluster-qcow2.json b/tests/qemublocktestdata/imagecreate/network-gluster-qcow2.json
new file mode 100644 (file)
index 0000000..aee7bfd
--- /dev/null
@@ -0,0 +1,28 @@
+protocol:
+{
+  "driver": "gluster",
+  "location": {
+    "volume": "asdf",
+    "path": "i.qcow2",
+    "server": [
+      {
+        "type": "inet",
+        "host": "example.com",
+        "port": "1234"
+      },
+      {
+        "type": "inet",
+        "host": "alternate.example.com",
+        "port": "3214"
+      }
+    ]
+  },
+  "size": 42
+}
+
+format:
+{
+  "driver": "qcow2",
+  "file": "0123456789ABCDEF0123456789ABCDE",
+  "size": 1337
+}
diff --git a/tests/qemublocktestdata/imagecreate/network-gluster-qcow2.xml b/tests/qemublocktestdata/imagecreate/network-gluster-qcow2.xml
new file mode 100644 (file)
index 0000000..f3dbf24
--- /dev/null
@@ -0,0 +1,13 @@
+<disk device='disk' name='vda' type='network'>
+  <driver type='qcow2'/>
+  <source protocol='gluster' name='asdf/i.qcow2'>
+    <host name='example.com' port='1234'/>
+    <host name='alternate.example.com' port='3214'/>
+    <privateData>
+      <nodenames>
+        <nodename type='storage' name='0123456789ABCDEF0123456789ABCDE'/>
+        <nodename type='format' name='0123456789ABCDEF0123456789ABCDE'/>
+      </nodenames>
+    </privateData>
+  </source>
+</disk>
diff --git a/tests/qemublocktestdata/imagecreate/network-rbd-qcow2.json b/tests/qemublocktestdata/imagecreate/network-rbd-qcow2.json
new file mode 100644 (file)
index 0000000..56d9c0f
--- /dev/null
@@ -0,0 +1,26 @@
+protocol:
+{
+  "driver": "rbd",
+  "location": {
+    "pool": "asdf",
+    "image": "i.qcow2",
+    "server": [
+      {
+        "host": "example.com",
+        "port": "1234"
+      },
+      {
+        "host": "alternate.example.com",
+        "port": "4321"
+      }
+    ]
+  },
+  "size": 42
+}
+
+format:
+{
+  "driver": "qcow2",
+  "file": "0123456789ABCDEF0123456789ABCDE",
+  "size": 1337
+}
diff --git a/tests/qemublocktestdata/imagecreate/network-rbd-qcow2.xml b/tests/qemublocktestdata/imagecreate/network-rbd-qcow2.xml
new file mode 100644 (file)
index 0000000..0f6c1dd
--- /dev/null
@@ -0,0 +1,13 @@
+<disk device='disk' name='vda' type='network'>
+  <driver type='qcow2'/>
+  <source protocol='rbd' name='asdf/i.qcow2'>
+    <host name='example.com' port='1234'/>
+    <host name='alternate.example.com' port='4321'/>
+    <privateData>
+      <nodenames>
+        <nodename type='storage' name='0123456789ABCDEF0123456789ABCDE'/>
+        <nodename type='format' name='0123456789ABCDEF0123456789ABCDE'/>
+      </nodenames>
+    </privateData>
+  </source>
+</disk>
diff --git a/tests/qemublocktestdata/imagecreate/network-sheepdog-qcow2.json b/tests/qemublocktestdata/imagecreate/network-sheepdog-qcow2.json
new file mode 100644 (file)
index 0000000..b727262
--- /dev/null
@@ -0,0 +1,20 @@
+protocol:
+{
+  "driver": "sheepdog",
+  "location": {
+    "server": {
+      "type": "inet",
+      "host": "example.com",
+      "port": "1234"
+    },
+    "vdi": "asdf/i.qcow2"
+  },
+  "size": 42
+}
+
+format:
+{
+  "driver": "qcow2",
+  "file": "0123456789ABCDEF0123456789ABCDE",
+  "size": 1337
+}
diff --git a/tests/qemublocktestdata/imagecreate/network-sheepdog-qcow2.xml b/tests/qemublocktestdata/imagecreate/network-sheepdog-qcow2.xml
new file mode 100644 (file)
index 0000000..1145daa
--- /dev/null
@@ -0,0 +1,12 @@
+<disk device='disk' name='vda' type='network'>
+  <driver type='qcow2'/>
+  <source protocol='sheepdog' name='asdf/i.qcow2'>
+    <host name='example.com' port='1234'/>
+    <privateData>
+      <nodenames>
+        <nodename type='storage' name='0123456789ABCDEF0123456789ABCDE'/>
+        <nodename type='format' name='0123456789ABCDEF0123456789ABCDE'/>
+      </nodenames>
+    </privateData>
+  </source>
+</disk>
diff --git a/tests/qemublocktestdata/imagecreate/network-ssh-qcow2.json b/tests/qemublocktestdata/imagecreate/network-ssh-qcow2.json
new file mode 100644 (file)
index 0000000..31416ed
--- /dev/null
@@ -0,0 +1,19 @@
+protocol:
+{
+  "driver": "ssh",
+  "location": {
+    "path": "asdf/i.qcow2",
+    "server": {
+      "host": "example.com",
+      "port": "1234"
+    }
+  },
+  "size": 42
+}
+
+format:
+{
+  "driver": "qcow2",
+  "file": "0123456789ABCDEF0123456789ABCDE",
+  "size": 1337
+}
diff --git a/tests/qemublocktestdata/imagecreate/network-ssh-qcow2.xml b/tests/qemublocktestdata/imagecreate/network-ssh-qcow2.xml
new file mode 100644 (file)
index 0000000..4c44f81
--- /dev/null
@@ -0,0 +1,12 @@
+<disk device='disk' name='vda' type='network'>
+  <driver type='qcow2'/>
+  <source protocol='ssh' name='asdf/i.qcow2'>
+    <host name='example.com' port='1234'/>
+    <privateData>
+      <nodenames>
+        <nodename type='storage' name='0123456789ABCDEF0123456789ABCDE'/>
+        <nodename type='format' name='0123456789ABCDEF0123456789ABCDE'/>
+      </nodenames>
+    </privateData>
+  </source>
+</disk>
diff --git a/tests/qemublocktestdata/imagecreate/qcow2-backing-luks.json b/tests/qemublocktestdata/imagecreate/qcow2-backing-luks.json
new file mode 100644 (file)
index 0000000..63ba35d
--- /dev/null
@@ -0,0 +1,15 @@
+protocol:
+{
+  "driver": "file",
+  "filename": "/var/lib/libvirt/images/i.qcow2",
+  "size": 42
+}
+
+format:
+{
+  "driver": "qcow2",
+  "file": "0123456789ABCDEF0123456789ABCDE",
+  "size": 1337,
+  "backing-file": "/var/lib/libvirt/images/i.img",
+  "backing-fmt": "luks"
+}
diff --git a/tests/qemublocktestdata/imagecreate/qcow2-backing-luks.xml b/tests/qemublocktestdata/imagecreate/qcow2-backing-luks.xml
new file mode 120000 (symlink)
index 0000000..5769c2c
--- /dev/null
@@ -0,0 +1 @@
+qcow2.xml
\ No newline at end of file
diff --git a/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-nbd.json b/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-nbd.json
new file mode 100644 (file)
index 0000000..34ce74a
--- /dev/null
@@ -0,0 +1,15 @@
+protocol:
+{
+  "driver": "file",
+  "filename": "/var/lib/libvirt/images/i.qcow2",
+  "size": 42
+}
+
+format:
+{
+  "driver": "qcow2",
+  "file": "0123456789ABCDEF0123456789ABCDE",
+  "size": 1337,
+  "backing-file": "json:{\"driver\":\"nbd\",\"server\":{\"type\":\"inet\",\"host\":\"example.com\",\"port\":\"1234\"}}",
+  "backing-fmt": "raw"
+}
diff --git a/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-nbd.xml b/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-nbd.xml
new file mode 120000 (symlink)
index 0000000..5769c2c
--- /dev/null
@@ -0,0 +1 @@
+qcow2.xml
\ No newline at end of file
diff --git a/tests/qemublocktestdata/imagecreate/qcow2-backing-raw.json b/tests/qemublocktestdata/imagecreate/qcow2-backing-raw.json
new file mode 100644 (file)
index 0000000..8176c8d
--- /dev/null
@@ -0,0 +1,15 @@
+protocol:
+{
+  "driver": "file",
+  "filename": "/var/lib/libvirt/images/i.qcow2",
+  "size": 42
+}
+
+format:
+{
+  "driver": "qcow2",
+  "file": "0123456789ABCDEF0123456789ABCDE",
+  "size": 1337,
+  "backing-file": "/var/lib/libvirt/images/i.img",
+  "backing-fmt": "raw"
+}
diff --git a/tests/qemublocktestdata/imagecreate/qcow2-backing-raw.xml b/tests/qemublocktestdata/imagecreate/qcow2-backing-raw.xml
new file mode 120000 (symlink)
index 0000000..5769c2c
--- /dev/null
@@ -0,0 +1 @@
+qcow2.xml
\ No newline at end of file
diff --git a/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts-backing.json b/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts-backing.json
new file mode 100644 (file)
index 0000000..a57617d
--- /dev/null
@@ -0,0 +1,24 @@
+protocol:
+{
+  "driver": "file",
+  "filename": "/var/lib/libvirt/images/i.qcow2",
+  "size": 42
+}
+
+format:
+{
+  "driver": "qcow2",
+  "file": "0123456789ABCDEF0123456789ABCDE",
+  "size": 1337,
+  "backing-file": "/var/lib/libvirt/images/i.qcow2",
+  "backing-fmt": "qcow2",
+  "encrypt": {
+    "key-secret": "0123456789ABCDEF0123456789ABCDE-encalias",
+    "cipher-alg": "serpent-256",
+    "cipher-mode": "cbc",
+    "hash-alg": "sha256",
+    "ivgen-alg": "plain64",
+    "ivgen-hash-alg": "sha256",
+    "format": "luks"
+  }
+}
diff --git a/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts-backing.xml b/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts-backing.xml
new file mode 120000 (symlink)
index 0000000..6ea018c
--- /dev/null
@@ -0,0 +1 @@
+qcow2-luks-encopts.xml
\ No newline at end of file
diff --git a/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts.json b/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts.json
new file mode 100644 (file)
index 0000000..8796726
--- /dev/null
@@ -0,0 +1,22 @@
+protocol:
+{
+  "driver": "file",
+  "filename": "/var/lib/libvirt/images/i.qcow2",
+  "size": 42
+}
+
+format:
+{
+  "driver": "qcow2",
+  "file": "0123456789ABCDEF0123456789ABCDE",
+  "size": 1337,
+  "encrypt": {
+    "key-secret": "0123456789ABCDEF0123456789ABCDE-encalias",
+    "cipher-alg": "serpent-256",
+    "cipher-mode": "cbc",
+    "hash-alg": "sha256",
+    "ivgen-alg": "plain64",
+    "ivgen-hash-alg": "sha256",
+    "format": "luks"
+  }
+}
diff --git a/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts.xml b/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts.xml
new file mode 100644 (file)
index 0000000..d6616bd
--- /dev/null
@@ -0,0 +1,16 @@
+<disk device='disk' name='vda'>
+  <driver type='qcow2'/>
+  <source file='/var/lib/libvirt/images/i.qcow2'>
+    <privateData>
+      <nodenames>
+        <nodename type='storage' name='0123456789ABCDEF0123456789ABCDE'/>
+        <nodename type='format' name='0123456789ABCDEF0123456789ABCDE'/>
+      </nodenames>
+    </privateData>
+    <encryption format='luks'>
+      <secret type='passphrase' uuid='f52a81b2-424e-490c-823d-6bd4235bc572'/>
+      <cipher name='serpent' size='256' mode='cbc' hash='sha256'/>
+      <ivgen name='plain64' hash='sha256'/>
+    </encryption>
+  </source>
+</disk>
diff --git a/tests/qemublocktestdata/imagecreate/qcow2-luks-noopts.json b/tests/qemublocktestdata/imagecreate/qcow2-luks-noopts.json
new file mode 100644 (file)
index 0000000..f9caaee
--- /dev/null
@@ -0,0 +1,17 @@
+protocol:
+{
+  "driver": "file",
+  "filename": "/var/lib/libvirt/images/i.qcow2",
+  "size": 42
+}
+
+format:
+{
+  "driver": "qcow2",
+  "file": "0123456789ABCDEF0123456789ABCDE",
+  "size": 1337,
+  "encrypt": {
+    "key-secret": "0123456789ABCDEF0123456789ABCDE-encalias",
+    "format": "luks"
+  }
+}
diff --git a/tests/qemublocktestdata/imagecreate/qcow2-luks-noopts.xml b/tests/qemublocktestdata/imagecreate/qcow2-luks-noopts.xml
new file mode 100644 (file)
index 0000000..e2d1c42
--- /dev/null
@@ -0,0 +1,14 @@
+<disk device='disk' name='vda'>
+  <driver type='qcow2'/>
+  <source file='/var/lib/libvirt/images/i.qcow2'>
+    <privateData>
+      <nodenames>
+        <nodename type='storage' name='0123456789ABCDEF0123456789ABCDE'/>
+        <nodename type='format' name='0123456789ABCDEF0123456789ABCDE'/>
+      </nodenames>
+    </privateData>
+    <encryption format='luks'>
+      <secret type='passphrase' uuid='f52a81b2-424e-490c-823d-6bd4235bc572'/>
+    </encryption>
+  </source>
+</disk>
diff --git a/tests/qemublocktestdata/imagecreate/qcow2.json b/tests/qemublocktestdata/imagecreate/qcow2.json
new file mode 100644 (file)
index 0000000..7142cf6
--- /dev/null
@@ -0,0 +1,13 @@
+protocol:
+{
+  "driver": "file",
+  "filename": "/var/lib/libvirt/images/i.qcow2",
+  "size": 42
+}
+
+format:
+{
+  "driver": "qcow2",
+  "file": "0123456789ABCDEF0123456789ABCDE",
+  "size": 1337
+}
diff --git a/tests/qemublocktestdata/imagecreate/qcow2.xml b/tests/qemublocktestdata/imagecreate/qcow2.xml
new file mode 100644 (file)
index 0000000..f3c235f
--- /dev/null
@@ -0,0 +1,11 @@
+<disk device='disk' name='vda'>
+  <driver type='qcow2'/>
+  <source file='/var/lib/libvirt/images/i.qcow2'>
+    <privateData>
+      <nodenames>
+        <nodename type='storage' name='0123456789ABCDEF0123456789ABCDE'/>
+        <nodename type='format' name='0123456789ABCDEF0123456789ABCDE'/>
+      </nodenames>
+    </privateData>
+  </source>
+</disk>
diff --git a/tests/qemublocktestdata/imagecreate/raw-nbd.json b/tests/qemublocktestdata/imagecreate/raw-nbd.json
new file mode 100644 (file)
index 0000000..d1e089e
--- /dev/null
@@ -0,0 +1,4 @@
+protocol:
+<null>
+format:
+<null>
diff --git a/tests/qemublocktestdata/imagecreate/raw-nbd.xml b/tests/qemublocktestdata/imagecreate/raw-nbd.xml
new file mode 100644 (file)
index 0000000..256bf23
--- /dev/null
@@ -0,0 +1,12 @@
+<disk device='disk' name='vda' type='network'>
+  <driver type='raw'/>
+  <source protocol='nbd'>
+    <host name='example.com' port='1234'/>
+    <privateData>
+      <nodenames>
+        <nodename type='storage' name='0123456789ABCDEF0123456789ABCDE'/>
+        <nodename type='format' name='0123456789ABCDEF0123456789ABCDE'/>
+      </nodenames>
+    </privateData>
+  </source>
+</disk>
diff --git a/tests/qemublocktestdata/imagecreate/raw.json b/tests/qemublocktestdata/imagecreate/raw.json
new file mode 100644 (file)
index 0000000..06abb25
--- /dev/null
@@ -0,0 +1,9 @@
+protocol:
+{
+  "driver": "file",
+  "filename": "/var/lib/libvirt/images/i.img",
+  "size": 42
+}
+
+format:
+<null>
diff --git a/tests/qemublocktestdata/imagecreate/raw.xml b/tests/qemublocktestdata/imagecreate/raw.xml
new file mode 100644 (file)
index 0000000..3a91600
--- /dev/null
@@ -0,0 +1,11 @@
+<disk device='disk' name='vda'>
+  <driver type='raw'/>
+  <source file='/var/lib/libvirt/images/i.img'>
+    <privateData>
+      <nodenames>
+        <nodename type='storage' name='0123456789ABCDEF0123456789ABCDE'/>
+        <nodename type='format' name='0123456789ABCDEF0123456789ABCDE'/>
+      </nodenames>
+    </privateData>
+  </source>
+</disk>