If you followed my last gist on how to deploy OpenStack on Hyper-V, if anyone has wondered if it is possible to run an OpenStack instance on the Hyperv hypervisor with nested virtualization, this is possible and this gist shows how to do it
The hyperv hypervisor if configured correctly with its controller, each instance launched with that hypervisor will run inside Windows, and on the Hyper-V Manager these VMs will have the name like this "instance-0000000x"
Open a PowerShell window as administrator and type the following commands
First of all get the list of all your instances:
openstack server list
+--------------------------------------+----------------+---------+----------------------+---------------------------+-----------+
| ID | Name | Status | Networks | Image | Flavor |
+--------------------------------------+----------------+---------+----------------------+---------------------------+-----------+
| 7f44ad59-6801-442c-a5b2-9b9fe67943ef | windows-server | SHUTOFF | public=192.168.1.171 | windows-server-2012-r2 | m1.medium |
| f6964e3c-294a-4f10-b82d-93e99a0892e3 | ubuntu-server | SHUTOFF | public=192.168.1.84 | ubuntu-server-jammy-amd64 | m1.small |
+--------------------------------------+----------------+---------+----------------------+---------------------------+-----------+
Now note and copy the ID of the instance for which you want to enable nested virtualization
Now let's show all the information of the current instance, we are interested in the column OS-EXT-SRV-ATTR:instance_name
Paste the ID or name of the instance in question into the command below
openstack server show <InstanceNameorID>
+-------------------------------------+---------------------------------------------------------------+
| Field | Value |
+-------------------------------------+---------------------------------------------------------------+
| OS-DCF:diskConfig | AUTO |
| OS-EXT-AZ:availability_zone | nova |
| OS-EXT-SRV-ATTR:host | WIN-A1NQ5V79E3O |
| OS-EXT-SRV-ATTR:hypervisor_hostname | WIN-A1NQ5V79E3O |
| OS-EXT-SRV-ATTR:instance_name | instance-00000012 |
| OS-EXT-STS:power_state | Shutdown |
| OS-EXT-STS:task_state | None |
| OS-EXT-STS:vm_state | stopped |
| OS-SRV-USG:launched_at | 2023-11-27T15:06:42.000000 |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | public=192.168.1.171 |
| config_drive | True |
| created | 2023-11-27T14:57:25Z |
| flavor | m1.medium (4) |
| hostId | e4ae496fc9193c8a79651363e52a76bcb194ef975fca7487edeb250a |
| id | 7f44ad59-6801-442c-a5b2-9b9fe67943ef |
| image | windows-server-2012-r2 (8f17fe68-df6d-4f40-95fb-82badc7271d4) |
| key_name | None |
| name | windows-server |
| project_id | 87585bf2461f41aea069472d353dffa1 |
| properties | |
| security_groups | name='default' |
| status | SHUTOFF |
| updated | 2023-11-27T17:07:26Z |
| user_id | 902c8ad3ca584dada6106ac1d206fc9b |
| volumes_attached | |
+-------------------------------------+---------------------------------------------------------------+
Now copy the name you find in the column OS-EXT-SRV-ATTR:instance_name
Another way to find the VM name that refers to the instance in question, you can open the Hyper-V Manager and look for the ID in the VM notes, that will be the instance ID that will match
Before doing this procedure your instance must be turned off!
Well now that we are ready we can give the actual command to enable nested virtualization on a specific instance
By entering the name found previously
To enable it type this:
Set-VMProcessor -VMName instance-0000000x -ExposeVirtualizationExtensions $true
If you want to disable it instead:
Set-VMProcessor -VMName instance-0000000x -ExposeVirtualizationExtensions $false
And after this command if everything went well, you will be able to run virtualization applications (VirtualBox, Hyper-V etc.) inside your Instance
This method can only be done if you are using a Hyperv hypervisor, it is just an exception since Hyper-V supports anidated virtualization, this way of enabling nested virtualization inside an instance in the Hyperv hypervisor is EXPERIMENTAL, and it is the same thing about having virtual machines inside virtual machines and this for a normal PC is a bit crazy, do it with caution.
Imagining if OpenStack was used by many members and users
This thing of enabling nested virtualization should only be done by the local administrator, perhaps following a request from one of his members who wants to enable nested virtualization from one of his instances, but this cannot be done in any way directly from OpenStack, I recommend I strongly recommend using Bare Metal machines and not a simple PC