[PATCH] qemu: Support readonly filesystem passthrough

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Upstream QEMU starts to support it from commit 2c74c2cb.
---
 docs/formatdomain.html.in    |    5 +++--
 src/qemu/qemu_capabilities.c |    7 ++++++-
 src/qemu/qemu_capabilities.h |    1 +
 src/qemu/qemu_command.c      |   11 +++++++++++
 4 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index c57b7b3..9cf0f12 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1399,8 +1399,9 @@
 
       <dt><code>readonly</code></dt>
       <dd>
-      An optional <code>readonly</code> attribute is available but currently
-      unused.
+        Enables exporting filesytem as a readonly mount for guest, by
+        default read-write access is given (currently only works for
+        QEMU/KVM driver).
       </dd>
     </dl>
 
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index de2bc13..43c7578 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -143,6 +143,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
               "rombar",
               "ich9-ahci",
               "no-acpi",
+              "fsdev-readonly",
     );
 
 struct qemu_feature_flags {
@@ -981,6 +982,7 @@ qemuCapsComputeCmdFlags(const char *help,
                         virBitmapPtr flags)
 {
     const char *p;
+    const char *fsdev;
 
     if (strstr(help, "-no-kqemu"))
         qemuCapsSet(flags, QEMU_CAPS_KQEMU);
@@ -1077,8 +1079,11 @@ qemuCapsComputeCmdFlags(const char *help,
         qemuCapsSet(flags, QEMU_CAPS_NESTING);
     if (strstr(help, ",menu=on"))
         qemuCapsSet(flags, QEMU_CAPS_BOOT_MENU);
-    if (strstr(help, "-fsdev"))
+    if ((fsdev = strstr(help, "-fsdev"))) {
         qemuCapsSet(flags, QEMU_CAPS_FSDEV);
+        if (strstr(fsdev, "readonly"))
+            qemuCapsSet(flags, QEMU_CAPS_FSDEV_READONLY);
+    }
     if (strstr(help, "-smbios type"))
         qemuCapsSet(flags, QEMU_CAPS_SMBIOS_TYPE);
 
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 08d8457..c759baf 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -116,6 +116,7 @@ enum qemuCapsFlags {
     QEMU_CAPS_PCI_ROMBAR         = 76, /* -device rombar=0|1 */
     QEMU_CAPS_ICH9_AHCI         = 77, /* -device ich9-ahci */
     QEMU_CAPS_NO_ACPI		= 78, /* -no-acpi */
+    QEMU_CAPS_FSDEV_READONLY    =79, /* -fsdev readonly supported */
 
     QEMU_CAPS_LAST,                   /* this must always be the last item */
 };
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 9d3bc23..ea1b763 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2108,6 +2108,17 @@ char *qemuBuildFSStr(virDomainFSDefPtr fs,
     virBufferAsprintf(&opt, ",id=%s%s", QEMU_FSDEV_HOST_PREFIX, fs->info.alias);
     virBufferAsprintf(&opt, ",path=%s", fs->src);
 
+    if (fs->readonly) {
+        if (qemuCapsGet(qemuCaps, QEMU_CAPS_FSDEV_READONLY)) {
+            virBufferAddLit(&opt, ",readonly");
+        } else {
+            qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                            _("readonly filesystem is not supported by this "
+                              "QEMU binary"));
+            goto error;
+        }
+    }
+
     if (virBufferError(&opt)) {
         virReportOOMError();
         goto error;
-- 
1.7.7.3

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


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]