2017-11-03 14:20:55 +00:00
|
|
|
/*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "testutils.h"
|
2018-03-23 08:06:40 +00:00
|
|
|
|
2018-09-04 11:00:14 +00:00
|
|
|
#if WITH_YAJL
|
|
|
|
# include "testutilsqemu.h"
|
|
|
|
# include "testutilsqemuschema.h"
|
|
|
|
# include "virstoragefile.h"
|
|
|
|
# include "virstring.h"
|
|
|
|
# include "virlog.h"
|
|
|
|
# include "qemu/qemu_block.h"
|
|
|
|
# include "qemu/qemu_qapi.h"
|
2017-11-03 14:20:55 +00:00
|
|
|
|
2018-09-04 11:00:14 +00:00
|
|
|
# include "qemu/qemu_command.h"
|
|
|
|
|
2018-09-04 11:40:01 +00:00
|
|
|
# define LIBVIRT_SNAPSHOT_CONF_PRIV_H_ALLOW
|
|
|
|
# include "conf/snapshot_conf_priv.h"
|
|
|
|
|
2018-09-04 11:00:14 +00:00
|
|
|
# define VIR_FROM_THIS VIR_FROM_NONE
|
2017-11-03 14:20:55 +00:00
|
|
|
|
|
|
|
VIR_LOG_INIT("tests.storagetest");
|
|
|
|
|
|
|
|
struct testBackingXMLjsonXMLdata {
|
|
|
|
int type;
|
|
|
|
const char *xml;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
testBackingXMLjsonXML(const void *args)
|
|
|
|
{
|
|
|
|
const struct testBackingXMLjsonXMLdata *data = args;
|
2019-03-08 15:10:07 +00:00
|
|
|
VIR_AUTOPTR(xmlDoc) xml = NULL;
|
|
|
|
VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
|
|
|
|
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
VIR_AUTOPTR(virJSONValue) backendprops = NULL;
|
|
|
|
VIR_AUTOPTR(virJSONValue) wrapper = NULL;
|
|
|
|
VIR_AUTOFREE(char *) propsstr = NULL;
|
|
|
|
VIR_AUTOFREE(char *) protocolwrapper = NULL;
|
|
|
|
VIR_AUTOFREE(char *) actualxml = NULL;
|
2019-02-15 11:52:45 +00:00
|
|
|
VIR_AUTOUNREF(virStorageSourcePtr) xmlsrc = NULL;
|
|
|
|
VIR_AUTOUNREF(virStorageSourcePtr) jsonsrc = NULL;
|
2017-11-03 14:20:55 +00:00
|
|
|
|
2019-02-14 15:20:25 +00:00
|
|
|
if (!(xmlsrc = virStorageSourceNew()))
|
2017-11-03 14:20:55 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
xmlsrc->type = data->type;
|
|
|
|
|
|
|
|
if (!(xml = virXMLParseStringCtxt(data->xml, "(test storage source XML)", &ctxt)))
|
2019-03-08 15:11:20 +00:00
|
|
|
return -1;
|
2017-11-03 14:20:55 +00:00
|
|
|
|
2019-03-11 09:47:53 +00:00
|
|
|
if (virDomainStorageSourceParse(ctxt->node, ctxt, xmlsrc, 0, NULL) < 0) {
|
2017-11-03 14:20:55 +00:00
|
|
|
fprintf(stderr, "failed to parse disk source xml\n");
|
2019-03-08 15:11:20 +00:00
|
|
|
return -1;
|
2017-11-03 14:20:55 +00:00
|
|
|
}
|
|
|
|
|
2018-09-04 17:29:10 +00:00
|
|
|
if (!(backendprops = qemuBlockStorageSourceGetBackendProps(xmlsrc, true, false,
|
|
|
|
false))) {
|
2017-11-03 14:20:55 +00:00
|
|
|
fprintf(stderr, "failed to format disk source json\n");
|
2019-03-08 15:11:20 +00:00
|
|
|
return -1;
|
2017-11-03 14:20:55 +00:00
|
|
|
}
|
|
|
|
|
2018-03-30 09:12:57 +00:00
|
|
|
if (virJSONValueObjectCreate(&wrapper, "a:file", &backendprops, NULL) < 0)
|
2019-03-08 15:11:20 +00:00
|
|
|
return -1;
|
2017-11-03 14:20:55 +00:00
|
|
|
|
|
|
|
if (!(propsstr = virJSONValueToString(wrapper, false)))
|
2019-03-08 15:11:20 +00:00
|
|
|
return -1;
|
2017-11-03 14:20:55 +00:00
|
|
|
|
|
|
|
if (virAsprintf(&protocolwrapper, "json:%s", propsstr) < 0)
|
2019-03-08 15:11:20 +00:00
|
|
|
return -1;
|
2017-11-03 14:20:55 +00:00
|
|
|
|
|
|
|
if (!(jsonsrc = virStorageSourceNewFromBackingAbsolute(protocolwrapper))) {
|
|
|
|
fprintf(stderr, "failed to parse disk json\n");
|
2019-03-08 15:11:20 +00:00
|
|
|
return -1;
|
2017-11-03 14:20:55 +00:00
|
|
|
}
|
|
|
|
|
2019-04-04 20:32:05 +00:00
|
|
|
if (virDomainDiskSourceFormat(&buf, jsonsrc, "source", 0, false, 0,
|
|
|
|
NULL) < 0 ||
|
2017-11-03 14:20:55 +00:00
|
|
|
!(actualxml = virBufferContentAndReset(&buf))) {
|
|
|
|
fprintf(stderr, "failed to format disk source xml\n");
|
2019-03-08 15:11:20 +00:00
|
|
|
return -1;
|
2017-11-03 14:20:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (STRNEQ(actualxml, data->xml)) {
|
|
|
|
fprintf(stderr, "\n expected storage source xml:\n'%s'\n"
|
|
|
|
"actual storage source xml:\n%s\n"
|
|
|
|
"intermediate json:\n%s\n",
|
|
|
|
data->xml, actualxml, protocolwrapper);
|
2019-03-08 15:11:20 +00:00
|
|
|
return -1;
|
2017-11-03 14:20:55 +00:00
|
|
|
}
|
|
|
|
|
2019-03-08 15:11:20 +00:00
|
|
|
return 0;
|
2017-11-03 14:20:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-23 08:06:40 +00:00
|
|
|
struct testQemuDiskXMLToJSONData {
|
|
|
|
virQEMUDriverPtr driver;
|
|
|
|
virHashTablePtr schema;
|
|
|
|
virJSONValuePtr schemaroot;
|
|
|
|
const char *name;
|
|
|
|
bool fail;
|
|
|
|
|
|
|
|
virJSONValuePtr *props;
|
|
|
|
size_t nprops;
|
|
|
|
|
2018-12-17 15:29:05 +00:00
|
|
|
virJSONValuePtr *propssrc;
|
|
|
|
size_t npropssrc;
|
|
|
|
|
2018-03-23 08:06:40 +00:00
|
|
|
virQEMUCapsPtr qemuCaps;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
testQemuDiskXMLToPropsClear(struct testQemuDiskXMLToJSONData *data)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < data->nprops; i++)
|
|
|
|
virJSONValueFree(data->props[i]);
|
|
|
|
|
2018-12-17 15:29:05 +00:00
|
|
|
for (i = 0; i < data->npropssrc; i++)
|
|
|
|
virJSONValueFree(data->propssrc[i]);
|
|
|
|
|
2018-03-23 08:06:40 +00:00
|
|
|
data->nprops = 0;
|
|
|
|
VIR_FREE(data->props);
|
2018-12-17 15:29:05 +00:00
|
|
|
data->npropssrc = 0;
|
|
|
|
VIR_FREE(data->propssrc);
|
2018-03-23 08:06:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-19 14:16:44 +00:00
|
|
|
static int
|
|
|
|
testQemuDiskXMLToJSONFakeSecrets(virStorageSourcePtr src)
|
|
|
|
{
|
|
|
|
qemuDomainStorageSourcePrivatePtr srcpriv;
|
|
|
|
|
|
|
|
if (!src->privateData &&
|
|
|
|
!(src->privateData = qemuDomainStorageSourcePrivateNew()))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
|
|
|
|
|
|
|
|
if (src->auth) {
|
|
|
|
if (VIR_ALLOC(srcpriv->secinfo) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
srcpriv->secinfo->type = VIR_DOMAIN_SECRET_INFO_TYPE_AES;
|
|
|
|
if (VIR_STRDUP(srcpriv->secinfo->s.aes.username, src->auth->username) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (virAsprintf(&srcpriv->secinfo->s.aes.alias, "%s-secalias",
|
|
|
|
NULLSTR(src->nodestorage)) < 0)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (src->encryption) {
|
|
|
|
if (VIR_ALLOC(srcpriv->encinfo) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
srcpriv->encinfo->type = VIR_DOMAIN_SECRET_INFO_TYPE_AES;
|
|
|
|
if (virAsprintf(&srcpriv->encinfo->s.aes.alias, "%s-encalias",
|
|
|
|
NULLSTR(src->nodeformat)) < 0)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-23 08:06:40 +00:00
|
|
|
static const char *testQemuDiskXMLToJSONPath = abs_srcdir "/qemublocktestdata/xml2json/";
|
|
|
|
|
|
|
|
static int
|
|
|
|
testQemuDiskXMLToProps(const void *opaque)
|
|
|
|
{
|
|
|
|
struct testQemuDiskXMLToJSONData *data = (void *) opaque;
|
|
|
|
virDomainDiskDefPtr disk = NULL;
|
|
|
|
virStorageSourcePtr n;
|
2018-05-14 11:54:12 +00:00
|
|
|
virJSONValuePtr formatProps = NULL;
|
|
|
|
virJSONValuePtr storageProps = NULL;
|
2018-12-17 15:29:05 +00:00
|
|
|
VIR_AUTOPTR(virJSONValue) storageSrcOnlyProps = NULL;
|
2018-03-23 08:06:40 +00:00
|
|
|
char *xmlpath = NULL;
|
|
|
|
char *xmlstr = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (virAsprintf(&xmlpath, "%s%s.xml",
|
|
|
|
testQemuDiskXMLToJSONPath, data->name) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (virTestLoadFile(xmlpath, &xmlstr) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* qemu stores node names in the status XML portion */
|
|
|
|
if (!(disk = virDomainDiskDefParse(xmlstr, NULL, data->driver->xmlopt,
|
|
|
|
VIR_DOMAIN_DEF_PARSE_STATUS)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (qemuCheckDiskConfig(disk, data->qemuCaps) < 0 ||
|
|
|
|
qemuDomainDeviceDefValidateDisk(disk, data->qemuCaps) < 0) {
|
|
|
|
VIR_TEST_VERBOSE("invalid configuration for disk\n");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (n = disk->src; virStorageSourceIsBacking(n); n = n->backingStore) {
|
2018-04-19 14:16:44 +00:00
|
|
|
if (testQemuDiskXMLToJSONFakeSecrets(n) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2018-05-29 15:28:11 +00:00
|
|
|
if (qemuDomainValidateStorageSource(n, data->qemuCaps) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2018-05-29 15:05:05 +00:00
|
|
|
if (qemuDomainPrepareDiskSourceData(disk, n, NULL, data->qemuCaps) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2018-05-14 11:54:12 +00:00
|
|
|
if (!(formatProps = qemuBlockStorageSourceGetBlockdevProps(n)) ||
|
2018-09-04 17:29:10 +00:00
|
|
|
!(storageSrcOnlyProps = qemuBlockStorageSourceGetBackendProps(n, false, true, true)) ||
|
|
|
|
!(storageProps = qemuBlockStorageSourceGetBackendProps(n, false, false, true))) {
|
2018-03-23 08:06:40 +00:00
|
|
|
if (!data->fail) {
|
|
|
|
VIR_TEST_VERBOSE("failed to generate qemu blockdev props\n");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
} else if (data->fail) {
|
|
|
|
VIR_TEST_VERBOSE("qemu blockdev props should have failed\n");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2018-05-14 11:54:12 +00:00
|
|
|
if (VIR_APPEND_ELEMENT(data->props, data->nprops, formatProps) < 0 ||
|
2018-12-17 15:29:05 +00:00
|
|
|
VIR_APPEND_ELEMENT(data->props, data->nprops, storageProps) < 0 ||
|
|
|
|
VIR_APPEND_ELEMENT(data->propssrc, data->npropssrc, storageSrcOnlyProps) < 0)
|
2018-03-23 08:06:40 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2018-05-14 11:54:12 +00:00
|
|
|
virJSONValueFree(formatProps);
|
|
|
|
virJSONValueFree(storageProps);
|
2018-03-23 08:06:40 +00:00
|
|
|
virDomainDiskDefFree(disk);
|
|
|
|
VIR_FREE(xmlpath);
|
|
|
|
VIR_FREE(xmlstr);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
testQemuDiskXMLToPropsValidateSchema(const void *opaque)
|
|
|
|
{
|
|
|
|
struct testQemuDiskXMLToJSONData *data = (void *) opaque;
|
|
|
|
virBuffer debug = VIR_BUFFER_INITIALIZER;
|
|
|
|
char *propsstr = NULL;
|
|
|
|
char *debugmsg = NULL;
|
|
|
|
int ret = 0;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (data->fail)
|
|
|
|
return EXIT_AM_SKIP;
|
|
|
|
|
|
|
|
for (i = 0; i < data->nprops; i++) {
|
|
|
|
if (testQEMUSchemaValidate(data->props[i], data->schemaroot,
|
|
|
|
data->schema, &debug) < 0) {
|
|
|
|
debugmsg = virBufferContentAndReset(&debug);
|
|
|
|
propsstr = virJSONValueToString(data->props[i], true);
|
|
|
|
VIR_TEST_VERBOSE("json does not conform to QAPI schema");
|
|
|
|
VIR_TEST_DEBUG("json:\n%s\ndoes not match schema. Debug output:\n %s",
|
|
|
|
propsstr, NULLSTR(debugmsg));
|
|
|
|
VIR_FREE(debugmsg);
|
|
|
|
VIR_FREE(propsstr);
|
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
virBufferFreeAndReset(&debug);
|
|
|
|
}
|
2018-12-17 15:29:05 +00:00
|
|
|
|
|
|
|
for (i = 0; i < data->npropssrc; i++) {
|
|
|
|
if (testQEMUSchemaValidate(data->propssrc[i], data->schemaroot,
|
|
|
|
data->schema, &debug) < 0) {
|
|
|
|
debugmsg = virBufferContentAndReset(&debug);
|
|
|
|
propsstr = virJSONValueToString(data->propssrc[i], true);
|
|
|
|
VIR_TEST_VERBOSE("json does not conform to QAPI schema");
|
|
|
|
VIR_TEST_DEBUG("json:\n%s\ndoes not match schema. Debug output:\n %s",
|
|
|
|
propsstr, NULLSTR(debugmsg));
|
|
|
|
VIR_FREE(debugmsg);
|
|
|
|
VIR_FREE(propsstr);
|
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
virBufferFreeAndReset(&debug);
|
|
|
|
}
|
|
|
|
|
2018-03-23 08:06:40 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
testQemuDiskXMLToPropsValidateFile(const void *opaque)
|
|
|
|
{
|
|
|
|
struct testQemuDiskXMLToJSONData *data = (void *) opaque;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
char *jsonpath = NULL;
|
|
|
|
char *actual = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (data->fail)
|
|
|
|
return EXIT_AM_SKIP;
|
|
|
|
|
|
|
|
if (virAsprintf(&jsonpath, "%s%s.json",
|
|
|
|
testQemuDiskXMLToJSONPath, data->name) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
for (i = 0; i < data->nprops; i++) {
|
|
|
|
char *jsonstr;
|
|
|
|
|
|
|
|
if (!(jsonstr = virJSONValueToString(data->props[i], true)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
virBufferAdd(&buf, jsonstr, -1);
|
|
|
|
VIR_FREE(jsonstr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virBufferCheckError(&buf) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
actual = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = virTestCompareToFile(actual, jsonpath);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
VIR_FREE(jsonpath);
|
|
|
|
VIR_FREE(actual);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-04 11:40:01 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-12-17 15:29:05 +00:00
|
|
|
static int
|
|
|
|
testQemuDiskXMLToPropsValidateFileSrcOnly(const void *opaque)
|
|
|
|
{
|
|
|
|
struct testQemuDiskXMLToJSONData *data = (void *) opaque;
|
|
|
|
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
VIR_AUTOFREE(char *) jsonpath = NULL;
|
|
|
|
VIR_AUTOFREE(char *) actual = NULL;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (data->fail)
|
|
|
|
return EXIT_AM_SKIP;
|
|
|
|
|
|
|
|
if (virAsprintf(&jsonpath, "%s%s-srconly.json",
|
|
|
|
testQemuDiskXMLToJSONPath, data->name) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
for (i = 0; i < data->npropssrc; i++) {
|
|
|
|
VIR_AUTOFREE(char *) jsonstr = NULL;
|
|
|
|
|
|
|
|
if (!(jsonstr = virJSONValueToString(data->propssrc[i], true)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
virBufferAdd(&buf, jsonstr, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virBufferCheckError(&buf) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
actual = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
return virTestCompareToFile(actual, jsonpath);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-03 14:20:55 +00:00
|
|
|
static int
|
|
|
|
mymain(void)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
2018-03-23 08:06:40 +00:00
|
|
|
virQEMUDriver driver;
|
2018-03-16 16:11:29 +00:00
|
|
|
struct testBackingXMLjsonXMLdata xmljsonxmldata;
|
2018-03-23 08:06:40 +00:00
|
|
|
struct testQemuDiskXMLToJSONData diskxmljsondata;
|
2018-09-04 11:40:01 +00:00
|
|
|
struct testQemuImageCreateData imagecreatedata;
|
2018-03-23 08:06:40 +00:00
|
|
|
char *capslatest_x86_64 = NULL;
|
|
|
|
virQEMUCapsPtr caps_x86_64 = NULL;
|
|
|
|
|
|
|
|
if (qemuTestDriverInit(&driver) < 0)
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
|
|
|
diskxmljsondata.driver = &driver;
|
2018-09-04 11:40:01 +00:00
|
|
|
imagecreatedata.driver = &driver;
|
2018-03-23 08:06:40 +00:00
|
|
|
|
2019-04-16 10:26:22 +00:00
|
|
|
if (!(capslatest_x86_64 = testQemuGetLatestCapsForArch("x86_64", "xml")))
|
2018-03-23 08:06:40 +00:00
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
|
|
|
VIR_TEST_VERBOSE("\nlatest caps x86_64: %s\n", capslatest_x86_64);
|
|
|
|
|
|
|
|
if (!(caps_x86_64 = qemuTestParseCapabilitiesArch(virArchFromString("x86_64"),
|
|
|
|
capslatest_x86_64)))
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
|
|
|
diskxmljsondata.qemuCaps = caps_x86_64;
|
2018-09-04 11:40:01 +00:00
|
|
|
imagecreatedata.qemuCaps = caps_x86_64;
|
2017-11-03 14:20:55 +00:00
|
|
|
|
|
|
|
virTestCounterReset("qemu storage source xml->json->xml ");
|
|
|
|
|
2018-09-04 11:00:14 +00:00
|
|
|
# define TEST_JSON_FORMAT(tpe, xmlstr) \
|
2017-11-03 14:20:55 +00:00
|
|
|
do { \
|
2018-03-16 16:11:29 +00:00
|
|
|
xmljsonxmldata.type = tpe; \
|
|
|
|
xmljsonxmldata.xml = xmlstr; \
|
|
|
|
if (virTestRun(virTestCounterNext(), testBackingXMLjsonXML, \
|
|
|
|
&xmljsonxmldata) < 0) \
|
2017-11-03 14:20:55 +00:00
|
|
|
ret = -1; \
|
|
|
|
} while (0)
|
|
|
|
|
2018-09-04 11:00:14 +00:00
|
|
|
# define TEST_JSON_FORMAT_NET(xmlstr) \
|
2017-11-03 14:20:55 +00:00
|
|
|
TEST_JSON_FORMAT(VIR_STORAGE_TYPE_NETWORK, xmlstr)
|
|
|
|
|
|
|
|
TEST_JSON_FORMAT(VIR_STORAGE_TYPE_FILE, "<source file='/path/to/file'/>\n");
|
|
|
|
|
|
|
|
/* type VIR_STORAGE_TYPE_BLOCK is not tested since it parses back to 'file' */
|
|
|
|
/* type VIR_STORAGE_TYPE_DIR it is a 'format' driver in qemu */
|
|
|
|
|
2018-10-11 10:22:21 +00:00
|
|
|
TEST_JSON_FORMAT_NET("<source protocol='http' name=''>\n"
|
|
|
|
" <host name='example.com' port='80'/>\n"
|
|
|
|
"</source>\n");
|
2017-11-03 14:20:55 +00:00
|
|
|
TEST_JSON_FORMAT_NET("<source protocol='http' name='file'>\n"
|
|
|
|
" <host name='example.com' port='80'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_JSON_FORMAT_NET("<source protocol='https' name='file'>\n"
|
|
|
|
" <host name='example.com' port='432'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_JSON_FORMAT_NET("<source protocol='gluster' name='vol/file'>\n"
|
|
|
|
" <host name='example.com' port='24007'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_JSON_FORMAT_NET("<source protocol='gluster' name='testvol/img.qcow2'>\n"
|
|
|
|
" <host name='example.com' port='1234'/>\n"
|
|
|
|
" <host transport='unix' socket='/path/socket'/>\n"
|
|
|
|
" <host name='example.com' port='24007'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_JSON_FORMAT_NET("<source protocol='nbd'>\n"
|
|
|
|
" <host transport='unix' socket='/path/to/socket'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_JSON_FORMAT_NET("<source protocol='nbd' name='blah'>\n"
|
|
|
|
" <host name='example.org' port='6000'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_JSON_FORMAT_NET("<source protocol='nbd'>\n"
|
|
|
|
" <host name='example.org' port='6000'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_JSON_FORMAT_NET("<source protocol='ssh' name='blah'>\n"
|
|
|
|
" <host name='example.org' port='6000'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_JSON_FORMAT_NET("<source protocol='rbd' name='libvirt/test'>\n"
|
|
|
|
" <host name='example.com' port='1234'/>\n"
|
|
|
|
" <host name='example2.com'/>\n"
|
|
|
|
" <snapshot name='snapshotname'/>\n"
|
|
|
|
" <config file='/path/to/conf'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_JSON_FORMAT_NET("<source protocol='iscsi' name='iqn.2016-12.com.virttest:emulated-iscsi-noauth.target/0'>\n"
|
|
|
|
" <host name='test.org' port='3260'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_JSON_FORMAT_NET("<source protocol='iscsi' name='iqn.2016-12.com.virttest:emulated-iscsi-noauth.target/6'>\n"
|
|
|
|
" <host name='test.org' port='1234'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_JSON_FORMAT_NET("<source protocol='sheepdog' name='test'>\n"
|
|
|
|
" <host name='example.com' port='321'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_JSON_FORMAT_NET("<source protocol='vxhs' name='c6718f6b-0401-441d-a8c3-1f0064d75ee0'>\n"
|
|
|
|
" <host name='example.com' port='9999'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
|
2018-09-04 11:00:14 +00:00
|
|
|
# define TEST_DISK_TO_JSON_FULL(nme, fl) \
|
2018-03-23 08:06:40 +00:00
|
|
|
do { \
|
|
|
|
diskxmljsondata.name = nme; \
|
|
|
|
diskxmljsondata.props = NULL; \
|
|
|
|
diskxmljsondata.nprops = 0; \
|
2018-12-17 15:29:05 +00:00
|
|
|
diskxmljsondata.propssrc = NULL; \
|
|
|
|
diskxmljsondata.npropssrc = 0; \
|
2018-03-23 08:06:40 +00:00
|
|
|
diskxmljsondata.fail = fl; \
|
|
|
|
if (virTestRun("disk xml to props " nme, testQemuDiskXMLToProps, \
|
|
|
|
&diskxmljsondata) < 0) \
|
|
|
|
ret = -1; \
|
|
|
|
if (virTestRun("disk xml to props validate schema " nme, \
|
|
|
|
testQemuDiskXMLToPropsValidateSchema, &diskxmljsondata) < 0) \
|
|
|
|
ret = -1; \
|
|
|
|
if (virTestRun("disk xml to props validate file " nme, \
|
|
|
|
testQemuDiskXMLToPropsValidateFile, &diskxmljsondata) < 0) \
|
|
|
|
ret = -1; \
|
2018-12-17 15:29:05 +00:00
|
|
|
if (virTestRun("disk xml to props source only validate file " nme, \
|
|
|
|
testQemuDiskXMLToPropsValidateFileSrcOnly, &diskxmljsondata) < 0) \
|
|
|
|
ret = -1; \
|
2018-03-23 08:06:40 +00:00
|
|
|
testQemuDiskXMLToPropsClear(&diskxmljsondata); \
|
|
|
|
} while (0)
|
|
|
|
|
2018-09-04 11:00:14 +00:00
|
|
|
# define TEST_DISK_TO_JSON(nme) TEST_DISK_TO_JSON_FULL(nme, false)
|
2018-03-23 08:06:40 +00:00
|
|
|
|
|
|
|
if (!(diskxmljsondata.schema = testQEMUSchemaLoad())) {
|
|
|
|
ret = -1;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virQEMUQAPISchemaPathGet("blockdev-add/arg-type",
|
|
|
|
diskxmljsondata.schema,
|
|
|
|
&diskxmljsondata.schemaroot) < 0 ||
|
|
|
|
!diskxmljsondata.schemaroot) {
|
|
|
|
VIR_TEST_VERBOSE("failed to find schema entry for blockdev-add\n");
|
|
|
|
ret = -1;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_DISK_TO_JSON_FULL("nodename-long-format", true);
|
|
|
|
TEST_DISK_TO_JSON_FULL("nodename-long-protocol", true);
|
|
|
|
|
2018-03-28 07:40:03 +00:00
|
|
|
TEST_DISK_TO_JSON("file-raw-noopts");
|
tests: qemublock: Add tests for all other format without special options
Similarly to the 'raw' case add tests for bochs, cloop, dmg, ploop, vdi
vhd, and vpc. Covering all supported non-backing formats.
Note that the JSON name for 'ploop' maps to 'parallels' and 'vhd' maps
to 'vhdx'.
Files added here would result in the followint configs:
file-bochs-noopts.xml:
-drive file=/path/to/i.img,format=bochs,if=none,id=drive-dummy
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
file-cloop-noopts.xml:
-drive file=/path/to/i.img,format=cloop,if=none,id=drive-dummy
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
file-dmg-noopts.xml:
-drive file=/path/to/i.img,format=dmg,if=none,id=drive-dummy
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
file-ploop-noopts.xml:
-drive file=/path/to/i.img,format=ploop,if=none,id=drive-dummy
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
file-vdi-noopts.xml:
-drive file=/path/to/i.img,format=vdi,if=none,id=drive-dummy
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
file-vhd-noopts.xml:
-drive file=/path/to/i.img,format=vhd,if=none,id=drive-dummy
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
file-vpc-noopts.xml:
-drive file=/path/to/i.img,format=vpc,if=none,id=drive-dummy
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-28 08:11:38 +00:00
|
|
|
TEST_DISK_TO_JSON("file-bochs-noopts");
|
|
|
|
TEST_DISK_TO_JSON("file-cloop-noopts");
|
|
|
|
TEST_DISK_TO_JSON("file-dmg-noopts");
|
|
|
|
TEST_DISK_TO_JSON("file-ploop-noopts");
|
|
|
|
TEST_DISK_TO_JSON("file-vdi-noopts");
|
|
|
|
TEST_DISK_TO_JSON("file-vhd-noopts");
|
|
|
|
TEST_DISK_TO_JSON("file-vpc-noopts");
|
2018-03-28 07:40:03 +00:00
|
|
|
|
2018-03-28 08:27:14 +00:00
|
|
|
TEST_DISK_TO_JSON("file-backing_basic-noopts");
|
2018-03-19 07:00:19 +00:00
|
|
|
TEST_DISK_TO_JSON("dir-fat-readonly");
|
|
|
|
TEST_DISK_TO_JSON("dir-fat-floppy");
|
tests: qemublock: Add test cases for 'aio' options of 'file' storage
Test that the 'aio' option is applied correctly for the 'file' protocol
backend and across the backing chain.
The top level disk image would generate the following '-drive' cmdline:
file-backing_basic-aio_threads:
-drive file=/var/lib/libvirt/images/a,format=qcow,if=none,id=drive-dummy,aio=threads
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
file-raw-aio_native:
-drive file=/path/to/i.img,format=raw,if=none,id=drive-dummy,cache=none,aio=native
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy,write-cache=on
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-19 07:59:19 +00:00
|
|
|
TEST_DISK_TO_JSON("file-raw-aio_native");
|
|
|
|
TEST_DISK_TO_JSON("file-backing_basic-aio_threads");
|
2018-04-19 14:16:44 +00:00
|
|
|
TEST_DISK_TO_JSON("file-raw-luks");
|
tests: qemublock: basic qcow2 tests
Add tests for backing chain handling, including a very long chain which
is fully specified in the XML and an unterminated chain.
The top level disk image would generate the following '-drive':
file-qcow2-backing-chain-encryption.xml:
-drive file=/var/lib/libvirt/images/a,encrypt.format=luks,
encrypt.key-secret=node-b-f-encalias,format=qcow2,if=none,id=drive-dummy
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
file-qcow2-backing-chain-noopts.xml:
-drive file=/var/lib/libvirt/images/rhel7.3.1507297895,format=qcow2,if=none,id=drive-dummy
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
file-qcow2-backing-chain-unterminated.xml:
-drive file=/var/lib/libvirt/images/rhel7.3.1507297895,format=qcow2,if=none,id=drive-dummy
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-16 16:56:16 +00:00
|
|
|
TEST_DISK_TO_JSON("file-qcow2-backing-chain-noopts");
|
|
|
|
TEST_DISK_TO_JSON("file-qcow2-backing-chain-unterminated");
|
|
|
|
TEST_DISK_TO_JSON("file-qcow2-backing-chain-encryption");
|
2018-03-19 11:51:20 +00:00
|
|
|
TEST_DISK_TO_JSON("network-qcow2-backing-chain-encryption_auth");
|
2018-03-28 08:27:14 +00:00
|
|
|
|
tests: qemublock: Test handling of 'unmap' and 'detect-zeroes' options
The test cases would correspond to the following -drive command lines:
file-backing_basic-detect.xml:
-drive file=/var/lib/libvirt/images/a,format=qcow,if=none,id=drive-dummy,detect-zeroes=on
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
file-backing_basic-unmap-detect.xml:
-drive file=/var/lib/libvirt/images/a,format=qcow,if=none,id=drive-dummy,discard=unmap,detect-zeroes=unmap
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
file-backing_basic-unmap-ignore.xml:
-drive file=/var/lib/libvirt/images/a,format=qcow,if=none,id=drive-dummy,discard=ignore,detect-zeroes=on
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
file-backing_basic-unmap.xml:
-drive file=/var/lib/libvirt/images/a,format=qcow,if=none,id=drive-dummy,discard=unmap
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-04-06 12:07:44 +00:00
|
|
|
TEST_DISK_TO_JSON("file-backing_basic-unmap");
|
|
|
|
TEST_DISK_TO_JSON("file-backing_basic-unmap-detect");
|
|
|
|
TEST_DISK_TO_JSON("file-backing_basic-unmap-ignore");
|
|
|
|
TEST_DISK_TO_JSON("file-backing_basic-detect");
|
|
|
|
|
tests: qemublock: Test handling of all cache modes
The test cases would correspond to the following -drive command lines:
dir-fat-cache.xml:
-drive file=fat:/var/somefiles,if=none,id=drive-dummy,readonly=on,cache=directsync
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy,write-cache=off
file-backing_basic-cache-directsync.xml:
-drive file=/var/lib/libvirt/images/a,format=qcow2,if=none,id=drive-dummy,cache=directsync
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy,write-cache=off
file-backing_basic-cache-none.xml:
-drive file=/var/lib/libvirt/images/a,format=qcow2,if=none,id=drive-dummy,cache=none
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy,write-cache=on
file-backing_basic-cache-unsafe.xml:
-drive file=/var/lib/libvirt/images/a,format=qcow2,if=none,id=drive-dummy,cache=unsafe
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy,write-cache=on
file-backing_basic-cache-writeback.xml:
-drive file=/var/lib/libvirt/images/a,format=qcow2,if=none,id=drive-dummy,cache=writeback
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy,write-cache=on
file-backing_basic-cache-writethrough.xml:
-drive file=/var/lib/libvirt/images/a,format=qcow2,if=none,id=drive-dummy,cache=writethrough
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy,write-cache=off
network-qcow2-backing-chain-cache-unsafe.xml:
-drive file=rbd:rbdpool/rbdimg:id=testuser-rbd:auth_supported=cephx\;none:
mon_host=host1.example.com\;host2.example.com,
file.password-secret=node-a-s-secalias,format=qcow2,
if=none,id=drive-dummy,cache=directsync
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy,write-cache=off
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-04-06 12:24:51 +00:00
|
|
|
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");
|
2018-05-30 13:28:24 +00:00
|
|
|
TEST_DISK_TO_JSON("network-nbd-tls");
|
tests: qemublock: Test handling of all cache modes
The test cases would correspond to the following -drive command lines:
dir-fat-cache.xml:
-drive file=fat:/var/somefiles,if=none,id=drive-dummy,readonly=on,cache=directsync
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy,write-cache=off
file-backing_basic-cache-directsync.xml:
-drive file=/var/lib/libvirt/images/a,format=qcow2,if=none,id=drive-dummy,cache=directsync
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy,write-cache=off
file-backing_basic-cache-none.xml:
-drive file=/var/lib/libvirt/images/a,format=qcow2,if=none,id=drive-dummy,cache=none
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy,write-cache=on
file-backing_basic-cache-unsafe.xml:
-drive file=/var/lib/libvirt/images/a,format=qcow2,if=none,id=drive-dummy,cache=unsafe
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy,write-cache=on
file-backing_basic-cache-writeback.xml:
-drive file=/var/lib/libvirt/images/a,format=qcow2,if=none,id=drive-dummy,cache=writeback
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy,write-cache=on
file-backing_basic-cache-writethrough.xml:
-drive file=/var/lib/libvirt/images/a,format=qcow2,if=none,id=drive-dummy,cache=writethrough
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy,write-cache=off
network-qcow2-backing-chain-cache-unsafe.xml:
-drive file=rbd:rbdpool/rbdimg:id=testuser-rbd:auth_supported=cephx\;none:
mon_host=host1.example.com\;host2.example.com,
file.password-secret=node-a-s-secalias,format=qcow2,
if=none,id=drive-dummy,cache=directsync
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy,write-cache=off
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-04-06 12:24:51 +00:00
|
|
|
|
2018-04-25 13:53:18 +00:00
|
|
|
TEST_DISK_TO_JSON("block-raw-noopts");
|
2018-05-30 13:47:13 +00:00
|
|
|
TEST_DISK_TO_JSON("block-raw-reservations");
|
2018-04-25 13:53:18 +00:00
|
|
|
|
2018-09-04 11:40:01 +00:00
|
|
|
# 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);
|
|
|
|
|
2018-03-23 08:06:40 +00:00
|
|
|
cleanup:
|
|
|
|
virHashFree(diskxmljsondata.schema);
|
|
|
|
qemuTestDriverFree(&driver);
|
|
|
|
VIR_FREE(capslatest_x86_64);
|
|
|
|
virObjectUnref(caps_x86_64);
|
|
|
|
|
2017-11-03 14:20:55 +00:00
|
|
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2018-09-04 11:00:14 +00:00
|
|
|
#else
|
|
|
|
static int
|
|
|
|
mymain(void)
|
|
|
|
{
|
|
|
|
return EXIT_AM_SKIP;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-11-03 14:20:55 +00:00
|
|
|
VIR_TEST_MAIN(mymain)
|