虚拟化技术比较 —— Virtualization

以下主 要列出 不影响 Ubuntu Server 性能的虚拟化技术

List of pages in CategoryVirtualization

Popular virtual machine applications

On the Ubuntu 10.04 > Ubuntu Server Guide > Virtualization

The default virtualization technology supported in Ubuntu is KVM , a technology that takes advantage of virtualization extensions built into Intel and AMD hardware . For hardware without virtualization extensions , Xen and Qemu are popular solutions.

 

KVM

Ubuntu uses KVM as the backend virtualisation technology and libvirt as its toolkit/API. Libvirt frontends for managing VMs include virt-manager (GUI) or virsh (CLI). Alternative management options include convirt (GUI) or convirt2 (WWW).

Notes

The use case targeted when KVM was moved into main is "server virtualization" . This means that even though KVM can be used to serve other purposes, it has been designed to be run on Ubuntu Server Edition to host non-graphical server operating systems . If you are looking for software to serve graphically-based virtual machines , VirtualBox , Parallels Workstation (or Parallels Desktop for Mac), or VMware Player/Server are more suitable alternatives.

 

Linux-KVM (for Kernel-based Virtual Machine ) is a full virtualization solution for Linux on x86 hardware containing virtualization extensions (Intel VT or AMD-V). It consists of a loadable kernel module , kvm.ko , that provides the core virtualization infrastructure and a processor specific module , kvm-intel.ko or kvm-amd.ko . KVM also requires a modified QEMU although work is underway to get the required changes upstream.


Using KVM, one can run multiple virtual machines running unmodified Linux or Windows images. Each virtual machine has private virtualized hardware : a network card, disk, graphics adapter, etc.

Installation

Check that your CPU supports hardware virtualization

To run KVM, you need a processor that supports hardware virtualization . Intel and AMD both have developed extensions for their processors, deemed respectively Intel VT-x (code name Vanderpool) and AMD-V (code name Pacifica). To see if your processor supports one of these, you can review the output from this command:

egrep -c '(vmx|svm)' /proc/cpuinfo 

If 0 it means that your CPU doesn't support hardware virtualization.

If 1 (or more) it does - but you still need to make sure that virtualization is enabled in the BIOS.

 

 

 

LXC

Linux Containers (LXC) provide lightweight virtualization that lets you isolate processes and resources without the need to provide instruction interpretation mechanisms and other complexities of full virtualization.

Notes

 

  • Upstream libvirt support LXC.
  • KVM + LXC can function properly on same host.
  • LXC inside KVM works properly on same host.
  • LXC take advantage of KMS feature of new Kernels.
  • 64bit OS using a 32bit container.
  • LXC works well with btrfs.
  • No special hardware required.
  • No patch is required to the kernel, since LXC is already integrated into the Kernel .
  • OpenVZ Containers run on LXC, only Config modification required.

 

Xen

Xen is an open-source virtual machine layer which runs on the bare hardware , allowing multiple operating systems to run on the same hardware at the same time . It does this without emulation or instruction translation, and provides near-native ( ~97% ) CPU performance.


Xen is optimized for servers -- running many instances of Linux or other operating systems, each with their own kernel, securely and cleanly partitioned from each other, on one piece of server hardware . If you just want to run a virtual instance of windows on your workstation, then KVM or VirtualBox is probably what you want instead.


Xen is what has made " cloud computing " possible, including Amazon's EC2 . One of Xen's strengths is the ability to make this old hardware (circa Pentium III or later) usable again in a modern data center.


Server Virtualization with the Xen Hypervisor

 

Xen Cloud Platform - Advanced Virtualization Infrastructure for the Clouds

 

 

### 半虚拟化(Para-Virtualization)的概念 半虚拟化是一种虚拟化技术,其中客户机操作系统知道自己正在运行在一个虚拟环境中,并对其进行定制化修改以更好地与 Hypervisor 配合工作[^1]。这种方式的主要特点是客户机操作系统需要针对虚拟化环境进行特定的调整和优化。 --- ### 半虚拟化的工作原理 在半虚拟化中,Hypervisor 提供了一组接口(API),这些接口允许客户机操作系统直接调用底层硬件资源而无需完全模拟整个物理平台[^3]。以下是具体的工作流程: 1. **通信机制** 客户机操作系统通过专门设计的驱动程序与 Hypervisor 进行交互。这种驱动通常被称为“半虚拟化驱动”,它能够绕过传统的 I/O 模拟过程,从而减少开销并提高效率[^4]。 2. **共享内存页** 在某些情况下,Hypervisor 和客户机之间会使用共享内存页来进行高效的数据交换。例如,在网络传输过程中,数据可以直接从客户机的缓冲区传递到实际的网络设备中,而不必经历多次拷贝[^4]。 3. **中断处理优化** 对于中断请求,半虚拟化系统可以通过预先定义好的协议快速响应,而不是依赖复杂的仿真逻辑。这进一步降低了延迟并提升了整体性能[^1]。 4. **典型实现——Virtio** Virtio 是一种广泛应用于 KVM/QEMU 平台上的半虚拟化框架。它提供了一系列标准化的抽象层,使得不同类型的设备(如磁盘、网络适配器等)都可以基于统一的标准被有效管理[^2]。为了支持 virtio 技术,不仅宿主机端需要加载相应的模块,而且客户端也需要安装匹配版本的驱动程序。 --- ### 性能对比与其他特性分析 相比全虚拟化而言,虽然半虚拟化要求对目标 OS 做适当改造,但它显著减少了因频繁上下文切换以及冗余指令执行所带来的额外负担[^1]。然而这也意味着并非所有的未加修改的操作系统都能无缝迁移到此类平台上运行。 另外值得注意的是,尽管现代 CPU 往往内置了诸如 Intel VT-x 或 AMD-V 这样的硬件加速功能来简化全虚拟化的部署难度,但对于追求极致效能的应用场景来说,采用 Para-Virtualization 方案仍然具有不可替代的优势。 ```python # 示例代码展示如何检测当前 Linux 系统是否启用了 Virtio 磁盘驱动 import os def check_virtio_block(): path = "/sys/class/block/vda/device/driver" if os.path.exists(path): with open(os.path.join(path, "name"), 'r') as f: driver_name = f.read().strip() return True if "virtio" in driver_name else False return False print("Is Virtio Block Driver Active:", check_virtio_block()) ``` --- ####
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值