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>
|
|
|
|
|
|
|
|
|
2021-01-22 09:36:21 +00:00
|
|
|
#include "storage_source.h"
|
2017-11-03 14:20:55 +00:00
|
|
|
#include "testutils.h"
|
2019-12-12 17:17:08 +00:00
|
|
|
#include "testutilsqemu.h"
|
|
|
|
#include "testutilsqemuschema.h"
|
|
|
|
#include "virlog.h"
|
|
|
|
#include "qemu/qemu_block.h"
|
|
|
|
#include "qemu/qemu_qapi.h"
|
|
|
|
#include "qemu/qemu_monitor_json.h"
|
|
|
|
#include "qemu/qemu_backup.h"
|
2020-01-08 13:56:45 +00:00
|
|
|
#include "qemu/qemu_checkpoint.h"
|
2020-03-26 21:31:19 +00:00
|
|
|
#include "qemu/qemu_validate.h"
|
2018-03-23 08:06:40 +00:00
|
|
|
|
2019-12-12 17:17:08 +00:00
|
|
|
#define LIBVIRT_SNAPSHOT_CONF_PRIV_H_ALLOW
|
|
|
|
#include "conf/snapshot_conf_priv.h"
|
2018-09-04 11:00:14 +00:00
|
|
|
|
2019-12-12 17:17:08 +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;
|
2020-03-09 14:39:04 +00:00
|
|
|
bool legacy;
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *schema;
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue *schemaroot;
|
2017-11-03 14:20:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
testBackingXMLjsonXML(const void *args)
|
|
|
|
{
|
|
|
|
const struct testBackingXMLjsonXMLdata *data = args;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(xmlDoc) xml = NULL;
|
|
|
|
g_autoptr(xmlXPathContext) ctxt = NULL;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(virJSONValue) backendprops = NULL;
|
|
|
|
g_autoptr(virJSONValue) wrapper = NULL;
|
2019-10-15 13:16:31 +00:00
|
|
|
g_autofree char *propsstr = NULL;
|
|
|
|
g_autofree char *protocolwrapper = NULL;
|
|
|
|
g_autofree char *actualxml = NULL;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(virStorageSource) xmlsrc = NULL;
|
|
|
|
g_autoptr(virStorageSource) jsonsrc = NULL;
|
2020-03-09 14:39:04 +00:00
|
|
|
g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER;
|
2020-06-19 14:28:12 +00:00
|
|
|
unsigned int backendpropsflags = 0;
|
|
|
|
|
|
|
|
if (data->legacy)
|
|
|
|
backendpropsflags |= QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_LEGACY;
|
2017-11-03 14:20:55 +00:00
|
|
|
|
2020-09-22 09:04:17 +00:00
|
|
|
xmlsrc = virStorageSourceNew();
|
2017-11-03 14:20:55 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-03-09 14:39:04 +00:00
|
|
|
if (!(backendprops = qemuBlockStorageSourceGetBackendProps(xmlsrc,
|
2020-06-19 14:28:12 +00:00
|
|
|
backendpropsflags))) {
|
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
|
|
|
}
|
|
|
|
|
2020-03-09 14:39:04 +00:00
|
|
|
if (!data->legacy) {
|
|
|
|
if (testQEMUSchemaValidate(backendprops, data->schemaroot,
|
2020-04-29 15:52:43 +00:00
|
|
|
data->schema, false, &debug) < 0) {
|
2020-03-09 14:39:04 +00:00
|
|
|
g_autofree char *debugmsg = virBufferContentAndReset(&debug);
|
|
|
|
g_autofree char *debugprops = virJSONValueToString(backendprops, 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",
|
|
|
|
debugprops, NULLSTR(debugmsg));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-08 16:24:50 +00:00
|
|
|
if (virJSONValueObjectAdd(&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
|
|
|
|
2019-10-22 13:26:14 +00:00
|
|
|
protocolwrapper = g_strdup_printf("json:%s", propsstr);
|
2017-11-03 14:20:55 +00:00
|
|
|
|
2019-08-15 14:43:40 +00:00
|
|
|
if (virStorageSourceNewFromBackingAbsolute(protocolwrapper,
|
|
|
|
&jsonsrc) < 0) {
|
2017-11-03 14:20:55 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-05-07 12:00:28 +00:00
|
|
|
if (virDomainDiskSourceFormat(&buf, jsonsrc, "source", 0, false, 0,
|
|
|
|
false, false, 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
|
|
|
}
|
|
|
|
|
2020-03-09 16:06:10 +00:00
|
|
|
static const char *testJSONtoJSONPath = abs_srcdir "/qemublocktestdata/jsontojson/";
|
|
|
|
|
|
|
|
struct testJSONtoJSONData {
|
|
|
|
const char *name;
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *schema;
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue *schemaroot;
|
2020-03-09 16:06:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
testJSONtoJSON(const void *args)
|
|
|
|
{
|
|
|
|
const struct testJSONtoJSONData *data = args;
|
|
|
|
g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER;
|
|
|
|
g_autoptr(virJSONValue) jsonsrcout = NULL;
|
|
|
|
g_autoptr(virStorageSource) src = NULL;
|
|
|
|
g_autofree char *actual = NULL;
|
|
|
|
g_autofree char *in = NULL;
|
|
|
|
g_autofree char *infile = g_strdup_printf("%s%s-in.json", testJSONtoJSONPath,
|
|
|
|
data->name);
|
|
|
|
g_autofree char *outfile = g_strdup_printf("%s%s-out.json", testJSONtoJSONPath,
|
|
|
|
data->name);
|
|
|
|
|
|
|
|
if (virTestLoadFile(infile, &in) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (virStorageSourceNewFromBackingAbsolute(in, &src) < 0) {
|
|
|
|
fprintf(stderr, "failed to parse disk json\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2020-06-19 14:28:12 +00:00
|
|
|
if (!(jsonsrcout = qemuBlockStorageSourceGetBackendProps(src,
|
|
|
|
QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_AUTO_READONLY))) {
|
2020-03-09 16:06:10 +00:00
|
|
|
fprintf(stderr, "failed to format disk source json\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(actual = virJSONValueToString(jsonsrcout, true)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (testQEMUSchemaValidate(jsonsrcout, data->schemaroot,
|
2020-04-29 15:52:43 +00:00
|
|
|
data->schema, false, &debug) < 0) {
|
2020-03-09 16:06:10 +00:00
|
|
|
g_autofree char *debugmsg = virBufferContentAndReset(&debug);
|
|
|
|
|
|
|
|
VIR_TEST_VERBOSE("json does not conform to QAPI schema");
|
|
|
|
VIR_TEST_DEBUG("json:\n%s\ndoes not match schema. Debug output:\n %s",
|
|
|
|
actual, NULLSTR(debugmsg));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return virTestCompareToFile(actual, outfile);
|
|
|
|
}
|
|
|
|
|
2017-11-03 14:20:55 +00:00
|
|
|
|
2020-03-23 11:10:38 +00:00
|
|
|
struct testQemuDiskXMLToJSONImageData {
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue *formatprops;
|
|
|
|
virJSONValue *storageprops;
|
|
|
|
virJSONValue *storagepropssrc;
|
2020-03-23 11:35:32 +00:00
|
|
|
char *backingstore;
|
2020-03-23 11:10:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-03-23 08:06:40 +00:00
|
|
|
struct testQemuDiskXMLToJSONData {
|
2021-03-11 07:16:13 +00:00
|
|
|
virQEMUDriver *driver;
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *schema;
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue *schemaroot;
|
2018-03-23 08:06:40 +00:00
|
|
|
const char *name;
|
|
|
|
bool fail;
|
|
|
|
|
2020-03-23 11:10:38 +00:00
|
|
|
struct testQemuDiskXMLToJSONImageData *images;
|
|
|
|
size_t nimages;
|
2018-12-17 15:29:05 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virQEMUCaps *qemuCaps;
|
2018-03-23 08:06:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
testQemuDiskXMLToPropsClear(struct testQemuDiskXMLToJSONData *data)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
2020-03-23 11:10:38 +00:00
|
|
|
for (i = 0; i < data->nimages; i++) {
|
|
|
|
virJSONValueFree(data->images[i].formatprops);
|
|
|
|
virJSONValueFree(data->images[i].storageprops);
|
|
|
|
virJSONValueFree(data->images[i].storagepropssrc);
|
2020-03-23 11:35:32 +00:00
|
|
|
g_free(data->images[i].backingstore);
|
2020-03-23 11:10:38 +00:00
|
|
|
}
|
|
|
|
data->nimages = 0;
|
|
|
|
VIR_FREE(data->images);
|
2018-03-23 08:06:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-19 14:16:44 +00:00
|
|
|
static int
|
2021-03-11 07:16:13 +00:00
|
|
|
testQemuDiskXMLToJSONFakeSecrets(virStorageSource *src)
|
2018-04-19 14:16:44 +00:00
|
|
|
{
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuDomainStorageSourcePrivate *srcpriv;
|
2018-04-19 14:16:44 +00:00
|
|
|
|
|
|
|
if (!src->privateData &&
|
|
|
|
!(src->privateData = qemuDomainStorageSourcePrivateNew()))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
|
|
|
|
|
|
|
|
if (src->auth) {
|
2020-09-22 22:42:45 +00:00
|
|
|
srcpriv->secinfo = g_new0(qemuDomainSecretInfo, 1);
|
2018-04-19 14:16:44 +00:00
|
|
|
|
2021-09-22 07:34:31 +00:00
|
|
|
srcpriv->secinfo->username = g_strdup(src->auth->username);
|
|
|
|
srcpriv->secinfo->alias = g_strdup_printf("%s-secalias",
|
|
|
|
NULLSTR(src->nodestorage));
|
2018-04-19 14:16:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (src->encryption) {
|
2023-03-13 09:50:20 +00:00
|
|
|
srcpriv->encinfo = g_new0(qemuDomainSecretInfo *, 1);
|
|
|
|
srcpriv->encinfo[0] = g_new0(qemuDomainSecretInfo, 1);
|
2018-04-19 14:16:44 +00:00
|
|
|
|
2023-03-13 09:50:20 +00:00
|
|
|
srcpriv->encinfo[0]->alias = g_strdup_printf("%s-encalias",
|
|
|
|
NULLSTR(src->nodeformat));
|
2023-03-17 14:34:02 +00:00
|
|
|
srcpriv->enccount = 1;
|
2018-04-19 14:16:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2020-01-08 06:49:27 +00:00
|
|
|
g_autoptr(virDomainDef) vmdef = NULL;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainDiskDef *disk = NULL;
|
|
|
|
virStorageSource *n;
|
2020-03-23 10:24:39 +00:00
|
|
|
g_autoptr(virJSONValue) formatProps = NULL;
|
|
|
|
g_autoptr(virJSONValue) storageProps = NULL;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(virJSONValue) storageSrcOnlyProps = NULL;
|
2020-03-23 10:24:39 +00:00
|
|
|
g_autofree char *xmlpath = NULL;
|
|
|
|
g_autofree char *xmlstr = NULL;
|
2018-03-23 08:06:40 +00:00
|
|
|
|
2019-10-22 13:26:14 +00:00
|
|
|
xmlpath = g_strdup_printf("%s%s.xml", testQemuDiskXMLToJSONPath, data->name);
|
2018-03-23 08:06:40 +00:00
|
|
|
|
|
|
|
if (virTestLoadFile(xmlpath, &xmlstr) < 0)
|
2020-03-23 10:24:39 +00:00
|
|
|
return -1;
|
2018-03-23 08:06:40 +00:00
|
|
|
|
|
|
|
/* qemu stores node names in the status XML portion */
|
2019-11-26 18:42:56 +00:00
|
|
|
if (!(disk = virDomainDiskDefParse(xmlstr, data->driver->xmlopt,
|
2018-03-23 08:06:40 +00:00
|
|
|
VIR_DOMAIN_DEF_PARSE_STATUS)))
|
2020-03-23 10:24:39 +00:00
|
|
|
return -1;
|
2018-03-23 08:06:40 +00:00
|
|
|
|
2021-10-24 09:51:26 +00:00
|
|
|
if (qemuDomainDeviceDiskDefPostParse(disk, 0) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2021-08-03 09:00:48 +00:00
|
|
|
if (!(vmdef = virDomainDefNew(data->driver->xmlopt)))
|
2020-03-23 10:24:39 +00:00
|
|
|
return -1;
|
2020-01-08 06:49:27 +00:00
|
|
|
|
2020-11-06 03:32:57 +00:00
|
|
|
virDomainDiskInsert(vmdef, disk);
|
|
|
|
|
2020-05-04 17:21:55 +00:00
|
|
|
if (qemuValidateDomainDeviceDefDisk(disk, vmdef, data->qemuCaps) < 0) {
|
2019-05-03 08:45:58 +00:00
|
|
|
VIR_TEST_VERBOSE("invalid configuration for disk");
|
2020-03-23 10:24:39 +00:00
|
|
|
return -1;
|
2018-03-23 08:06:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (n = disk->src; virStorageSourceIsBacking(n); n = n->backingStore) {
|
2020-03-23 11:35:32 +00:00
|
|
|
g_autofree char *backingstore = NULL;
|
2020-06-19 14:28:12 +00:00
|
|
|
unsigned int backendpropsflagsnormal = QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_AUTO_READONLY;
|
|
|
|
unsigned int backendpropsflagstarget = QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_AUTO_READONLY |
|
|
|
|
QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_TARGET_ONLY;
|
2020-03-23 11:10:38 +00:00
|
|
|
|
2018-04-19 14:16:44 +00:00
|
|
|
if (testQemuDiskXMLToJSONFakeSecrets(n) < 0)
|
2020-03-23 10:24:39 +00:00
|
|
|
return -1;
|
2018-04-19 14:16:44 +00:00
|
|
|
|
2022-07-21 15:12:46 +00:00
|
|
|
if (qemuDomainValidateStorageSource(n, data->qemuCaps) < 0)
|
2020-03-23 10:24:39 +00:00
|
|
|
return -1;
|
2018-05-29 15:28:11 +00:00
|
|
|
|
2019-10-08 13:14:22 +00:00
|
|
|
qemuDomainPrepareDiskSourceData(disk, n);
|
2018-05-29 15:05:05 +00:00
|
|
|
|
2019-09-03 11:27:52 +00:00
|
|
|
if (!(formatProps = qemuBlockStorageSourceGetBlockdevProps(n, n->backingStore)) ||
|
2020-06-19 14:28:12 +00:00
|
|
|
!(storageSrcOnlyProps = qemuBlockStorageSourceGetBackendProps(n, backendpropsflagstarget)) ||
|
|
|
|
!(storageProps = qemuBlockStorageSourceGetBackendProps(n, backendpropsflagsnormal)) ||
|
2020-03-23 11:35:32 +00:00
|
|
|
!(backingstore = qemuBlockGetBackingStoreString(n, true))) {
|
2018-03-23 08:06:40 +00:00
|
|
|
if (!data->fail) {
|
2019-05-03 08:45:58 +00:00
|
|
|
VIR_TEST_VERBOSE("failed to generate qemu blockdev props");
|
2020-03-23 10:24:39 +00:00
|
|
|
return -1;
|
2018-03-23 08:06:40 +00:00
|
|
|
}
|
|
|
|
} else if (data->fail) {
|
2019-05-03 08:45:58 +00:00
|
|
|
VIR_TEST_VERBOSE("qemu blockdev props should have failed");
|
2020-03-23 10:24:39 +00:00
|
|
|
return -1;
|
2018-03-23 08:06:40 +00:00
|
|
|
}
|
|
|
|
|
2021-03-19 23:37:05 +00:00
|
|
|
VIR_REALLOC_N(data->images, data->nimages + 1);
|
2020-03-23 11:10:38 +00:00
|
|
|
|
|
|
|
data->images[data->nimages].formatprops = g_steal_pointer(&formatProps);
|
|
|
|
data->images[data->nimages].storageprops = g_steal_pointer(&storageProps);
|
|
|
|
data->images[data->nimages].storagepropssrc = g_steal_pointer(&storageSrcOnlyProps);
|
2020-03-23 11:35:32 +00:00
|
|
|
data->images[data->nimages].backingstore = g_steal_pointer(&backingstore);
|
2020-03-23 11:10:38 +00:00
|
|
|
|
|
|
|
data->nimages++;
|
2018-03-23 08:06:40 +00:00
|
|
|
}
|
|
|
|
|
2020-03-23 10:24:39 +00:00
|
|
|
return 0;
|
2018-03-23 08:06:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
testQemuDiskXMLToPropsValidateSchema(const void *opaque)
|
|
|
|
{
|
|
|
|
struct testQemuDiskXMLToJSONData *data = (void *) opaque;
|
|
|
|
int ret = 0;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (data->fail)
|
|
|
|
return EXIT_AM_SKIP;
|
|
|
|
|
2020-03-23 11:10:38 +00:00
|
|
|
for (i = 0; i < data->nimages; i++) {
|
2020-03-23 10:24:39 +00:00
|
|
|
g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER;
|
|
|
|
|
2020-03-23 11:10:38 +00:00
|
|
|
if (testQEMUSchemaValidate(data->images[i].formatprops, data->schemaroot,
|
2020-04-29 15:52:43 +00:00
|
|
|
data->schema, false, &debug) < 0) {
|
2020-03-23 10:24:39 +00:00
|
|
|
g_autofree char *debugmsg = virBufferContentAndReset(&debug);
|
2020-03-23 11:10:38 +00:00
|
|
|
g_autofree char *propsstr = virJSONValueToString(data->images[i].formatprops, true);
|
2018-03-23 08:06:40 +00:00
|
|
|
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));
|
|
|
|
ret = -1;
|
|
|
|
}
|
2018-12-17 15:29:05 +00:00
|
|
|
|
2020-03-23 11:10:38 +00:00
|
|
|
virBufferFreeAndReset(&debug);
|
2020-03-23 10:24:39 +00:00
|
|
|
|
2020-03-23 11:10:38 +00:00
|
|
|
if (testQEMUSchemaValidate(data->images[i].storageprops, data->schemaroot,
|
2020-04-29 15:52:43 +00:00
|
|
|
data->schema, false, &debug) < 0) {
|
2020-03-23 10:24:39 +00:00
|
|
|
g_autofree char *debugmsg = virBufferContentAndReset(&debug);
|
2020-03-23 11:10:38 +00:00
|
|
|
g_autofree char *propsstr = virJSONValueToString(data->images[i].storageprops, 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));
|
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
virBufferFreeAndReset(&debug);
|
|
|
|
|
|
|
|
if (testQEMUSchemaValidate(data->images[i].storagepropssrc, data->schemaroot,
|
2020-04-29 15:52:43 +00:00
|
|
|
data->schema, false, &debug) < 0) {
|
2020-03-23 11:10:38 +00:00
|
|
|
g_autofree char *debugmsg = virBufferContentAndReset(&debug);
|
|
|
|
g_autofree char *propsstr = virJSONValueToString(data->images[i].storagepropssrc, true);
|
2018-12-17 15:29:05 +00:00
|
|
|
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));
|
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-23 08:06:40 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
testQemuDiskXMLToPropsValidateFile(const void *opaque)
|
|
|
|
{
|
|
|
|
struct testQemuDiskXMLToJSONData *data = (void *) opaque;
|
2020-07-02 23:35:41 +00:00
|
|
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
2020-03-23 10:24:39 +00:00
|
|
|
g_autofree char *jsonpath = NULL;
|
|
|
|
g_autofree char *actual = NULL;
|
2018-03-23 08:06:40 +00:00
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (data->fail)
|
|
|
|
return EXIT_AM_SKIP;
|
|
|
|
|
2019-10-22 13:26:14 +00:00
|
|
|
jsonpath = g_strdup_printf("%s%s.json", testQemuDiskXMLToJSONPath, data->name);
|
2018-03-23 08:06:40 +00:00
|
|
|
|
2020-03-23 11:10:38 +00:00
|
|
|
for (i = 0; i < data->nimages; i++) {
|
|
|
|
g_autofree char *formatprops = NULL;
|
|
|
|
g_autofree char *storageprops = NULL;
|
2018-03-23 08:06:40 +00:00
|
|
|
|
2020-03-23 11:10:38 +00:00
|
|
|
if (!(formatprops = virJSONValueToString(data->images[i].formatprops, true)))
|
2020-03-23 10:24:39 +00:00
|
|
|
return -1;
|
2018-03-23 08:06:40 +00:00
|
|
|
|
2020-03-23 11:10:38 +00:00
|
|
|
if (!(storageprops = virJSONValueToString(data->images[i].storageprops, true)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
virBufferStrcat(&buf, formatprops, storageprops, NULL);
|
2018-03-23 08:06:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
actual = virBufferContentAndReset(&buf);
|
|
|
|
|
2020-03-23 10:24:39 +00:00
|
|
|
return virTestCompareToFile(actual, jsonpath);
|
2018-03-23 08:06:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-23 10:50:57 +00:00
|
|
|
static int
|
|
|
|
testQemuDiskXMLToPropsValidateFileSrcOnly(const void *opaque)
|
|
|
|
{
|
|
|
|
struct testQemuDiskXMLToJSONData *data = (void *) opaque;
|
|
|
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
g_autofree char *jsonpath = NULL;
|
|
|
|
g_autofree char *actual = NULL;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (data->fail)
|
|
|
|
return EXIT_AM_SKIP;
|
|
|
|
|
|
|
|
jsonpath = g_strdup_printf("%s%s-srconly.json", testQemuDiskXMLToJSONPath,
|
|
|
|
data->name);
|
|
|
|
|
2020-03-23 11:10:38 +00:00
|
|
|
for (i = 0; i < data->nimages; i++) {
|
2020-03-23 10:50:57 +00:00
|
|
|
g_autofree char *jsonstr = NULL;
|
|
|
|
|
2020-03-23 11:35:32 +00:00
|
|
|
virBufferAddLit(&buf, "(\n");
|
|
|
|
virBufferAdjustIndent(&buf, 2);
|
|
|
|
virBufferAddLit(&buf, "source only properties:\n");
|
|
|
|
|
2020-03-23 11:10:38 +00:00
|
|
|
if (!(jsonstr = virJSONValueToString(data->images[i].storagepropssrc, true)))
|
2020-03-23 10:50:57 +00:00
|
|
|
return -1;
|
|
|
|
|
2020-03-23 11:35:32 +00:00
|
|
|
virBufferAddStr(&buf, jsonstr);
|
|
|
|
|
|
|
|
virBufferAddLit(&buf, "backing store string:\n");
|
|
|
|
virBufferAddStr(&buf, data->images[i].backingstore);
|
|
|
|
|
|
|
|
virBufferTrim(&buf, "\n");
|
|
|
|
virBufferAdjustIndent(&buf, -2);
|
|
|
|
virBufferAddLit(&buf, "\n)\n");
|
2020-03-23 10:50:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
actual = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
return virTestCompareToFile(actual, jsonpath);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-09-04 11:40:01 +00:00
|
|
|
struct testQemuImageCreateData {
|
|
|
|
const char *name;
|
|
|
|
const char *backingname;
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *schema;
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue *schemaroot;
|
|
|
|
virQEMUDriver *driver;
|
|
|
|
virQEMUCaps *qemuCaps;
|
2018-09-04 11:40:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const char *testQemuImageCreatePath = abs_srcdir "/qemublocktestdata/imagecreate/";
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
static virStorageSource *
|
2018-09-04 11:40:01 +00:00
|
|
|
testQemuImageCreateLoadDiskXML(const char *name,
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt)
|
2018-09-04 11:40:01 +00:00
|
|
|
|
|
|
|
{
|
2021-10-25 14:11:49 +00:00
|
|
|
g_autoptr(virDomainDiskDef) disk = NULL;
|
2019-10-15 13:16:31 +00:00
|
|
|
g_autofree char *xmlpath = NULL;
|
2021-10-24 09:51:26 +00:00
|
|
|
g_autofree char *xmlstr = NULL;
|
2018-09-04 11:40:01 +00:00
|
|
|
|
2019-10-22 13:26:14 +00:00
|
|
|
xmlpath = g_strdup_printf("%s%s.xml", testQemuImageCreatePath, name);
|
2018-09-04 11:40:01 +00:00
|
|
|
|
2021-10-24 09:51:26 +00:00
|
|
|
if (virTestLoadFile(xmlpath, &xmlstr) < 0)
|
2018-09-04 11:40:01 +00:00
|
|
|
return NULL;
|
|
|
|
|
2021-10-24 09:51:26 +00:00
|
|
|
/* qemu stores node names in the status XML portion */
|
|
|
|
if (!(disk = virDomainDiskDefParse(xmlstr, xmlopt,
|
|
|
|
VIR_DOMAIN_DEF_PARSE_STATUS)))
|
2018-09-04 11:40:01 +00:00
|
|
|
return NULL;
|
|
|
|
|
2021-10-24 09:51:26 +00:00
|
|
|
if (qemuDomainDeviceDiskDefPostParse(disk, 0) < 0)
|
|
|
|
return NULL;
|
2018-09-04 11:40:01 +00:00
|
|
|
|
2021-10-25 14:11:49 +00:00
|
|
|
return g_steal_pointer(&disk->src);
|
2018-09-04 11:40:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
testQemuImageCreate(const void *opaque)
|
|
|
|
{
|
|
|
|
struct testQemuImageCreateData *data = (void *) opaque;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(virJSONValue) protocolprops = NULL;
|
|
|
|
g_autoptr(virJSONValue) formatprops = NULL;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(virStorageSource) src = NULL;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER;
|
|
|
|
g_auto(virBuffer) actualbuf = VIR_BUFFER_INITIALIZER;
|
2019-10-15 13:16:31 +00:00
|
|
|
g_autofree char *jsonprotocol = NULL;
|
|
|
|
g_autofree char *jsonformat = NULL;
|
|
|
|
g_autofree char *actual = NULL;
|
|
|
|
g_autofree char *jsonpath = NULL;
|
2018-09-04 11:40:01 +00:00
|
|
|
|
|
|
|
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 */
|
2019-08-30 14:36:15 +00:00
|
|
|
src->capacity = UINT_MAX * 2ULL;
|
|
|
|
src->physical = UINT_MAX + 1ULL;
|
2018-09-04 11:40:01 +00:00
|
|
|
|
2022-07-21 15:12:46 +00:00
|
|
|
if (qemuDomainValidateStorageSource(src, data->qemuCaps) < 0)
|
2018-09-04 11:40:01 +00:00
|
|
|
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,
|
2020-04-29 15:52:43 +00:00
|
|
|
false, &debug) < 0) {
|
2019-10-15 13:16:31 +00:00
|
|
|
g_autofree char *debugmsg = virBufferContentAndReset(&debug);
|
2018-09-04 11:40:01 +00:00
|
|
|
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,
|
2020-04-29 15:52:43 +00:00
|
|
|
false, &debug) < 0) {
|
2019-10-15 13:16:31 +00:00
|
|
|
g_autofree char *debugmsg = virBufferContentAndReset(&debug);
|
2018-09-04 11:40:01 +00:00
|
|
|
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);
|
2020-02-02 19:26:38 +00:00
|
|
|
virBufferTrim(&actualbuf, "\n");
|
2018-09-04 11:40:01 +00:00
|
|
|
virBufferAddLit(&actualbuf, "\n");
|
|
|
|
|
2019-10-22 13:26:14 +00:00
|
|
|
jsonpath = g_strdup_printf("%s%s.json", testQemuImageCreatePath, data->name);
|
2018-09-04 11:40:01 +00:00
|
|
|
|
|
|
|
if (!(actual = virBufferContentAndReset(&actualbuf)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return virTestCompareToFile(actual, jsonpath);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-12 12:37:01 +00:00
|
|
|
static const char *bitmapDetectPrefix = "qemublocktestdata/bitmap/";
|
|
|
|
|
|
|
|
static void
|
2020-10-22 17:04:18 +00:00
|
|
|
testQemuDetectBitmapsWorker(GHashTable *nodedata,
|
2019-12-12 12:37:01 +00:00
|
|
|
const char *nodename,
|
2021-03-11 07:16:13 +00:00
|
|
|
virBuffer *buf)
|
2019-12-12 12:37:01 +00:00
|
|
|
{
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockNamedNodeData *data;
|
2019-12-12 12:37:01 +00:00
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (!(data = virHashLookup(nodedata, nodename)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
virBufferAsprintf(buf, "%s:\n", nodename);
|
2021-01-29 13:35:57 +00:00
|
|
|
if (data->qcow2v2)
|
|
|
|
virBufferAddLit(buf, " qcow2 v2\n");
|
2019-12-12 12:37:01 +00:00
|
|
|
virBufferAdjustIndent(buf, 1);
|
|
|
|
|
|
|
|
for (i = 0; i < data->nbitmaps; i++) {
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockNamedNodeDataBitmap *bitmap = data->bitmaps[i];
|
2019-12-12 12:37:01 +00:00
|
|
|
|
|
|
|
virBufferAsprintf(buf, "%8s: record:%d busy:%d persist:%d inconsist:%d gran:%llu dirty:%llu\n",
|
|
|
|
bitmap->name, bitmap->recording, bitmap->busy,
|
|
|
|
bitmap->persistent, bitmap->inconsistent,
|
|
|
|
bitmap->granularity, bitmap->dirtybytes);
|
|
|
|
}
|
|
|
|
|
|
|
|
virBufferAdjustIndent(buf, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
testQemuDetectBitmaps(const void *opaque)
|
|
|
|
{
|
|
|
|
const char *name = opaque;
|
|
|
|
g_autoptr(virJSONValue) nodedatajson = NULL;
|
2020-10-22 17:04:18 +00:00
|
|
|
g_autoptr(GHashTable) nodedata = NULL;
|
2019-12-12 12:37:01 +00:00
|
|
|
g_autofree char *actual = NULL;
|
|
|
|
g_autofree char *expectpath = NULL;
|
|
|
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
expectpath = g_strdup_printf("%s/%s%s.out", abs_srcdir,
|
|
|
|
bitmapDetectPrefix, name);
|
|
|
|
|
|
|
|
if (!(nodedatajson = virTestLoadFileJSON(bitmapDetectPrefix, name,
|
|
|
|
".json", NULL)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (!(nodedata = qemuMonitorJSONBlockGetNamedNodeDataJSON(nodedatajson))) {
|
|
|
|
VIR_TEST_VERBOSE("failed to load nodedata JSON");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we detect for the first 30 nodenames for simplicity */
|
|
|
|
for (i = 0; i < 30; i++) {
|
|
|
|
g_autofree char *nodename = g_strdup_printf("libvirt-%zu-format", i);
|
|
|
|
|
|
|
|
testQemuDetectBitmapsWorker(nodedata, nodename, &buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
actual = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
return virTestCompareToFile(actual, expectpath);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-06-02 07:11:36 +00:00
|
|
|
static void
|
|
|
|
testQemuBitmapListPrint(const char *title,
|
|
|
|
GSList *next,
|
2021-03-11 07:16:13 +00:00
|
|
|
virBuffer *buf)
|
2020-06-02 07:11:36 +00:00
|
|
|
{
|
|
|
|
if (!next)
|
|
|
|
return;
|
|
|
|
|
|
|
|
virBufferAsprintf(buf, "%s\n", title);
|
|
|
|
|
|
|
|
for (; next; next = next->next) {
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSource *src = next->data;
|
2020-06-02 07:11:36 +00:00
|
|
|
virBufferAsprintf(buf, "%s\n", src->nodeformat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
static virStorageSource *
|
2019-12-12 15:01:22 +00:00
|
|
|
testQemuBackupIncrementalBitmapCalculateGetFakeImage(size_t idx)
|
|
|
|
{
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSource *ret = virStorageSourceNew();
|
2019-12-12 15:01:22 +00:00
|
|
|
|
2020-03-02 14:03:07 +00:00
|
|
|
ret->id = idx;
|
2019-12-12 15:01:22 +00:00
|
|
|
ret->type = VIR_STORAGE_TYPE_FILE;
|
|
|
|
ret->format = VIR_STORAGE_FILE_QCOW2;
|
|
|
|
ret->path = g_strdup_printf("/image%zu", idx);
|
|
|
|
ret->nodestorage = g_strdup_printf("libvirt-%zu-storage", idx);
|
|
|
|
ret->nodeformat = g_strdup_printf("libvirt-%zu-format", idx);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
static virStorageSource *
|
2019-12-12 15:01:22 +00:00
|
|
|
testQemuBackupIncrementalBitmapCalculateGetFakeChain(void)
|
|
|
|
{
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSource *ret;
|
|
|
|
virStorageSource *n;
|
2019-12-12 15:01:22 +00:00
|
|
|
size_t i;
|
|
|
|
|
|
|
|
n = ret = testQemuBackupIncrementalBitmapCalculateGetFakeImage(1);
|
|
|
|
|
2020-03-02 14:03:07 +00:00
|
|
|
for (i = 2; i < 6; i++) {
|
2019-12-12 15:01:22 +00:00
|
|
|
n->backingStore = testQemuBackupIncrementalBitmapCalculateGetFakeImage(i);
|
|
|
|
n = n->backingStore;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
static virStorageSource *
|
|
|
|
testQemuBitmapGetFakeChainEntry(virStorageSource *src,
|
2020-03-02 16:16:17 +00:00
|
|
|
size_t idx)
|
|
|
|
{
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSource *n;
|
2020-03-02 16:16:17 +00:00
|
|
|
|
|
|
|
for (n = src; n; n = n->backingStore) {
|
|
|
|
if (n->id == idx)
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-12 15:01:22 +00:00
|
|
|
static const char *backupDataPrefix = "qemublocktestdata/backupmerge/";
|
|
|
|
|
|
|
|
struct testQemuBackupIncrementalBitmapCalculateData {
|
|
|
|
const char *name;
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSource *chain;
|
2019-12-12 15:01:22 +00:00
|
|
|
const char *incremental;
|
|
|
|
const char *nodedatafile;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
testQemuBackupIncrementalBitmapCalculate(const void *opaque)
|
|
|
|
{
|
|
|
|
const struct testQemuBackupIncrementalBitmapCalculateData *data = opaque;
|
|
|
|
g_autoptr(virJSONValue) nodedatajson = NULL;
|
2020-10-22 17:04:18 +00:00
|
|
|
g_autoptr(GHashTable) nodedata = NULL;
|
2020-05-22 12:48:46 +00:00
|
|
|
g_autoptr(virJSONValue) actions = virJSONValueNewArray();
|
2019-12-12 15:01:22 +00:00
|
|
|
g_autofree char *expectpath = NULL;
|
2020-05-22 12:48:46 +00:00
|
|
|
g_autoptr(virStorageSource) target = NULL;
|
|
|
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
2019-12-12 15:01:22 +00:00
|
|
|
|
|
|
|
expectpath = g_strdup_printf("%s/%s%s-out.json", abs_srcdir,
|
|
|
|
backupDataPrefix, data->name);
|
|
|
|
|
|
|
|
if (!(nodedatajson = virTestLoadFileJSON(bitmapDetectPrefix, data->nodedatafile,
|
|
|
|
".json", NULL)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (!(nodedata = qemuMonitorJSONBlockGetNamedNodeDataJSON(nodedatajson))) {
|
|
|
|
VIR_TEST_VERBOSE("failed to load nodedata JSON\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2020-09-22 09:04:17 +00:00
|
|
|
target = virStorageSourceNew();
|
2020-05-22 12:48:46 +00:00
|
|
|
target->nodeformat = g_strdup_printf("target_node");
|
2019-12-12 15:01:22 +00:00
|
|
|
|
2020-05-22 12:48:46 +00:00
|
|
|
if (qemuBackupDiskPrepareOneBitmapsChain(data->chain,
|
|
|
|
target,
|
|
|
|
"target-bitmap-name",
|
|
|
|
data->incremental,
|
|
|
|
actions,
|
|
|
|
nodedata) >= 0) {
|
|
|
|
if (virJSONValueToBuffer(actions, &buf, true) < 0)
|
2020-05-28 14:25:55 +00:00
|
|
|
return -1;
|
|
|
|
} else {
|
2020-05-22 12:48:46 +00:00
|
|
|
virBufferAddLit(&buf, "NULL\n");
|
2019-12-12 15:01:22 +00:00
|
|
|
}
|
|
|
|
|
2020-05-22 12:48:46 +00:00
|
|
|
return virTestCompareToFile(virBufferCurrentContent(&buf), expectpath);
|
2019-12-12 15:01:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-08 13:56:45 +00:00
|
|
|
static const char *checkpointDeletePrefix = "qemublocktestdata/checkpointdelete/";
|
|
|
|
|
2020-06-01 08:40:04 +00:00
|
|
|
struct testQemuCheckpointDeleteData {
|
2020-01-08 13:56:45 +00:00
|
|
|
const char *name;
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSource *chain;
|
2020-01-08 13:56:45 +00:00
|
|
|
const char *deletebitmap;
|
2020-01-09 13:19:07 +00:00
|
|
|
const char *nodedatafile;
|
2020-01-08 13:56:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2020-06-01 08:40:04 +00:00
|
|
|
testQemuCheckpointDelete(const void *opaque)
|
2020-01-08 13:56:45 +00:00
|
|
|
{
|
2020-06-01 08:40:04 +00:00
|
|
|
const struct testQemuCheckpointDeleteData *data = opaque;
|
2020-01-08 13:56:45 +00:00
|
|
|
g_autofree char *actual = NULL;
|
|
|
|
g_autofree char *expectpath = NULL;
|
|
|
|
g_autoptr(virJSONValue) actions = NULL;
|
2020-01-09 13:19:07 +00:00
|
|
|
g_autoptr(virJSONValue) nodedatajson = NULL;
|
2020-10-22 17:04:18 +00:00
|
|
|
g_autoptr(GHashTable) nodedata = NULL;
|
2020-01-09 16:34:29 +00:00
|
|
|
g_autoptr(GSList) reopenimages = NULL;
|
|
|
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
2020-01-08 13:56:45 +00:00
|
|
|
|
|
|
|
expectpath = g_strdup_printf("%s/%s%s-out.json", abs_srcdir,
|
|
|
|
checkpointDeletePrefix, data->name);
|
|
|
|
|
2020-01-09 13:19:07 +00:00
|
|
|
if (!(nodedatajson = virTestLoadFileJSON(bitmapDetectPrefix, data->nodedatafile,
|
|
|
|
".json", NULL)))
|
2020-01-08 13:56:45 +00:00
|
|
|
return -1;
|
|
|
|
|
2020-01-09 13:19:07 +00:00
|
|
|
if (!(nodedata = qemuMonitorJSONBlockGetNamedNodeDataJSON(nodedatajson))) {
|
|
|
|
VIR_TEST_VERBOSE("failed to load nodedata JSON\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2020-01-31 07:18:36 +00:00
|
|
|
actions = virJSONValueNewArray();
|
2020-01-08 13:56:45 +00:00
|
|
|
|
|
|
|
if (qemuCheckpointDiscardDiskBitmaps(data->chain,
|
2020-01-09 13:19:07 +00:00
|
|
|
nodedata,
|
2020-01-08 13:56:45 +00:00
|
|
|
data->deletebitmap,
|
2020-01-09 13:19:07 +00:00
|
|
|
actions,
|
2020-01-09 16:34:29 +00:00
|
|
|
"testdisk",
|
2020-05-28 14:30:06 +00:00
|
|
|
&reopenimages) >= 0) {
|
|
|
|
if (virJSONValueToBuffer(actions, &buf, true) < 0)
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
virBufferAddLit(&buf, "NULL\n");
|
2020-01-08 13:56:45 +00:00
|
|
|
}
|
|
|
|
|
2020-06-02 07:11:36 +00:00
|
|
|
testQemuBitmapListPrint("reopen nodes:", reopenimages, &buf);
|
2020-01-09 16:34:29 +00:00
|
|
|
|
|
|
|
actual = virBufferContentAndReset(&buf);
|
|
|
|
|
2020-01-08 13:56:45 +00:00
|
|
|
return virTestCompareToFile(actual, expectpath);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-29 11:08:50 +00:00
|
|
|
struct testQemuBlockBitmapValidateData {
|
|
|
|
const char *name;
|
|
|
|
const char *bitmapname;
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSource *chain;
|
2020-01-29 11:08:50 +00:00
|
|
|
bool expect;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
testQemuBlockBitmapValidate(const void *opaque)
|
|
|
|
{
|
|
|
|
const struct testQemuBlockBitmapValidateData *data = opaque;
|
|
|
|
g_autoptr(virJSONValue) nodedatajson = NULL;
|
2020-10-22 17:04:18 +00:00
|
|
|
g_autoptr(GHashTable) nodedata = NULL;
|
2020-01-29 11:08:50 +00:00
|
|
|
bool actual;
|
|
|
|
|
|
|
|
if (!(nodedatajson = virTestLoadFileJSON(bitmapDetectPrefix, data->name,
|
|
|
|
".json", NULL)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (!(nodedata = qemuMonitorJSONBlockGetNamedNodeDataJSON(nodedatajson))) {
|
|
|
|
VIR_TEST_VERBOSE("failed to load nodedata JSON\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
actual = qemuBlockBitmapChainIsValid(data->chain, data->bitmapname, nodedata);
|
|
|
|
|
|
|
|
if (actual != data->expect) {
|
|
|
|
VIR_TEST_VERBOSE("expected rv:'%d' actual rv:'%d'\n", data->expect, actual);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-29 16:12:47 +00:00
|
|
|
static const char *blockcopyPrefix = "qemublocktestdata/bitmapblockcopy/";
|
|
|
|
|
|
|
|
struct testQemuBlockBitmapBlockcopyData {
|
|
|
|
const char *name;
|
|
|
|
bool shallow;
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSource *chain;
|
2020-01-29 16:12:47 +00:00
|
|
|
const char *nodedatafile;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
testQemuBlockBitmapBlockcopy(const void *opaque)
|
|
|
|
{
|
|
|
|
const struct testQemuBlockBitmapBlockcopyData *data = opaque;
|
|
|
|
g_autofree char *actual = NULL;
|
|
|
|
g_autofree char *expectpath = NULL;
|
|
|
|
g_autoptr(virJSONValue) actions = NULL;
|
|
|
|
g_autoptr(virJSONValue) nodedatajson = NULL;
|
2020-10-22 17:04:18 +00:00
|
|
|
g_autoptr(GHashTable) nodedata = NULL;
|
2020-01-29 16:12:47 +00:00
|
|
|
g_autoptr(virStorageSource) fakemirror = virStorageSourceNew();
|
2020-05-29 08:34:11 +00:00
|
|
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
2020-01-29 16:12:47 +00:00
|
|
|
|
|
|
|
fakemirror->nodeformat = g_strdup("mirror-format-node");
|
|
|
|
|
|
|
|
expectpath = g_strdup_printf("%s/%s%s-out.json", abs_srcdir,
|
|
|
|
blockcopyPrefix, data->name);
|
|
|
|
|
|
|
|
if (!(nodedatajson = virTestLoadFileJSON(bitmapDetectPrefix, data->nodedatafile,
|
|
|
|
".json", NULL)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (!(nodedata = qemuMonitorJSONBlockGetNamedNodeDataJSON(nodedatajson))) {
|
|
|
|
VIR_TEST_VERBOSE("failed to load nodedata JSON\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qemuBlockBitmapsHandleBlockcopy(data->chain, fakemirror, nodedata,
|
|
|
|
data->shallow, &actions) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2020-05-29 08:34:11 +00:00
|
|
|
|
2020-01-29 16:12:47 +00:00
|
|
|
if (actions &&
|
2020-05-29 08:34:11 +00:00
|
|
|
virJSONValueToBuffer(actions, &buf, true) < 0)
|
2020-01-29 16:12:47 +00:00
|
|
|
return -1;
|
|
|
|
|
2020-05-29 08:34:11 +00:00
|
|
|
actual = virBufferContentAndReset(&buf);
|
|
|
|
|
2020-01-29 16:12:47 +00:00
|
|
|
return virTestCompareToFile(actual, expectpath);
|
|
|
|
}
|
|
|
|
|
2020-03-02 16:16:17 +00:00
|
|
|
static const char *blockcommitPrefix = "qemublocktestdata/bitmapblockcommit/";
|
|
|
|
|
|
|
|
struct testQemuBlockBitmapBlockcommitData {
|
|
|
|
const char *name;
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSource *top;
|
|
|
|
virStorageSource *base;
|
|
|
|
virStorageSource *chain;
|
2020-03-02 16:16:17 +00:00
|
|
|
const char *nodedatafile;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
testQemuBlockBitmapBlockcommit(const void *opaque)
|
|
|
|
{
|
|
|
|
const struct testQemuBlockBitmapBlockcommitData *data = opaque;
|
|
|
|
|
|
|
|
g_autofree char *actual = NULL;
|
|
|
|
g_autofree char *expectpath = NULL;
|
|
|
|
g_autoptr(virJSONValue) actionsMerge = NULL;
|
|
|
|
g_autoptr(virJSONValue) nodedatajson = NULL;
|
2020-10-22 17:04:18 +00:00
|
|
|
g_autoptr(GHashTable) nodedata = NULL;
|
2020-03-02 16:16:17 +00:00
|
|
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
2020-04-17 07:51:40 +00:00
|
|
|
bool active = data->top == data->chain;
|
2020-03-02 16:16:17 +00:00
|
|
|
|
|
|
|
expectpath = g_strdup_printf("%s/%s%s", abs_srcdir,
|
|
|
|
blockcommitPrefix, data->name);
|
|
|
|
|
|
|
|
if (!(nodedatajson = virTestLoadFileJSON(bitmapDetectPrefix, data->nodedatafile,
|
|
|
|
".json", NULL)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (!(nodedata = qemuMonitorJSONBlockGetNamedNodeDataJSON(nodedatajson))) {
|
|
|
|
VIR_TEST_VERBOSE("failed to load nodedata JSON\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
virBufferAddLit(&buf, "merge bitmpas:\n");
|
|
|
|
|
2020-04-17 07:51:40 +00:00
|
|
|
if (qemuBlockBitmapsHandleCommitFinish(data->top, data->base, active, nodedata,
|
|
|
|
&actionsMerge) < 0)
|
2020-03-02 16:16:17 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (actionsMerge &&
|
|
|
|
virJSONValueToBuffer(actionsMerge, &buf, true) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
actual = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
return virTestCompareToFile(actual, expectpath);
|
|
|
|
}
|
|
|
|
|
2020-01-29 16:12:47 +00:00
|
|
|
|
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;
|
2020-03-09 16:06:10 +00:00
|
|
|
struct testJSONtoJSONData jsontojsondata;
|
2018-09-04 11:40:01 +00:00
|
|
|
struct testQemuImageCreateData imagecreatedata;
|
2019-12-12 15:01:22 +00:00
|
|
|
struct testQemuBackupIncrementalBitmapCalculateData backupbitmapcalcdata;
|
2020-06-01 08:40:04 +00:00
|
|
|
struct testQemuCheckpointDeleteData checkpointdeletedata;
|
2020-01-29 11:08:50 +00:00
|
|
|
struct testQemuBlockBitmapValidateData blockbitmapvalidatedata;
|
2020-01-29 16:12:47 +00:00
|
|
|
struct testQemuBlockBitmapBlockcopyData blockbitmapblockcopydata;
|
2020-03-02 16:16:17 +00:00
|
|
|
struct testQemuBlockBitmapBlockcommitData blockbitmapblockcommitdata;
|
2018-03-23 08:06:40 +00:00
|
|
|
char *capslatest_x86_64 = NULL;
|
2020-07-28 19:58:18 +00:00
|
|
|
g_autoptr(virQEMUCaps) caps_x86_64 = NULL;
|
2020-10-22 17:04:18 +00:00
|
|
|
g_autoptr(GHashTable) qmp_schema_x86_64 = NULL;
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue *qmp_schemaroot_x86_64_blockdev_add = NULL;
|
2019-12-12 15:01:22 +00:00
|
|
|
g_autoptr(virStorageSource) bitmapSourceChain = NULL;
|
2018-03-23 08:06:40 +00:00
|
|
|
|
|
|
|
if (qemuTestDriverInit(&driver) < 0)
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
2019-12-12 15:01:22 +00:00
|
|
|
bitmapSourceChain = testQemuBackupIncrementalBitmapCalculateGetFakeChain();
|
|
|
|
|
2018-03-23 08:06:40 +00:00
|
|
|
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;
|
|
|
|
|
2019-05-03 08:45:58 +00:00
|
|
|
VIR_TEST_VERBOSE("\nlatest caps x86_64: %s", capslatest_x86_64);
|
2018-03-23 08:06:40 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2020-05-15 14:21:25 +00:00
|
|
|
if (!(qmp_schema_x86_64 = testQEMUSchemaLoadLatest("x86_64"))) {
|
2020-03-09 14:24:56 +00:00
|
|
|
ret = -1;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2020-03-09 14:33:58 +00:00
|
|
|
if (virQEMUQAPISchemaPathGet("blockdev-add/arg-type",
|
|
|
|
qmp_schema_x86_64,
|
|
|
|
&qmp_schemaroot_x86_64_blockdev_add) < 0 ||
|
|
|
|
!qmp_schemaroot_x86_64_blockdev_add) {
|
|
|
|
VIR_TEST_VERBOSE("failed to find schema entry for blockdev-add");
|
|
|
|
ret = -1;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2017-11-03 14:20:55 +00:00
|
|
|
virTestCounterReset("qemu storage source xml->json->xml ");
|
|
|
|
|
2019-12-12 17:17:08 +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; \
|
2020-03-09 14:39:04 +00:00
|
|
|
xmljsonxmldata.legacy = true; \
|
|
|
|
if (virTestRun(virTestCounterNext(), testBackingXMLjsonXML, \
|
|
|
|
&xmljsonxmldata) < 0) \
|
|
|
|
xmljsonxmldata.legacy = false; \
|
2018-03-16 16:11:29 +00:00
|
|
|
if (virTestRun(virTestCounterNext(), testBackingXMLjsonXML, \
|
|
|
|
&xmljsonxmldata) < 0) \
|
2017-11-03 14:20:55 +00:00
|
|
|
ret = -1; \
|
|
|
|
} while (0)
|
|
|
|
|
2019-12-12 17:17:08 +00:00
|
|
|
#define TEST_JSON_FORMAT_NET(xmlstr) \
|
2017-11-03 14:20:55 +00:00
|
|
|
TEST_JSON_FORMAT(VIR_STORAGE_TYPE_NETWORK, xmlstr)
|
|
|
|
|
2020-03-09 14:39:04 +00:00
|
|
|
xmljsonxmldata.schema = qmp_schema_x86_64;
|
|
|
|
xmljsonxmldata.schemaroot = qmp_schemaroot_x86_64_blockdev_add;
|
|
|
|
|
2017-11-03 14:20:55 +00:00
|
|
|
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 */
|
|
|
|
|
2020-03-23 17:06:56 +00:00
|
|
|
TEST_JSON_FORMAT(VIR_STORAGE_TYPE_NVME,
|
|
|
|
"<source type='pci' namespace='1'>\n"
|
|
|
|
" <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
|
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");
|
2020-03-06 07:13:06 +00:00
|
|
|
TEST_JSON_FORMAT_NET("<source protocol='https' name='file'>\n"
|
|
|
|
" <host name='example.com' port='432'/>\n"
|
|
|
|
" <ssl verify='no'/>\n"
|
|
|
|
" <readahead size='1024'/>\n"
|
|
|
|
" <timeout seconds='1337'/>\n"
|
|
|
|
"</source>\n");
|
2017-11-03 14:20:55 +00:00
|
|
|
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");
|
|
|
|
|
2019-12-12 17:17:08 +00:00
|
|
|
#define TEST_DISK_TO_JSON_FULL(nme, fl) \
|
2018-03-23 08:06:40 +00:00
|
|
|
do { \
|
|
|
|
diskxmljsondata.name = nme; \
|
2020-03-23 11:10:38 +00:00
|
|
|
diskxmljsondata.images = NULL; \
|
|
|
|
diskxmljsondata.nimages = 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)
|
|
|
|
|
2019-12-12 17:17:08 +00:00
|
|
|
#define TEST_DISK_TO_JSON(nme) TEST_DISK_TO_JSON_FULL(nme, false)
|
2018-03-23 08:06:40 +00:00
|
|
|
|
2020-03-09 14:24:56 +00:00
|
|
|
diskxmljsondata.schema = qmp_schema_x86_64;
|
2020-03-09 14:33:58 +00:00
|
|
|
diskxmljsondata.schemaroot = qmp_schemaroot_x86_64_blockdev_add;
|
2018-03-23 08:06:40 +00:00
|
|
|
|
|
|
|
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");
|
2020-04-21 12:19:37 +00:00
|
|
|
TEST_DISK_TO_JSON("file-backing_basic-aio_io_uring");
|
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");
|
2020-03-23 15:36:22 +00:00
|
|
|
TEST_DISK_TO_JSON("network-http-noopts");
|
|
|
|
TEST_DISK_TO_JSON("network-http-curlopts");
|
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
|
|
|
|
2020-03-18 17:49:10 +00:00
|
|
|
TEST_DISK_TO_JSON("nvme-raw-noopts");
|
|
|
|
|
2020-03-09 16:06:10 +00:00
|
|
|
#define TEST_JSON_TO_JSON(nme) \
|
|
|
|
do { \
|
|
|
|
jsontojsondata.name = nme; \
|
|
|
|
if (virTestRun("JSON to JSON " nme, testJSONtoJSON, \
|
|
|
|
&jsontojsondata) < 0) \
|
|
|
|
ret = -1; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
jsontojsondata.schema = qmp_schema_x86_64;
|
|
|
|
jsontojsondata.schemaroot = qmp_schemaroot_x86_64_blockdev_add;
|
|
|
|
|
|
|
|
TEST_JSON_TO_JSON("curl-libguestfs");
|
2020-03-09 14:05:58 +00:00
|
|
|
TEST_JSON_TO_JSON("ssh-passthrough-libguestfs");
|
2020-03-09 16:06:10 +00:00
|
|
|
|
2019-12-12 17:17:08 +00:00
|
|
|
#define TEST_IMAGE_CREATE(testname, testbacking) \
|
2018-09-04 11:40:01 +00:00
|
|
|
do { \
|
|
|
|
imagecreatedata.name = testname; \
|
|
|
|
imagecreatedata.backingname = testbacking; \
|
|
|
|
if (virTestRun("image create xml to props " testname, testQemuImageCreate, \
|
|
|
|
&imagecreatedata) < 0) \
|
|
|
|
ret = -1; \
|
|
|
|
} while (0)
|
2020-03-09 14:24:56 +00:00
|
|
|
|
|
|
|
imagecreatedata.schema = qmp_schema_x86_64;
|
|
|
|
|
2018-09-04 11:40:01 +00:00
|
|
|
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");
|
2021-08-20 11:25:19 +00:00
|
|
|
TEST_IMAGE_CREATE("qcow2-backing-qcow2luks", "qcow2-luks-noopts");
|
2018-09-04 11:40:01 +00:00
|
|
|
TEST_IMAGE_CREATE("qcow2-luks-encopts-backing", "qcow2");
|
2020-02-12 16:26:18 +00:00
|
|
|
TEST_IMAGE_CREATE("qcow2-backing-raw-slice", "raw-slice");
|
|
|
|
TEST_IMAGE_CREATE("qcow2-backing-qcow2-slice", "qcow2-slice");
|
2018-09-04 11:40:01 +00:00
|
|
|
|
|
|
|
TEST_IMAGE_CREATE("network-gluster-qcow2", NULL);
|
|
|
|
TEST_IMAGE_CREATE("network-rbd-qcow2", NULL);
|
2022-10-20 12:50:21 +00:00
|
|
|
TEST_IMAGE_CREATE("network-ssh-qcow2-invalid", NULL);
|
2018-09-04 11:40:01 +00:00
|
|
|
|
2019-12-12 17:17:08 +00:00
|
|
|
#define TEST_BITMAP_DETECT(testname) \
|
2019-12-12 12:37:01 +00:00
|
|
|
do { \
|
|
|
|
if (virTestRun("bitmap detect " testname, \
|
|
|
|
testQemuDetectBitmaps, testname) < 0) \
|
|
|
|
ret = -1; \
|
|
|
|
} while (0)
|
|
|
|
|
2020-05-28 14:19:07 +00:00
|
|
|
TEST_BITMAP_DETECT("empty");
|
|
|
|
|
2019-12-12 12:37:01 +00:00
|
|
|
TEST_BITMAP_DETECT("basic");
|
2019-12-12 12:50:55 +00:00
|
|
|
TEST_BITMAP_DETECT("snapshots");
|
2020-06-02 13:11:25 +00:00
|
|
|
TEST_BITMAP_DETECT("synthetic");
|
2019-12-12 12:37:01 +00:00
|
|
|
|
2019-12-12 17:17:08 +00:00
|
|
|
#define TEST_BACKUP_BITMAP_CALCULATE(testname, source, incrbackup, named) \
|
2019-12-12 15:01:22 +00:00
|
|
|
do { \
|
|
|
|
backupbitmapcalcdata.name = testname; \
|
|
|
|
backupbitmapcalcdata.chain = source; \
|
|
|
|
backupbitmapcalcdata.incremental = incrbackup; \
|
|
|
|
backupbitmapcalcdata.nodedatafile = named; \
|
|
|
|
if (virTestRun("incremental backup bitmap " testname, \
|
|
|
|
testQemuBackupIncrementalBitmapCalculate, \
|
|
|
|
&backupbitmapcalcdata) < 0) \
|
|
|
|
ret = -1; \
|
|
|
|
} while (0)
|
|
|
|
|
2020-05-28 14:25:55 +00:00
|
|
|
TEST_BACKUP_BITMAP_CALCULATE("empty", bitmapSourceChain, "a", "empty");
|
|
|
|
|
2020-05-29 10:52:58 +00:00
|
|
|
TEST_BACKUP_BITMAP_CALCULATE("basic-flat", bitmapSourceChain, "current", "basic");
|
|
|
|
TEST_BACKUP_BITMAP_CALCULATE("basic-intermediate", bitmapSourceChain, "d", "basic");
|
|
|
|
TEST_BACKUP_BITMAP_CALCULATE("basic-deep", bitmapSourceChain, "a", "basic");
|
|
|
|
|
2020-05-29 10:55:02 +00:00
|
|
|
TEST_BACKUP_BITMAP_CALCULATE("snapshots-flat", bitmapSourceChain, "current", "snapshots");
|
|
|
|
TEST_BACKUP_BITMAP_CALCULATE("snapshots-intermediate", bitmapSourceChain, "d", "snapshots");
|
|
|
|
TEST_BACKUP_BITMAP_CALCULATE("snapshots-deep", bitmapSourceChain, "a", "snapshots");
|
|
|
|
|
2020-06-01 08:40:04 +00:00
|
|
|
#define TEST_CHECKPOINT_DELETE(testname, delbmp, named) \
|
2020-01-08 13:56:45 +00:00
|
|
|
do { \
|
|
|
|
checkpointdeletedata.name = testname; \
|
|
|
|
checkpointdeletedata.chain = bitmapSourceChain; \
|
|
|
|
checkpointdeletedata.deletebitmap = delbmp; \
|
2020-01-09 13:19:07 +00:00
|
|
|
checkpointdeletedata.nodedatafile = named; \
|
2020-01-08 13:56:45 +00:00
|
|
|
if (virTestRun("checkpoint delete " testname, \
|
2020-06-01 08:40:04 +00:00
|
|
|
testQemuCheckpointDelete, &checkpointdeletedata) < 0) \
|
2020-01-08 13:56:45 +00:00
|
|
|
ret = -1; \
|
|
|
|
} while (0)
|
|
|
|
|
2020-06-01 08:40:04 +00:00
|
|
|
TEST_CHECKPOINT_DELETE("empty", "a", "empty");
|
2020-05-28 14:30:06 +00:00
|
|
|
|
2020-06-01 08:41:16 +00:00
|
|
|
TEST_CHECKPOINT_DELETE("basic-noparent", "a", "basic");
|
|
|
|
TEST_CHECKPOINT_DELETE("basic-intermediate1", "b", "basic");
|
|
|
|
TEST_CHECKPOINT_DELETE("basic-intermediate2", "c", "basic");
|
|
|
|
TEST_CHECKPOINT_DELETE("basic-intermediate3", "d", "basic");
|
|
|
|
TEST_CHECKPOINT_DELETE("basic-current", "current", "basic");
|
|
|
|
|
|
|
|
TEST_CHECKPOINT_DELETE("snapshots-noparent", "a", "snapshots");
|
|
|
|
TEST_CHECKPOINT_DELETE("snapshots-intermediate1", "b", "snapshots");
|
|
|
|
TEST_CHECKPOINT_DELETE("snapshots-intermediate2", "c", "snapshots");
|
|
|
|
TEST_CHECKPOINT_DELETE("snapshots-intermediate3", "d", "snapshots");
|
|
|
|
TEST_CHECKPOINT_DELETE("snapshots-current", "current", "snapshots");
|
|
|
|
|
|
|
|
TEST_CHECKPOINT_DELETE("synthetic-noparent", "a", "synthetic");
|
|
|
|
TEST_CHECKPOINT_DELETE("synthetic-intermediate1", "b", "synthetic");
|
|
|
|
TEST_CHECKPOINT_DELETE("synthetic-intermediate2", "c", "synthetic");
|
|
|
|
TEST_CHECKPOINT_DELETE("synthetic-intermediate3", "d", "synthetic");
|
|
|
|
TEST_CHECKPOINT_DELETE("synthetic-current", "current", "synthetic");
|
|
|
|
|
2020-01-29 11:08:50 +00:00
|
|
|
#define TEST_BITMAP_VALIDATE(testname, bitmap, rc) \
|
|
|
|
do { \
|
|
|
|
blockbitmapvalidatedata.name = testname; \
|
|
|
|
blockbitmapvalidatedata.chain = bitmapSourceChain; \
|
|
|
|
blockbitmapvalidatedata.bitmapname = bitmap; \
|
|
|
|
blockbitmapvalidatedata.expect = rc; \
|
|
|
|
if (virTestRun("bitmap validate " testname " " bitmap, \
|
|
|
|
testQemuBlockBitmapValidate, \
|
|
|
|
&blockbitmapvalidatedata) < 0) \
|
|
|
|
ret = -1; \
|
|
|
|
} while (0)
|
2020-01-09 15:37:43 +00:00
|
|
|
|
2020-05-28 14:19:07 +00:00
|
|
|
TEST_BITMAP_VALIDATE("empty", "a", false);
|
|
|
|
|
2020-06-02 14:47:35 +00:00
|
|
|
TEST_BITMAP_VALIDATE("basic", "a", true);
|
|
|
|
TEST_BITMAP_VALIDATE("basic", "b", true);
|
|
|
|
TEST_BITMAP_VALIDATE("basic", "c", true);
|
|
|
|
TEST_BITMAP_VALIDATE("basic", "d", true);
|
|
|
|
TEST_BITMAP_VALIDATE("basic", "current", true);
|
|
|
|
|
|
|
|
TEST_BITMAP_VALIDATE("snapshots", "a", true);
|
|
|
|
TEST_BITMAP_VALIDATE("snapshots", "b", true);
|
|
|
|
TEST_BITMAP_VALIDATE("snapshots", "c", true);
|
|
|
|
TEST_BITMAP_VALIDATE("snapshots", "d", true);
|
|
|
|
TEST_BITMAP_VALIDATE("snapshots", "current", true);
|
|
|
|
|
2020-06-02 13:11:25 +00:00
|
|
|
TEST_BITMAP_VALIDATE("synthetic", "a", false);
|
|
|
|
TEST_BITMAP_VALIDATE("synthetic", "b", false);
|
|
|
|
TEST_BITMAP_VALIDATE("synthetic", "c", false);
|
|
|
|
TEST_BITMAP_VALIDATE("synthetic", "d", false);
|
|
|
|
TEST_BITMAP_VALIDATE("synthetic", "current", false);
|
|
|
|
TEST_BITMAP_VALIDATE("synthetic", "top-ok", true);
|
|
|
|
TEST_BITMAP_VALIDATE("synthetic", "top-inactive", false);
|
|
|
|
TEST_BITMAP_VALIDATE("synthetic", "top-transient", false);
|
|
|
|
TEST_BITMAP_VALIDATE("synthetic", "top-inactive-transient", false);
|
|
|
|
|
2020-01-29 16:12:47 +00:00
|
|
|
#define TEST_BITMAP_BLOCKCOPY(testname, shllw, ndf) \
|
|
|
|
do { \
|
|
|
|
blockbitmapblockcopydata.name = testname; \
|
|
|
|
blockbitmapblockcopydata.shallow = shllw; \
|
|
|
|
blockbitmapblockcopydata.nodedatafile = ndf; \
|
|
|
|
blockbitmapblockcopydata.chain = bitmapSourceChain;\
|
|
|
|
if (virTestRun("bitmap block copy " testname, \
|
|
|
|
testQemuBlockBitmapBlockcopy, \
|
|
|
|
&blockbitmapblockcopydata) < 0) \
|
|
|
|
ret = -1; \
|
|
|
|
} while (0)
|
|
|
|
|
2020-05-28 14:33:06 +00:00
|
|
|
TEST_BITMAP_BLOCKCOPY("empty-shallow", true, "empty");
|
|
|
|
TEST_BITMAP_BLOCKCOPY("empty-deep", false, "empty");
|
|
|
|
|
2020-06-01 15:37:14 +00:00
|
|
|
TEST_BITMAP_BLOCKCOPY("basic-shallow", true, "basic");
|
|
|
|
TEST_BITMAP_BLOCKCOPY("basic-deep", false, "basic");
|
|
|
|
|
|
|
|
TEST_BITMAP_BLOCKCOPY("snapshots-shallow", true, "snapshots");
|
|
|
|
TEST_BITMAP_BLOCKCOPY("snapshots-deep", false, "snapshots");
|
2020-03-02 16:16:17 +00:00
|
|
|
|
|
|
|
#define TEST_BITMAP_BLOCKCOMMIT(testname, topimg, baseimg, ndf) \
|
|
|
|
do {\
|
|
|
|
blockbitmapblockcommitdata.name = testname; \
|
2020-04-17 07:51:40 +00:00
|
|
|
blockbitmapblockcommitdata.chain = bitmapSourceChain; \
|
2020-03-02 16:16:17 +00:00
|
|
|
blockbitmapblockcommitdata.top = testQemuBitmapGetFakeChainEntry(bitmapSourceChain, topimg); \
|
|
|
|
blockbitmapblockcommitdata.base = testQemuBitmapGetFakeChainEntry(bitmapSourceChain, baseimg); \
|
|
|
|
blockbitmapblockcommitdata.nodedatafile = ndf; \
|
|
|
|
if (virTestRun("bitmap block commit " testname, \
|
|
|
|
testQemuBlockBitmapBlockcommit, \
|
|
|
|
&blockbitmapblockcommitdata) < 0) \
|
|
|
|
ret = -1; \
|
|
|
|
} while (0)
|
|
|
|
|
2020-05-28 14:34:40 +00:00
|
|
|
TEST_BITMAP_BLOCKCOMMIT("empty", 1, 2, "empty");
|
|
|
|
|
2020-05-29 11:01:55 +00:00
|
|
|
TEST_BITMAP_BLOCKCOMMIT("basic-1-2", 1, 2, "basic");
|
|
|
|
TEST_BITMAP_BLOCKCOMMIT("basic-1-3", 1, 3, "basic");
|
|
|
|
TEST_BITMAP_BLOCKCOMMIT("basic-2-3", 2, 3, "basic");
|
|
|
|
|
2020-05-29 11:03:53 +00:00
|
|
|
TEST_BITMAP_BLOCKCOMMIT("snapshots-1-2", 1, 2, "snapshots");
|
|
|
|
TEST_BITMAP_BLOCKCOMMIT("snapshots-1-3", 1, 3, "snapshots");
|
|
|
|
TEST_BITMAP_BLOCKCOMMIT("snapshots-1-4", 1, 4, "snapshots");
|
|
|
|
TEST_BITMAP_BLOCKCOMMIT("snapshots-1-5", 1, 5, "snapshots");
|
|
|
|
|
|
|
|
TEST_BITMAP_BLOCKCOMMIT("snapshots-2-3", 2, 3, "snapshots");
|
|
|
|
TEST_BITMAP_BLOCKCOMMIT("snapshots-2-4", 2, 4, "snapshots");
|
|
|
|
TEST_BITMAP_BLOCKCOMMIT("snapshots-2-5", 2, 5, "snapshots");
|
|
|
|
|
|
|
|
TEST_BITMAP_BLOCKCOMMIT("snapshots-3-4", 3, 4, "snapshots");
|
|
|
|
TEST_BITMAP_BLOCKCOMMIT("snapshots-3-5", 3, 5, "snapshots");
|
|
|
|
|
|
|
|
TEST_BITMAP_BLOCKCOMMIT("snapshots-4-5", 4, 5, "snapshots");
|
|
|
|
|
2018-03-23 08:06:40 +00:00
|
|
|
cleanup:
|
|
|
|
qemuTestDriverFree(&driver);
|
|
|
|
VIR_FREE(capslatest_x86_64);
|
|
|
|
|
2017-11-03 14:20:55 +00:00
|
|
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2020-10-21 14:53:26 +00:00
|
|
|
VIR_TEST_MAIN(mymain)
|