Manage the nested virtualization constraint

Linux

This document describes how to check whether nested virtualization is enabled,and how to modify the boolean constraint that controls whether nestedvirtualization is enabled for your organization, project, or folder.

A boolean constraint within an organization policy determines whether you cancreate nested VMs. The boolean constraint for nested virtualization is arestriction, which means that when it is enforced, it tells the organizationpolicy to restrict the creation of nested VMs. For more information aboutboolean constraints, seeUnderstanding constraints.

TheDisable VM nested virtualization constraint is not enforced by default,so you do not have to modify any boolean constraint to enable nestedvirtualization. Even so, Google recommends explicitly setting the value of theconstraint so that your organization, folders, and projects don't rely on thedefault setting. If your project is not subordinate to an organization, theconstraint is not enforced by default and you can't change the constraint.

Before you begin

Check whether nested virtualization is allowed

Permissions required for this task

To perform this task, you must have the followingpermissions:

  • orgpolicy.policy.get on the organization, folder, or project

Check whether nested virtualization is allowed for an organization, folder, orproject by using the Google Cloud console, the Google Cloud CLI, orREST.

Console

Check whether you can create nested VMs in your organization, folder, orproject by checking if the boolean constraint for disabling nestedvirtualization is not enforced. If theDisable VM nested virtualizationconstraint is not enforced by the organization policy, then you can createnested VMs.

  1. In the Google Cloud console, go to theOrganization policies page.

    Go to Organization policies

  2. In the organization, folder, and project selector, select the entity toview the organization policies for.

  3. Select theDisable VM nested virtualization constraint to open thePolicy details page.

  4. View the value forEnforcement:

    • If the value isNot enforced, then nested virtualization isenabled, and you can create nested VMs.

    • If the value isEnforced, then nested virtualization is disabled,and you can't create nested VMs.

gcloud

Check the value of thecompute.disableNestedVirtualization booleanconstraint by using thegcloud resource-manager org-policies describecommand.

If the Google Cloud CLI output does not show a value forbooleanPolicy,then nested virtualization is allowed and you can create nested VMs.

If the Google Cloud CLI output value forbooleanPolicy isenforced: true,then the organization policy is enforcing the disable nested virtualizationconstraint and you can't create nested VMs.

gcloud resource-manager org-policies \  describe constraints/compute.disableNestedVirtualization \  (--organization=ORGANIZATION_ID | --folder=FOLDER_ID |  --project=PROJECT_ID) --effective

Replace exactly one of the following:

REST

Use REST to check the value of thecompute.disableNestedVirtualization boolean constraint, which determineswhether you can create nested VMs in your organization, folder, or project.

If the REST response doesn't return a value for"booleanPolicy"for the constraint, then nested virtualization is not disabled and you cancreate nested VMs.

If the value for"booleanPolicy" in the output is"enforced": true, thennested virtualization is disabled and you can't create nested VMs.

POST https://cloudresourcemanager.googleapis.com/v1/RESOURCE/RESOURCE_ID:getOrgPolicy{  "constraint": "compute.disableNestedVirtualization"}

Replace the following:

Modify the nested virtualization organization policy

Permissions required for this task

To perform this task, you must have the followingpermissions:

  • orgpolicy.policy.get on the organization, folder, or project
  • orgpolicy.policy.set on the organization, folder, or project

If you have the appropriate role, you can control whether an organization,folder, or project can create nested VMs. Control this enforcement by using theboolean constraint for nested virtualization.

Use the Google Cloud console, the Google Cloud CLI, or REST to enablenested virtualization for an organization, folder, or project.

Console

To enable nested virtualization, disable the enforcement of theDisable VMnested virtualization boolean constraint, and to disable nestedvirtualization, enable the enforcement of the boolean constraint.

  1. In the Google Cloud console, go to theOrganization policies page.

    Go to Organization policies

  2. In the organization, folder, and project selector, select the entity toedit the organization policies for.

  3. Select theDisable VM nested virtualization constraint to open thePolicy details page.

  4. ClickEdit, then selectCustomize.

  5. UnderEnforcement, select one of the following enforcement optionsfor theDisable VM nested virtualization boolean constraint:

    • On: enable enforcement and disable nested virtualization
    • Off: disable enforcement and enable nested virtualization
  6. ClickSave.

gcloud

Use thegcloud resource-manager org-policiescommand to enable ordisable enforcement of thecompute.disableNestedVirtualization organizationpolicy boolean constraint.

If you disable thecompute.disableNestedVirtualization constraint by usingthedisable-enforce command, then you can create VMs that have nestedvirtualization enabled.

If you enable the constraint by using theenable-enforce command, then youcan't create VMs that have nested virtualization enabled.

gcloud resource-manager org-policies \  ( disable-enforce | enable-enforce ) compute.disableNestedVirtualization \  (--organization=ORGANIZATION_ID | --folder=FOLDER_ID |  --project=PROJECT_ID)

Replace exactly one of the following:

REST

Use REST to modify the value of thecompute.disableNestedVirtualization boolean constraint, which determineswhether you can create nested VMs in your organization, folder, or project.

POST https://cloudresourcemanager.googleapis.com/v1/RESOURCE/RESOURCE_ID:setOrgPolicy{  "policy": {    "booleanPolicy": {      "enforced":ENFORCE    },    "constraint": "constraints/compute.disableNestedVirtualization"  }}

Replace the following:

  • RESOURCE: the resource to modify the organizationpolicy of. Set this to one of the following:

  • RESOURCE_ID: the organization, folder, or projecton which to check the status of the disable nested virtualizationconstraint

  • ENFORCE: determines whether the organizationpolicy enforces thecompute.disableNestedVirtualization booleanconstraint. Set to one of the following:

    • true: to enforce the constraint. With this setting you can't createVMs that have nested virtualization enabled.

    • false: to not enforce the constraint. With this setting, you cancreate VMs that have nested virtualization enabled.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.