Bug 501018 - virsh list on xen broken after shutdown/restart
Summary: virsh list on xen broken after shutdown/restart
Keywords:
Status: CLOSED DEFERRED
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Libvirt Maintainers
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-05-15 14:23 UTC by tgraves_cs
Modified: 2015-04-27 21:02 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-04-27 21:02:50 UTC
Embargoed:


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

Description tgraves_cs 2009-05-15 14:23:54 UTC
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 Berrangé 2009-05-15 16:12:06 UTC
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>
+
+       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
  xenstore-ls

Comment 2 tgraves_cs 2009-05-15 19:27:39 UTC
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 19:28:09 UTC
Created attachment 344221 [details]
xenstore-ls output

Comment 4 tgraves_cs 2009-05-15 19:28:36 UTC
Created attachment 344222 [details]
xm list --long output

Comment 5 tgraves_cs 2009-05-15 19:30:53 UTC
In the bugfix listed when xm list not showing all domains?

Comment 6 Cole Robinson 2015-04-27 21:02:50 UTC
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.