[libvirt] [PATCH 09/35] qemu: block: Add support for accessing directories via the 'vvfat' driver

Peter Krempa posted 35 patches 7 years ago
[libvirt] [PATCH 09/35] qemu: block: Add support for accessing directories via the 'vvfat' driver
Posted by Peter Krempa 7 years ago
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>
---
 src/qemu/qemu_block.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 6cf41cf544..516b006ce9 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -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:
-- 
2.16.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 09/35] qemu: block: Add support for accessing directories via the 'vvfat' driver
Posted by John Ferlan 7 years ago

On 04/25/2018 11:15 AM, Peter Krempa wrote:
> 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>
> ---
>  src/qemu/qemu_block.c | 27 ++++++++++++++++++++++++++-
>  1 file changed, 26 insertions(+), 1 deletion(-)
> 

So I suppose the only question I have for this one relates to whether
vvfat is supported in QEMU 1.5 or later and that's been the expectation
to use it for a long time, but libvirt wasn't doing the right thing?

Assuming 1.5 or later and that we don't have to do anything special or
use qemuBlockStorageSourceGetFileProps for some variant between 1.5 and
when vvfat was first supported,

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

I'm half surprised we didn't have some test failure!

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 09/35] qemu: block: Add support for accessing directories via the 'vvfat' driver
Posted by Peter Krempa 7 years ago
On Tue, May 01, 2018 at 20:21:11 -0400, John Ferlan wrote:
> 
> 
> On 04/25/2018 11:15 AM, Peter Krempa wrote:
> > 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>
> > ---
> >  src/qemu/qemu_block.c | 27 ++++++++++++++++++++++++++-
> >  1 file changed, 26 insertions(+), 1 deletion(-)
> > 
> 
> So I suppose the only question I have for this one relates to whether
> vvfat is supported in QEMU 1.5 or later and that's been the expectation
> to use it for a long time, but libvirt wasn't doing the right thing?

Actually this code is not used yet mostly and will be only once we
switch to blockdev. Since blockdev support will require a much newer
qemu anyways we are fine to change this now.

> 
> Assuming 1.5 or later and that we don't have to do anything special or
> use qemuBlockStorageSourceGetFileProps for some variant between 1.5 and
> when vvfat was first supported,

Currently we format it the old way by using -drive, which will continue
to be supported.

> 
> Reviewed-by: John Ferlan <jferlan@redhat.com>
> 
> John
> 
> I'm half surprised we didn't have some test failure!

Well, since it was not used there wasn't much test coverage. The test
coverage was mostly in the XML->json->XML test, which did not handle the
vvfat case.

This series adds better coverage at least for the formatter. This will
also lessen the need to add a lot of xml->argv tests, since the
convertor will be tested separately.

> 
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list