-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for mounting a shared folder between the host and guest via virtiofs #82
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nathanchance
requested review from
msfjarvis,
nickdesaulniers and
tpimh
as code owners
December 7, 2022 22:21
I just pushed a change to warn when |
This will be useful for a follow up commit, which will attempt to look for a binary relative to QEMU's prefix. It happens to simplify the code as well. Signed-off-by: Nathan Chancellor <[email protected]>
virtiofs, available in QEMU 5.2 or newer and Linux guests 5.4 or newer, is a more modern way to pass local folders along to QEMU, as it takes advantage of the fact that the folders are on the same machine as the hypervisor. To use virtiofs, we first need to run virtiofsd, which is included with most base QEMU packages. Once we find it, we run it in the background and connect to it using some QEMU parameters, which were shamelessly taken from the official virtiofs website: https://virtio-fs.gitlab.io/howto-qemu.html To use it within the guest (you can use a different path than /mnt/shared but 'mount -t virtio shared' must be used): # mkdir /mnt/shared # mount -t virtiofs shared /mnt/shared # echo "$(uname -a)" >/mnt/shared/foo On the host: $ cat shared/foo Linux (none) 6.1.0-rc8-next-20221207 ClangBuiltLinux#2 SMP PREEMPT Wed Dec 7 14:56:03 MST 2022 aarch64 GNU/Linux This does require guest kernel support (CONFIG_VIRTIO_FS=y), otherwise it will not work inside the guest: / # mount -t virtiofs shared /mnt/shared mount: mounting shared on /mnt/shared failed: No such device Link: ClangBuiltLinux#81 Signed-off-by: Nathan Chancellor <[email protected]>
Fix the following backtrace: Traceback (most recent call last): File ".../boot-qemu.py", line 870, in <module> launch_qemu(config) File ".../boot-qemu.py", line 770, in launch_qemu virtiofsd = utils.find_first_file(qemu_prefix, virtiofsd_locations) File ".../utils.py", line 52, in find_first_file f"No files from list ('{', '.join(possible_files)}') could be found within '{relative_root}'!" TypeError: sequence item 0: expected str instance, PosixPath found Signed-off-by: Nathan Chancellor <[email protected]>
launch_qemu() has gotten quite unweildy in terms of indentation level and readability. Fix it by breaking it a part into several different functions, each of which has full documentation behind it to understand what they are doing and why they exist. Take the opportunity to optimize launch_qemu_gdb() a bit by pulling as many unnecessary changes out of the while loop as possible. There are a couple of minor changes around spacing in this, which came about due to changes to the order in which strings are printed. Signed-off-by: Nathan Chancellor <[email protected]>
This will come in handy in trying to warn people when they are missing configurations needed for certain features. While we are at it, make getting the configuration value a little more robust using re.search() + match groups. Signed-off-by: Nathan Chancellor <[email protected]>
1. Warn the user if CONFIG_VIRTIO_FS=y cannot be found in the configuration (or if the configuration cannot be found). 2. Print information about using the shared folder within the guest. Signed-off-by: Nathan Chancellor <[email protected]>
nathanchance
force-pushed
the
virtiofs
branch
from
December 17, 2022 00:26
e6e34b0
to
14adce2
Compare
I've rebased on latest main, as there have been quite a few changes to the |
v2: #93 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
virtiofs, available in QEMU 5.2 or newer and Linux guests 5.4 or newer,
is a more modern way to pass local folders along to QEMU, as it takes
advantage of the fact that the folders are on the same machine as the
hypervisor.
To use virtiofs, we first need to run
virtiofsd
, which is included withmost base QEMU packages. Once we find it, we run it in the background
and connect to it using some QEMU parameters, which were shamelessly
taken from the official virtiofs website:
https://virtio-fs.gitlab.io/howto-qemu.html
To use it within the guest (you can use a different path than
/mnt/shared
butmount -t virtio shared
must be used):On the host:
This does require guest kernel support (
CONFIG_VIRTIO_FS=y
), otherwiseit will not work inside the guest:
Closes: #81