我正在尝试利用Google平台(GCP)上的嵌套虚拟化功能,但是在尝试使用它时没有成功。根据GCP文件的说法,这是我遵循的程序
cpu-checker包gcloud compute disks create disk1 --image-project ubuntu-os-cloud --image-family ubuntu-1804-lts --zone us-central1-a
gcloud compute images create nested-vm-image --source-disk disk1 --source-disk-zone us-central1-a --licenses "https://compute.googleapis.com/compute/v1/projects/vm-options/global/licenses/enable-vmx"
gcloud compute instances create firecracker --description firecracker --image nested-vm-image --zone us-central1-a --preemptible --machine-type e2-micro在运行sudo kvm-ok命令时,我收到以下消息:
信息:您的CPU不支持KVM扩展。 不能使用KVM加速
故障排除
确保我使用的是Haswell CPU
根据GCP文档,我使用gcloud compute instances describe命令确认我的e2-micro VM正在使用Intel,这是嵌套虚拟化工作所需的最低限度。
(base) ➜ ~ gcloud compute instances describe firecracker
No zone specified. Using zone [us-central1-a] for instance: [firecracker].
canIpForward: false
cpuPlatform: Intel Haswell
creationTimestamp: 'xxxxxxxxxxxxxxx'
deletionProtection: false
description: firecracker
disks:
- autoDelete: true
boot: true
deviceName: persistent-disk-0
guestOsFeatures:
- type: VIRTIO_SCSI_MULTIQUEUE
index: 0
interface: SCSI
kind: compute#attachedDisk
licenses:
- https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/licenses/ubuntu-1804-lts
- https://www.googleapis.com/compute/v1/projects/vm-options/global/licenses/enable-vmx
mode: READ_WRITE
source: https://www.googleapis.com/compute/v1/projects/xxxxxxxx/zones/us-central1-a/disks/firecracker
type: PERSISTENT
id: 'xxxxxxxxxxxxxxxxxxxxx'
kind: compute#instance
labelFingerprint: xxxxxxxxxxxxxx
machineType: https://www.googleapis.com/compute/v1/projects/xxxxxxxx/zones/us-central1-a/machineTypes/e2-micro
metadata:
fingerprint: xxxxxxxxxxxxxxx
kind: compute#metadata
name: firecracker
networkInterfaces:
- accessConfigs:
- kind: compute#accessConfig
name: external-nat
natIP: xxxxxxxxxxx
networkTier: PREMIUM
type: ONE_TO_ONE_NAT
fingerprint: xxxxxxxxxxxxxx
kind: compute#networkInterface
name: nic0
network: https://www.googleapis.com/compute/v1/projects/xxxxxxxx/global/networks/default
networkIP: xxxxxxxxxxxxxx
subnetwork: https://www.googleapis.com/compute/v1/projects/xxxxxxxx/regions/us-central1/subnetworks/default
scheduling:
automaticRestart: false
onHostMaintenance: TERMINATE
preemptible: true
selfLink: https://www.googleapis.com/compute/v1/projects/xxxxxxxx/zones/us-central1-a/instances/firecracker
serviceAccounts:
- email: xxxxxxxx@developer.gserviceaccount.com
scopes:
- https://www.googleapis.com/auth/devstorage.read_only
- https://www.googleapis.com/auth/logging.write
- https://www.googleapis.com/auth/monitoring.write
- https://www.googleapis.com/auth/pubsub
- https://www.googleapis.com/auth/service.management.readonly
- https://www.googleapis.com/auth/servicecontrol
- https://www.googleapis.com/auth/trace.append
startRestricted: false
status: RUNNING
tags:
fingerprint: xxxxxxxxxxxxxxxx
zone: https://www.googleapis.com/compute/v1/projects/xxxxxxxx/zones/us-central1-a试用Ubuntu 16.04 LTS
根据文档,我也尝试了Ubuntu16.04LTS的相同过程,并得到了与Ubuntu18.04LTS相同的结果。
问题
问题:我如何成功地构建一个支持嵌套虚拟化的GCP?据我所知,我遵循了文档的要求,但无法让它正常工作。
我意识到,这些文档并没有明确表示它们使用Ubuntu18LTS测试嵌套虚拟化,但这并不一定意味着它无法工作。
发布于 2019-12-17 09:11:45
我尝试过和您一样的命令,但是使用Ubuntu16.04和18.04LTS,而且我的VM一开始也不支持KVM。
我决定检查文档并再试一次:
gcloud compute disks create disk1 --image-project ubuntu-os-cloud \ --image-family ubuntu-1804-lts --zone us-central1-agcloud compute images create nested-vm-image \ --source-disk disk1 --source-disk-zone us-central1-a \ --licenses "https://compute.googleapis.com/compute/v1/projects/vm-options/global/licenses/enable-vmx"gcloud compute instances create example-nested-vm --zone us-central1-b \ --min-cpu-platform "Intel Haswell" \ --image nested-vm-image嵌套虚拟化工作正常:
$ grep -cw vmx /proc/cpuinfo 1 $ sudo kvm-ok INFO: /dev/kvm exists KVM acceleration can be used
它也适用于可抢占的VM:
gcloud compute instances create preemptible-nested-vm \ --zone us-central1-a --preemptible \ --min-cpu-platform "Intel Haswell" \ --image nested-vm-image
我试图在步骤3中设置另一台计算机类型,但得到了一个错误:
gcloud compute instances create e2-nested-vm --zone us-central1-a \ --machine-type e2-standard-2 \ --min-cpu-platform "Intel Haswell" \ --image nested-vm-image
ERROR: (gcloud.compute.instances.create) Could not fetch resource: - Setting minimum CPU platform is not supported for the selected machine type e2- standard-2.
但是这个命令不遵循https://cloud.google.com/compute/docs/instances/enable-nested-virtualization-vm-instances。
因此,嵌套虚拟化对于Ubuntu16.04和18.04来说是正确的,如果您一步一步地遵循指南和机器类型e2标准-2不支持嵌套虚拟化。。
发布于 2019-12-17 04:26:09
这是猜测答案..。如果错了,发表评论就会被删除.
如果我们在机器类型下面查看,我们会发现以下内容:
共享核心计算机类型可在N1和E2系列中使用。这些机器类型分时度假是一个物理核心。对于运行小型、非资源密集型应用程序,这是一种成本效益高的方法.
在你的故事里,你说你用的是e2-微型机器。我们看到,您已经选择了一种机器类型,它似乎要执行共享核处理,并且正在尝试启用嵌套虚拟化。我的直觉是,共享核心意味着运行操作系统/应用程序的CPU在运行OS/应用程序的其他用户之间浪费时间.嵌套虚拟化(我认为)的概念要求您拥有CPU的独占所有权,就像在“正常”家庭成员中发现的那样。我建议您使用N1标准-2机器类型运行您的配方,并查看您应用的相同配方是否有效。如果有的话..。然后,我们可以得出一个初步的结论,即具有共享核心处理器的微/小处理器可能不支持嵌套虚拟化。
https://stackoverflow.com/questions/59367377
复制相似问题