Bug 501018 - virsh list on xen broken after shutdown/restart
virsh list on xen broken after shutdown/restart
Product: Virtualization Tools
Classification: Community
Component: libvirt (Show other bugs)
All Linux
low Severity medium
: ---
: ---
Assigned To: Libvirt Maintainers
Depends On:
  Show dependency treegraph
Reported: 2009-05-15 10:23 EDT by tgraves_cs
Modified: 2015-04-27 17:02 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2015-04-27 17:02:50 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
patch for virsh list on xen issue (1.21 KB, patch)
2009-05-15 10:23 EDT, tgraves_cs
no flags Details | Diff
xenstore-ls output (26.03 KB, text/plain)
2009-05-15 15:28 EDT, tgraves_cs
no flags Details
xm list --long output (12.65 KB, text/plain)
2009-05-15 15:28 EDT, tgraves_cs
no flags Details

  None (edit)
Description tgraves_cs 2009-05-15 10:23:54 EDT
Created attachment 344162 [details]
patch for virsh list on xen issue

Description of problem:
After running virsh shutdown and then virsh start on a vm virsh list does not properly report that vm.  This occurs in both 0.6.1 and 0.6.3. It does not happen on 0.3.3.  The issue seems to be that the new libvirt is going to xenstore before the hypervisor.  When you shutdown and restart the vm the domid changes and xenstore still has the old id in it.  I have created a patch to change the order it checks things back to the way it was in 0.3.3 and that has fixed the problem.  I am attaching the patch for libvirt 0.6.3

Version-Release number of selected component (if applicable):
This occurs in both 0.6.1 and 0.6.3. It does not happen on 0.3.3. 

How reproducible:
Every time. Create vm, shutdown vm, start vm. Virsh list now doesn't show it.

Steps to Reproduce:
1. create vm with virsh create
2. run virsh list - it properly shows up
3. shutdown vm with virsh shutdown
4. start vm with virsh start
5. run virsh list and it is now missing. you can run xm list to see that it is actually running though.
Actual results:
vm not listed

Expected results:
vm should be listed

Additional info:
Comment 1 Daniel Berrange 2009-05-15 12:12:06 EDT
I don't think this patch is suitable, because it is effectively reverting a previous bugfix

+Fri Nov 28 16:16:54 CET 2008 Guido Günther <agx@sigxcpu.org>
+       Prefer xenstore driver for listDomains, since xen HV reports ghost ids
+       of already shutdown domains in some xen versions
+       * src/proxy_internal.c, src/proxy_internal.h: declare
+       xenProxyListDomains non static
+       * src/xend_internal.c, src/xend_internal.h: declare
+       xenDaemonListDomains non static
+       * src/xen_unified.c: prefer xenStoreListDomains over
+       xenHypervisorListDomains for xenUnifiedListDomains

Can you provide the output of the following 3 commands, running as root:

  virsh list --all
  xm list --long
Comment 2 tgraves_cs 2009-05-15 15:27:39 EDT
actually the issue I was seeing was due to ghost ids in the xenstore and libvirt not properly ignoring them.  When you shutdown a domU, the domid is just marked as cancelled in the xenstore and then when you restart it, it creates a new domid and entry into the xenstore.   The libvirt code was just taking the first ones it comes to which are invalid and thus why virsh list wasn't displaying any that you stop and start. I'm using xen 3.3.1.  I'm using hvm domU's and it works fine with this patch. Do we know which versions of xen he had issues with?

It maybe that we should really fix the code that parses the xenstore output to handle that properly.  the domU being manipulated here is the testrhel4.vmnet.com. You'll notice it doesn't show up in the virsh list --all.

I'm attaching output of xen list --long and xenstore-ls

xm list 
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0   925     2     r-----   1437.4
jeffbsd6.vmnet.com                     1   256     1     -b----   1697.0
jeffrhel4.vmnet.com                    2   256     1     -b----   3151.3
testrhel1.vmnet.com                        256     1                39.5
testrhel4.vmnet.com                    5   256     1     -b----     44.2
tomfreey.vmnet.com                     4   256     1     -b----   1819.6

virsh list --all
 Id Name                 State
  0 Domain-0             running
  1 jeffbsd6.vmnet.com idle
  2 jeffrhel4.vmnet.com idle
  4 tomfreey.vmnet.com idle
  - testrhel1.vmnet.com shut off
Comment 3 tgraves_cs 2009-05-15 15:28:09 EDT
Created attachment 344221 [details]
xenstore-ls output
Comment 4 tgraves_cs 2009-05-15 15:28:36 EDT
Created attachment 344222 [details]
xm list --long output
Comment 5 tgraves_cs 2009-05-15 15:30:53 EDT
In the bugfix listed when xm list not showing all domains?
Comment 6 Cole Robinson 2015-04-27 17:02:50 EDT
This is a very old bug report, I presume it's no longer valid since the code in this area has changed significantly. If anyone can still reproduce with modern libvirt, please open a new bug

Note You need to log in before you can comment on or make changes to this bug.