[libvirt-users] Mounting VM filesystem on host while VM running

Hello, All my VMs are using LVs created on the host side. I'm using collectd to monitor some of the ressources of my host as well as the libvirt pluging to monitor my VMs. Collectd has an interesting plugin ( df ) which can monitor the filesystem usage. I would like to use it to monitor the VMs filesytsem usage. As it is obvious that if I mount the VM filesystem on the host while the VM is running, I'm wondering if I could mount it in READONLY without expecting any panic/corruption problem. Any advices ? Patrick

On 08.08.2016 09:33, Patrick PICHON wrote:
Hello,
All my VMs are using LVs created on the host side.
I'm using collectd to monitor some of the ressources of my host as well as the libvirt pluging to monitor my VMs.
Collectd has an interesting plugin ( df ) which can monitor the filesystem usage.
I would like to use it to monitor the VMs filesytsem usage.
As it is obvious that if I mount the VM filesystem on the host while the VM is running, I'm wondering if I could mount it in READONLY without expecting any panic/corruption problem.
Any advices ?
I don't think it is a good idea. Mostly because of caching - you probably won't get consistent results. Moreover, some filesystems (e.g. ext4) replay journal even if mounted as RO (frankly, I haven't found a way how to mount ext really RO). I don't know of any filesystem that would support being mounted multiple times from two different hosts (except network FS obviously). What you could do is to write small guest agent that will report disk usage to host (e.g. via virito serial console). Michal

hello Michal, That was my worries as well, and I think that your advice is probably the right one. Or even, I'm might request an enhancement to the collect libvirt plugin to report also FS information. Kind regards patrick On , Michal Privoznik wrote:
On 08.08.2016 09:33, Patrick PICHON wrote:
Hello,
All my VMs are using LVs created on the host side.
I'm using collectd to monitor some of the ressources of my host as well as the libvirt pluging to monitor my VMs.
Collectd has an interesting plugin ( df ) which can monitor the filesystem usage.
I would like to use it to monitor the VMs filesytsem usage.
As it is obvious that if I mount the VM filesystem on the host while the VM is running, I'm wondering if I could mount it in READONLY without expecting any panic/corruption problem.
Any advices ?
I don't think it is a good idea. Mostly because of caching - you probably won't get consistent results. Moreover, some filesystems (e.g. ext4) replay journal even if mounted as RO (frankly, I haven't found a way how to mount ext really RO). I don't know of any filesystem that would support being mounted multiple times from two different hosts (except network FS obviously).
What you could do is to write small guest agent that will report disk usage to host (e.g. via virito serial console).
Michal

On 08.08.2016 10:23, Patrick PICHON wrote:
hello Michal,
That was my worries as well, and I think that your advice is probably the right one. Or even, I'm might request an enhancement to the collect libvirt plugin to report also FS information.
What I'd like to see is libvirt's ability to spawn commands inside guest. But it is not that simple. I mean, the hardest part is to design public libvirt API. For instance, we'd have to deal with both blocking & non-blocking (i.e. long-running) commands; then we would need to give users possibility to read command's output (possibly asynchronously). With this, you'd just: virDomainRunCommand(dom, 'df', '-h', NULL); or something and you'd be good. Michal

On Mon, 2016-08-08 at 10:37 +0200, Michal Privoznik wrote:
hello Michal, That was my worries as well, and I think that your advice is probably the right one. Or even, I'm might request an enhancement to the collect libvirt plugin to report also FS information. What I'd like to see is libvirt's ability to spawn commands inside guest. But it is not that simple. I mean, the hardest part is to design
On 08.08.2016 10:23, Patrick PICHON wrote: public libvirt API. For instance, we'd have to deal with both blocking & non-blocking (i.e. long-running) commands; then we would need to give users possibility to read command's output (possibly asynchronously). With this, you'd just: virDomainRunCommand(dom, 'df', '-h', NULL); or something and you'd be good.
Not as straightforward as you'd like, but if you use QEMU you can already achieve something similar via qemu-guest-agent. https://www.redhat.com/archives/libvir-list/2016-August/msg00339.html -- Andrea Bolognani / Red Hat / Virtualization

Hello Andrea, https://www.redhat.com/archives/libvir-list/2016-August/msg00339.html This looks indeed promising. I had a look to virt-df (from the libguestfs-tools), but to install this is embarking a lot of packages that I do not want to leave on the server :-( Kind regards patrick On , Andrea Bolognani wrote:
On Mon, 2016-08-08 at 10:37 +0200, Michal Privoznik wrote:
hello Michal, That was my worries as well, and I think that your advice is probably the right one. Or even, I'm might request an enhancement to the collect libvirt plugin to report also FS information. What I'd like to see is libvirt's ability to spawn commands inside guest. But it is not that simple. I mean, the hardest part is to design
On 08.08.2016 10:23, Patrick PICHON wrote: public libvirt API. For instance, we'd have to deal with both blocking & non-blocking (i.e. long-running) commands; then we would need to give users possibility to read command's output (possibly asynchronously). With this, you'd just: virDomainRunCommand(dom, 'df', '-h', NULL); or something and you'd be good.
Not as straightforward as you'd like, but if you use QEMU you can already achieve something similar via qemu-guest-agent.
https://www.redhat.com/archives/libvir-list/2016-August/msg00339.html
-- Andrea Bolognani / Red Hat / Virtualization

On 08.08.2016 13:23, Andrea Bolognani wrote:
On Mon, 2016-08-08 at 10:37 +0200, Michal Privoznik wrote:
On 08.08.2016 10:23, Patrick PICHON wrote:
hello Michal,
That was my worries as well, and I think that your advice is probably the right one. Or even, I'm might request an enhancement to the collect libvirt plugin to report also FS information.
What I'd like to see is libvirt's ability to spawn commands inside guest. But it is not that simple. I mean, the hardest part is to design public libvirt API. For instance, we'd have to deal with both blocking & non-blocking (i.e. long-running) commands; then we would need to give users possibility to read command's output (possibly asynchronously).
With this, you'd just: virDomainRunCommand(dom, 'df', '-h', NULL); or something and you'd be good.
Not as straightforward as you'd like, but if you use QEMU you can already achieve something similar via qemu-guest-agent.
https://www.redhat.com/archives/libvir-list/2016-August/msg00339.html
This is exactly what I had in mind when writing those lines above. It is not very convenient for user I'd say. Anyway, it shows that we should start discussing the design for our virDomainCommand* API - users would benefit from it. Michal

Just found virt-df ( libguestfs package) which seems doing what I need. Just need to integrate the result in an collectd/rrd format On , Michal Privoznik wrote:
On 08.08.2016 09:33, Patrick PICHON wrote:
Hello,
All my VMs are using LVs created on the host side.
I'm using collectd to monitor some of the ressources of my host as well as the libvirt pluging to monitor my VMs.
Collectd has an interesting plugin ( df ) which can monitor the filesystem usage.
I would like to use it to monitor the VMs filesytsem usage.
As it is obvious that if I mount the VM filesystem on the host while the VM is running, I'm wondering if I could mount it in READONLY without expecting any panic/corruption problem.
Any advices ?
I don't think it is a good idea. Mostly because of caching - you probably won't get consistent results. Moreover, some filesystems (e.g. ext4) replay journal even if mounted as RO (frankly, I haven't found a way how to mount ext really RO). I don't know of any filesystem that would support being mounted multiple times from two different hosts (except network FS obviously).
What you could do is to write small guest agent that will report disk usage to host (e.g. via virito serial console).
Michal
_______________________________________________ libvirt-users mailing list libvirt-users@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-users

On Mon, Aug 08, 2016 at 10:19:29AM +0200, Michal Privoznik wrote:
On 08.08.2016 09:33, Patrick PICHON wrote:
Hello,
All my VMs are using LVs created on the host side.
I'm using collectd to monitor some of the ressources of my host as well as the libvirt pluging to monitor my VMs.
Collectd has an interesting plugin ( df ) which can monitor the filesystem usage.
I would like to use it to monitor the VMs filesytsem usage.
As it is obvious that if I mount the VM filesystem on the host while the VM is running, I'm wondering if I could mount it in READONLY without expecting any panic/corruption problem.
Any advices ?
I don't think it is a good idea. Mostly because of caching - you probably won't get consistent results. Moreover, some filesystems (e.g. ext4) replay journal even if mounted as RO (frankly, I haven't found a way how to mount ext really RO). I don't know of any filesystem that would support being mounted multiple times from two different hosts (except network FS obviously).
Yep, mounting the guest FS on the host is practically guaranteed to lead to data loss. Don't even think about trying it.
What you could do is to write small guest agent that will report disk usage to host (e.g. via virito serial console).
FWIW, you can run the libguestfs guest agent inside a running guest and then connect to it using normal libguestfs API Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (4)
-
Andrea Bolognani
-
Daniel P. Berrange
-
Michal Privoznik
-
Patrick PICHON