WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud
  • Tanzu
    • Application Modernization
    • Tanzu services
    • Tanzu Community Edition
    • Tanzu Kubernetes Grid
    • vSphere with Tanzu
  • Home Lab
  • Nested Virtualization
  • Apple
You are here: Home / Automation / Power off VM from Guest OS Reboot capability in vSphere 8

Power off VM from Guest OS Reboot capability in vSphere 8

09.26.2022 by William Lam // 3 Comments

In 2019, a new VM advanced setting called vmx.reboot.PowerCycle was introduced and greatly simplified the remediation of CPU vulnerabilities for our customers. The operational challenge that came with applying CPU microcode updates was that all running VMs on an ESXi host would need to go through a complete power cycle (power off and power back on) before the guest operating system(s) would be fully protected.

The new VM setting would notify ESXi to convert a guest operating system reboot into a VM power cycle operation, which aligns nicely when an organization applies a guest OS update or patch and the guest OS is then rebooted afterwards. The benefit to our customers is that the remediation of CPU vulnerabilities can co-exists with an organizations existing maintenance window and the OS is remediated through a regular guest OS reboot. From the guest OS point of view, nothing has changed, it still sees a reboot but from the VM virtual hardware point of view, a complete power cycle has occurred. A very cool and innovative solution if you ask me!?

The reason for this background, there is another use case that has also been operationally challenging which is upgrading the VM Compatibility, also known as VM Virtual Hardware. A VM must be powered off before you can change the VM Compatibility and a simliar challenge arises with coordinating the downtime of a VM with application owners/teams. What if we had a simliar capability like the guest OS reboot triggering a power cycle, but instead of power cycling the VM, it would simply power it off?

Well, we now have this new capability in both vSphere 8 and VMware Cloud on AWS with the latest 1.20 release and as the title suggests, it is about powering off a VM from a guest OS reboot. Before we dive in and see how this feature works, I do want to acknowledge that this feature was a result of a feature enhancement that was submitted by Patrick Kremer, who many of you know in the VMware Community. While Patrick is no longer with VMware, it was certainly nice to see his feature request get implemented and now made available to customers! I also had the opportunity to work with the VMware Engineer who implemented the feature and through early testing and feedback, he was able to improve the user experience from the original request.

So how does it work? In vSphere 8, a new API property is introduced for the VM managed object called rebootPowerOff which is a boolean that specifies whether this capability is enabled or not. If enabled, which can only be applied to a VM when it is powered on, will notify ESXi to convert the guest operating system reboot into a VM powered off operation.

Here is the quick PowerCLI snippet to reconfigure a VM and enable the rebootPowerOff property:

$vm = Get-VM "Test"
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.rebootPowerOff = $true
$vm.ExtensionData.ReconfigVM_Task($spec)

Note: A new version of PowerCLI will be required that understands the new API property, but the snippet above will work once you have an updated version of PowerCLI. In the mean time, you can use vSphere MOB and simply pass in single field called rebootPowerOff = "true" to the XML spec or you could even automate the vSphere MOB operation.

Once the rebootPowerOff flag is enabled and a guest OS reboot is performed for a VM, you will see the VM is then powered off. The rebootPowerOff property is automatically reset back to the default value of false and if you wish to enable this capability, you will need to reapply it.

You can also see the result of the guest OS reboot getting converted into a VM power off by looking at the vCenter Events for the VM as shown in the screenshot below.


In addition to powering off the VM, a new vSphere Event is also generated by vCenter for this operation called com.vmware.vim.vm.reboot.powerOff and this can then be easily consumed by the VMware Event Broker Appliance (VEBA) solution to automatically upgrade to the desired VM Compatibility when this event occurs, further reducing the operational overhead and simplifying VM Compatibility management or any other offline VM reconfiguration that requires a VM to be powered off completely.

More from my site

  • Quick Tip - How to deploy vCenter Server Appliance (VCSA) to legacy CPU without VMX Unrestricted Guest feature?
  • Quick Tip - Automating allowed and not allowed Datastores for use with vSphere Cluster Services (vCLS)
  • How to bootstrap vSAN Express Storage Architecture (ESA) on unsupported hardware?
  • Nested ESXi installation using HTTPS boot over VirtualEFI in vSphere 8
  • ACPI motherboard layout requires EFI - Considerations for switching VM firmware in vSphere 8 

Categories // Automation, vSphere 8.0 Tags // com.vmware.vim.vm.reboot.powerOff, vSphere 8.0

Comments

  1. Claudio says

    09/26/2022 at 9:41 am

    Ok, but...
    Is the VM automatically powered on back again after this rebootpoweroff?

    Reply
    • William Lam says

      09/26/2022 at 9:46 am

      No. If you need that, then see other setting which I described at beginning of the post. This new setting is for different use case and if you really need it powered on, use VEBA 🙂

      Reply
  2. iwik says

    10/11/2022 at 2:33 am

    On the reboot event, we just need to make snapshot, upgrade VM compatibility and then automatically remove snapshot after few days. This is impossible currently. Upgrade VM compatibility can be scheduled on reboot, which is great, but it can't do snapshot. And Lifecycle manager can do rest, but it does not allow to schedule it on vm reboot event.
    I am looking at VEBA, but it is like took atom bomb to kill one bird.

    Reply

Thanks for the comment! Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Author

William Lam is a Senior Staff Solution Architect working in the VMware Cloud team within the Cloud Infrastructure Business Group (CIBG) at VMware. He focuses on Cloud Native technologies, Automation, Integration and Operation for the VMware Cloud based Software Defined Datacenters (SDDC)

Connect

  • Email
  • GitHub
  • LinkedIn
  • RSS
  • Twitter
  • Vimeo

Recent

  • How to disable the Efficiency Cores (E-cores) on an Intel NUC? 03/24/2023
  • Changing the default HTTP(s) Reverse Proxy Ports on ESXi 8.0 03/22/2023
  • NFS Multi-Connections in vSphere 8.0 Update 1 03/20/2023
  • Quick Tip - How to download ESXi ISO image for all releases including patch updates? 03/15/2023
  • SSD with multiple NVMe namespaces for VMware Homelab 03/14/2023

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2023

 

Loading Comments...