提交 5a70f104 编写于 作者: P Peter Krempa

storage: Implement backing store support for "fat:" prefix

qemublocktest showed that we don't add the "fat:" prefix for directory
storage when formatting the backing store string. While it's unlikely to
be used it's simple enough to actually implement the support rather than
trying to forbid it.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 c60fe310
......@@ -2045,8 +2045,13 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr src,
g_autofree char *backingJSON = NULL;
if (!src->sliceStorage) {
if (virStorageSourceIsLocalStorage(src))
if (virStorageSourceIsLocalStorage(src)) {
if (src->type == VIR_STORAGE_TYPE_DIR &&
src->format == VIR_STORAGE_FILE_FAT)
return g_strdup_printf("fat:%s", src->path);
return g_strdup(src->path);
}
/* generate simplified URIs for the easy cases */
if (actualType == VIR_STORAGE_TYPE_NETWORK &&
......
......@@ -3922,6 +3922,7 @@ virStorageSourceNewFromBackingAbsolute(const char *path,
virStorageSourcePtr *src)
{
const char *json;
const char *dirpath;
int rc = 0;
g_autoptr(virStorageSource) def = NULL;
......@@ -3935,6 +3936,14 @@ virStorageSourceNewFromBackingAbsolute(const char *path,
def->path = g_strdup(path);
} else {
if ((dirpath = STRSKIP(path, "fat:"))) {
def->type = VIR_STORAGE_TYPE_DIR;
def->format = VIR_STORAGE_FILE_FAT;
def->path = g_strdup(dirpath);
*src = g_steal_pointer(&def);
return 0;
}
def->type = VIR_STORAGE_TYPE_NETWORK;
VIR_DEBUG("parsing backing store string: '%s'", path);
......
......@@ -6,5 +6,5 @@
"floppy": false
}
backing store string:
/var/somefiles
fat:/var/somefiles
)
......@@ -6,5 +6,5 @@
"floppy": true
}
backing store string:
/var/somefiles
fat:/var/somefiles
)
......@@ -6,5 +6,5 @@
"floppy": false
}
backing store string:
/var/somefiles
fat:/var/somefiles
)
......@@ -1226,6 +1226,7 @@ mymain(void)
TEST_BACKING_PARSE_FULL(bck, xml, 0)
TEST_BACKING_PARSE("path", "<source file='path'/>\n");
TEST_BACKING_PARSE("fat:/somedir", "<source dir='/somedir'/>\n");
TEST_BACKING_PARSE("://", NULL);
TEST_BACKING_PARSE("http://example.com",
"<source protocol='http' name=''>\n"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册