2013-02-14 02:04:05 +08:00
|
|
|
/*
|
2014-04-02 09:13:51 +08:00
|
|
|
* Copyright (C) 2013-2014 Red Hat, Inc.
|
2013-02-14 02:04:05 +08: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>
|
|
|
|
|
2020-02-17 05:59:28 +08:00
|
|
|
#include <unistd.h>
|
2013-02-14 02:04:05 +08:00
|
|
|
|
|
|
|
#include "testutils.h"
|
|
|
|
#include "vircommand.h"
|
|
|
|
#include "virerror.h"
|
2013-05-10 02:59:04 +08:00
|
|
|
#include "virfile.h"
|
2013-02-14 02:04:05 +08:00
|
|
|
#include "virlog.h"
|
|
|
|
#include "virstoragefile.h"
|
2013-04-03 18:36:23 +08:00
|
|
|
#include "virstring.h"
|
2013-02-14 02:04:05 +08:00
|
|
|
|
2014-04-24 18:14:01 +08:00
|
|
|
#include "storage/storage_driver.h"
|
|
|
|
|
2013-02-14 02:04:05 +08:00
|
|
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
|
|
|
|
2014-02-28 20:16:17 +08:00
|
|
|
VIR_LOG_INIT("tests.storagetest");
|
|
|
|
|
2013-02-14 02:04:05 +08:00
|
|
|
#define datadir abs_builddir "/virstoragedata"
|
|
|
|
|
|
|
|
/* This test creates the following files, all in datadir:
|
|
|
|
|
|
|
|
* raw: 1024-byte raw file
|
|
|
|
* qcow2: qcow2 file with 'raw' as backing
|
|
|
|
* wrap: qcow2 file with 'qcow2' as backing
|
|
|
|
* qed: qed file with 'raw' as backing
|
|
|
|
* sub/link1: symlink to qcow2
|
|
|
|
* sub/link2: symlink to wrap
|
|
|
|
*
|
|
|
|
* Relative names to these files are known at compile time, but absolute
|
2019-03-13 00:21:37 +08:00
|
|
|
* names depend on where the test is run; for convenience,
|
2013-02-14 02:04:05 +08:00
|
|
|
* we pre-populate the computation of these names for use during the test.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static char *qemuimg;
|
|
|
|
static char *absraw;
|
|
|
|
static char *absqcow2;
|
|
|
|
static char *abswrap;
|
|
|
|
static char *absqed;
|
2014-04-05 03:35:22 +08:00
|
|
|
static char *absdir;
|
2013-02-14 02:04:05 +08:00
|
|
|
static char *abslink2;
|
|
|
|
|
|
|
|
static void
|
|
|
|
testCleanupImages(void)
|
|
|
|
{
|
|
|
|
VIR_FREE(qemuimg);
|
|
|
|
VIR_FREE(absraw);
|
|
|
|
VIR_FREE(absqcow2);
|
|
|
|
VIR_FREE(abswrap);
|
|
|
|
VIR_FREE(absqed);
|
2014-04-05 03:35:22 +08:00
|
|
|
VIR_FREE(absdir);
|
2013-02-14 02:04:05 +08:00
|
|
|
VIR_FREE(abslink2);
|
|
|
|
|
|
|
|
if (chdir(abs_builddir) < 0) {
|
|
|
|
fprintf(stderr, "unable to return to correct directory, refusing to "
|
|
|
|
"clean up %s\n", datadir);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-04-03 05:52:18 +08:00
|
|
|
virFileDeleteTree(datadir);
|
2013-02-14 02:04:05 +08:00
|
|
|
}
|
|
|
|
|
2014-04-18 20:49:54 +08:00
|
|
|
|
|
|
|
static virStorageSourcePtr
|
|
|
|
testStorageFileGetMetadata(const char *path,
|
|
|
|
int format,
|
2018-06-04 15:39:28 +08:00
|
|
|
uid_t uid, gid_t gid)
|
2014-04-18 20:49:54 +08:00
|
|
|
{
|
2014-04-26 03:44:06 +08:00
|
|
|
struct stat st;
|
2020-09-22 17:04:17 +08:00
|
|
|
g_autoptr(virStorageSource) def = virStorageSourceNew();
|
2014-04-18 20:49:54 +08:00
|
|
|
|
2019-02-08 21:35:56 +08:00
|
|
|
def->type = VIR_STORAGE_TYPE_FILE;
|
|
|
|
def->format = format;
|
2014-04-18 20:49:54 +08:00
|
|
|
|
2014-04-26 03:44:06 +08:00
|
|
|
if (stat(path, &st) == 0) {
|
|
|
|
if (S_ISDIR(st.st_mode)) {
|
2019-02-08 21:35:56 +08:00
|
|
|
def->type = VIR_STORAGE_TYPE_DIR;
|
2014-04-26 03:44:06 +08:00
|
|
|
} else if (S_ISBLK(st.st_mode)) {
|
2019-02-08 21:35:56 +08:00
|
|
|
def->type = VIR_STORAGE_TYPE_BLOCK;
|
2014-04-26 03:44:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-20 19:49:46 +08:00
|
|
|
def->path = g_strdup(path);
|
2014-04-18 20:49:54 +08:00
|
|
|
|
2019-12-18 00:46:18 +08:00
|
|
|
if (virStorageFileGetMetadata(def, uid, gid, true) < 0)
|
2019-02-13 02:17:56 +08:00
|
|
|
return NULL;
|
2014-04-18 20:49:54 +08:00
|
|
|
|
2019-10-17 16:10:10 +08:00
|
|
|
return g_steal_pointer(&def);
|
2014-04-18 20:49:54 +08:00
|
|
|
}
|
|
|
|
|
2013-02-14 02:04:05 +08:00
|
|
|
static int
|
|
|
|
testPrepImages(void)
|
|
|
|
{
|
|
|
|
int ret = EXIT_FAILURE;
|
2013-12-18 07:28:20 +08:00
|
|
|
bool compat = false;
|
2019-10-15 20:47:50 +08:00
|
|
|
g_autoptr(virCommand) cmd = NULL;
|
2019-10-15 21:16:31 +08:00
|
|
|
g_autofree char *buf = NULL;
|
2013-02-14 02:04:05 +08:00
|
|
|
|
2016-04-16 05:00:40 +08:00
|
|
|
qemuimg = virFindFileInPath("qemu-img");
|
2013-02-27 03:45:38 +08:00
|
|
|
if (!qemuimg)
|
|
|
|
goto skip;
|
2013-02-14 02:04:05 +08:00
|
|
|
|
2014-04-11 03:34:15 +08:00
|
|
|
/* Clean up from any earlier failed tests */
|
|
|
|
virFileDeleteTree(datadir);
|
|
|
|
|
2013-12-18 07:28:20 +08:00
|
|
|
/* See if qemu-img supports '-o compat=xxx'. If so, we force the
|
|
|
|
* use of both v2 and v3 files; if not, it is v2 only but the test
|
|
|
|
* still works. */
|
|
|
|
cmd = virCommandNewArgList(qemuimg, "create", "-f", "qcow2",
|
|
|
|
"-o?", "/dev/null", NULL);
|
|
|
|
virCommandSetOutputBuffer(cmd, &buf);
|
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
|
|
|
goto skip;
|
|
|
|
if (strstr(buf, "compat "))
|
|
|
|
compat = true;
|
|
|
|
VIR_FREE(buf);
|
|
|
|
|
2019-10-22 21:26:14 +08:00
|
|
|
absraw = g_strdup_printf("%s/raw", datadir);
|
|
|
|
absqcow2 = g_strdup_printf("%s/qcow2", datadir);
|
|
|
|
abswrap = g_strdup_printf("%s/wrap", datadir);
|
|
|
|
absqed = g_strdup_printf("%s/qed", datadir);
|
|
|
|
absdir = g_strdup_printf("%s/dir", datadir);
|
|
|
|
abslink2 = g_strdup_printf("%s/sub/link2", datadir);
|
2013-02-14 02:04:05 +08:00
|
|
|
|
|
|
|
if (virFileMakePath(datadir "/sub") < 0) {
|
|
|
|
fprintf(stderr, "unable to create directory %s\n", datadir "/sub");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2014-04-05 03:35:22 +08:00
|
|
|
if (virFileMakePath(datadir "/dir") < 0) {
|
|
|
|
fprintf(stderr, "unable to create directory %s\n", datadir "/dir");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2013-02-14 02:04:05 +08:00
|
|
|
|
|
|
|
if (chdir(datadir) < 0) {
|
|
|
|
fprintf(stderr, "unable to test relative backing chains\n");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2019-10-22 21:26:14 +08:00
|
|
|
buf = g_strdup_printf("%1024d", 0);
|
|
|
|
if (virFileWriteStr("raw", buf, 0600) < 0) {
|
2013-02-27 03:45:38 +08:00
|
|
|
fprintf(stderr, "unable to create raw file\n");
|
2013-02-14 02:04:05 +08:00
|
|
|
goto cleanup;
|
2013-02-27 03:45:38 +08:00
|
|
|
}
|
2013-02-14 02:04:05 +08:00
|
|
|
|
|
|
|
/* Create a qcow2 wrapping relative raw; later on, we modify its
|
|
|
|
* metadata to test other configurations */
|
|
|
|
virCommandFree(cmd);
|
2013-12-18 07:28:20 +08:00
|
|
|
cmd = virCommandNewArgList(qemuimg, "create", "-f", "qcow2", NULL);
|
|
|
|
virCommandAddArgFormat(cmd, "-obacking_file=raw,backing_fmt=raw%s",
|
|
|
|
compat ? ",compat=0.10" : "");
|
|
|
|
virCommandAddArg(cmd, "qcow2");
|
2013-02-14 02:04:05 +08:00
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
2013-02-27 03:45:38 +08:00
|
|
|
goto skip;
|
2013-02-14 02:04:05 +08:00
|
|
|
/* Make sure our later uses of 'qemu-img rebase' will work */
|
|
|
|
virCommandFree(cmd);
|
2013-02-27 03:45:38 +08:00
|
|
|
cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
|
2013-02-14 02:04:05 +08:00
|
|
|
"-F", "raw", "-b", "raw", "qcow2", NULL);
|
2013-02-27 03:45:38 +08:00
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
|
|
|
goto skip;
|
2013-02-14 02:04:05 +08:00
|
|
|
|
|
|
|
/* Create a second qcow2 wrapping the first, to be sure that we
|
|
|
|
* can correctly avoid insecure probing. */
|
|
|
|
virCommandFree(cmd);
|
2013-02-27 03:45:38 +08:00
|
|
|
cmd = virCommandNewArgList(qemuimg, "create", "-f", "qcow2", NULL);
|
2013-12-18 07:28:20 +08:00
|
|
|
virCommandAddArgFormat(cmd, "-obacking_file=%s,backing_fmt=qcow2%s",
|
|
|
|
absqcow2, compat ? ",compat=1.1" : "");
|
2013-02-14 02:04:05 +08:00
|
|
|
virCommandAddArg(cmd, "wrap");
|
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
2013-02-27 03:45:38 +08:00
|
|
|
goto skip;
|
2013-02-14 02:04:05 +08:00
|
|
|
|
|
|
|
/* Create a qed file. */
|
|
|
|
virCommandFree(cmd);
|
2013-02-27 03:45:38 +08:00
|
|
|
cmd = virCommandNewArgList(qemuimg, "create", "-f", "qed", NULL);
|
2013-02-14 02:04:05 +08:00
|
|
|
virCommandAddArgFormat(cmd, "-obacking_file=%s,backing_fmt=raw",
|
|
|
|
absraw);
|
|
|
|
virCommandAddArg(cmd, "qed");
|
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
2013-02-27 03:45:38 +08:00
|
|
|
goto skip;
|
2013-02-14 02:04:05 +08:00
|
|
|
|
2020-09-01 19:27:44 +08:00
|
|
|
#ifdef WITH_SYMLINK
|
2013-02-14 02:04:05 +08:00
|
|
|
/* Create some symlinks in a sub-directory. */
|
|
|
|
if (symlink("../qcow2", datadir "/sub/link1") < 0 ||
|
|
|
|
symlink("../wrap", datadir "/sub/link2") < 0) {
|
|
|
|
fprintf(stderr, "unable to create symlink");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2013-04-16 00:00:17 +08:00
|
|
|
#endif
|
2013-02-14 02:04:05 +08:00
|
|
|
|
|
|
|
ret = 0;
|
2014-03-25 14:53:44 +08:00
|
|
|
cleanup:
|
2013-02-14 02:04:05 +08:00
|
|
|
if (ret)
|
|
|
|
testCleanupImages();
|
|
|
|
return ret;
|
2013-02-27 03:45:38 +08:00
|
|
|
|
2014-03-25 14:53:44 +08:00
|
|
|
skip:
|
2013-02-27 03:45:38 +08:00
|
|
|
fputs("qemu-img is too old; skipping this test\n", stderr);
|
|
|
|
ret = EXIT_AM_SKIP;
|
|
|
|
goto cleanup;
|
2013-02-14 02:04:05 +08:00
|
|
|
}
|
|
|
|
|
2014-04-06 02:00:48 +08:00
|
|
|
/* Many fields of virStorageFileMetadata have the same content whether
|
|
|
|
* we access the file relatively or absolutely; but file names differ
|
|
|
|
* depending on how the chain was opened. For ease of testing, we
|
|
|
|
* test both relative and absolute starts, and use a flag to say which
|
|
|
|
* of the two variations to compare against. */
|
2013-02-14 02:04:05 +08:00
|
|
|
typedef struct _testFileData testFileData;
|
|
|
|
struct _testFileData
|
|
|
|
{
|
|
|
|
const char *expBackingStoreRaw;
|
|
|
|
unsigned long long expCapacity;
|
|
|
|
bool expEncrypted;
|
2014-04-04 12:03:04 +08:00
|
|
|
const char *pathRel;
|
2014-04-17 19:47:41 +08:00
|
|
|
const char *path;
|
2014-04-09 12:28:35 +08:00
|
|
|
int type;
|
|
|
|
int format;
|
2014-11-04 21:26:45 +08:00
|
|
|
const char *secret;
|
|
|
|
const char *hostname;
|
|
|
|
int protocol;
|
2013-02-14 02:04:05 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
EXP_PASS = 0,
|
|
|
|
EXP_FAIL = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct testChainData
|
|
|
|
{
|
|
|
|
const char *start;
|
2014-04-27 08:15:22 +08:00
|
|
|
virStorageFileFormat format;
|
2014-04-06 02:00:48 +08:00
|
|
|
const testFileData *files[4];
|
2013-02-14 02:04:05 +08:00
|
|
|
int nfiles;
|
|
|
|
unsigned int flags;
|
|
|
|
};
|
|
|
|
|
2014-05-26 21:38:29 +08:00
|
|
|
|
|
|
|
static const char testStorageChainFormat[] =
|
2014-05-26 22:39:38 +08:00
|
|
|
"chain member: %zu\n"
|
2014-05-26 22:05:44 +08:00
|
|
|
"path:%s\n"
|
2014-05-26 21:38:29 +08:00
|
|
|
"backingStoreRaw: %s\n"
|
|
|
|
"capacity: %lld\n"
|
|
|
|
"encryption: %d\n"
|
|
|
|
"relPath:%s\n"
|
|
|
|
"type:%d\n"
|
2014-11-04 21:26:45 +08:00
|
|
|
"format:%d\n"
|
|
|
|
"protocol:%s\n"
|
2018-02-14 21:12:23 +08:00
|
|
|
"hostname:%s\n";
|
2014-05-26 21:38:29 +08:00
|
|
|
|
2013-02-14 02:04:05 +08:00
|
|
|
static int
|
|
|
|
testStorageChain(const void *args)
|
|
|
|
{
|
|
|
|
const struct testChainData *data = args;
|
2014-04-17 22:05:16 +08:00
|
|
|
virStorageSourcePtr elt;
|
Convert 'int i' to 'size_t i' in tests/ files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 22:09:33 +08:00
|
|
|
size_t i = 0;
|
2019-10-15 20:47:50 +08:00
|
|
|
g_autoptr(virStorageSource) meta = NULL;
|
2013-02-14 02:04:05 +08:00
|
|
|
|
2018-06-04 15:39:28 +08:00
|
|
|
meta = testStorageFileGetMetadata(data->start, data->format, -1, -1);
|
2013-02-14 02:04:05 +08:00
|
|
|
if (!meta) {
|
|
|
|
if (data->flags & EXP_FAIL) {
|
|
|
|
virResetLastError();
|
2019-02-13 02:17:56 +08:00
|
|
|
return 0;
|
2013-02-14 02:04:05 +08:00
|
|
|
}
|
2019-02-13 02:17:56 +08:00
|
|
|
return -1;
|
2013-02-14 02:04:05 +08:00
|
|
|
} else if (data->flags & EXP_FAIL) {
|
|
|
|
fprintf(stderr, "call should have failed\n");
|
2019-02-13 02:17:56 +08:00
|
|
|
return -1;
|
2013-02-14 02:04:05 +08:00
|
|
|
}
|
2019-12-18 00:49:36 +08:00
|
|
|
|
|
|
|
if (virGetLastErrorCode()) {
|
|
|
|
fprintf(stderr, "call should not have reported error\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-02-14 02:04:05 +08:00
|
|
|
elt = meta;
|
2017-10-13 01:27:40 +08:00
|
|
|
while (virStorageSourceIsBacking(elt)) {
|
2019-10-15 21:16:31 +08:00
|
|
|
g_autofree char *expect = NULL;
|
|
|
|
g_autofree char *actual = NULL;
|
2013-02-14 02:04:05 +08:00
|
|
|
|
|
|
|
if (i == data->nfiles) {
|
|
|
|
fprintf(stderr, "probed chain was too long\n");
|
2019-02-13 02:17:56 +08:00
|
|
|
return -1;
|
2013-02-14 02:04:05 +08:00
|
|
|
}
|
|
|
|
|
2019-10-22 21:26:14 +08:00
|
|
|
expect = g_strdup_printf(testStorageChainFormat, i,
|
|
|
|
NULLSTR(data->files[i]->path),
|
|
|
|
NULLSTR(data->files[i]->expBackingStoreRaw),
|
|
|
|
data->files[i]->expCapacity,
|
|
|
|
data->files[i]->expEncrypted,
|
|
|
|
NULLSTR(data->files[i]->pathRel),
|
|
|
|
data->files[i]->type,
|
|
|
|
data->files[i]->format,
|
|
|
|
virStorageNetProtocolTypeToString(data->files[i]->protocol),
|
|
|
|
NULLSTR(data->files[i]->hostname));
|
|
|
|
actual = g_strdup_printf(testStorageChainFormat, i,
|
|
|
|
NULLSTR(elt->path),
|
|
|
|
NULLSTR(elt->backingStoreRaw),
|
|
|
|
elt->capacity,
|
|
|
|
!!elt->encryption,
|
|
|
|
NULLSTR(elt->relPath),
|
|
|
|
elt->type,
|
|
|
|
elt->format,
|
|
|
|
virStorageNetProtocolTypeToString(elt->protocol),
|
|
|
|
NULLSTR(elt->nhosts ? elt->hosts[0].name : NULL));
|
2013-02-14 02:04:05 +08:00
|
|
|
if (STRNEQ(expect, actual)) {
|
2016-05-26 23:01:51 +08:00
|
|
|
virTestDifference(stderr, expect, actual);
|
2019-02-13 02:17:56 +08:00
|
|
|
return -1;
|
2013-02-14 02:04:05 +08:00
|
|
|
}
|
2014-04-18 04:46:18 +08:00
|
|
|
elt = elt->backingStore;
|
2013-02-14 02:04:05 +08:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
if (i != data->nfiles) {
|
|
|
|
fprintf(stderr, "probed chain was too short\n");
|
2019-02-13 02:17:56 +08:00
|
|
|
return -1;
|
2013-02-14 02:04:05 +08:00
|
|
|
}
|
|
|
|
|
2019-02-13 02:17:56 +08:00
|
|
|
return 0;
|
2013-02-14 02:04:05 +08:00
|
|
|
}
|
|
|
|
|
2014-04-11 03:56:57 +08:00
|
|
|
struct testLookupData
|
|
|
|
{
|
2014-04-17 22:05:16 +08:00
|
|
|
virStorageSourcePtr chain;
|
2014-04-18 20:35:33 +08:00
|
|
|
const char *target;
|
2014-06-13 23:23:10 +08:00
|
|
|
virStorageSourcePtr from;
|
2014-04-11 03:56:57 +08:00
|
|
|
const char *name;
|
2014-04-18 20:35:33 +08:00
|
|
|
unsigned int expIndex;
|
2014-04-11 03:56:57 +08:00
|
|
|
const char *expResult;
|
2014-04-17 22:05:16 +08:00
|
|
|
virStorageSourcePtr expMeta;
|
2014-06-25 21:43:04 +08:00
|
|
|
virStorageSourcePtr expParent;
|
2014-04-11 03:56:57 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
testStorageLookup(const void *args)
|
|
|
|
{
|
|
|
|
const struct testLookupData *data = args;
|
|
|
|
int ret = 0;
|
2014-04-18 21:25:19 +08:00
|
|
|
virStorageSourcePtr result;
|
2014-06-25 21:43:04 +08:00
|
|
|
virStorageSourcePtr actualParent;
|
2014-04-18 20:35:33 +08:00
|
|
|
unsigned int idx;
|
|
|
|
|
|
|
|
if (virStorageFileParseChainIndex(data->target, data->name, &idx) < 0 &&
|
|
|
|
data->expIndex) {
|
|
|
|
fprintf(stderr, "call should not have failed\n");
|
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
if (idx != data->expIndex) {
|
|
|
|
fprintf(stderr, "index: expected %u, got %u\n", data->expIndex, idx);
|
|
|
|
ret = -1;
|
|
|
|
}
|
2014-04-11 03:56:57 +08:00
|
|
|
|
2014-04-18 21:25:19 +08:00
|
|
|
/* Test twice to ensure optional parameter doesn't cause NULL deref. */
|
2014-06-13 23:23:10 +08:00
|
|
|
result = virStorageFileChainLookup(data->chain, data->from,
|
2014-04-18 20:35:33 +08:00
|
|
|
idx ? NULL : data->name,
|
|
|
|
idx, NULL);
|
2014-04-11 03:56:57 +08:00
|
|
|
|
|
|
|
if (!data->expResult) {
|
2018-05-05 20:04:21 +08:00
|
|
|
if (virGetLastErrorCode() == VIR_ERR_OK) {
|
2014-04-11 03:56:57 +08:00
|
|
|
fprintf(stderr, "call should have failed\n");
|
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
virResetLastError();
|
|
|
|
} else {
|
2018-05-05 20:04:21 +08:00
|
|
|
if (virGetLastErrorCode()) {
|
2014-04-11 03:56:57 +08:00
|
|
|
fprintf(stderr, "call should not have warned\n");
|
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-18 21:25:19 +08:00
|
|
|
if (!result) {
|
|
|
|
if (data->expResult) {
|
|
|
|
fprintf(stderr, "result 1: expected %s, got NULL\n",
|
|
|
|
data->expResult);
|
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
} else if (STRNEQ_NULLABLE(data->expResult, result->path)) {
|
2014-04-11 03:56:57 +08:00
|
|
|
fprintf(stderr, "result 1: expected %s, got %s\n",
|
2014-04-18 21:25:19 +08:00
|
|
|
NULLSTR(data->expResult), NULLSTR(result->path));
|
2014-04-11 03:56:57 +08:00
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
|
2014-06-13 23:23:10 +08:00
|
|
|
result = virStorageFileChainLookup(data->chain, data->from,
|
2014-04-18 20:35:33 +08:00
|
|
|
data->name, idx, &actualParent);
|
2014-04-11 03:56:57 +08:00
|
|
|
if (!data->expResult)
|
|
|
|
virResetLastError();
|
2014-04-18 21:25:19 +08:00
|
|
|
|
|
|
|
if (!result) {
|
|
|
|
if (data->expResult) {
|
|
|
|
fprintf(stderr, "result 2: expected %s, got NULL\n",
|
|
|
|
data->expResult);
|
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
} else if (STRNEQ_NULLABLE(data->expResult, result->path)) {
|
2014-04-11 03:56:57 +08:00
|
|
|
fprintf(stderr, "result 2: expected %s, got %s\n",
|
2014-04-18 21:25:19 +08:00
|
|
|
NULLSTR(data->expResult), NULLSTR(result->path));
|
2014-04-11 03:56:57 +08:00
|
|
|
ret = -1;
|
|
|
|
}
|
2014-04-18 21:25:19 +08:00
|
|
|
if (data->expMeta != result) {
|
2014-04-11 03:56:57 +08:00
|
|
|
fprintf(stderr, "meta: expected %p, got %p\n",
|
2014-04-18 21:25:19 +08:00
|
|
|
data->expMeta, result);
|
2014-04-11 03:56:57 +08:00
|
|
|
ret = -1;
|
|
|
|
}
|
2014-06-25 21:43:04 +08:00
|
|
|
if (data->expParent != actualParent) {
|
2014-04-11 03:56:57 +08:00
|
|
|
fprintf(stderr, "parent: expected %s, got %s\n",
|
2014-06-25 21:43:04 +08:00
|
|
|
NULLSTR(data->expParent ? data->expParent->path : NULL),
|
|
|
|
NULLSTR(actualParent ? actualParent->path : NULL));
|
2014-04-11 03:56:57 +08:00
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-05-03 01:22:17 +08:00
|
|
|
|
|
|
|
struct testPathCanonicalizeData
|
|
|
|
{
|
|
|
|
const char *path;
|
|
|
|
const char *expect;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *testPathCanonicalizeSymlinks[][2] =
|
|
|
|
{
|
|
|
|
{"/path/blah", "/other/path/huzah"},
|
|
|
|
{"/path/to/relative/symlink", "../../actual/file"},
|
|
|
|
{"/cycle", "/cycle"},
|
|
|
|
{"/cycle2/link", "./link"},
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
testPathCanonicalizeReadlink(const char *path,
|
2014-06-24 18:53:44 +08:00
|
|
|
char **linkpath,
|
2019-10-14 20:45:03 +08:00
|
|
|
void *data G_GNUC_UNUSED)
|
2014-05-03 01:22:17 +08:00
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
2014-06-24 18:53:44 +08:00
|
|
|
*linkpath = NULL;
|
2014-05-03 01:22:17 +08:00
|
|
|
|
2019-10-15 19:55:26 +08:00
|
|
|
for (i = 0; i < G_N_ELEMENTS(testPathCanonicalizeSymlinks); i++) {
|
2014-05-03 01:22:17 +08:00
|
|
|
if (STREQ(path, testPathCanonicalizeSymlinks[i][0])) {
|
2019-10-20 19:49:46 +08:00
|
|
|
*linkpath = g_strdup(testPathCanonicalizeSymlinks[i][1]);
|
2014-05-03 01:22:17 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
testPathCanonicalize(const void *args)
|
|
|
|
{
|
|
|
|
const struct testPathCanonicalizeData *data = args;
|
2019-10-15 21:16:31 +08:00
|
|
|
g_autofree char *canon = NULL;
|
2014-05-03 01:22:17 +08:00
|
|
|
|
|
|
|
canon = virStorageFileCanonicalizePath(data->path,
|
|
|
|
testPathCanonicalizeReadlink,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (STRNEQ_NULLABLE(data->expect, canon)) {
|
|
|
|
fprintf(stderr,
|
|
|
|
"path canonicalization of '%s' failed: expected '%s' got '%s'\n",
|
|
|
|
data->path, NULLSTR(data->expect), NULLSTR(canon));
|
|
|
|
|
2019-02-02 01:03:16 +08:00
|
|
|
return -1;
|
2014-05-03 01:22:17 +08:00
|
|
|
}
|
|
|
|
|
2019-02-02 01:03:16 +08:00
|
|
|
return 0;
|
2014-05-03 01:22:17 +08:00
|
|
|
}
|
|
|
|
|
2014-05-13 16:10:56 +08:00
|
|
|
static virStorageSource backingchain[12];
|
|
|
|
|
|
|
|
static void
|
|
|
|
testPathRelativePrepare(void)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
2019-10-15 19:55:26 +08:00
|
|
|
for (i = 0; i < G_N_ELEMENTS(backingchain); i++) {
|
2017-10-13 02:45:50 +08:00
|
|
|
backingchain[i].type = VIR_STORAGE_TYPE_FILE;
|
2019-10-15 19:55:26 +08:00
|
|
|
if (i < G_N_ELEMENTS(backingchain) - 1)
|
2014-05-13 16:10:56 +08:00
|
|
|
backingchain[i].backingStore = &backingchain[i + 1];
|
|
|
|
else
|
|
|
|
backingchain[i].backingStore = NULL;
|
|
|
|
|
2014-05-27 16:40:59 +08:00
|
|
|
backingchain[i].relPath = NULL;
|
2014-05-13 16:10:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* normal relative backing chain */
|
|
|
|
backingchain[0].path = (char *) "/path/to/some/img";
|
|
|
|
|
|
|
|
backingchain[1].path = (char *) "/path/to/some/asdf";
|
|
|
|
backingchain[1].relPath = (char *) "asdf";
|
|
|
|
|
|
|
|
backingchain[2].path = (char *) "/path/to/some/test";
|
|
|
|
backingchain[2].relPath = (char *) "test";
|
|
|
|
|
|
|
|
backingchain[3].path = (char *) "/path/to/some/blah";
|
|
|
|
backingchain[3].relPath = (char *) "blah";
|
|
|
|
|
|
|
|
/* ovirt's backing chain */
|
|
|
|
backingchain[4].path = (char *) "/path/to/volume/image1";
|
|
|
|
|
|
|
|
backingchain[5].path = (char *) "/path/to/volume/image2";
|
|
|
|
backingchain[5].relPath = (char *) "../volume/image2";
|
|
|
|
|
|
|
|
backingchain[6].path = (char *) "/path/to/volume/image3";
|
|
|
|
backingchain[6].relPath = (char *) "../volume/image3";
|
|
|
|
|
|
|
|
backingchain[7].path = (char *) "/path/to/volume/image4";
|
|
|
|
backingchain[7].relPath = (char *) "../volume/image4";
|
|
|
|
|
|
|
|
/* some arbitrarily crazy backing chains */
|
|
|
|
backingchain[8].path = (char *) "/crazy/base/image";
|
|
|
|
|
|
|
|
backingchain[9].path = (char *) "/crazy/base/directory/stuff/volumes/garbage/image2";
|
|
|
|
backingchain[9].relPath = (char *) "directory/stuff/volumes/garbage/image2";
|
|
|
|
|
|
|
|
backingchain[10].path = (char *) "/crazy/base/directory/image3";
|
|
|
|
backingchain[10].relPath = (char *) "../../../image3";
|
|
|
|
|
|
|
|
backingchain[11].path = (char *) "/crazy/base/blah/image4";
|
|
|
|
backingchain[11].relPath = (char *) "../blah/image4";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct testPathRelativeBacking
|
|
|
|
{
|
|
|
|
virStorageSourcePtr top;
|
|
|
|
virStorageSourcePtr base;
|
|
|
|
|
|
|
|
const char *expect;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
testPathRelative(const void *args)
|
|
|
|
{
|
|
|
|
const struct testPathRelativeBacking *data = args;
|
2019-10-15 21:16:31 +08:00
|
|
|
g_autofree char *actual = NULL;
|
2014-05-13 16:10:56 +08:00
|
|
|
|
|
|
|
if (virStorageFileGetRelativeBackingPath(data->top,
|
|
|
|
data->base,
|
|
|
|
&actual) < 0) {
|
|
|
|
fprintf(stderr, "relative backing path resolution failed\n");
|
2019-02-02 01:03:16 +08:00
|
|
|
return -1;
|
2014-05-13 16:10:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (STRNEQ_NULLABLE(data->expect, actual)) {
|
|
|
|
fprintf(stderr, "relative path resolution from '%s' to '%s': "
|
|
|
|
"expected '%s', got '%s'\n",
|
|
|
|
data->top->path, data->base->path,
|
|
|
|
NULLSTR(data->expect), NULLSTR(actual));
|
2019-02-02 01:03:16 +08:00
|
|
|
return -1;
|
2014-05-13 16:10:56 +08:00
|
|
|
}
|
|
|
|
|
2019-02-02 01:03:16 +08:00
|
|
|
return 0;
|
2014-05-13 16:10:56 +08:00
|
|
|
}
|
|
|
|
|
2014-05-03 01:22:17 +08:00
|
|
|
|
2016-07-12 23:04:16 +08:00
|
|
|
struct testBackingParseData {
|
|
|
|
const char *backing;
|
|
|
|
const char *expect;
|
2019-08-16 01:27:43 +08:00
|
|
|
int rv;
|
2016-07-12 23:04:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
testBackingParse(const void *args)
|
|
|
|
{
|
|
|
|
const struct testBackingParseData *data = args;
|
2019-10-15 20:47:50 +08:00
|
|
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
2019-10-15 21:16:31 +08:00
|
|
|
g_autofree char *xml = NULL;
|
2019-10-15 20:47:50 +08:00
|
|
|
g_autoptr(virStorageSource) src = NULL;
|
2019-08-16 01:27:43 +08:00
|
|
|
int rc;
|
|
|
|
int erc = data->rv;
|
2020-04-14 16:26:24 +08:00
|
|
|
unsigned int xmlformatflags = VIR_DOMAIN_DEF_FORMAT_SECURE;
|
2016-07-12 23:04:16 +08:00
|
|
|
|
2019-08-16 01:27:43 +08:00
|
|
|
/* expect failure return code with NULL expected data */
|
|
|
|
if (!data->expect)
|
|
|
|
erc = -1;
|
|
|
|
|
|
|
|
if ((rc = virStorageSourceNewFromBackingAbsolute(data->backing, &src)) != erc) {
|
|
|
|
fprintf(stderr, "expected return value '%d' actual '%d'\n", erc, rc);
|
|
|
|
return -1;
|
2016-07-12 23:04:16 +08:00
|
|
|
}
|
|
|
|
|
2019-08-16 01:27:43 +08:00
|
|
|
if (!src)
|
|
|
|
return 0;
|
|
|
|
|
2016-07-12 23:04:16 +08:00
|
|
|
if (src && !data->expect) {
|
|
|
|
fprintf(stderr, "parsing of backing store string '%s' should "
|
|
|
|
"have failed\n", data->backing);
|
2019-08-16 01:16:21 +08:00
|
|
|
return -1;
|
2016-07-12 23:04:16 +08:00
|
|
|
}
|
|
|
|
|
2020-05-07 20:00:28 +08:00
|
|
|
if (virDomainDiskSourceFormat(&buf, src, "source", 0, false, xmlformatflags,
|
|
|
|
false, false, NULL) < 0 ||
|
2016-07-12 23:04:16 +08:00
|
|
|
!(xml = virBufferContentAndReset(&buf))) {
|
|
|
|
fprintf(stderr, "failed to format disk source xml\n");
|
2019-08-16 01:16:21 +08:00
|
|
|
return -1;
|
2016-07-12 23:04:16 +08:00
|
|
|
}
|
|
|
|
|
2016-06-16 20:16:43 +08:00
|
|
|
if (STRNEQ(xml, data->expect)) {
|
2016-07-12 23:04:16 +08:00
|
|
|
fprintf(stderr, "\n backing store string '%s'\n"
|
|
|
|
"expected storage source xml:\n%s\n"
|
|
|
|
"actual storage source xml:\n%s\n",
|
|
|
|
data->backing, data->expect, xml);
|
2019-08-16 01:16:21 +08:00
|
|
|
return -1;
|
2016-07-12 23:04:16 +08:00
|
|
|
}
|
|
|
|
|
2019-08-16 01:16:21 +08:00
|
|
|
return 0;
|
2016-07-12 23:04:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-14 02:04:05 +08:00
|
|
|
static int
|
|
|
|
mymain(void)
|
|
|
|
{
|
|
|
|
int ret;
|
tests: refactor virstoragetest for less stack space
I'm about to add fields to virStorageFileMetadata, which means
also adding fields to the testFileData struct in virstoragetest.
Alas, adding even one pointer on an x86_64 machine gave me a
dreaded compiler error:
virstoragetest.c:712:1: error: the frame size of 4208 bytes is larger than 4096 bytes [-Werror=frame-larger-than=]
After some experimentation, I realized that each test was creating
yet another testChainData (which contains testFileData) on the stack;
forcing the reuse of one of these structures instead of creating a
fresh one each time drastically reduces the size requirements. While
at it, I also got rid of a lot of intermediate structs, with some
macro magic that lets me directly build up the destination chains
inline.
For a bit more insight into what this patch does:
The old code uses an intermediate variable as a fixed-size array
of structs:
testFileData chain[] = { a, b };
data.files = chain;
In the new code, the use of VIR_FLATTEN_* allows the TEST_CHAIN()
macro to still take a single argument for each chain, but now of
the form '(a, b)', where it is turned into the var-args 'a, b'
multiple arguments understood by TEST_ONE_CHAIN(). Thus, the
new code avoids an intermediate variable, and directly provides
the list of pointers to be assigned into array elements:
data.files = { &a, &b };
* tests/virstoragetest.c (mymain): Rewrite TEST_ONE_CHAIN to
reuse the same struct for each test, and to take the data
inline rather than via intermediate variables.
(testChainData): Use bounded array of pointers instead of
unlimited array of struct.
(testStorageChain): Reflect struct change.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-04-04 10:26:59 +08:00
|
|
|
struct testChainData data;
|
2014-06-13 23:23:10 +08:00
|
|
|
struct testLookupData data2;
|
2014-05-03 01:22:17 +08:00
|
|
|
struct testPathCanonicalizeData data3;
|
2014-05-13 16:10:56 +08:00
|
|
|
struct testPathRelativeBacking data4;
|
2016-07-12 23:04:16 +08:00
|
|
|
struct testBackingParseData data5;
|
2014-06-13 22:44:09 +08:00
|
|
|
virStorageSourcePtr chain2; /* short for chain->backingStore */
|
|
|
|
virStorageSourcePtr chain3; /* short for chain2->backingStore */
|
2019-10-15 20:47:50 +08:00
|
|
|
g_autoptr(virCommand) cmd = NULL;
|
2019-10-15 20:47:50 +08:00
|
|
|
g_autoptr(virStorageSource) chain = NULL;
|
2013-02-14 02:04:05 +08:00
|
|
|
|
2017-05-11 22:50:04 +08:00
|
|
|
if (storageRegisterAll() < 0)
|
|
|
|
return EXIT_FAILURE;
|
2017-01-13 23:50:11 +08:00
|
|
|
|
2013-02-14 02:04:05 +08:00
|
|
|
/* Prep some files with qemu-img; if that is not found on PATH, or
|
|
|
|
* if it lacks support for qcow2 and qed, skip this test. */
|
|
|
|
if ((ret = testPrepImages()) != 0)
|
|
|
|
return ret;
|
|
|
|
|
2017-11-03 20:09:47 +08:00
|
|
|
#define TEST_ONE_CHAIN(start, format, flags, ...) \
|
|
|
|
do { \
|
|
|
|
size_t i; \
|
|
|
|
memset(&data, 0, sizeof(data)); \
|
|
|
|
data = (struct testChainData){ \
|
|
|
|
start, format, { __VA_ARGS__ }, 0, flags, \
|
|
|
|
}; \
|
2019-10-15 19:55:26 +08:00
|
|
|
for (i = 0; i < G_N_ELEMENTS(data.files); i++) \
|
2017-11-03 20:09:47 +08:00
|
|
|
if (data.files[i]) \
|
|
|
|
data.nfiles++; \
|
|
|
|
if (virTestRun(virTestCounterNext(), \
|
|
|
|
testStorageChain, &data) < 0) \
|
|
|
|
ret = -1; \
|
2013-02-14 02:04:05 +08:00
|
|
|
} while (0)
|
|
|
|
|
tests: refactor virstoragetest for less stack space
I'm about to add fields to virStorageFileMetadata, which means
also adding fields to the testFileData struct in virstoragetest.
Alas, adding even one pointer on an x86_64 machine gave me a
dreaded compiler error:
virstoragetest.c:712:1: error: the frame size of 4208 bytes is larger than 4096 bytes [-Werror=frame-larger-than=]
After some experimentation, I realized that each test was creating
yet another testChainData (which contains testFileData) on the stack;
forcing the reuse of one of these structures instead of creating a
fresh one each time drastically reduces the size requirements. While
at it, I also got rid of a lot of intermediate structs, with some
macro magic that lets me directly build up the destination chains
inline.
For a bit more insight into what this patch does:
The old code uses an intermediate variable as a fixed-size array
of structs:
testFileData chain[] = { a, b };
data.files = chain;
In the new code, the use of VIR_FLATTEN_* allows the TEST_CHAIN()
macro to still take a single argument for each chain, but now of
the form '(a, b)', where it is turned into the var-args 'a, b'
multiple arguments understood by TEST_ONE_CHAIN(). Thus, the
new code avoids an intermediate variable, and directly provides
the list of pointers to be assigned into array elements:
data.files = { &a, &b };
* tests/virstoragetest.c (mymain): Rewrite TEST_ONE_CHAIN to
reuse the same struct for each test, and to take the data
inline rather than via intermediate variables.
(testChainData): Use bounded array of pointers instead of
unlimited array of struct.
(testStorageChain): Reflect struct change.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-04-04 10:26:59 +08:00
|
|
|
#define VIR_FLATTEN_2(...) __VA_ARGS__
|
|
|
|
#define VIR_FLATTEN_1(_1) VIR_FLATTEN_2 _1
|
|
|
|
|
2018-06-04 16:16:03 +08:00
|
|
|
#define TEST_CHAIN(path, format, chain, flags) \
|
|
|
|
TEST_ONE_CHAIN(path, format, flags, VIR_FLATTEN_1(chain));
|
2013-02-14 02:04:05 +08:00
|
|
|
|
|
|
|
/* The actual tests, in several groups. */
|
2016-05-26 23:01:57 +08:00
|
|
|
virTestCounterReset("Storage backing chain ");
|
2013-02-14 02:04:05 +08:00
|
|
|
|
|
|
|
/* Missing file */
|
2015-02-04 00:54:04 +08:00
|
|
|
TEST_ONE_CHAIN("bogus", VIR_STORAGE_FILE_RAW, EXP_FAIL);
|
2013-02-14 02:04:05 +08:00
|
|
|
|
2020-08-03 23:32:22 +08:00
|
|
|
VIR_WARNINGS_NO_DECLARATION_AFTER_STATEMENT
|
2013-02-14 02:04:05 +08:00
|
|
|
/* Raw image, whether with right format or no specified format */
|
2014-04-06 01:34:32 +08:00
|
|
|
testFileData raw = {
|
2019-03-13 00:21:37 +08:00
|
|
|
.path = absraw,
|
2014-04-09 12:28:35 +08:00
|
|
|
.type = VIR_STORAGE_TYPE_FILE,
|
|
|
|
.format = VIR_STORAGE_FILE_RAW,
|
2014-04-06 01:34:32 +08:00
|
|
|
};
|
2018-06-04 16:16:03 +08:00
|
|
|
TEST_CHAIN(absraw, VIR_STORAGE_FILE_RAW, (&raw), EXP_PASS);
|
|
|
|
TEST_CHAIN(absraw, VIR_STORAGE_FILE_AUTO, (&raw), EXP_PASS);
|
2013-02-14 02:04:05 +08:00
|
|
|
|
|
|
|
/* Qcow2 file with relative raw backing, format provided */
|
2014-05-27 16:05:57 +08:00
|
|
|
raw.pathRel = "raw";
|
2014-04-06 02:00:48 +08:00
|
|
|
testFileData qcow2 = {
|
2014-04-06 01:34:32 +08:00
|
|
|
.expBackingStoreRaw = "raw",
|
|
|
|
.expCapacity = 1024,
|
2019-03-13 00:21:37 +08:00
|
|
|
.path = absqcow2,
|
2014-04-09 12:28:35 +08:00
|
|
|
.type = VIR_STORAGE_TYPE_FILE,
|
|
|
|
.format = VIR_STORAGE_FILE_QCOW2,
|
2014-04-04 12:03:04 +08:00
|
|
|
};
|
|
|
|
testFileData qcow2_as_raw = {
|
2019-03-13 00:21:37 +08:00
|
|
|
.path = absqcow2,
|
2014-04-09 12:28:35 +08:00
|
|
|
.type = VIR_STORAGE_TYPE_FILE,
|
|
|
|
.format = VIR_STORAGE_FILE_RAW,
|
2014-04-06 01:34:32 +08:00
|
|
|
};
|
2018-06-04 16:16:03 +08:00
|
|
|
TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2, &raw), EXP_PASS);
|
|
|
|
TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_AUTO, (&qcow2_as_raw), EXP_PASS);
|
2013-02-14 02:04:05 +08:00
|
|
|
|
|
|
|
/* Rewrite qcow2 file to use absolute backing name */
|
|
|
|
virCommandFree(cmd);
|
|
|
|
cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
|
|
|
|
"-F", "raw", "-b", absraw, "qcow2", NULL);
|
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
|
|
|
ret = -1;
|
2014-04-06 02:00:48 +08:00
|
|
|
qcow2.expBackingStoreRaw = absraw;
|
2014-05-27 16:05:57 +08:00
|
|
|
raw.pathRel = NULL;
|
2013-02-14 02:04:05 +08:00
|
|
|
|
|
|
|
/* Qcow2 file with raw as absolute backing, backing format provided */
|
2018-06-04 16:16:03 +08:00
|
|
|
TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2, &raw), EXP_PASS);
|
|
|
|
TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_AUTO, (&qcow2_as_raw), EXP_PASS);
|
2013-02-14 02:04:05 +08:00
|
|
|
|
|
|
|
/* Wrapped file access */
|
2014-04-06 01:34:32 +08:00
|
|
|
testFileData wrap = {
|
|
|
|
.expBackingStoreRaw = absqcow2,
|
|
|
|
.expCapacity = 1024,
|
2019-03-13 00:21:37 +08:00
|
|
|
.path = abswrap,
|
2014-04-09 12:28:35 +08:00
|
|
|
.type = VIR_STORAGE_TYPE_FILE,
|
|
|
|
.format = VIR_STORAGE_FILE_QCOW2,
|
2014-04-06 01:34:32 +08:00
|
|
|
};
|
2018-06-04 16:16:03 +08:00
|
|
|
TEST_CHAIN(abswrap, VIR_STORAGE_FILE_QCOW2, (&wrap, &qcow2, &raw), EXP_PASS);
|
2013-02-14 02:04:05 +08:00
|
|
|
|
|
|
|
/* Rewrite qcow2 and wrap file to omit backing file type */
|
|
|
|
virCommandFree(cmd);
|
|
|
|
cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
|
|
|
|
"-b", absraw, "qcow2", NULL);
|
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
|
|
|
ret = -1;
|
|
|
|
|
|
|
|
virCommandFree(cmd);
|
|
|
|
cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
|
|
|
|
"-b", absqcow2, "wrap", NULL);
|
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
|
|
|
ret = -1;
|
|
|
|
|
|
|
|
/* Qcow2 file with raw as absolute backing, backing format omitted */
|
2014-04-06 01:34:32 +08:00
|
|
|
testFileData wrap_as_raw = {
|
|
|
|
.expBackingStoreRaw = absqcow2,
|
|
|
|
.expCapacity = 1024,
|
2019-03-13 00:21:37 +08:00
|
|
|
.path = abswrap,
|
2014-04-09 12:28:35 +08:00
|
|
|
.type = VIR_STORAGE_TYPE_FILE,
|
|
|
|
.format = VIR_STORAGE_FILE_QCOW2,
|
2014-04-06 01:34:32 +08:00
|
|
|
};
|
2015-02-04 00:54:04 +08:00
|
|
|
TEST_CHAIN(abswrap, VIR_STORAGE_FILE_QCOW2,
|
2019-12-18 00:04:04 +08:00
|
|
|
(&wrap_as_raw, &qcow2_as_raw), EXP_FAIL);
|
2013-02-14 02:04:05 +08:00
|
|
|
|
|
|
|
/* Rewrite qcow2 to a missing backing file, with backing type */
|
|
|
|
virCommandFree(cmd);
|
|
|
|
cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
|
|
|
|
"-F", "qcow2", "-b", datadir "/bogus",
|
|
|
|
"qcow2", NULL);
|
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
|
|
|
ret = -1;
|
2014-04-06 02:00:48 +08:00
|
|
|
qcow2.expBackingStoreRaw = datadir "/bogus";
|
2013-02-14 02:04:05 +08:00
|
|
|
|
|
|
|
/* Qcow2 file with missing backing file but specified type */
|
2019-12-18 00:46:18 +08:00
|
|
|
TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2), EXP_FAIL);
|
2013-02-14 02:04:05 +08:00
|
|
|
|
|
|
|
/* Rewrite qcow2 to a missing backing file, without backing type */
|
|
|
|
virCommandFree(cmd);
|
|
|
|
cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
|
|
|
|
"-b", datadir "/bogus", "qcow2", NULL);
|
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
|
|
|
ret = -1;
|
|
|
|
|
|
|
|
/* Qcow2 file with missing backing file and no specified type */
|
2019-12-18 00:46:18 +08:00
|
|
|
TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2), EXP_FAIL);
|
2013-02-14 02:04:05 +08:00
|
|
|
|
|
|
|
/* Rewrite qcow2 to use an nbd: protocol as backend */
|
|
|
|
virCommandFree(cmd);
|
|
|
|
cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
|
2014-05-06 00:05:03 +08:00
|
|
|
"-F", "raw", "-b", "nbd:example.org:6000:exportname=blah",
|
2013-02-14 02:04:05 +08:00
|
|
|
"qcow2", NULL);
|
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
|
|
|
ret = -1;
|
2014-05-06 00:05:03 +08:00
|
|
|
qcow2.expBackingStoreRaw = "nbd:example.org:6000:exportname=blah";
|
2013-02-14 02:04:05 +08:00
|
|
|
|
|
|
|
/* Qcow2 file with backing protocol instead of file */
|
2014-04-10 05:36:30 +08:00
|
|
|
testFileData nbd = {
|
2014-05-06 00:05:03 +08:00
|
|
|
.path = "blah",
|
2014-04-10 05:36:30 +08:00
|
|
|
.type = VIR_STORAGE_TYPE_NETWORK,
|
|
|
|
.format = VIR_STORAGE_FILE_RAW,
|
2014-11-04 21:26:45 +08:00
|
|
|
.protocol = VIR_STORAGE_NET_PROTOCOL_NBD,
|
|
|
|
.hostname = "example.org",
|
2014-04-10 05:36:30 +08:00
|
|
|
};
|
2018-06-04 16:16:03 +08:00
|
|
|
TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2, &nbd), EXP_PASS);
|
2013-02-14 02:04:05 +08:00
|
|
|
|
2014-10-29 17:55:23 +08:00
|
|
|
/* Rewrite qcow2 to use an nbd: protocol as backend */
|
|
|
|
virCommandFree(cmd);
|
|
|
|
cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
|
|
|
|
"-F", "raw", "-b", "nbd+tcp://example.org:6000/blah",
|
|
|
|
"qcow2", NULL);
|
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
|
|
|
ret = -1;
|
|
|
|
qcow2.expBackingStoreRaw = "nbd+tcp://example.org:6000/blah";
|
|
|
|
|
|
|
|
/* Qcow2 file with backing protocol instead of file */
|
|
|
|
testFileData nbd2 = {
|
|
|
|
.path = "blah",
|
|
|
|
.type = VIR_STORAGE_TYPE_NETWORK,
|
|
|
|
.format = VIR_STORAGE_FILE_RAW,
|
2014-11-04 21:26:45 +08:00
|
|
|
.protocol = VIR_STORAGE_NET_PROTOCOL_NBD,
|
|
|
|
.hostname = "example.org",
|
2014-10-29 17:55:23 +08:00
|
|
|
};
|
2018-06-04 16:16:03 +08:00
|
|
|
TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2, &nbd2), EXP_PASS);
|
2014-10-29 17:55:23 +08:00
|
|
|
|
2015-02-04 01:03:41 +08:00
|
|
|
/* Rewrite qcow2 to use an nbd: protocol without path as backend */
|
|
|
|
virCommandFree(cmd);
|
|
|
|
cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
|
|
|
|
"-F", "raw", "-b", "nbd://example.org",
|
|
|
|
"qcow2", NULL);
|
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
|
|
|
ret = -1;
|
|
|
|
qcow2.expBackingStoreRaw = "nbd://example.org";
|
|
|
|
|
|
|
|
nbd2.path = NULL;
|
2018-06-04 16:16:03 +08:00
|
|
|
TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2, &nbd2), EXP_PASS);
|
2015-02-04 01:03:41 +08:00
|
|
|
|
2013-02-14 02:04:05 +08:00
|
|
|
/* qed file */
|
2014-04-06 01:34:32 +08:00
|
|
|
testFileData qed = {
|
|
|
|
.expBackingStoreRaw = absraw,
|
|
|
|
.expCapacity = 1024,
|
2019-03-13 00:21:37 +08:00
|
|
|
.path = absqed,
|
2014-04-09 12:28:35 +08:00
|
|
|
.type = VIR_STORAGE_TYPE_FILE,
|
|
|
|
.format = VIR_STORAGE_FILE_QED,
|
2014-04-04 12:03:04 +08:00
|
|
|
};
|
|
|
|
testFileData qed_as_raw = {
|
2019-03-13 00:21:37 +08:00
|
|
|
.path = absqed,
|
2014-04-09 12:28:35 +08:00
|
|
|
.type = VIR_STORAGE_TYPE_FILE,
|
|
|
|
.format = VIR_STORAGE_FILE_RAW,
|
2014-04-06 01:34:32 +08:00
|
|
|
};
|
2018-06-04 16:16:03 +08:00
|
|
|
TEST_CHAIN(absqed, VIR_STORAGE_FILE_QED, (&qed, &raw), EXP_PASS);
|
|
|
|
TEST_CHAIN(absqed, VIR_STORAGE_FILE_AUTO, (&qed_as_raw), EXP_PASS);
|
2013-02-14 02:04:05 +08:00
|
|
|
|
2014-04-05 03:35:22 +08:00
|
|
|
/* directory */
|
2014-04-06 01:34:32 +08:00
|
|
|
testFileData dir = {
|
2019-03-13 00:21:37 +08:00
|
|
|
.path = absdir,
|
2014-04-09 12:28:35 +08:00
|
|
|
.type = VIR_STORAGE_TYPE_DIR,
|
|
|
|
.format = VIR_STORAGE_FILE_DIR,
|
2014-04-06 01:34:32 +08:00
|
|
|
};
|
2017-08-25 20:45:56 +08:00
|
|
|
testFileData dir_as_raw = {
|
2019-03-13 00:21:37 +08:00
|
|
|
.path = absdir,
|
2017-08-25 20:45:56 +08:00
|
|
|
.type = VIR_STORAGE_TYPE_DIR,
|
|
|
|
.format = VIR_STORAGE_FILE_RAW,
|
|
|
|
};
|
2018-06-04 16:16:03 +08:00
|
|
|
TEST_CHAIN(absdir, VIR_STORAGE_FILE_RAW, (&dir_as_raw), EXP_PASS);
|
|
|
|
TEST_CHAIN(absdir, VIR_STORAGE_FILE_NONE, (&dir), EXP_PASS);
|
|
|
|
TEST_CHAIN(absdir, VIR_STORAGE_FILE_DIR, (&dir), EXP_PASS);
|
2014-04-05 03:35:22 +08:00
|
|
|
|
2020-09-01 19:27:44 +08:00
|
|
|
#ifdef WITH_SYMLINK
|
2013-02-14 02:04:05 +08:00
|
|
|
/* Rewrite qcow2 and wrap file to use backing names relative to a
|
|
|
|
* symlink from a different directory */
|
|
|
|
virCommandFree(cmd);
|
|
|
|
cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
|
|
|
|
"-F", "raw", "-b", "../raw", "qcow2", NULL);
|
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
|
|
|
ret = -1;
|
|
|
|
|
|
|
|
virCommandFree(cmd);
|
|
|
|
cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
|
|
|
|
"-F", "qcow2", "-b", "../sub/link1", "wrap",
|
|
|
|
NULL);
|
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
|
|
|
ret = -1;
|
|
|
|
|
|
|
|
/* Behavior of symlinks to qcow2 with relative backing files */
|
2014-04-06 02:00:48 +08:00
|
|
|
testFileData link1 = {
|
2014-04-06 01:34:32 +08:00
|
|
|
.expBackingStoreRaw = "../raw",
|
|
|
|
.expCapacity = 1024,
|
2014-04-04 12:03:04 +08:00
|
|
|
.pathRel = "../sub/link1",
|
2014-05-27 20:49:41 +08:00
|
|
|
.path = datadir "/sub/../sub/link1",
|
2014-04-09 12:28:35 +08:00
|
|
|
.type = VIR_STORAGE_TYPE_FILE,
|
|
|
|
.format = VIR_STORAGE_FILE_QCOW2,
|
2014-04-06 01:34:32 +08:00
|
|
|
};
|
2014-04-06 02:00:48 +08:00
|
|
|
testFileData link2 = {
|
2014-04-06 01:34:32 +08:00
|
|
|
.expBackingStoreRaw = "../sub/link1",
|
|
|
|
.expCapacity = 1024,
|
2014-05-27 20:49:41 +08:00
|
|
|
.path = abslink2,
|
2014-04-09 12:28:35 +08:00
|
|
|
.type = VIR_STORAGE_TYPE_FILE,
|
|
|
|
.format = VIR_STORAGE_FILE_QCOW2,
|
2014-04-06 01:34:32 +08:00
|
|
|
};
|
2014-05-27 20:49:41 +08:00
|
|
|
|
|
|
|
raw.path = datadir "/sub/../sub/../raw";
|
2014-04-04 12:03:04 +08:00
|
|
|
raw.pathRel = "../raw";
|
2015-02-04 00:54:04 +08:00
|
|
|
TEST_CHAIN(abslink2, VIR_STORAGE_FILE_QCOW2,
|
2018-06-04 15:50:13 +08:00
|
|
|
(&link2, &link1, &raw), EXP_PASS);
|
2013-04-16 00:00:17 +08:00
|
|
|
#endif
|
2014-04-05 03:35:22 +08:00
|
|
|
|
|
|
|
/* Rewrite qcow2 to be a self-referential loop */
|
|
|
|
virCommandFree(cmd);
|
|
|
|
cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
|
|
|
|
"-F", "qcow2", "-b", "qcow2", "qcow2", NULL);
|
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
|
|
|
ret = -1;
|
2014-04-06 02:00:48 +08:00
|
|
|
qcow2.expBackingStoreRaw = "qcow2";
|
2014-04-05 03:35:22 +08:00
|
|
|
|
|
|
|
/* Behavior of an infinite loop chain */
|
2019-12-18 00:46:18 +08:00
|
|
|
TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2), EXP_FAIL);
|
2014-04-05 03:35:22 +08:00
|
|
|
|
|
|
|
/* Rewrite wrap and qcow2 to be mutually-referential loop */
|
|
|
|
virCommandFree(cmd);
|
|
|
|
cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
|
|
|
|
"-F", "qcow2", "-b", "wrap", "qcow2", NULL);
|
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
|
|
|
ret = -1;
|
|
|
|
|
|
|
|
virCommandFree(cmd);
|
|
|
|
cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
|
|
|
|
"-F", "qcow2", "-b", absqcow2, "wrap", NULL);
|
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
|
|
|
ret = -1;
|
2014-04-06 02:00:48 +08:00
|
|
|
qcow2.expBackingStoreRaw = "wrap";
|
2014-04-05 03:35:22 +08:00
|
|
|
|
|
|
|
/* Behavior of an infinite loop chain */
|
2019-12-18 00:46:18 +08:00
|
|
|
TEST_CHAIN(abswrap, VIR_STORAGE_FILE_QCOW2, (&wrap, &qcow2), EXP_FAIL);
|
2014-04-05 03:35:22 +08:00
|
|
|
|
2014-11-05 00:35:16 +08:00
|
|
|
/* Rewrite qcow2 to use an rbd: protocol as backend */
|
|
|
|
virCommandFree(cmd);
|
|
|
|
cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
|
|
|
|
"-F", "raw", "-b", "rbd:testshare",
|
|
|
|
"qcow2", NULL);
|
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
|
|
|
ret = -1;
|
|
|
|
qcow2.expBackingStoreRaw = "rbd:testshare";
|
|
|
|
|
|
|
|
/* Qcow2 file with backing protocol instead of file */
|
|
|
|
testFileData rbd1 = {
|
|
|
|
.path = "testshare",
|
|
|
|
.type = VIR_STORAGE_TYPE_NETWORK,
|
|
|
|
.format = VIR_STORAGE_FILE_RAW,
|
|
|
|
.protocol = VIR_STORAGE_NET_PROTOCOL_RBD,
|
|
|
|
};
|
2018-06-04 16:16:03 +08:00
|
|
|
TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2, &rbd1), EXP_PASS);
|
2014-11-05 00:35:16 +08:00
|
|
|
|
|
|
|
/* Rewrite qcow2 to use an rbd: protocol as backend */
|
|
|
|
virCommandFree(cmd);
|
|
|
|
cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
|
|
|
|
"-F", "raw", "-b", "rbd:testshare:id=asdf:mon_host=example.com",
|
|
|
|
"qcow2", NULL);
|
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
|
|
|
ret = -1;
|
|
|
|
qcow2.expBackingStoreRaw = "rbd:testshare:id=asdf:mon_host=example.com";
|
|
|
|
|
|
|
|
/* Qcow2 file with backing protocol instead of file */
|
|
|
|
testFileData rbd2 = {
|
|
|
|
.path = "testshare",
|
|
|
|
.type = VIR_STORAGE_TYPE_NETWORK,
|
|
|
|
.format = VIR_STORAGE_FILE_RAW,
|
|
|
|
.protocol = VIR_STORAGE_NET_PROTOCOL_RBD,
|
|
|
|
.secret = "asdf",
|
|
|
|
.hostname = "example.com",
|
|
|
|
};
|
2018-06-04 16:16:03 +08:00
|
|
|
TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2, &rbd2), EXP_PASS);
|
2014-11-05 00:35:16 +08:00
|
|
|
|
2020-08-03 23:32:22 +08:00
|
|
|
VIR_WARNINGS_RESET
|
2014-11-05 00:35:16 +08:00
|
|
|
|
2014-04-11 03:56:57 +08:00
|
|
|
/* Rewrite wrap and qcow2 back to 3-deep chain, absolute backing */
|
|
|
|
virCommandFree(cmd);
|
|
|
|
cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
|
2020-02-21 19:06:49 +08:00
|
|
|
"-F", "raw", "-b", absraw, "qcow2", NULL);
|
2014-04-11 03:56:57 +08:00
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
|
|
|
ret = -1;
|
|
|
|
|
2014-04-12 12:08:07 +08:00
|
|
|
/* Test behavior of chain lookups, absolute backing from relative start */
|
2014-04-18 20:49:54 +08:00
|
|
|
chain = testStorageFileGetMetadata("wrap", VIR_STORAGE_FILE_QCOW2,
|
2018-06-04 15:39:28 +08:00
|
|
|
-1, -1);
|
2014-04-11 03:56:57 +08:00
|
|
|
if (!chain) {
|
|
|
|
ret = -1;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2014-06-13 22:44:09 +08:00
|
|
|
chain2 = chain->backingStore;
|
|
|
|
chain3 = chain2->backingStore;
|
2014-04-11 03:56:57 +08:00
|
|
|
|
2017-11-03 20:09:47 +08:00
|
|
|
#define TEST_LOOKUP_TARGET(id, target, from, name, index, result, \
|
|
|
|
meta, parent) \
|
|
|
|
do { \
|
|
|
|
data2 = (struct testLookupData){ \
|
|
|
|
chain, target, from, name, index, \
|
|
|
|
result, meta, parent, }; \
|
|
|
|
if (virTestRun("Chain lookup " #id, \
|
|
|
|
testStorageLookup, &data2) < 0) \
|
|
|
|
ret = -1; \
|
2014-04-11 03:56:57 +08:00
|
|
|
} while (0)
|
2017-11-03 20:09:47 +08:00
|
|
|
#define TEST_LOOKUP(id, from, name, result, meta, parent) \
|
2014-06-14 00:01:14 +08:00
|
|
|
TEST_LOOKUP_TARGET(id, NULL, from, name, 0, result, meta, parent)
|
|
|
|
|
|
|
|
TEST_LOOKUP(0, NULL, "bogus", NULL, NULL, NULL);
|
2014-06-13 23:23:10 +08:00
|
|
|
TEST_LOOKUP(1, chain, "bogus", NULL, NULL, NULL);
|
2014-06-14 00:01:14 +08:00
|
|
|
TEST_LOOKUP(2, NULL, "wrap", chain->path, chain, NULL);
|
blockcommit: require base below top
The block commit code looks for an explicit base file relative
to the discovered top file; so for a chain of:
base <- snap1 <- snap2 <- snap3
and a command of:
virsh blockcommit $dom vda --base snap2 --top snap1
we got a sane message (here from libvirt 1.0.5):
error: invalid argument: could not find base 'snap2' below 'snap1' in chain for 'vda'
Meanwhile, recent refactoring has slightly reduced the quality of the
libvirt error messages, by losing the phrase 'below xyz':
error: invalid argument: could not find image 'snap2' in chain for 'snap3'
But we had a one-off, where we were not excluding the top file
itself in searching for the base; thankfully qemu still reports
the error, but the quality is worse:
virsh blockcommit $dom vda --base snap2 --top snap2
error: internal error unable to execute QEMU command 'block-commit': Base '/snap2' not found
Fix the one-off in blockcommit by changing the semantics of name
lookup - if a starting point is specified, then the result must
be below that point, rather than including that point. The only
other call to chain lookup was blockpull code, which was already
forcing the lookup to omit the active layer and only needs a
tweak to use the new semantics.
This also fixes the bug exposed in the testsuite, where when doing
a lookup pinned to an intermediate point in the chain, we were
unable to return the name of the parent also in the chain.
* src/util/virstoragefile.c (virStorageFileChainLookup): Change
semantics for non-NULL startFrom.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Adjust caller,
to keep existing semantics.
* tests/virstoragetest.c (mymain): Adjust to expose new semantics.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-06-12 06:22:57 +08:00
|
|
|
TEST_LOOKUP(3, chain, "wrap", NULL, NULL, NULL);
|
2014-06-13 23:23:10 +08:00
|
|
|
TEST_LOOKUP(4, chain2, "wrap", NULL, NULL, NULL);
|
2014-06-14 00:01:14 +08:00
|
|
|
TEST_LOOKUP(5, NULL, abswrap, chain->path, chain, NULL);
|
blockcommit: require base below top
The block commit code looks for an explicit base file relative
to the discovered top file; so for a chain of:
base <- snap1 <- snap2 <- snap3
and a command of:
virsh blockcommit $dom vda --base snap2 --top snap1
we got a sane message (here from libvirt 1.0.5):
error: invalid argument: could not find base 'snap2' below 'snap1' in chain for 'vda'
Meanwhile, recent refactoring has slightly reduced the quality of the
libvirt error messages, by losing the phrase 'below xyz':
error: invalid argument: could not find image 'snap2' in chain for 'snap3'
But we had a one-off, where we were not excluding the top file
itself in searching for the base; thankfully qemu still reports
the error, but the quality is worse:
virsh blockcommit $dom vda --base snap2 --top snap2
error: internal error unable to execute QEMU command 'block-commit': Base '/snap2' not found
Fix the one-off in blockcommit by changing the semantics of name
lookup - if a starting point is specified, then the result must
be below that point, rather than including that point. The only
other call to chain lookup was blockpull code, which was already
forcing the lookup to omit the active layer and only needs a
tweak to use the new semantics.
This also fixes the bug exposed in the testsuite, where when doing
a lookup pinned to an intermediate point in the chain, we were
unable to return the name of the parent also in the chain.
* src/util/virstoragefile.c (virStorageFileChainLookup): Change
semantics for non-NULL startFrom.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Adjust caller,
to keep existing semantics.
* tests/virstoragetest.c (mymain): Adjust to expose new semantics.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-06-12 06:22:57 +08:00
|
|
|
TEST_LOOKUP(6, chain, abswrap, NULL, NULL, NULL);
|
2014-06-13 23:23:10 +08:00
|
|
|
TEST_LOOKUP(7, chain2, abswrap, NULL, NULL, NULL);
|
2014-06-25 21:43:04 +08:00
|
|
|
TEST_LOOKUP(8, NULL, "qcow2", chain2->path, chain2, chain);
|
|
|
|
TEST_LOOKUP(9, chain, "qcow2", chain2->path, chain2, chain);
|
blockcommit: require base below top
The block commit code looks for an explicit base file relative
to the discovered top file; so for a chain of:
base <- snap1 <- snap2 <- snap3
and a command of:
virsh blockcommit $dom vda --base snap2 --top snap1
we got a sane message (here from libvirt 1.0.5):
error: invalid argument: could not find base 'snap2' below 'snap1' in chain for 'vda'
Meanwhile, recent refactoring has slightly reduced the quality of the
libvirt error messages, by losing the phrase 'below xyz':
error: invalid argument: could not find image 'snap2' in chain for 'snap3'
But we had a one-off, where we were not excluding the top file
itself in searching for the base; thankfully qemu still reports
the error, but the quality is worse:
virsh blockcommit $dom vda --base snap2 --top snap2
error: internal error unable to execute QEMU command 'block-commit': Base '/snap2' not found
Fix the one-off in blockcommit by changing the semantics of name
lookup - if a starting point is specified, then the result must
be below that point, rather than including that point. The only
other call to chain lookup was blockpull code, which was already
forcing the lookup to omit the active layer and only needs a
tweak to use the new semantics.
This also fixes the bug exposed in the testsuite, where when doing
a lookup pinned to an intermediate point in the chain, we were
unable to return the name of the parent also in the chain.
* src/util/virstoragefile.c (virStorageFileChainLookup): Change
semantics for non-NULL startFrom.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Adjust caller,
to keep existing semantics.
* tests/virstoragetest.c (mymain): Adjust to expose new semantics.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-06-12 06:22:57 +08:00
|
|
|
TEST_LOOKUP(10, chain2, "qcow2", NULL, NULL, NULL);
|
2014-06-13 23:23:10 +08:00
|
|
|
TEST_LOOKUP(11, chain3, "qcow2", NULL, NULL, NULL);
|
2014-06-25 21:43:04 +08:00
|
|
|
TEST_LOOKUP(12, NULL, absqcow2, chain2->path, chain2, chain);
|
|
|
|
TEST_LOOKUP(13, chain, absqcow2, chain2->path, chain2, chain);
|
blockcommit: require base below top
The block commit code looks for an explicit base file relative
to the discovered top file; so for a chain of:
base <- snap1 <- snap2 <- snap3
and a command of:
virsh blockcommit $dom vda --base snap2 --top snap1
we got a sane message (here from libvirt 1.0.5):
error: invalid argument: could not find base 'snap2' below 'snap1' in chain for 'vda'
Meanwhile, recent refactoring has slightly reduced the quality of the
libvirt error messages, by losing the phrase 'below xyz':
error: invalid argument: could not find image 'snap2' in chain for 'snap3'
But we had a one-off, where we were not excluding the top file
itself in searching for the base; thankfully qemu still reports
the error, but the quality is worse:
virsh blockcommit $dom vda --base snap2 --top snap2
error: internal error unable to execute QEMU command 'block-commit': Base '/snap2' not found
Fix the one-off in blockcommit by changing the semantics of name
lookup - if a starting point is specified, then the result must
be below that point, rather than including that point. The only
other call to chain lookup was blockpull code, which was already
forcing the lookup to omit the active layer and only needs a
tweak to use the new semantics.
This also fixes the bug exposed in the testsuite, where when doing
a lookup pinned to an intermediate point in the chain, we were
unable to return the name of the parent also in the chain.
* src/util/virstoragefile.c (virStorageFileChainLookup): Change
semantics for non-NULL startFrom.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Adjust caller,
to keep existing semantics.
* tests/virstoragetest.c (mymain): Adjust to expose new semantics.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-06-12 06:22:57 +08:00
|
|
|
TEST_LOOKUP(14, chain2, absqcow2, NULL, NULL, NULL);
|
2014-06-13 23:23:10 +08:00
|
|
|
TEST_LOOKUP(15, chain3, absqcow2, NULL, NULL, NULL);
|
2014-06-25 21:43:04 +08:00
|
|
|
TEST_LOOKUP(16, NULL, "raw", chain3->path, chain3, chain2);
|
|
|
|
TEST_LOOKUP(17, chain, "raw", chain3->path, chain3, chain2);
|
|
|
|
TEST_LOOKUP(18, chain2, "raw", chain3->path, chain3, chain2);
|
blockcommit: require base below top
The block commit code looks for an explicit base file relative
to the discovered top file; so for a chain of:
base <- snap1 <- snap2 <- snap3
and a command of:
virsh blockcommit $dom vda --base snap2 --top snap1
we got a sane message (here from libvirt 1.0.5):
error: invalid argument: could not find base 'snap2' below 'snap1' in chain for 'vda'
Meanwhile, recent refactoring has slightly reduced the quality of the
libvirt error messages, by losing the phrase 'below xyz':
error: invalid argument: could not find image 'snap2' in chain for 'snap3'
But we had a one-off, where we were not excluding the top file
itself in searching for the base; thankfully qemu still reports
the error, but the quality is worse:
virsh blockcommit $dom vda --base snap2 --top snap2
error: internal error unable to execute QEMU command 'block-commit': Base '/snap2' not found
Fix the one-off in blockcommit by changing the semantics of name
lookup - if a starting point is specified, then the result must
be below that point, rather than including that point. The only
other call to chain lookup was blockpull code, which was already
forcing the lookup to omit the active layer and only needs a
tweak to use the new semantics.
This also fixes the bug exposed in the testsuite, where when doing
a lookup pinned to an intermediate point in the chain, we were
unable to return the name of the parent also in the chain.
* src/util/virstoragefile.c (virStorageFileChainLookup): Change
semantics for non-NULL startFrom.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Adjust caller,
to keep existing semantics.
* tests/virstoragetest.c (mymain): Adjust to expose new semantics.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-06-12 06:22:57 +08:00
|
|
|
TEST_LOOKUP(19, chain3, "raw", NULL, NULL, NULL);
|
2014-06-25 21:43:04 +08:00
|
|
|
TEST_LOOKUP(20, NULL, absraw, chain3->path, chain3, chain2);
|
|
|
|
TEST_LOOKUP(21, chain, absraw, chain3->path, chain3, chain2);
|
|
|
|
TEST_LOOKUP(22, chain2, absraw, chain3->path, chain3, chain2);
|
blockcommit: require base below top
The block commit code looks for an explicit base file relative
to the discovered top file; so for a chain of:
base <- snap1 <- snap2 <- snap3
and a command of:
virsh blockcommit $dom vda --base snap2 --top snap1
we got a sane message (here from libvirt 1.0.5):
error: invalid argument: could not find base 'snap2' below 'snap1' in chain for 'vda'
Meanwhile, recent refactoring has slightly reduced the quality of the
libvirt error messages, by losing the phrase 'below xyz':
error: invalid argument: could not find image 'snap2' in chain for 'snap3'
But we had a one-off, where we were not excluding the top file
itself in searching for the base; thankfully qemu still reports
the error, but the quality is worse:
virsh blockcommit $dom vda --base snap2 --top snap2
error: internal error unable to execute QEMU command 'block-commit': Base '/snap2' not found
Fix the one-off in blockcommit by changing the semantics of name
lookup - if a starting point is specified, then the result must
be below that point, rather than including that point. The only
other call to chain lookup was blockpull code, which was already
forcing the lookup to omit the active layer and only needs a
tweak to use the new semantics.
This also fixes the bug exposed in the testsuite, where when doing
a lookup pinned to an intermediate point in the chain, we were
unable to return the name of the parent also in the chain.
* src/util/virstoragefile.c (virStorageFileChainLookup): Change
semantics for non-NULL startFrom.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Adjust caller,
to keep existing semantics.
* tests/virstoragetest.c (mymain): Adjust to expose new semantics.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-06-12 06:22:57 +08:00
|
|
|
TEST_LOOKUP(23, chain3, absraw, NULL, NULL, NULL);
|
2014-06-25 21:43:04 +08:00
|
|
|
TEST_LOOKUP(24, NULL, NULL, chain3->path, chain3, chain2);
|
|
|
|
TEST_LOOKUP(25, chain, NULL, chain3->path, chain3, chain2);
|
|
|
|
TEST_LOOKUP(26, chain2, NULL, chain3->path, chain3, chain2);
|
blockcommit: require base below top
The block commit code looks for an explicit base file relative
to the discovered top file; so for a chain of:
base <- snap1 <- snap2 <- snap3
and a command of:
virsh blockcommit $dom vda --base snap2 --top snap1
we got a sane message (here from libvirt 1.0.5):
error: invalid argument: could not find base 'snap2' below 'snap1' in chain for 'vda'
Meanwhile, recent refactoring has slightly reduced the quality of the
libvirt error messages, by losing the phrase 'below xyz':
error: invalid argument: could not find image 'snap2' in chain for 'snap3'
But we had a one-off, where we were not excluding the top file
itself in searching for the base; thankfully qemu still reports
the error, but the quality is worse:
virsh blockcommit $dom vda --base snap2 --top snap2
error: internal error unable to execute QEMU command 'block-commit': Base '/snap2' not found
Fix the one-off in blockcommit by changing the semantics of name
lookup - if a starting point is specified, then the result must
be below that point, rather than including that point. The only
other call to chain lookup was blockpull code, which was already
forcing the lookup to omit the active layer and only needs a
tweak to use the new semantics.
This also fixes the bug exposed in the testsuite, where when doing
a lookup pinned to an intermediate point in the chain, we were
unable to return the name of the parent also in the chain.
* src/util/virstoragefile.c (virStorageFileChainLookup): Change
semantics for non-NULL startFrom.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Adjust caller,
to keep existing semantics.
* tests/virstoragetest.c (mymain): Adjust to expose new semantics.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-06-12 06:22:57 +08:00
|
|
|
TEST_LOOKUP(27, chain3, NULL, NULL, NULL, NULL);
|
2014-04-11 03:56:57 +08:00
|
|
|
|
|
|
|
/* Rewrite wrap and qcow2 back to 3-deep chain, relative backing */
|
|
|
|
virCommandFree(cmd);
|
|
|
|
cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
|
|
|
|
"-F", "raw", "-b", "raw", "qcow2", NULL);
|
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
|
|
|
ret = -1;
|
|
|
|
|
|
|
|
virCommandFree(cmd);
|
|
|
|
cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
|
|
|
|
"-F", "qcow2", "-b", "qcow2", "wrap", NULL);
|
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
|
|
|
ret = -1;
|
|
|
|
|
2014-04-12 12:08:07 +08:00
|
|
|
/* Test behavior of chain lookups, relative backing from absolute start */
|
2019-02-15 20:03:58 +08:00
|
|
|
virObjectUnref(chain);
|
2018-06-04 15:39:28 +08:00
|
|
|
chain = testStorageFileGetMetadata(abswrap, VIR_STORAGE_FILE_QCOW2, -1, -1);
|
2014-04-11 03:56:57 +08:00
|
|
|
if (!chain) {
|
|
|
|
ret = -1;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2014-06-13 22:44:09 +08:00
|
|
|
chain2 = chain->backingStore;
|
|
|
|
chain3 = chain2->backingStore;
|
2014-04-11 03:56:57 +08:00
|
|
|
|
2014-06-14 00:01:14 +08:00
|
|
|
TEST_LOOKUP(28, NULL, "bogus", NULL, NULL, NULL);
|
2014-06-13 23:23:10 +08:00
|
|
|
TEST_LOOKUP(29, chain, "bogus", NULL, NULL, NULL);
|
2014-06-14 00:01:14 +08:00
|
|
|
TEST_LOOKUP(30, NULL, "wrap", chain->path, chain, NULL);
|
blockcommit: require base below top
The block commit code looks for an explicit base file relative
to the discovered top file; so for a chain of:
base <- snap1 <- snap2 <- snap3
and a command of:
virsh blockcommit $dom vda --base snap2 --top snap1
we got a sane message (here from libvirt 1.0.5):
error: invalid argument: could not find base 'snap2' below 'snap1' in chain for 'vda'
Meanwhile, recent refactoring has slightly reduced the quality of the
libvirt error messages, by losing the phrase 'below xyz':
error: invalid argument: could not find image 'snap2' in chain for 'snap3'
But we had a one-off, where we were not excluding the top file
itself in searching for the base; thankfully qemu still reports
the error, but the quality is worse:
virsh blockcommit $dom vda --base snap2 --top snap2
error: internal error unable to execute QEMU command 'block-commit': Base '/snap2' not found
Fix the one-off in blockcommit by changing the semantics of name
lookup - if a starting point is specified, then the result must
be below that point, rather than including that point. The only
other call to chain lookup was blockpull code, which was already
forcing the lookup to omit the active layer and only needs a
tweak to use the new semantics.
This also fixes the bug exposed in the testsuite, where when doing
a lookup pinned to an intermediate point in the chain, we were
unable to return the name of the parent also in the chain.
* src/util/virstoragefile.c (virStorageFileChainLookup): Change
semantics for non-NULL startFrom.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Adjust caller,
to keep existing semantics.
* tests/virstoragetest.c (mymain): Adjust to expose new semantics.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-06-12 06:22:57 +08:00
|
|
|
TEST_LOOKUP(31, chain, "wrap", NULL, NULL, NULL);
|
2014-06-13 23:23:10 +08:00
|
|
|
TEST_LOOKUP(32, chain2, "wrap", NULL, NULL, NULL);
|
2014-06-14 00:01:14 +08:00
|
|
|
TEST_LOOKUP(33, NULL, abswrap, chain->path, chain, NULL);
|
blockcommit: require base below top
The block commit code looks for an explicit base file relative
to the discovered top file; so for a chain of:
base <- snap1 <- snap2 <- snap3
and a command of:
virsh blockcommit $dom vda --base snap2 --top snap1
we got a sane message (here from libvirt 1.0.5):
error: invalid argument: could not find base 'snap2' below 'snap1' in chain for 'vda'
Meanwhile, recent refactoring has slightly reduced the quality of the
libvirt error messages, by losing the phrase 'below xyz':
error: invalid argument: could not find image 'snap2' in chain for 'snap3'
But we had a one-off, where we were not excluding the top file
itself in searching for the base; thankfully qemu still reports
the error, but the quality is worse:
virsh blockcommit $dom vda --base snap2 --top snap2
error: internal error unable to execute QEMU command 'block-commit': Base '/snap2' not found
Fix the one-off in blockcommit by changing the semantics of name
lookup - if a starting point is specified, then the result must
be below that point, rather than including that point. The only
other call to chain lookup was blockpull code, which was already
forcing the lookup to omit the active layer and only needs a
tweak to use the new semantics.
This also fixes the bug exposed in the testsuite, where when doing
a lookup pinned to an intermediate point in the chain, we were
unable to return the name of the parent also in the chain.
* src/util/virstoragefile.c (virStorageFileChainLookup): Change
semantics for non-NULL startFrom.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Adjust caller,
to keep existing semantics.
* tests/virstoragetest.c (mymain): Adjust to expose new semantics.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-06-12 06:22:57 +08:00
|
|
|
TEST_LOOKUP(34, chain, abswrap, NULL, NULL, NULL);
|
2014-06-13 23:23:10 +08:00
|
|
|
TEST_LOOKUP(35, chain2, abswrap, NULL, NULL, NULL);
|
2014-06-25 21:43:04 +08:00
|
|
|
TEST_LOOKUP(36, NULL, "qcow2", chain2->path, chain2, chain);
|
|
|
|
TEST_LOOKUP(37, chain, "qcow2", chain2->path, chain2, chain);
|
blockcommit: require base below top
The block commit code looks for an explicit base file relative
to the discovered top file; so for a chain of:
base <- snap1 <- snap2 <- snap3
and a command of:
virsh blockcommit $dom vda --base snap2 --top snap1
we got a sane message (here from libvirt 1.0.5):
error: invalid argument: could not find base 'snap2' below 'snap1' in chain for 'vda'
Meanwhile, recent refactoring has slightly reduced the quality of the
libvirt error messages, by losing the phrase 'below xyz':
error: invalid argument: could not find image 'snap2' in chain for 'snap3'
But we had a one-off, where we were not excluding the top file
itself in searching for the base; thankfully qemu still reports
the error, but the quality is worse:
virsh blockcommit $dom vda --base snap2 --top snap2
error: internal error unable to execute QEMU command 'block-commit': Base '/snap2' not found
Fix the one-off in blockcommit by changing the semantics of name
lookup - if a starting point is specified, then the result must
be below that point, rather than including that point. The only
other call to chain lookup was blockpull code, which was already
forcing the lookup to omit the active layer and only needs a
tweak to use the new semantics.
This also fixes the bug exposed in the testsuite, where when doing
a lookup pinned to an intermediate point in the chain, we were
unable to return the name of the parent also in the chain.
* src/util/virstoragefile.c (virStorageFileChainLookup): Change
semantics for non-NULL startFrom.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Adjust caller,
to keep existing semantics.
* tests/virstoragetest.c (mymain): Adjust to expose new semantics.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-06-12 06:22:57 +08:00
|
|
|
TEST_LOOKUP(38, chain2, "qcow2", NULL, NULL, NULL);
|
2014-06-13 23:23:10 +08:00
|
|
|
TEST_LOOKUP(39, chain3, "qcow2", NULL, NULL, NULL);
|
2014-06-25 21:43:04 +08:00
|
|
|
TEST_LOOKUP(40, NULL, absqcow2, chain2->path, chain2, chain);
|
|
|
|
TEST_LOOKUP(41, chain, absqcow2, chain2->path, chain2, chain);
|
blockcommit: require base below top
The block commit code looks for an explicit base file relative
to the discovered top file; so for a chain of:
base <- snap1 <- snap2 <- snap3
and a command of:
virsh blockcommit $dom vda --base snap2 --top snap1
we got a sane message (here from libvirt 1.0.5):
error: invalid argument: could not find base 'snap2' below 'snap1' in chain for 'vda'
Meanwhile, recent refactoring has slightly reduced the quality of the
libvirt error messages, by losing the phrase 'below xyz':
error: invalid argument: could not find image 'snap2' in chain for 'snap3'
But we had a one-off, where we were not excluding the top file
itself in searching for the base; thankfully qemu still reports
the error, but the quality is worse:
virsh blockcommit $dom vda --base snap2 --top snap2
error: internal error unable to execute QEMU command 'block-commit': Base '/snap2' not found
Fix the one-off in blockcommit by changing the semantics of name
lookup - if a starting point is specified, then the result must
be below that point, rather than including that point. The only
other call to chain lookup was blockpull code, which was already
forcing the lookup to omit the active layer and only needs a
tweak to use the new semantics.
This also fixes the bug exposed in the testsuite, where when doing
a lookup pinned to an intermediate point in the chain, we were
unable to return the name of the parent also in the chain.
* src/util/virstoragefile.c (virStorageFileChainLookup): Change
semantics for non-NULL startFrom.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Adjust caller,
to keep existing semantics.
* tests/virstoragetest.c (mymain): Adjust to expose new semantics.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-06-12 06:22:57 +08:00
|
|
|
TEST_LOOKUP(42, chain2, absqcow2, NULL, NULL, NULL);
|
2014-06-13 23:23:10 +08:00
|
|
|
TEST_LOOKUP(43, chain3, absqcow2, NULL, NULL, NULL);
|
2014-06-25 21:43:04 +08:00
|
|
|
TEST_LOOKUP(44, NULL, "raw", chain3->path, chain3, chain2);
|
|
|
|
TEST_LOOKUP(45, chain, "raw", chain3->path, chain3, chain2);
|
|
|
|
TEST_LOOKUP(46, chain2, "raw", chain3->path, chain3, chain2);
|
blockcommit: require base below top
The block commit code looks for an explicit base file relative
to the discovered top file; so for a chain of:
base <- snap1 <- snap2 <- snap3
and a command of:
virsh blockcommit $dom vda --base snap2 --top snap1
we got a sane message (here from libvirt 1.0.5):
error: invalid argument: could not find base 'snap2' below 'snap1' in chain for 'vda'
Meanwhile, recent refactoring has slightly reduced the quality of the
libvirt error messages, by losing the phrase 'below xyz':
error: invalid argument: could not find image 'snap2' in chain for 'snap3'
But we had a one-off, where we were not excluding the top file
itself in searching for the base; thankfully qemu still reports
the error, but the quality is worse:
virsh blockcommit $dom vda --base snap2 --top snap2
error: internal error unable to execute QEMU command 'block-commit': Base '/snap2' not found
Fix the one-off in blockcommit by changing the semantics of name
lookup - if a starting point is specified, then the result must
be below that point, rather than including that point. The only
other call to chain lookup was blockpull code, which was already
forcing the lookup to omit the active layer and only needs a
tweak to use the new semantics.
This also fixes the bug exposed in the testsuite, where when doing
a lookup pinned to an intermediate point in the chain, we were
unable to return the name of the parent also in the chain.
* src/util/virstoragefile.c (virStorageFileChainLookup): Change
semantics for non-NULL startFrom.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Adjust caller,
to keep existing semantics.
* tests/virstoragetest.c (mymain): Adjust to expose new semantics.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-06-12 06:22:57 +08:00
|
|
|
TEST_LOOKUP(47, chain3, "raw", NULL, NULL, NULL);
|
2014-06-25 21:43:04 +08:00
|
|
|
TEST_LOOKUP(48, NULL, absraw, chain3->path, chain3, chain2);
|
|
|
|
TEST_LOOKUP(49, chain, absraw, chain3->path, chain3, chain2);
|
|
|
|
TEST_LOOKUP(50, chain2, absraw, chain3->path, chain3, chain2);
|
blockcommit: require base below top
The block commit code looks for an explicit base file relative
to the discovered top file; so for a chain of:
base <- snap1 <- snap2 <- snap3
and a command of:
virsh blockcommit $dom vda --base snap2 --top snap1
we got a sane message (here from libvirt 1.0.5):
error: invalid argument: could not find base 'snap2' below 'snap1' in chain for 'vda'
Meanwhile, recent refactoring has slightly reduced the quality of the
libvirt error messages, by losing the phrase 'below xyz':
error: invalid argument: could not find image 'snap2' in chain for 'snap3'
But we had a one-off, where we were not excluding the top file
itself in searching for the base; thankfully qemu still reports
the error, but the quality is worse:
virsh blockcommit $dom vda --base snap2 --top snap2
error: internal error unable to execute QEMU command 'block-commit': Base '/snap2' not found
Fix the one-off in blockcommit by changing the semantics of name
lookup - if a starting point is specified, then the result must
be below that point, rather than including that point. The only
other call to chain lookup was blockpull code, which was already
forcing the lookup to omit the active layer and only needs a
tweak to use the new semantics.
This also fixes the bug exposed in the testsuite, where when doing
a lookup pinned to an intermediate point in the chain, we were
unable to return the name of the parent also in the chain.
* src/util/virstoragefile.c (virStorageFileChainLookup): Change
semantics for non-NULL startFrom.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Adjust caller,
to keep existing semantics.
* tests/virstoragetest.c (mymain): Adjust to expose new semantics.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-06-12 06:22:57 +08:00
|
|
|
TEST_LOOKUP(51, chain3, absraw, NULL, NULL, NULL);
|
2014-06-25 21:43:04 +08:00
|
|
|
TEST_LOOKUP(52, NULL, NULL, chain3->path, chain3, chain2);
|
|
|
|
TEST_LOOKUP(53, chain, NULL, chain3->path, chain3, chain2);
|
|
|
|
TEST_LOOKUP(54, chain2, NULL, chain3->path, chain3, chain2);
|
blockcommit: require base below top
The block commit code looks for an explicit base file relative
to the discovered top file; so for a chain of:
base <- snap1 <- snap2 <- snap3
and a command of:
virsh blockcommit $dom vda --base snap2 --top snap1
we got a sane message (here from libvirt 1.0.5):
error: invalid argument: could not find base 'snap2' below 'snap1' in chain for 'vda'
Meanwhile, recent refactoring has slightly reduced the quality of the
libvirt error messages, by losing the phrase 'below xyz':
error: invalid argument: could not find image 'snap2' in chain for 'snap3'
But we had a one-off, where we were not excluding the top file
itself in searching for the base; thankfully qemu still reports
the error, but the quality is worse:
virsh blockcommit $dom vda --base snap2 --top snap2
error: internal error unable to execute QEMU command 'block-commit': Base '/snap2' not found
Fix the one-off in blockcommit by changing the semantics of name
lookup - if a starting point is specified, then the result must
be below that point, rather than including that point. The only
other call to chain lookup was blockpull code, which was already
forcing the lookup to omit the active layer and only needs a
tweak to use the new semantics.
This also fixes the bug exposed in the testsuite, where when doing
a lookup pinned to an intermediate point in the chain, we were
unable to return the name of the parent also in the chain.
* src/util/virstoragefile.c (virStorageFileChainLookup): Change
semantics for non-NULL startFrom.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Adjust caller,
to keep existing semantics.
* tests/virstoragetest.c (mymain): Adjust to expose new semantics.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-06-12 06:22:57 +08:00
|
|
|
TEST_LOOKUP(55, chain3, NULL, NULL, NULL, NULL);
|
2014-04-11 03:56:57 +08:00
|
|
|
|
|
|
|
/* Use link to wrap with cross-directory relative backing */
|
|
|
|
virCommandFree(cmd);
|
|
|
|
cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
|
|
|
|
"-F", "qcow2", "-b", "../qcow2", "wrap", NULL);
|
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
|
|
|
ret = -1;
|
|
|
|
|
|
|
|
/* Test behavior of chain lookups, relative backing */
|
2019-02-15 20:03:58 +08:00
|
|
|
virObjectUnref(chain);
|
2014-04-18 20:49:54 +08:00
|
|
|
chain = testStorageFileGetMetadata("sub/link2", VIR_STORAGE_FILE_QCOW2,
|
2018-06-04 15:39:28 +08:00
|
|
|
-1, -1);
|
2014-04-11 03:56:57 +08:00
|
|
|
if (!chain) {
|
|
|
|
ret = -1;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2014-06-13 22:44:09 +08:00
|
|
|
chain2 = chain->backingStore;
|
|
|
|
chain3 = chain2->backingStore;
|
2014-04-11 03:56:57 +08:00
|
|
|
|
2014-06-14 00:01:14 +08:00
|
|
|
TEST_LOOKUP(56, NULL, "bogus", NULL, NULL, NULL);
|
|
|
|
TEST_LOOKUP(57, NULL, "sub/link2", chain->path, chain, NULL);
|
|
|
|
TEST_LOOKUP(58, NULL, "wrap", chain->path, chain, NULL);
|
|
|
|
TEST_LOOKUP(59, NULL, abswrap, chain->path, chain, NULL);
|
2014-06-25 21:43:04 +08:00
|
|
|
TEST_LOOKUP(60, NULL, "../qcow2", chain2->path, chain2, chain);
|
2014-06-14 00:01:14 +08:00
|
|
|
TEST_LOOKUP(61, NULL, "qcow2", NULL, NULL, NULL);
|
2014-06-25 21:43:04 +08:00
|
|
|
TEST_LOOKUP(62, NULL, absqcow2, chain2->path, chain2, chain);
|
|
|
|
TEST_LOOKUP(63, NULL, "raw", chain3->path, chain3, chain2);
|
|
|
|
TEST_LOOKUP(64, NULL, absraw, chain3->path, chain3, chain2);
|
|
|
|
TEST_LOOKUP(65, NULL, NULL, chain3->path, chain3, chain2);
|
2014-06-14 00:01:14 +08:00
|
|
|
|
|
|
|
TEST_LOOKUP_TARGET(66, "vda", NULL, "bogus[1]", 0, NULL, NULL, NULL);
|
|
|
|
TEST_LOOKUP_TARGET(67, "vda", NULL, "vda[-1]", 0, NULL, NULL, NULL);
|
|
|
|
TEST_LOOKUP_TARGET(68, "vda", NULL, "vda[1][1]", 0, NULL, NULL, NULL);
|
|
|
|
TEST_LOOKUP_TARGET(69, "vda", NULL, "wrap", 0, chain->path, chain, NULL);
|
blockcommit: require base below top
The block commit code looks for an explicit base file relative
to the discovered top file; so for a chain of:
base <- snap1 <- snap2 <- snap3
and a command of:
virsh blockcommit $dom vda --base snap2 --top snap1
we got a sane message (here from libvirt 1.0.5):
error: invalid argument: could not find base 'snap2' below 'snap1' in chain for 'vda'
Meanwhile, recent refactoring has slightly reduced the quality of the
libvirt error messages, by losing the phrase 'below xyz':
error: invalid argument: could not find image 'snap2' in chain for 'snap3'
But we had a one-off, where we were not excluding the top file
itself in searching for the base; thankfully qemu still reports
the error, but the quality is worse:
virsh blockcommit $dom vda --base snap2 --top snap2
error: internal error unable to execute QEMU command 'block-commit': Base '/snap2' not found
Fix the one-off in blockcommit by changing the semantics of name
lookup - if a starting point is specified, then the result must
be below that point, rather than including that point. The only
other call to chain lookup was blockpull code, which was already
forcing the lookup to omit the active layer and only needs a
tweak to use the new semantics.
This also fixes the bug exposed in the testsuite, where when doing
a lookup pinned to an intermediate point in the chain, we were
unable to return the name of the parent also in the chain.
* src/util/virstoragefile.c (virStorageFileChainLookup): Change
semantics for non-NULL startFrom.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Adjust caller,
to keep existing semantics.
* tests/virstoragetest.c (mymain): Adjust to expose new semantics.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-06-12 06:22:57 +08:00
|
|
|
TEST_LOOKUP_TARGET(70, "vda", chain, "wrap", 0, NULL, NULL, NULL);
|
2014-06-13 23:23:10 +08:00
|
|
|
TEST_LOOKUP_TARGET(71, "vda", chain2, "wrap", 0, NULL, NULL, NULL);
|
2014-06-14 00:01:14 +08:00
|
|
|
TEST_LOOKUP_TARGET(72, "vda", NULL, "vda[0]", 0, NULL, NULL, NULL);
|
2014-06-25 21:43:04 +08:00
|
|
|
TEST_LOOKUP_TARGET(73, "vda", NULL, "vda[1]", 1, chain2->path, chain2, chain);
|
|
|
|
TEST_LOOKUP_TARGET(74, "vda", chain, "vda[1]", 1, chain2->path, chain2, chain);
|
blockcommit: require base below top
The block commit code looks for an explicit base file relative
to the discovered top file; so for a chain of:
base <- snap1 <- snap2 <- snap3
and a command of:
virsh blockcommit $dom vda --base snap2 --top snap1
we got a sane message (here from libvirt 1.0.5):
error: invalid argument: could not find base 'snap2' below 'snap1' in chain for 'vda'
Meanwhile, recent refactoring has slightly reduced the quality of the
libvirt error messages, by losing the phrase 'below xyz':
error: invalid argument: could not find image 'snap2' in chain for 'snap3'
But we had a one-off, where we were not excluding the top file
itself in searching for the base; thankfully qemu still reports
the error, but the quality is worse:
virsh blockcommit $dom vda --base snap2 --top snap2
error: internal error unable to execute QEMU command 'block-commit': Base '/snap2' not found
Fix the one-off in blockcommit by changing the semantics of name
lookup - if a starting point is specified, then the result must
be below that point, rather than including that point. The only
other call to chain lookup was blockpull code, which was already
forcing the lookup to omit the active layer and only needs a
tweak to use the new semantics.
This also fixes the bug exposed in the testsuite, where when doing
a lookup pinned to an intermediate point in the chain, we were
unable to return the name of the parent also in the chain.
* src/util/virstoragefile.c (virStorageFileChainLookup): Change
semantics for non-NULL startFrom.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Adjust caller,
to keep existing semantics.
* tests/virstoragetest.c (mymain): Adjust to expose new semantics.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-06-12 06:22:57 +08:00
|
|
|
TEST_LOOKUP_TARGET(75, "vda", chain2, "vda[1]", 1, NULL, NULL, NULL);
|
2014-06-13 23:23:10 +08:00
|
|
|
TEST_LOOKUP_TARGET(76, "vda", chain3, "vda[1]", 1, NULL, NULL, NULL);
|
2014-06-25 21:43:04 +08:00
|
|
|
TEST_LOOKUP_TARGET(77, "vda", NULL, "vda[2]", 2, chain3->path, chain3, chain2);
|
|
|
|
TEST_LOOKUP_TARGET(78, "vda", chain, "vda[2]", 2, chain3->path, chain3, chain2);
|
|
|
|
TEST_LOOKUP_TARGET(79, "vda", chain2, "vda[2]", 2, chain3->path, chain3, chain2);
|
blockcommit: require base below top
The block commit code looks for an explicit base file relative
to the discovered top file; so for a chain of:
base <- snap1 <- snap2 <- snap3
and a command of:
virsh blockcommit $dom vda --base snap2 --top snap1
we got a sane message (here from libvirt 1.0.5):
error: invalid argument: could not find base 'snap2' below 'snap1' in chain for 'vda'
Meanwhile, recent refactoring has slightly reduced the quality of the
libvirt error messages, by losing the phrase 'below xyz':
error: invalid argument: could not find image 'snap2' in chain for 'snap3'
But we had a one-off, where we were not excluding the top file
itself in searching for the base; thankfully qemu still reports
the error, but the quality is worse:
virsh blockcommit $dom vda --base snap2 --top snap2
error: internal error unable to execute QEMU command 'block-commit': Base '/snap2' not found
Fix the one-off in blockcommit by changing the semantics of name
lookup - if a starting point is specified, then the result must
be below that point, rather than including that point. The only
other call to chain lookup was blockpull code, which was already
forcing the lookup to omit the active layer and only needs a
tweak to use the new semantics.
This also fixes the bug exposed in the testsuite, where when doing
a lookup pinned to an intermediate point in the chain, we were
unable to return the name of the parent also in the chain.
* src/util/virstoragefile.c (virStorageFileChainLookup): Change
semantics for non-NULL startFrom.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Adjust caller,
to keep existing semantics.
* tests/virstoragetest.c (mymain): Adjust to expose new semantics.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-06-12 06:22:57 +08:00
|
|
|
TEST_LOOKUP_TARGET(80, "vda", chain3, "vda[2]", 2, NULL, NULL, NULL);
|
2014-06-14 00:01:14 +08:00
|
|
|
TEST_LOOKUP_TARGET(81, "vda", NULL, "vda[3]", 3, NULL, NULL, NULL);
|
2014-04-18 20:35:33 +08:00
|
|
|
|
2017-11-03 20:09:47 +08:00
|
|
|
#define TEST_PATH_CANONICALIZE(id, PATH, EXPECT) \
|
|
|
|
do { \
|
|
|
|
data3.path = PATH; \
|
|
|
|
data3.expect = EXPECT; \
|
|
|
|
if (virTestRun("Path canonicalize " #id, \
|
|
|
|
testPathCanonicalize, &data3) < 0) \
|
|
|
|
ret = -1; \
|
2014-05-03 01:22:17 +08:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
TEST_PATH_CANONICALIZE(1, "/", "/");
|
|
|
|
TEST_PATH_CANONICALIZE(2, "/path", "/path");
|
|
|
|
TEST_PATH_CANONICALIZE(3, "/path/to/blah", "/path/to/blah");
|
|
|
|
TEST_PATH_CANONICALIZE(4, "/path/", "/path");
|
|
|
|
TEST_PATH_CANONICALIZE(5, "///////", "/");
|
|
|
|
TEST_PATH_CANONICALIZE(6, "//", "//");
|
|
|
|
TEST_PATH_CANONICALIZE(7, "", "");
|
|
|
|
TEST_PATH_CANONICALIZE(8, ".", ".");
|
|
|
|
TEST_PATH_CANONICALIZE(9, "../", "..");
|
|
|
|
TEST_PATH_CANONICALIZE(10, "../../", "../..");
|
|
|
|
TEST_PATH_CANONICALIZE(11, "../../blah", "../../blah");
|
|
|
|
TEST_PATH_CANONICALIZE(12, "/./././blah", "/blah");
|
|
|
|
TEST_PATH_CANONICALIZE(13, ".././../././../blah", "../../../blah");
|
|
|
|
TEST_PATH_CANONICALIZE(14, "/././", "/");
|
|
|
|
TEST_PATH_CANONICALIZE(15, "./././", ".");
|
|
|
|
TEST_PATH_CANONICALIZE(16, "blah/../foo", "foo");
|
|
|
|
TEST_PATH_CANONICALIZE(17, "foo/bar/../blah", "foo/blah");
|
|
|
|
TEST_PATH_CANONICALIZE(18, "foo/bar/.././blah", "foo/blah");
|
|
|
|
TEST_PATH_CANONICALIZE(19, "/path/to/foo/bar/../../../../../../../../baz", "/baz");
|
|
|
|
TEST_PATH_CANONICALIZE(20, "path/to/foo/bar/../../../../../../../../baz", "../../../../baz");
|
|
|
|
TEST_PATH_CANONICALIZE(21, "path/to/foo/bar", "path/to/foo/bar");
|
|
|
|
TEST_PATH_CANONICALIZE(22, "//foo//bar", "//foo/bar");
|
|
|
|
TEST_PATH_CANONICALIZE(23, "/bar//foo", "/bar/foo");
|
|
|
|
TEST_PATH_CANONICALIZE(24, "//../blah", "//blah");
|
|
|
|
|
|
|
|
/* test paths with symlinks */
|
|
|
|
TEST_PATH_CANONICALIZE(25, "/path/blah", "/other/path/huzah");
|
|
|
|
TEST_PATH_CANONICALIZE(26, "/path/to/relative/symlink", "/path/actual/file");
|
|
|
|
TEST_PATH_CANONICALIZE(27, "/path/to/relative/symlink/blah", "/path/actual/file/blah");
|
|
|
|
TEST_PATH_CANONICALIZE(28, "/path/blah/yippee", "/other/path/huzah/yippee");
|
|
|
|
TEST_PATH_CANONICALIZE(29, "/cycle", NULL);
|
|
|
|
TEST_PATH_CANONICALIZE(30, "/cycle2/link", NULL);
|
|
|
|
TEST_PATH_CANONICALIZE(31, "///", "/");
|
|
|
|
|
2017-11-03 20:09:47 +08:00
|
|
|
#define TEST_RELATIVE_BACKING(id, TOP, BASE, EXPECT) \
|
|
|
|
do { \
|
|
|
|
data4.top = &TOP; \
|
|
|
|
data4.base = &BASE; \
|
|
|
|
data4.expect = EXPECT; \
|
|
|
|
if (virTestRun("Path relative resolve " #id, \
|
|
|
|
testPathRelative, &data4) < 0) \
|
|
|
|
ret = -1; \
|
2014-05-13 16:10:56 +08:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
testPathRelativePrepare();
|
|
|
|
|
|
|
|
/* few negative tests first */
|
|
|
|
|
|
|
|
/* a non-relative image is in the backing chain span */
|
|
|
|
TEST_RELATIVE_BACKING(1, backingchain[0], backingchain[1], NULL);
|
|
|
|
TEST_RELATIVE_BACKING(2, backingchain[0], backingchain[2], NULL);
|
|
|
|
TEST_RELATIVE_BACKING(3, backingchain[0], backingchain[3], NULL);
|
|
|
|
TEST_RELATIVE_BACKING(4, backingchain[1], backingchain[5], NULL);
|
|
|
|
|
|
|
|
/* image is not in chain (specified backwards) */
|
|
|
|
TEST_RELATIVE_BACKING(5, backingchain[2], backingchain[1], NULL);
|
|
|
|
|
|
|
|
/* positive tests */
|
|
|
|
TEST_RELATIVE_BACKING(6, backingchain[1], backingchain[1], "asdf");
|
|
|
|
TEST_RELATIVE_BACKING(7, backingchain[1], backingchain[2], "test");
|
|
|
|
TEST_RELATIVE_BACKING(8, backingchain[1], backingchain[3], "blah");
|
|
|
|
TEST_RELATIVE_BACKING(9, backingchain[2], backingchain[2], "test");
|
|
|
|
TEST_RELATIVE_BACKING(10, backingchain[2], backingchain[3], "blah");
|
|
|
|
TEST_RELATIVE_BACKING(11, backingchain[3], backingchain[3], "blah");
|
|
|
|
|
|
|
|
/* oVirt spelling */
|
|
|
|
TEST_RELATIVE_BACKING(12, backingchain[5], backingchain[5], "../volume/image2");
|
|
|
|
TEST_RELATIVE_BACKING(13, backingchain[5], backingchain[6], "../volume/../volume/image3");
|
|
|
|
TEST_RELATIVE_BACKING(14, backingchain[5], backingchain[7], "../volume/../volume/../volume/image4");
|
|
|
|
TEST_RELATIVE_BACKING(15, backingchain[6], backingchain[6], "../volume/image3");
|
|
|
|
TEST_RELATIVE_BACKING(16, backingchain[6], backingchain[7], "../volume/../volume/image4");
|
|
|
|
TEST_RELATIVE_BACKING(17, backingchain[7], backingchain[7], "../volume/image4");
|
|
|
|
|
|
|
|
/* crazy spellings */
|
|
|
|
TEST_RELATIVE_BACKING(17, backingchain[9], backingchain[9], "directory/stuff/volumes/garbage/image2");
|
|
|
|
TEST_RELATIVE_BACKING(18, backingchain[9], backingchain[10], "directory/stuff/volumes/garbage/../../../image3");
|
|
|
|
TEST_RELATIVE_BACKING(19, backingchain[9], backingchain[11], "directory/stuff/volumes/garbage/../../../../blah/image4");
|
|
|
|
TEST_RELATIVE_BACKING(20, backingchain[10], backingchain[10], "../../../image3");
|
|
|
|
TEST_RELATIVE_BACKING(21, backingchain[10], backingchain[11], "../../../../blah/image4");
|
|
|
|
TEST_RELATIVE_BACKING(22, backingchain[11], backingchain[11], "../blah/image4");
|
|
|
|
|
2016-07-12 23:04:16 +08:00
|
|
|
|
|
|
|
virTestCounterReset("Backing store parse ");
|
|
|
|
|
2019-08-16 01:27:43 +08:00
|
|
|
#define TEST_BACKING_PARSE_FULL(bck, xml, rc) \
|
2017-11-03 20:09:47 +08:00
|
|
|
do { \
|
|
|
|
data5.backing = bck; \
|
|
|
|
data5.expect = xml; \
|
2019-08-16 01:27:43 +08:00
|
|
|
data5.rv = rc; \
|
2017-11-03 20:09:47 +08:00
|
|
|
if (virTestRun(virTestCounterNext(), \
|
|
|
|
testBackingParse, &data5) < 0) \
|
|
|
|
ret = -1; \
|
2016-07-12 23:04:16 +08:00
|
|
|
} while (0)
|
|
|
|
|
2019-08-16 01:27:43 +08:00
|
|
|
#define TEST_BACKING_PARSE(bck, xml) \
|
|
|
|
TEST_BACKING_PARSE_FULL(bck, xml, 0)
|
|
|
|
|
2016-07-12 23:04:16 +08:00
|
|
|
TEST_BACKING_PARSE("path", "<source file='path'/>\n");
|
2020-03-23 23:04:19 +08:00
|
|
|
TEST_BACKING_PARSE("fat:/somedir", "<source dir='/somedir'/>\n");
|
2016-07-12 23:04:16 +08:00
|
|
|
TEST_BACKING_PARSE("://", NULL);
|
2018-10-11 18:22:21 +08:00
|
|
|
TEST_BACKING_PARSE("http://example.com",
|
|
|
|
"<source protocol='http' name=''>\n"
|
|
|
|
" <host name='example.com' port='80'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_BACKING_PARSE("http://example.com/",
|
|
|
|
"<source protocol='http' name=''>\n"
|
|
|
|
" <host name='example.com' port='80'/>\n"
|
|
|
|
"</source>\n");
|
2016-07-12 23:04:16 +08:00
|
|
|
TEST_BACKING_PARSE("http://example.com/file",
|
|
|
|
"<source protocol='http' name='file'>\n"
|
2017-07-20 20:18:04 +08:00
|
|
|
" <host name='example.com' port='80'/>\n"
|
2016-07-12 23:04:16 +08:00
|
|
|
"</source>\n");
|
2019-08-16 01:29:43 +08:00
|
|
|
TEST_BACKING_PARSE_FULL("http://user:pass@example.com/file",
|
|
|
|
"<source protocol='http' name='file'>\n"
|
|
|
|
" <host name='example.com' port='80'/>\n"
|
|
|
|
"</source>\n", 1);
|
2016-07-12 23:04:16 +08:00
|
|
|
TEST_BACKING_PARSE("rbd:testshare:id=asdf:mon_host=example.com",
|
|
|
|
"<source protocol='rbd' name='testshare'>\n"
|
|
|
|
" <host name='example.com'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_BACKING_PARSE("nbd:example.org:6000:exportname=blah",
|
|
|
|
"<source protocol='nbd' name='blah'>\n"
|
|
|
|
" <host name='example.org' port='6000'/>\n"
|
|
|
|
"</source>\n");
|
2019-07-31 23:17:30 +08:00
|
|
|
TEST_BACKING_PARSE("nbd:example.org:6000:exportname=:",
|
|
|
|
"<source protocol='nbd' name=':'>\n"
|
|
|
|
" <host name='example.org' port='6000'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_BACKING_PARSE("nbd:example.org:6000:exportname=:test",
|
|
|
|
"<source protocol='nbd' name=':test'>\n"
|
|
|
|
" <host name='example.org' port='6000'/>\n"
|
|
|
|
"</source>\n");
|
2020-04-24 19:59:21 +08:00
|
|
|
TEST_BACKING_PARSE("nbd:[::1]:6000:exportname=:test",
|
|
|
|
"<source protocol='nbd' name=':test'>\n"
|
|
|
|
" <host name='::1' port='6000'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_BACKING_PARSE("nbd:127.0.0.1:6000:exportname=:test",
|
|
|
|
"<source protocol='nbd' name=':test'>\n"
|
|
|
|
" <host name='127.0.0.1' port='6000'/>\n"
|
|
|
|
"</source>\n");
|
2020-01-16 19:34:13 +08:00
|
|
|
TEST_BACKING_PARSE("nbd:unix:/tmp/sock:exportname=/",
|
|
|
|
"<source protocol='nbd' name='/'>\n"
|
|
|
|
" <host transport='unix' socket='/tmp/sock'/>\n"
|
|
|
|
"</source>\n");
|
2020-04-24 19:59:21 +08:00
|
|
|
TEST_BACKING_PARSE("nbd:unix:/tmp/sock:",
|
|
|
|
"<source protocol='nbd'>\n"
|
|
|
|
" <host transport='unix' socket='/tmp/sock:'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_BACKING_PARSE("nbd:unix:/tmp/sock::exportname=:",
|
|
|
|
"<source protocol='nbd' name=':'>\n"
|
|
|
|
" <host transport='unix' socket='/tmp/sock:'/>\n"
|
|
|
|
"</source>\n");
|
2018-10-11 18:22:21 +08:00
|
|
|
TEST_BACKING_PARSE("nbd://example.org:1234",
|
|
|
|
"<source protocol='nbd'>\n"
|
|
|
|
" <host name='example.org' port='1234'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_BACKING_PARSE("nbd://example.org:1234/",
|
|
|
|
"<source protocol='nbd'>\n"
|
|
|
|
" <host name='example.org' port='1234'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_BACKING_PARSE("nbd://example.org:1234/exportname",
|
|
|
|
"<source protocol='nbd' name='exportname'>\n"
|
|
|
|
" <host name='example.org' port='1234'/>\n"
|
|
|
|
"</source>\n");
|
2020-01-16 20:49:37 +08:00
|
|
|
TEST_BACKING_PARSE("nbd+unix://?socket=/tmp/sock",
|
|
|
|
"<source protocol='nbd'>\n"
|
|
|
|
" <host transport='unix' socket='/tmp/sock'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_BACKING_PARSE("nbd+unix:///?socket=/tmp/sock",
|
|
|
|
"<source protocol='nbd'>\n"
|
|
|
|
" <host transport='unix' socket='/tmp/sock'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_BACKING_PARSE("nbd+unix:////?socket=/tmp/sock",
|
|
|
|
"<source protocol='nbd' name='/'>\n"
|
|
|
|
" <host transport='unix' socket='/tmp/sock'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_BACKING_PARSE("nbd+unix:///exp?socket=/tmp/sock",
|
|
|
|
"<source protocol='nbd' name='exp'>\n"
|
|
|
|
" <host transport='unix' socket='/tmp/sock'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_BACKING_PARSE("nbd+unix:////exp?socket=/tmp/sock",
|
|
|
|
"<source protocol='nbd' name='/exp'>\n"
|
|
|
|
" <host transport='unix' socket='/tmp/sock'/>\n"
|
|
|
|
"</source>\n");
|
2019-08-16 01:29:43 +08:00
|
|
|
TEST_BACKING_PARSE_FULL("iscsi://testuser:testpass@example.org:1234/exportname",
|
|
|
|
"<source protocol='iscsi' name='exportname'>\n"
|
|
|
|
" <host name='example.org' port='1234'/>\n"
|
|
|
|
"</source>\n", 1);
|
2017-06-21 20:55:58 +08:00
|
|
|
|
2018-08-13 19:40:18 +08:00
|
|
|
#ifdef WITH_YAJL
|
2016-04-08 15:55:46 +08:00
|
|
|
TEST_BACKING_PARSE("json:", NULL);
|
|
|
|
TEST_BACKING_PARSE("json:asdgsdfg", NULL);
|
|
|
|
TEST_BACKING_PARSE("json:{}", NULL);
|
|
|
|
TEST_BACKING_PARSE("json: { \"file.driver\":\"blah\"}", NULL);
|
|
|
|
TEST_BACKING_PARSE("json:{\"file.driver\":\"file\"}", NULL);
|
|
|
|
TEST_BACKING_PARSE("json:{\"file.driver\":\"file\", "
|
|
|
|
"\"file.filename\":\"/path/to/file\"}",
|
|
|
|
"<source file='/path/to/file'/>\n");
|
|
|
|
TEST_BACKING_PARSE("json:{\"file.driver\":\"file\", "
|
|
|
|
"\"filename\":\"/path/to/file\"}", NULL);
|
|
|
|
TEST_BACKING_PARSE("json:{\"file\" : { \"driver\":\"file\","
|
|
|
|
"\"filename\":\"/path/to/file\""
|
|
|
|
"}"
|
|
|
|
"}",
|
|
|
|
"<source file='/path/to/file'/>\n");
|
2020-02-03 23:40:16 +08:00
|
|
|
TEST_BACKING_PARSE("json:{\"driver\":\"file\","
|
|
|
|
"\"filename\":\"/path/to/file\""
|
|
|
|
"}",
|
|
|
|
"<source file='/path/to/file'/>\n");
|
2016-07-14 19:58:26 +08:00
|
|
|
TEST_BACKING_PARSE("json:{\"file.driver\":\"host_device\", "
|
|
|
|
"\"file.filename\":\"/path/to/dev\"}",
|
|
|
|
"<source dev='/path/to/dev'/>\n");
|
|
|
|
TEST_BACKING_PARSE("json:{\"file.driver\":\"host_cdrom\", "
|
|
|
|
"\"file.filename\":\"/path/to/cdrom\"}",
|
|
|
|
"<source dev='/path/to/cdrom'/>\n");
|
2016-07-12 23:59:58 +08:00
|
|
|
TEST_BACKING_PARSE("json:{\"file.driver\":\"http\", "
|
2016-08-16 15:24:12 +08:00
|
|
|
"\"file.url\":\"http://example.com/file\"}",
|
2016-07-12 23:59:58 +08:00
|
|
|
"<source protocol='http' name='file'>\n"
|
2017-07-20 20:18:04 +08:00
|
|
|
" <host name='example.com' port='80'/>\n"
|
2016-07-12 23:59:58 +08:00
|
|
|
"</source>\n");
|
|
|
|
TEST_BACKING_PARSE("json:{\"file\":{ \"driver\":\"http\","
|
2016-08-16 15:24:12 +08:00
|
|
|
"\"url\":\"http://example.com/file\""
|
2016-07-12 23:59:58 +08:00
|
|
|
"}"
|
|
|
|
"}",
|
|
|
|
"<source protocol='http' name='file'>\n"
|
2017-07-20 20:18:04 +08:00
|
|
|
" <host name='example.com' port='80'/>\n"
|
2016-07-12 23:59:58 +08:00
|
|
|
"</source>\n");
|
|
|
|
TEST_BACKING_PARSE("json:{\"file.driver\":\"ftp\", "
|
2016-08-16 15:24:12 +08:00
|
|
|
"\"file.url\":\"http://example.com/file\"}",
|
2016-07-12 23:59:58 +08:00
|
|
|
NULL);
|
2016-07-13 21:35:29 +08:00
|
|
|
TEST_BACKING_PARSE("json:{\"file.driver\":\"gluster\", "
|
|
|
|
"\"file.filename\":\"gluster://example.com/vol/file\"}",
|
|
|
|
"<source protocol='gluster' name='vol/file'>\n"
|
2017-07-20 20:18:04 +08:00
|
|
|
" <host name='example.com' port='24007'/>\n"
|
2016-07-13 21:35:29 +08:00
|
|
|
"</source>\n");
|
|
|
|
TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"gluster\","
|
|
|
|
"\"volume\":\"testvol\","
|
|
|
|
"\"path\":\"img.qcow2\","
|
|
|
|
"\"server\":[ { \"type\":\"tcp\","
|
|
|
|
"\"host\":\"example.com\","
|
|
|
|
"\"port\":\"1234\""
|
|
|
|
"},"
|
|
|
|
"{ \"type\":\"unix\","
|
|
|
|
"\"socket\":\"/path/socket\""
|
|
|
|
"},"
|
|
|
|
"{ \"type\":\"tcp\","
|
|
|
|
"\"host\":\"example.com\""
|
|
|
|
"}"
|
|
|
|
"]"
|
|
|
|
"}"
|
|
|
|
"}",
|
2016-09-05 21:31:44 +08:00
|
|
|
"<source protocol='gluster' name='testvol/img.qcow2'>\n"
|
2016-07-13 21:35:29 +08:00
|
|
|
" <host name='example.com' port='1234'/>\n"
|
|
|
|
" <host transport='unix' socket='/path/socket'/>\n"
|
2017-07-20 20:18:04 +08:00
|
|
|
" <host name='example.com' port='24007'/>\n"
|
2016-07-13 21:35:29 +08:00
|
|
|
"</source>\n");
|
|
|
|
TEST_BACKING_PARSE("json:{\"file.driver\":\"gluster\","
|
|
|
|
"\"file.volume\":\"testvol\","
|
|
|
|
"\"file.path\":\"img.qcow2\","
|
|
|
|
"\"file.server\":[ { \"type\":\"tcp\","
|
|
|
|
"\"host\":\"example.com\","
|
|
|
|
"\"port\":\"1234\""
|
|
|
|
"},"
|
|
|
|
"{ \"type\":\"unix\","
|
|
|
|
"\"socket\":\"/path/socket\""
|
|
|
|
"},"
|
2017-06-19 20:37:47 +08:00
|
|
|
"{ \"type\":\"inet\","
|
2016-07-13 21:35:29 +08:00
|
|
|
"\"host\":\"example.com\""
|
|
|
|
"}"
|
|
|
|
"]"
|
|
|
|
"}",
|
2016-09-05 21:31:44 +08:00
|
|
|
"<source protocol='gluster' name='testvol/img.qcow2'>\n"
|
2016-07-13 21:35:29 +08:00
|
|
|
" <host name='example.com' port='1234'/>\n"
|
|
|
|
" <host transport='unix' socket='/path/socket'/>\n"
|
2017-07-20 20:18:04 +08:00
|
|
|
" <host name='example.com' port='24007'/>\n"
|
2016-07-13 21:35:29 +08:00
|
|
|
"</source>\n");
|
2017-12-15 01:01:05 +08:00
|
|
|
TEST_BACKING_PARSE("json:{\"driver\": \"raw\","
|
|
|
|
"\"file\": {\"server.0.host\": \"A.A.A.A\","
|
|
|
|
"\"server.1.host\": \"B.B.B.B\","
|
|
|
|
"\"server.2.host\": \"C.C.C.C\","
|
|
|
|
"\"driver\": \"gluster\","
|
|
|
|
"\"path\": \"raw\","
|
|
|
|
"\"server.0.type\": \"tcp\","
|
|
|
|
"\"server.1.type\": \"tcp\","
|
|
|
|
"\"server.2.type\": \"tcp\","
|
|
|
|
"\"server.0.port\": \"24007\","
|
|
|
|
"\"server.1.port\": \"24007\","
|
|
|
|
"\"server.2.port\": \"24007\","
|
|
|
|
"\"volume\": \"vol1\"}}",
|
|
|
|
"<source protocol='gluster' name='vol1/raw'>\n"
|
|
|
|
" <host name='A.A.A.A' port='24007'/>\n"
|
|
|
|
" <host name='B.B.B.B' port='24007'/>\n"
|
|
|
|
" <host name='C.C.C.C' port='24007'/>\n"
|
|
|
|
"</source>\n");
|
2016-07-14 14:10:31 +08:00
|
|
|
TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"nbd\","
|
|
|
|
"\"path\":\"/path/to/socket\""
|
|
|
|
"}"
|
|
|
|
"}",
|
|
|
|
"<source protocol='nbd'>\n"
|
|
|
|
" <host transport='unix' socket='/path/to/socket'/>\n"
|
|
|
|
"</source>\n");
|
2020-02-03 23:40:16 +08:00
|
|
|
TEST_BACKING_PARSE("json:{\"driver\":\"nbd\","
|
|
|
|
"\"path\":\"/path/to/socket\""
|
|
|
|
"}",
|
|
|
|
"<source protocol='nbd'>\n"
|
|
|
|
" <host transport='unix' socket='/path/to/socket'/>\n"
|
|
|
|
"</source>\n");
|
2016-07-14 14:10:31 +08:00
|
|
|
TEST_BACKING_PARSE("json:{\"file.driver\":\"nbd\","
|
|
|
|
"\"file.path\":\"/path/to/socket\""
|
|
|
|
"}",
|
|
|
|
"<source protocol='nbd'>\n"
|
|
|
|
" <host transport='unix' socket='/path/to/socket'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"nbd\","
|
|
|
|
"\"export\":\"blah\","
|
|
|
|
"\"host\":\"example.org\","
|
|
|
|
"\"port\":\"6000\""
|
|
|
|
"}"
|
|
|
|
"}",
|
|
|
|
"<source protocol='nbd' name='blah'>\n"
|
|
|
|
" <host name='example.org' port='6000'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_BACKING_PARSE("json:{\"file.driver\":\"nbd\","
|
|
|
|
"\"file.export\":\"blah\","
|
|
|
|
"\"file.host\":\"example.org\","
|
|
|
|
"\"file.port\":\"6000\""
|
|
|
|
"}",
|
|
|
|
"<source protocol='nbd' name='blah'>\n"
|
|
|
|
" <host name='example.org' port='6000'/>\n"
|
|
|
|
"</source>\n");
|
2017-06-15 23:44:18 +08:00
|
|
|
TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"nbd\","
|
|
|
|
"\"export\":\"blah\","
|
|
|
|
"\"server\": { \"type\":\"inet\","
|
|
|
|
"\"host\":\"example.org\","
|
|
|
|
"\"port\":\"6000\""
|
|
|
|
"}"
|
|
|
|
"}"
|
|
|
|
"}",
|
|
|
|
"<source protocol='nbd' name='blah'>\n"
|
|
|
|
" <host name='example.org' port='6000'/>\n"
|
|
|
|
"</source>\n");
|
2018-02-12 23:16:42 +08:00
|
|
|
TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"nbd\","
|
|
|
|
"\"server\": { \"type\":\"unix\","
|
|
|
|
"\"path\":\"/path/socket\""
|
|
|
|
"}"
|
|
|
|
"}"
|
|
|
|
"}",
|
|
|
|
"<source protocol='nbd'>\n"
|
|
|
|
" <host transport='unix' socket='/path/socket'/>\n"
|
|
|
|
"</source>\n");
|
2016-07-15 21:12:10 +08:00
|
|
|
TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"ssh\","
|
|
|
|
"\"host\":\"example.org\","
|
|
|
|
"\"port\":\"6000\","
|
|
|
|
"\"path\":\"blah\","
|
|
|
|
"\"user\":\"user\""
|
|
|
|
"}"
|
|
|
|
"}",
|
|
|
|
"<source protocol='ssh' name='blah'>\n"
|
|
|
|
" <host name='example.org' port='6000'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_BACKING_PARSE("json:{\"file.driver\":\"ssh\","
|
|
|
|
"\"file.host\":\"example.org\","
|
|
|
|
"\"file.port\":\"6000\","
|
|
|
|
"\"file.path\":\"blah\","
|
|
|
|
"\"file.user\":\"user\""
|
|
|
|
"}",
|
|
|
|
"<source protocol='ssh' name='blah'>\n"
|
|
|
|
" <host name='example.org' port='6000'/>\n"
|
|
|
|
"</source>\n");
|
2017-06-15 23:44:18 +08:00
|
|
|
TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"ssh\","
|
|
|
|
"\"path\":\"blah\","
|
|
|
|
"\"server\":{ \"host\":\"example.org\","
|
|
|
|
"\"port\":\"6000\""
|
|
|
|
"},"
|
|
|
|
"\"user\":\"user\""
|
|
|
|
"}"
|
|
|
|
"}",
|
|
|
|
"<source protocol='ssh' name='blah'>\n"
|
|
|
|
" <host name='example.org' port='6000'/>\n"
|
|
|
|
"</source>\n");
|
2016-09-05 21:15:22 +08:00
|
|
|
TEST_BACKING_PARSE("json:{\"file.driver\":\"rbd\","
|
|
|
|
"\"file.filename\":\"rbd:testshare:id=asdf:mon_host=example.com\""
|
|
|
|
"}",
|
|
|
|
"<source protocol='rbd' name='testshare'>\n"
|
|
|
|
" <host name='example.com'/>\n"
|
|
|
|
"</source>\n");
|
2017-06-15 23:44:18 +08:00
|
|
|
TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"rbd\","
|
|
|
|
"\"image\":\"test\","
|
|
|
|
"\"pool\":\"libvirt\","
|
|
|
|
"\"conf\":\"/path/to/conf\","
|
|
|
|
"\"snapshot\":\"snapshotname\","
|
|
|
|
"\"server\":[ {\"host\":\"example.com\","
|
|
|
|
"\"port\":\"1234\""
|
|
|
|
"},"
|
|
|
|
"{\"host\":\"example2.com\""
|
|
|
|
"}"
|
|
|
|
"]"
|
|
|
|
"}"
|
|
|
|
"}",
|
|
|
|
"<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");
|
2017-02-14 06:53:43 +08:00
|
|
|
TEST_BACKING_PARSE("json:{ \"file\": { "
|
|
|
|
"\"driver\": \"raw\","
|
|
|
|
"\"file\": {"
|
|
|
|
"\"driver\": \"file\","
|
|
|
|
"\"filename\": \"/path/to/file\" } } }",
|
|
|
|
"<source file='/path/to/file'/>\n");
|
2017-06-15 23:12:01 +08:00
|
|
|
TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"iscsi\","
|
|
|
|
"\"transport\":\"tcp\","
|
|
|
|
"\"portal\":\"test.org\","
|
|
|
|
"\"target\":\"iqn.2016-12.com.virttest:emulated-iscsi-noauth.target\""
|
|
|
|
"}"
|
|
|
|
"}",
|
|
|
|
"<source protocol='iscsi' name='iqn.2016-12.com.virttest:emulated-iscsi-noauth.target/0'>\n"
|
2017-07-20 20:18:04 +08:00
|
|
|
" <host name='test.org' port='3260'/>\n"
|
2017-06-15 23:12:01 +08:00
|
|
|
"</source>\n");
|
2019-08-16 01:29:43 +08:00
|
|
|
TEST_BACKING_PARSE_FULL("json:{\"file\":{\"driver\":\"iscsi\","
|
|
|
|
"\"transport\":\"tcp\","
|
|
|
|
"\"portal\":\"test.org\","
|
|
|
|
"\"user\":\"testuser\","
|
|
|
|
"\"target\":\"iqn.2016-12.com.virttest:emulated-iscsi-auth.target\""
|
|
|
|
"}"
|
|
|
|
"}",
|
|
|
|
"<source protocol='iscsi' name='iqn.2016-12.com.virttest:emulated-iscsi-auth.target/0'>\n"
|
|
|
|
" <host name='test.org' port='3260'/>\n"
|
|
|
|
"</source>\n", 1);
|
|
|
|
TEST_BACKING_PARSE_FULL("json:{\"file\":{\"driver\":\"iscsi\","
|
|
|
|
"\"transport\":\"tcp\","
|
|
|
|
"\"portal\":\"test.org\","
|
|
|
|
"\"password\":\"testpass\","
|
|
|
|
"\"target\":\"iqn.2016-12.com.virttest:emulated-iscsi-auth.target\""
|
|
|
|
"}"
|
|
|
|
"}",
|
|
|
|
"<source protocol='iscsi' name='iqn.2016-12.com.virttest:emulated-iscsi-auth.target/0'>\n"
|
|
|
|
" <host name='test.org' port='3260'/>\n"
|
|
|
|
"</source>\n", 1);
|
2017-06-15 23:12:01 +08:00
|
|
|
TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"iscsi\","
|
|
|
|
"\"transport\":\"tcp\","
|
|
|
|
"\"portal\":\"test.org:1234\","
|
|
|
|
"\"target\":\"iqn.2016-12.com.virttest:emulated-iscsi-noauth.target\","
|
2018-01-31 19:00:42 +08:00
|
|
|
"\"lun\":\"6\""
|
2017-06-15 23:12:01 +08:00
|
|
|
"}"
|
|
|
|
"}",
|
|
|
|
"<source protocol='iscsi' name='iqn.2016-12.com.virttest:emulated-iscsi-noauth.target/6'>\n"
|
|
|
|
" <host name='test.org' port='1234'/>\n"
|
|
|
|
"</source>\n");
|
2017-11-07 23:20:23 +08:00
|
|
|
TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"iscsi\","
|
|
|
|
"\"transport\":\"tcp\","
|
|
|
|
"\"portal\":\"[2001::0]:1234\","
|
|
|
|
"\"target\":\"iqn.2016-12.com.virttest:emulated-iscsi-noauth.target\","
|
|
|
|
"\"lun\":6"
|
|
|
|
"}"
|
|
|
|
"}",
|
|
|
|
"<source protocol='iscsi' name='iqn.2016-12.com.virttest:emulated-iscsi-noauth.target/6'>\n"
|
|
|
|
" <host name='[2001::0]' port='1234'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"iscsi\","
|
|
|
|
"\"transport\":\"tcp\","
|
|
|
|
"\"portal\":\"[2001::0]\","
|
|
|
|
"\"target\":\"iqn.2016-12.com.virttest:emulated-iscsi-noauth.target\","
|
|
|
|
"\"lun\":6"
|
|
|
|
"}"
|
|
|
|
"}",
|
|
|
|
"<source protocol='iscsi' name='iqn.2016-12.com.virttest:emulated-iscsi-noauth.target/6'>\n"
|
|
|
|
" <host name='[2001::0]' port='3260'/>\n"
|
|
|
|
"</source>\n");
|
2017-06-15 23:44:18 +08:00
|
|
|
TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"sheepdog\","
|
|
|
|
"\"vdi\":\"test\","
|
|
|
|
"\"server\":{ \"type\":\"inet\","
|
|
|
|
"\"host\":\"example.com\","
|
|
|
|
"\"port\":\"321\""
|
|
|
|
"}"
|
|
|
|
"}"
|
|
|
|
"}",
|
|
|
|
"<source protocol='sheepdog' name='test'>\n"
|
|
|
|
" <host name='example.com' port='321'/>\n"
|
|
|
|
"</source>\n");
|
2017-06-27 01:42:06 +08:00
|
|
|
TEST_BACKING_PARSE("json:{\"driver\": \"raw\","
|
|
|
|
"\"file\": {\"server.host\": \"10.10.10.10\","
|
|
|
|
"\"server.port\": \"7000\","
|
|
|
|
"\"tag\": \"\","
|
|
|
|
"\"driver\": \"sheepdog\","
|
|
|
|
"\"server.type\": \"inet\","
|
|
|
|
"\"vdi\": \"Alice\"}}",
|
|
|
|
"<source protocol='sheepdog' name='Alice'>\n"
|
|
|
|
" <host name='10.10.10.10' port='7000'/>\n"
|
|
|
|
"</source>\n");
|
2017-08-30 21:46:50 +08:00
|
|
|
TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"vxhs\","
|
|
|
|
"\"vdisk-id\":\"c6718f6b-0401-441d-a8c3-1f0064d75ee0\","
|
2017-10-24 00:02:28 +08:00
|
|
|
"\"server\": { \"host\":\"example.com\","
|
2017-08-30 21:46:50 +08:00
|
|
|
"\"port\":\"9999\""
|
|
|
|
"}"
|
|
|
|
"}"
|
|
|
|
"}",
|
|
|
|
"<source protocol='vxhs' name='c6718f6b-0401-441d-a8c3-1f0064d75ee0'>\n"
|
|
|
|
" <host name='example.com' port='9999'/>\n"
|
|
|
|
"</source>\n");
|
2021-01-07 05:32:31 +08:00
|
|
|
TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"nfs\","
|
|
|
|
"\"user\":2,"
|
|
|
|
"\"group\":9,"
|
|
|
|
"\"path\":\"/foo/bar/baz\","
|
|
|
|
"\"server\": { \"host\":\"example.com\","
|
|
|
|
"\"type\":\"inet\""
|
|
|
|
"}"
|
|
|
|
"}"
|
|
|
|
"}",
|
|
|
|
"<source protocol='nfs' name='/foo/bar/baz'>\n"
|
|
|
|
" <host name='example.com'/>\n"
|
|
|
|
" <identity user='+2' group='+9'/>\n"
|
|
|
|
"</source>\n");
|
2020-01-16 23:02:15 +08:00
|
|
|
TEST_BACKING_PARSE_FULL("json:{ \"driver\": \"raw\","
|
|
|
|
"\"offset\": 10752,"
|
|
|
|
"\"size\": 4063232,"
|
|
|
|
"\"file\": { \"driver\": \"file\","
|
|
|
|
"\"filename\": \"/tmp/testfle\""
|
|
|
|
"}"
|
|
|
|
"}",
|
2020-02-06 01:09:55 +08:00
|
|
|
"<source file='/tmp/testfle'>\n"
|
|
|
|
" <slices>\n"
|
|
|
|
" <slice type='storage' offset='10752' size='4063232'/>\n"
|
|
|
|
" </slices>\n"
|
|
|
|
"</source>\n", 0);
|
2020-01-16 23:02:15 +08:00
|
|
|
|
2020-03-06 15:13:06 +08:00
|
|
|
TEST_BACKING_PARSE_FULL("json:{ \"file.cookie\": \"vmware_soap_session=\\\"0c8db85112873a79b7ef74f294cb70ef7f\\\"\","
|
|
|
|
"\"file.sslverify\": false,"
|
|
|
|
"\"file.driver\": \"https\","
|
2020-03-06 15:29:59 +08:00
|
|
|
"\"file.url\": \"https://host/folder/esx6.5-rhel7.7-x86%5f64/esx6.5-rhel7.7-x86%5f64-flat.vmdk?dcPath=data&dsName=esx6.5-matrix\","
|
|
|
|
"\"file.timeout\": 2000"
|
|
|
|
"}",
|
2020-03-27 23:26:50 +08:00
|
|
|
"<source protocol='https' name='folder/esx6.5-rhel7.7-x86_64/esx6.5-rhel7.7-x86_64-flat.vmdk' query='dcPath=data&dsName=esx6.5-matrix'>\n"
|
2020-03-06 15:29:59 +08:00
|
|
|
" <host name='host' port='443'/>\n"
|
|
|
|
" <ssl verify='no'/>\n"
|
|
|
|
" <cookies>\n"
|
|
|
|
" <cookie name='vmware_soap_session'>"0c8db85112873a79b7ef74f294cb70ef7f"</cookie>\n"
|
|
|
|
" </cookies>\n"
|
|
|
|
" <timeout seconds='2000'/>\n"
|
|
|
|
"</source>\n", 0);
|
|
|
|
|
|
|
|
TEST_BACKING_PARSE_FULL("json:{ \"file.cookie\": \"vmware_soap_session=\\\"0c8db85112873a79b7ef74f294cb70ef7f\\\"\","
|
|
|
|
"\"file.sslverify\": \"off\","
|
|
|
|
"\"file.driver\": \"https\","
|
2020-03-06 15:13:06 +08:00
|
|
|
"\"file.url\": \"https://host/folder/esx6.5-rhel7.7-x86%5f64/esx6.5-rhel7.7-x86%5f64-flat.vmdk?dcPath=data&dsName=esx6.5-matrix\","
|
|
|
|
"\"file.timeout\": 2000"
|
|
|
|
"}",
|
2020-03-27 23:26:50 +08:00
|
|
|
"<source protocol='https' name='folder/esx6.5-rhel7.7-x86_64/esx6.5-rhel7.7-x86_64-flat.vmdk' query='dcPath=data&dsName=esx6.5-matrix'>\n"
|
2020-03-06 15:13:06 +08:00
|
|
|
" <host name='host' port='443'/>\n"
|
|
|
|
" <ssl verify='no'/>\n"
|
|
|
|
" <cookies>\n"
|
|
|
|
" <cookie name='vmware_soap_session'>"0c8db85112873a79b7ef74f294cb70ef7f"</cookie>\n"
|
|
|
|
" </cookies>\n"
|
|
|
|
" <timeout seconds='2000'/>\n"
|
|
|
|
"</source>\n", 0);
|
|
|
|
|
2020-03-24 01:06:56 +08:00
|
|
|
TEST_BACKING_PARSE("json:{\"file\":{\"driver\": \"nvme\","
|
|
|
|
"\"device\": \"0000:01:00.0\","
|
|
|
|
"\"namespace\": 1"
|
|
|
|
"}"
|
|
|
|
"}",
|
|
|
|
"<source type='pci' namespace='1'>\n"
|
|
|
|
" <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>\n"
|
|
|
|
"</source>\n");
|
|
|
|
|
2018-08-13 19:40:18 +08:00
|
|
|
#endif /* WITH_YAJL */
|
2016-07-12 23:04:16 +08:00
|
|
|
|
2014-04-11 03:56:57 +08:00
|
|
|
cleanup:
|
2013-02-14 02:04:05 +08:00
|
|
|
/* Final cleanup */
|
|
|
|
testCleanupImages();
|
|
|
|
|
|
|
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2017-03-29 22:45:42 +08:00
|
|
|
VIR_TEST_MAIN(mymain)
|