Skip to content
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

File transfer to QEMU #2407

Open
z5241248 opened this issue Jul 26, 2024 · 5 comments
Open

File transfer to QEMU #2407

z5241248 opened this issue Jul 26, 2024 · 5 comments

Comments

@z5241248
Copy link
Contributor

For Docker, we can use the command "docker cp" to transfer files to a container. But for QEMU, how do we do it without using the cloud?

I tried using a shared folder (mount -t 9p…), but it's not the best way because I need to execute the command to mount the shared folder in the QEMU system every time it starts. Furthermore, mounting a shared folder doesn't seem to work with Windows systems.

Do you have a good way to transfer files without using the cloud?

@z5241248 z5241248 closed this as completed Aug 1, 2024
@grossmj
Copy link
Member

grossmj commented Aug 1, 2024

Do you have a good way to transfer files without using the cloud?

Have you found a way to do it?

@grossmj grossmj reopened this Aug 3, 2024
@z5241248
Copy link
Contributor Author

z5241248 commented Aug 9, 2024

Do you have a good way to transfer files without using the cloud?

Have you found a way to do it?

First, please forgive me if there are some mistakes in my grammar

I found a way to make it work. Still mount external folder.

For Linux Qemu

You can mount a shared folder like following content. Add the command when the Qemu starts:

qemu-system-x86_64 … -virtfs local,path=/mnt/shared,mount_tag=host0,security_model=passthrough,id=host0

And then, you should create a new folder in the system:

mkdir -p /mnt/shared
mount -t 9p -o trans=virtio,version=9p2000.L host0 /mnt/shared

For Windows Qemu

I tried to using Samba, it works.

You can refer this link, it's from Qemu official: https://www.qemu.org/docs/master/system/invocation.html#hxtool-5

First, you should install the Samba server in your host system.

And then, add the command when the Qemu starts:

-nic user,id=nic0,smb=/share_directory

There is a example

qemu-system-x86_64 -name win7-Lite-1 -m 2048M -smp cpus=1,sockets=1 -enable-kvm -machine smm=off -boot order=c -drive file=/data/gns3/data/GNS3/images/QEMU/win7-Lite.qcow2 -vnc 0.0.0.0:2 -nic user,id=nic0,smb=/opt -machine usb=on -device usb-tablet

When you start your Windows Qemu system, you should check your ip address.

image

And then, adding a Network mapping.

Samba uses the x.x.x.4 address by default, the qemu official document also mention it.
image

image

If it succeeds, a new hard drive will appear.

image

@grossmj grossmj reopened this Sep 18, 2024
@smart2128
Copy link

smart2128 commented Sep 20, 2024

A different approach could leverage the USB redirection feature supported by virt-viewer in order to alternatively attach/detach a pseudo USB removable disk to a virtual appliance.

@z5241248
Copy link
Contributor Author

z5241248 commented Sep 23, 2024

Actually, I found a new way to transfer files, set the IP address in real-time address, etc.

If your Qemu file can be pre-installed software, you can install the Qemu-Guest-Agent(QGA). I experimented with it on Windows 7-10, Centos 6-8, and Ubuntu 18-24. They all work.

For different platforms, QGA will have some version differences, but the basic features will work.

related reference:https://www.qemu.org/docs/master/interop/qemu-ga.html

@smart2128
Copy link

spice-webdavd + remote viewer's folder sharing is another way to transfer files between host and guest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants