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