首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在e2-microGCPVM上实现嵌套虚拟化?

如何在e2-microGCPVM上实现嵌套虚拟化?
EN

Stack Overflow用户
提问于 2019-12-17 03:49:53
回答 2查看 1.5K关注 0票数 2

我正在尝试利用Google平台(GCP)上的嵌套虚拟化功能,但是在尝试使用它时没有成功。根据GCP文件的说法,这是我遵循的程序

  1. 创建一个基于Ubuntu 18 LTS映像的新磁盘
  2. 从磁盘创建一个新映像,应用vmx许可证
  3. 从映像创建一个新的VM实例
  4. 检查是否支持嵌套虚拟化,使用Ubuntu中的cpu-checker
代码语言:javascript
复制
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,这是嵌套虚拟化工作所需的最低限度。

代码语言:javascript
复制
(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测试嵌套虚拟化,但这并不一定意味着它无法工作。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-12-17 09:11:45

我尝试过和您一样的命令,但是使用Ubuntu16.04和18.04LTS,而且我的VM一开始也不支持KVM。

我决定检查文档并再试一次:

  1. 引导磁盘(与您的相同) gcloud compute disks create disk1 --image-project ubuntu-os-cloud \ --image-family ubuntu-1804-lts --zone us-central1-a
  2. 自定义图像(与您的图像相同) 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"
  3. VMN1-标准-1(与正式文件相应) 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不支持嵌套虚拟化。

票数 4
EN

Stack Overflow用户

发布于 2019-12-17 04:26:09

这是猜测答案..。如果错了,发表评论就会被删除.

如果我们在机器类型下面查看,我们会发现以下内容:

共享核心计算机类型可在N1和E2系列中使用。这些机器类型分时度假是一个物理核心。对于运行小型、非资源密集型应用程序,这是一种成本效益高的方法.

  • N1: F1-微型和G1-小型共享核心机器类型有多达1 vCPU可用于短期爆破。
  • E2: E2-微,e2-小型和e2-中型共享核心机类型有2个vCPUs可用于短期爆破.

在你的故事里,你说你用的是e2-微型机器。我们看到,您已经选择了一种机器类型,它似乎要执行共享核处理,并且正在尝试启用嵌套虚拟化。我的直觉是,共享核心意味着运行操作系统/应用程序的CPU在运行OS/应用程序的其他用户之间浪费时间.嵌套虚拟化(我认为)的概念要求您拥有CPU的独占所有权,就像在“正常”家庭成员中发现的那样。我建议您使用N1标准-2机器类型运行您的配方,并查看您应用的相同配方是否有效。如果有的话..。然后,我们可以得出一个初步的结论,即具有共享核心处理器的微/小处理器可能不支持嵌套虚拟化。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59367377

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档