Discussion:
[libvirt-users] Persisting the libvirt guest's reason code.
Tanmoy Sinha
2018-03-20 08:21:00 UTC
Permalink
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)*
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-03-20 15:37:26 UTC
Permalink
Post by Tanmoy Sinha
Hi,
I am currently facing an issue with libvirt w.r.t a guest's state and
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)*
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-03-20 17:39:02 UTC
Permalink
Re-adding the mailing list - please don't take discussions off-list
in this way.
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 :|
Loading...