mirror of https://gitee.com/openkylin/libvirt.git
qemu: Support readonly filesystem passthrough
Upstream QEMU starts to support it from commit 2c74c2cb.
This commit is contained in:
parent
1c8f0cbb83
commit
a1a83c5874
|
@ -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>
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 */
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue