RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1460677 - [RFE] Enable dynamic configuration of powercycle event actions
Summary: [RFE] Enable dynamic configuration of powercycle event actions
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.5
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: rc
: ---
Assignee: Pavel Hrdina
QA Contact: jiyan
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-06-12 11:56 UTC by Martin Betak
Modified: 2018-04-10 10:50 UTC (History)
6 users (show)

Fixed In Version: libvirt-3.9.0-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-04-10 10:48:37 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2018:0704 0 None None None 2018-04-10 10:50:02 UTC

Description Martin Betak 2017-06-12 11:56:22 UTC
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 10:03:05 UTC
Upstream commit:

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

    qemu: implement virDomainSetLifecycleAction() API

Comment 4 jiyan 2017-11-06 07:51:08 UTC
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.

Comment 8 errata-xmlrpc 2018-04-10 10:48:37 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2018:0704


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