Tanmoy Sinha
2018-Mar-20 08:21 UTC
[libvirt-users] Persisting the libvirt guest's reason code.
Hi, I am currently facing an issue with libvirt w.r.t a guest's state and reason code. Precisely following are steps: 1. I have a running guest named *linux-test *on KVM 2. I do a * $> virsh save linux-test linux-saved.dat* 3. At this point * $> virsh domstate --reason linux-test *shows *shutoff(saved)* 4. I restarted the libvirtd daemon * $>systemctl restart libvirtd* 5. Now when I check for the domain state, * $> virsh domstate --reason linux-test *it reads *shutoff(unknown)*>From what I understand:The reason code for a particular state is maintained in-memory (no persistence in libvirt). Now when libvirtd restarts it queries the qemu monitor for all the running qemu processes and reassigns the state and reason. But for guests which are in shutoff state, there’s exists no QEMU instance for it, hence it has no way to know what was the last reason (i..e the default value 0 or UNKNOWN), but the state remains as shutfoff! Is there a patch for it? Or someway to retain the reason code across reboots and restart? Regards, Tanmoy Sinha
Daniel P. Berrangé
2018-Mar-20 15:37 UTC
Re: [libvirt-users] Persisting the libvirt guest's reason code.
On Tue, Mar 20, 2018 at 08:21:00AM +0000, Tanmoy Sinha wrote:> Hi, > > I am currently facing an issue with libvirt w.r.t a guest's state and > reason code. Precisely following are steps: > > 1. I have a running guest named *linux-test *on KVM > 2. I do a > * $> virsh save linux-test linux-saved.dat* > 3. At this point > * $> virsh domstate --reason linux-test *shows *shutoff(saved)* > 4. I restarted the libvirtd daemon > * $>systemctl restart libvirtd* > 5. Now when I check for the domain state, > * $> virsh domstate --reason linux-test *it reads > *shutoff(unknown)* > > > >From what I understand: > > The reason code for a particular state is maintained in-memory (no > persistence in libvirt). Now when libvirtd restarts it queries the qemu > monitor for all the running qemu processes and reassigns the state and > reason. But for guests which are in shutoff state, there’s exists no QEMU > instance for it, hence it has no way to know what was the last reason (i..e > the default value 0 or UNKNOWN), but the state remains as shutfoff! > > Is there a patch for it? Or someway to retain the reason code across > reboots and restart?In general libvirtd maintains state for running VMs across libvirtd restarts by recording it in /var/run/libivrt/qemu/$GUEST.xml. That file is only relevant when the guest is running though, so when you have saved the guest, it is now shutoff and we've no place in which to record the "reason" across the libvirtd restart. IOW we preserve the reason across restarts, except when shutting off Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Daniel P. Berrangé
2018-Mar-20 17:39 UTC
Re: [libvirt-users] Persisting the libvirt guest's reason code.
Re-adding the mailing list - please don't take discussions off-list in this way. On Tue, Mar 20, 2018 at 05:14:45PM +0000, Tanmoy Sinha wrote:> Daniel, > > Thanks for your prompt response. I have another question, as soon as I do > virsh save <GuestID> <filename>, the corresponding xml and pid under > /var/run/libvirt/qemu is gone, but the guest still has a definition. At > this point, if I query the domain state (i.e. virsh domstate --reason > <GUESTID>) it reads shutoff(saved). Where does this fetch the reason from, > when the /var/run/libvirt/qemu/Guestname.xml file is gone? Libvirtd > maintains the reason code in-memory?That's true only if the guest has a persistent config file in /etc/libvirt. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Possibly Parallel Threads
- Re: Persisting the libvirt guest's reason code.
- xm domstate command not found
- Re: Issue with libguestfs-test-tool on a guest hosted on VMWare ESXi
- Re: Nested KVM on VMware ESXi failure (was: Re: Issue with libguestfs-test-tool on a guest hosted on VMWare ESXi)
- mkfs fails on qemu-nbd device