Communication between host and guest VM when using virt-manager

Screenshot from 2023-07-05 08-01-28

How do I know?

You are still in shared
Go up,to /home/daniel and do ls -l there

Look at /etc/group file

What is that lock symbol in the file manager? Its not already mounted is it?

1 Like

I do not think it is.

Screenshot from 2023-07-05 08-09-35

OK shared is owned by daniel, but is in group root
How about
chgrp daniel shared
That should fix it
Then see what the file manager says

2 Likes

@nevj
@Rosika
This post I am about to make has no take-away from the excellent work that the both of you have already accomplished, if you think it does, then I apologize.
The subject hear, for this post, is being able to exchange data from host to guest and or vice-versa, which in most cases, is quite self explanatory, but this has a way of changing between platforms being used and the virtual machine software being used.
First I will do a screenshot with VirtualBox


With VB you see the mounted shared folder!!!
This is only because of the virtualbox-guest-additions have been installed with appropriate settings within Gentoo. This is the easy way of sharing data between host and guest and guest and host. There are other ways.
Now let us move on too Virt-Manager QEMU/KVM

The first screenshot shows no mounted shared folder???
Why is this?
In order too display a shred folder on the QEMU/KVM desktop, one has to use /etc/fstab and enter a line in /etc/fstab

The bottom line is my /etc/fstab entry
You then run the mount command
ā€œsudo mount -t virtiofs mount_home_daniel_shared /mnt/home/daniel/sharedā€
This mount has to configured and setup witin Virt-Manger under the ā€œadd hardwareā€ and ā€œfilesystemā€ tabs. This has already been discussed within this topic.

Now you see QEMU/KVM with a mounted shared folder

This mount will last as long as the Virt-Manager QEMU/KVM is running, in other words, if the VM is rebooted, then the above mounted command will have to be issued.
Why is this?
According to the data I have gotten from the internet, is pretty straight forward.
Using virtiofs a shared folder can indeed be entered into /etc/fstab, but if you try to save the state of the VM, like in VB, you will get a migration warning.
When one saves a VM, it will be migrated into ram, and virtiofs, as of now has no working way of migrating the VM.
Does this make VB any better than QEMU/KVM, NO, but it does lead one to the ? of which software is best suited for the user. In my case, since I run Windows, then I will almost always chose VirtualBox.
BTW I am running quickgui, qemu/kvm and VB on the Ubuntu 22.04 platform, so no Windows have been involved.
Except for guickgui this about covers my research, quickgui will come later.

1 Like

Daniel, that is a great explanation, thank you.
It would seem that , if one wants a permanent mount in Virt-manager, one has to use
an nfs-mount rather than a virtiofs-mountā€¦ unless we could find a way to put that mount statement in a startup scriptā€¦ eg put it in /etc/rc.local. Some distros dont have rc.local.

What @Rosika and I are trying to say in this topic is that with virt- manager it is easier to use
the standard linux network commands for communication, rather than fiddle around with menu settings. With Vbox, however, the way to go seems to be to use the menus.

2 Likes

My thinking also, but if VirtualBox can get the shared folder working, the way it should, then why canā€™t the devā€™s working on virtiofs do the same, what is the great mystery surrounding migration?

Back from Sydney
Ah, you are talking about the philosophy difference between Win and Linux.
Vbox is self contained, it does not need other parts of the OS to make it work
Virt-manager does one thing, like most Linux utilities,ā€¦ it manages vmā€™s. It depends on Linux for other things, so the best way to use it is to treat it as one cog in a machine, and to supply the other cogs from Linux. ā€¦ That is why @Rosika and I looked at the Linux networking apps for use with Vmanagerā€¦ it needs them to work properly.

Try putting the mount statement in /etc/rc.local. Just edit it and add the mount line to the end. That should work, after a reboot. All rc.local does is execute that mount statement (and anything else that you put in there) every time you bootā€¦ that is what you want to happen

The whole idea of a special shared folder is a Windows concept too. Most Linux users would just mount the directory they want to work in directly, not muck around copying stuff in and out of a special shared folder. Win and Lin are like chalk and cheese.

Those devs working on viftiofs and Vmanager will never make it like Vboxā€¦they are Unix peopleā€¦ they expect you to use Vmanager with Unix, not on its own

2 Likes

No!!! I am talking about the working difference between QEMU/KVM and VirtualBox, I could care less about the philosophy.

I have never edited the /etc/rc.local!!! Would this be for the host or guest.

Same thing. The working difference is the result of the philosophy difference

In the guest
You want the mount to happen when the guest boots
If the guest is gentoo, I think it will have an rc.local

NO, in Gentoo with OpenRC it is in /etc/local.d
You just write a script ( saying mount) and stick it in that directory. Look up local.d in Gentoo

But read this

It says you can make a file /etc/rc.local even if it does not existā€¦ at least in Debian
Try it, that is the easiest way

1 Like

I agree,

itĀ“s been a while since I last used virtualbox, so: sorry, I canĀ“t tell much about it. Back then I never even used a shared folder. :neutral_face:

All that was years ago and after using virtualbox I found out vmware was much more to my liking. But here again: I never used shared folders.

In the meantime IĀ“ve grown accustomed to virt-manager, so itĀ“s a good thing for me (and perhaps others as well) that @nevj also showed some extended interest in the matter. :wink:

That seems to be a good idea. :+1:

Cheers from Rosika :slightly_smiling_face:

2 Likes

Do you know how to do startup scripts @Rosika?
My experience only extends to rc.local.
This may help

also

I tried this one on my Debianā€¦ it works

1 Like

@nevj
Thanks for the suggestion, but I will just use the mount command when I need a mounted shared folder, when running QEMU/KVM. No telling what I would be mounting, if I was too write a script.

I would setup an nfs mount ( instead of a virtiofs mount)
Not difficult, just install nfs in the host and export the shared file
Then you can put the mount in /etc/fstab.

Hi Neville, :wave:

actually IĀ“ve never had cause to employ startup scripts so far.

Once in the past I was considering it for automatically running redshift:

gtk-redshift -l [...] -t 4200:3500

Yet I dismissed it in the end as I need different hue values on different days. It depends on various circumstances (sun is shining or not / degree of cloudiness etc).
As I have set up fish as my default shell itĀ“s easy to access different variants for the redshif command; so I didnĀ“t need a startup script for that.

That said it should be intersting to try out making a startup script.

That should be alright with me.

I just looked it up on my host (Linux Lite). It doesnĀ“t have the rc.local file. So according to your link IĀ“d have to ceate it first.

I also looked it up in my Debian VM:

rosika2@debian ~> locate rc.local
/snap/core/13308/etc/rc.local
/snap/core/13308/etc/init.d/rc.local
/snap/core/13308/etc/rc2.d/S03rc.local
/snap/core/13308/etc/rc3.d/S03rc.local
/snap/core/13308/etc/rc4.d/S03rc.local
/snap/core/13308/etc/rc5.d/S03rc.local
/snap/core/13308/lib/systemd/system/rc.local.service
/usr/lib/systemd/system/rc.local.service

Here it is present, but only as part of snap.

The link you provided says:

rc.local is simply a legacy from the System V init system. It is the last script to execute before proceeding to a login screen for the desktop environment or a login prompt at the terminal.

Would
/snap/core/13308/etc/rc.local
also be taken into account by the startup procedure :question:

I guess not, or am I mistaken?

Thanks a lot.
Cheers from Rosika :slightly_smiling_face:

P.S.:

thanks also for the other links

1 Like

Hi Rozika,
Not sure.

I have another ideaā€¦ why not use .bashrc instead of rc.local?
You can put any linux command in .bashrcā€¦ so why not do the mount there
I will test it tomorrow.
Regards
Neville

2 Likes

Hi Neville, :wave:

I guess - at least in my case - anything that has to do with snaps should be ignoredā€¦
ā€¦ as I have disabled autostart for the service.
I once needed snap for experimental purposes on Debian but later I disabled it:

sudo systemctl stop snapd.service
sudo systemctl disable snapd.service
sudo systemctl mask snapd.service # to make it reboot-safe

So I guess /snap/core/13308/etc/rc.local shouldnĀ“t be taken into accountā€¦
yet IĀ“m not completely sure.

O.K., IĀ“ll look into it.
Would this also be an option for me, as I have set the fish shell as my default shell? :thinking:

Many greetings from Rosika :slightly_smiling_face:

1 Like

Fish will have a dot file, which runs every time you start a shell. Dont know what it is called.

I just realised there is a problemā€¦ .bashrc runs for every shell you startā€¦ you dint wznt multiple mounts.
Maybe .profileā€¦ it might only run once.
We need some file that only runs at boot time. Ideally rc.local.

2 Likes