1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

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: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Peter Krempa 2020-03-23 16:04:19 +01:00
parent c60fe3106e
commit 5a70f1048f
6 changed files with 19 additions and 4 deletions

View File

@ -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 &&

View File

@ -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);

View File

@ -6,5 +6,5 @@
"floppy": false
}
backing store string:
/var/somefiles
fat:/var/somefiles
)

View File

@ -6,5 +6,5 @@
"floppy": true
}
backing store string:
/var/somefiles
fat:/var/somefiles
)

View File

@ -6,5 +6,5 @@
"floppy": false
}
backing store string:
/var/somefiles
fat:/var/somefiles
)

View File

@ -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"