qemu: Support readonly filesystem passthrough

Upstream QEMU starts to support it from commit 2c74c2cb.
This commit is contained in:
Osier Yang 2011-12-21 23:51:29 +08:00
parent 1c8f0cbb83
commit a1a83c5874
4 changed files with 21 additions and 3 deletions

View File

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

View File

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

View File

@ -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 */
};

View File

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