From: Guillaume Roche <groche@genymobile.com>
Cc: Guillaume Roche <groche@genymobile.com>,
Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>,
qemu-block@nongnu.org (open list:Block layer core),
qemu-devel@nongnu.org (open list:All patches CC here)
Subject: [PATCH] block/vvfat: Fix ro shared folder
Date: Tue, 31 Aug 2021 16:17:27 +0200 [thread overview]
Message-ID: <20210831141727.347597-1-groche@genymobile.com> (raw)
QEMU exits in error when passing a vfat shared folder in read-only mode.
To fix this issue, this patch removes any potential write permission
from cumulative_perms, when a read-only block device is in use.
Buglink: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=918950
Signed-off-by: Guillaume Roche <groche@genymobile.com>
---
This is an attempt to fix this behavior, but it feels a bit hacky to me
since this patch checks for the vvfat format in a generic function.
However, I'd be glad to have some advice to make it better. Anyway, I
ran the block tests to ensure this does not introduce any regression.
To add some context: I know that this can be worked around by setting
the shared folder in rw mode. But our use-case requires using both
shared and VM snapshots, and QEMU prevents using snapshot with a rw
shared folder.
block.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/block.c b/block.c
index e97ce0b1c8..3f59e3843f 100644
--- a/block.c
+++ b/block.c
@@ -2383,6 +2383,12 @@ void bdrv_get_cumulative_perm(BlockDriverState *bs, uint64_t *perm,
cumulative_shared_perms &= c->shared_perm;
}
+ /* Discard write permission if vvfat block device is read-only */
+ const char *format = bdrv_get_format_name(bs);
+ if (format != NULL && strncmp(format, "vvfat", 5) == 0 && bdrv_is_read_only(bs)) {
+ cumulative_perms &= ~BLK_PERM_WRITE;
+ }
+
*perm = cumulative_perms;
*shared_perm = cumulative_shared_perms;
}
--
2.31.1
next reply other threads:[~2021-08-31 15:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-31 14:17 Guillaume Roche [this message]
2021-08-31 16:06 ` [PATCH] block/vvfat: Fix ro shared folder Philippe Mathieu-Daudé
2021-09-02 15:41 ` Guillaume Roche
2021-09-08 14:11 ` Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210831141727.347597-1-groche@genymobile.com \
--to=groche@genymobile.com \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).