Bug 1460677 - [RFE] Enable dynamic configuration of powercycle event actions
[RFE] Enable dynamic configuration of powercycle event actions
Status: VERIFIED
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt (Show other bugs)
7.5
Unspecified Unspecified
low Severity low
: rc
: ---
Assigned To: Pavel Hrdina
jiyan
: FutureFeature
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-06-12 07:56 EDT by Martin Betak
Modified: 2017-11-08 02:10 EST (History)
6 users (show)

See Also:
Fixed In Version: libvirt-3.9.0-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Martin Betak 2017-06-12 07:56:22 EDT
Description of problem:

when configuring a VM (before run) currently it is possible to specify the actions to be performed on certain power-cycle related events, e.g:

<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>

It would be nice if this behavior was tweakable also for running VMs. The use case is the following

1) start a VM with <on_reboot>restart</on_reboot>
2) while VM is running, be able to change the behavior to <on_reboot>destroy</on_reboot>
3) when triggered reboot from guest, the VM should correctly shut down instead
Comment 2 Pavel Hrdina 2017-10-19 06:03:05 EDT
Upstream commit:

commit d66fc71d3150cb118ead04a7976d9b67d63b000d
Author: Pavel Hrdina <phrdina@redhat.com>
Date:   Wed Oct 11 16:09:49 2017 +0200

    qemu: implement virDomainSetLifecycleAction() API
Comment 4 jiyan 2017-11-06 02:51:08 EST
Test env components:
qemu-kvm-rhev-2.10.0-4.el7.x86_64
kernel-3.10.0-768.el7.x86_64
libvirt-3.9.0-1.el7.x86_64

Test scenarios:
Scenario-1: Dynamically configure 'on_reboot' from 'restart' to 'destroy' when the guest is started with not all actions set to "destroy"
Scenario-2: Dynamically configure 'on_poweroff' from 'destroy' to 'restart' when the guest is started with not all actions set to "destroy"
Scenario-3: Try to dynamically configure 'on_poweroff' from 'destroy' to 'restart' when the guest is started with all actions set to "destroy"
Scenario-4: when the guest is started with all actions set to "destroy", try to dynamically configure 'on_reboot' from 'destroy' to 'restart'

Detailed steps for test scenarios:
Scenario-1: Dynamically configure 'on_reboot' from 'restart' to 'destroy' when the guest is started with not all actions set to "destroy"
1. prepare a shutdown vm named 'qcow2' with the following inactive configuration
# virsh domstate qcow2
shut off

# virsh dumpxml qcow2 --inactive |grep on_
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>

# virsh start qcow2
Domain qcow2 started

2. Start 'qcow2' vm, then check status of vm and the related configuration
# virsh domstate qcow2
running

# virsh dumpxml qcow2 |grep on_
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>

3. Dynamically configure 'on_reboot' from 'restart' to 'destroy' for vm and check the related configuration
# virsh set-lifecycle-action qcow2 reboot destroy

# virsh dumpxml qcow2 |grep on_
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>destroy</on_reboot>
  <on_crash>destroy</on_crash>

4. Trigger reboot for vm via virsh command and check the state of vm after 1min (ensure the command takes effect)
# virsh reboot qcow2
Domain qcow2 is being rebooted

# virsh domstate qcow2
shut off

Result: The steps above shows configuration 'on_reboot' from 'restart' to 'destroy' for vm takes effect.



Scenario-2: Dynamically configure 'on_poweroff' from 'destroy' to 'restart' when the guest is started with not all actions set to "destroy"
1. prepare a shutdown vm named 'qcow2' with the following inactive configuration
# virsh domstate qcow2
shut off

# virsh dumpxml qcow2 --inactive |grep on_
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>

2. Start 'qcow2' vm, then check status of vm and the related configuration
# virsh start qcow2
Domain qcow2 started

# virsh domstate qcow2
running

# virsh dumpxml qcow2 |grep on_
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>

3. Dynamically configure 'on_poweroff' from 'destroy' to 'restart' for vm and check the related configuration
# virsh set-lifecycle-action qcow2 poweroff restart

# virsh dumpxml qcow2 |grep on_
  <on_poweroff>restart</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>

4. Trigger shutdown for vm via virsh command and check the state of vm after 1min (ensure the command takes effect)
# virsh shutdown qcow2
Domain qcow2 is being shutdown

# virsh domstate qcow2
running

Result: The steps above shows configuration 'on_poweroff' from 'destroy' to 'restart' for vm takes effect.



Scenario-3: Try to dynamically configure 'on_poweroff' from 'destroy' to 'restart' when the guest is started with all actions set to "destroy"
1. prepare a shutdown vm named 'qcow2' with the following inactive configuration
# virsh domstate qcow2
shut off

# virsh dumpxml qcow2 --inactive |grep on_
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>destroy</on_reboot>
  <on_crash>destroy</on_crash>

2. Start 'qcow2' vm, then check status of vm and the related configuration
# virsh start qcow2
Domain qcow2 started

# virsh domstate qcow2
running

# virsh dumpxml qcow2 |grep on_
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>destroy</on_reboot>
  <on_crash>destroy</on_crash>

3. Try to dynamically configure 'on_poweroff' from 'destroy' to 'restart' 
# virsh set-lifecycle-action qcow2 poweroff restart
error: Unable to change lifecycle action.
error: Operation not supported: cannot update lifecycle action because QEMU was started with -no-reboot option

Result: The limitation that virDomainSetLifecycleAction() API cannot be changed when the guest is started with all actions set to "destroy" we put "-no-reboot" on the QEMU command line. 



Scenario-4: when the guest is started with all actions set to "destroy", try to dynamically configure 'on_reboot' from 'destroy' to 'restart'
1. prepare a shutdown vm named 'qcow2' with the following inactive configuration
# virsh domstate qcow2
shut off

# virsh dumpxml qcow2 --inactive |grep on_
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>destroy</on_reboot>
  <on_crash>destroy</on_crash>

2. Start 'qcow2' vm, then check status of vm and the related configuration
# virsh start qcow2
Domain qcow2 started

# virsh domstate qcow2
running

# virsh dumpxml qcow2 |grep on_
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>destroy</on_reboot>
  <on_crash>destroy</on_crash>

3. Try to dynamically configure 'on_reboot' from 'destroy' to 'restart'
# virsh set-lifecycle-action qcow2 reboot restart
error: Unable to change lifecycle action.
error: Operation not supported: cannot update lifecycle action because QEMU was started with -no-reboot option

Result: The limitation that virDomainSetLifecycleAction() API cannot be changed when the guest is started with all actions set to "destroy" we put "-no-reboot" on the QEMU command line. 

All the results are as expected, move this bug to be verified.

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