qemu: block: Add support for accessing directories via the 'vvfat' driver

Handle VIR_STORAGE_TYPE_DIR in qemuBlockStorageSourceGetBackendProps so
that a 'vvfat' driver is used, which emulates a FAT filesystem
containing the folders.

qemu requires us to add it as a storage layer, since a 'raw' layer is
usually put on top of it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
Peter Krempa 2018-03-29 08:44:02 +02:00
parent c9b27af32d
commit 2b26ea1441

View File

@ -992,6 +992,25 @@ qemuBlockStorageSourceGetFileProps(virStorageSourcePtr src)
}
static virJSONValuePtr
qemuBlockStorageSourceGetVvfatProps(virStorageSourcePtr src)
{
virJSONValuePtr ret = NULL;
/* libvirt currently does not handle the following attributes:
* '*fat-type': 'int'
* '*label': 'str'
*/
ignore_value(virJSONValueObjectCreate(&ret,
"s:driver", "vvfat",
"s:dir", src->path,
"b:floppy", src->floppyimg,
"b:rw", !src->readonly, NULL));
return ret;
}
/**
* qemuBlockStorageSourceGetBackendProps:
* @src: disk source
@ -1008,11 +1027,17 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src)
switch ((virStorageType)actualType) {
case VIR_STORAGE_TYPE_BLOCK:
case VIR_STORAGE_TYPE_FILE:
case VIR_STORAGE_TYPE_DIR:
if (!(fileprops = qemuBlockStorageSourceGetFileProps(src)))
return NULL;
break;
case VIR_STORAGE_TYPE_DIR:
/* qemu handles directories by exposing them as a device with emulated
* FAT filesystem */
if (!(fileprops = qemuBlockStorageSourceGetVvfatProps(src)))
return NULL;
break;
case VIR_STORAGE_TYPE_VOLUME:
case VIR_STORAGE_TYPE_NONE:
case VIR_STORAGE_TYPE_LAST: