Bug 906644

Summary: Libvirt should enhance check for domain status before doing suspend and resume
Product: Red Hat Enterprise Linux 6 Reporter: Alex Jia <ajia>
Component: libvirtAssignee: John Ferlan <jferlan>
Status: CLOSED WONTFIX QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.4CC: acathrow, dyasny, dyuan, eblake, mzhan, rwu
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-04-16 12:03:39 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Alex Jia 2013-02-01 05:44:03 UTC
Description of problem:
I can repeat to run virsh suspend or resume for a running or paused guest, and also can get the same result "Domain XXX suspended" and "Domain XXX resumed" each time, I have never thought it's a question before, but if a guest is paused status then I'm successfully suspending a paused status guest? I think libvirt should check if a guest is paused status before doing suspend, if so, it should raise a friendly message to users such as "error: Domain is already paused", similarly, "error: Domain is already active" for virsh resume a running guest.


Version-Release number of selected component (if applicable):
# rpm -q libvirt
libvirt-0.10.2-18.el6.x86_64


How reproducible:
always

Steps to Reproduce:
1. virsh start <domain>
2. virsh suspend <domain>
3. repeat 2
4. virsh resume <domain>
5. repeat 4
  
Actual results:

# virsh list
 Id    Name                           State
----------------------------------------------------
 133   foo                            running

# virsh suspend foo
Domain foo suspended

# virsh list
 Id    Name                           State
----------------------------------------------------
 133   foo                            paused

# virsh suspend foo
Domain foo suspended

# virsh list
 Id    Name                           State
----------------------------------------------------
 133   foo                            paused

# virsh resume foo
Domain foo resumed

# virsh list
 Id    Name                           State
----------------------------------------------------
 133   foo                            running

# virsh resume foo
Domain foo resumed

# virsh list
 Id    Name                           State
----------------------------------------------------
 133   foo                            running


Expected results:
To raise "error: Domain is already paused" for a paused guest for virsh suspend, similarly, "error: Domain is already active" for virsh resume a running guest.

Additional info:

Comment 2 Eric Blake 2013-04-15 17:23:30 UTC
Upstream pointed out that any rejection of a state change (because the state is already correct) would have to come from libvirtd, not virsh, in order to avoid races.  But doing that would require the addition of a new flag, which in turn would require a new virDomainSuspendFlags() and virDomainResumeFlags() API.
https://www.redhat.com/archives/libvir-list/2013-April/msg01131.html

Comment 3 John Ferlan 2013-04-16 12:03:39 UTC
As upstream notes - the state checks don't belong in virsh and the drivers make the final determination of whether to pause or resume based on properly locked and sequenced checks.