KVM本身并不提供半虚拟化功能,是通过virtio来实现的

The benefits of virtio drivers are of lower overhead and higher performance.

Memory Ballooning (virtio_balloon)

memory ballooning可以动态调整guest的内存的大小

如果有-m参数,则向更大的内存调整时无效的,但是可以往小的里面调整

我们首先ssh到guest里面

ip netns exec qrouter-26a45e0e-a58a-443b-a972-d62c0c5a1323 ssh -i openstack.pem ubuntu@192.168.0.35

在虚拟机里面看内存的大小

ubuntu@testinject19:~$ free
             total       used       free     shared    buffers     cached
Mem:       2051748     478276    1573472          0      46620     345908
-/+ buffers/cache:      85748    1966000
Swap:            0          0          0

在Monitor上看balloon的大小

root:/home/cliu8# virsh qemu-monitor-command instance-00000024 --hmp "info balloon"
balloon: actual=2048

我们试图往大里调整

root:/home/cliu8# virsh qemu-monitor-command instance-00000024 --hmp "balloon 4096"

发现无效

root:/home/cliu8# virsh qemu-monitor-command instance-00000024 --hmp "info balloon"
balloon: actual=2048

ubuntu@testinject19:~$ free
             total       used       free     shared    buffers     cached
Mem:       2051748     478276    1573472          0      46628     345920
-/+ buffers/cache:      85728    1966020
Swap:            0          0          0

我们往小里调整内存

root:/home/cliu8# virsh qemu-monitor-command instance-00000024 --hmp "balloon 1024"

发现生效了

root:/home/cliu8# virsh qemu-monitor-command instance-00000024 --hmp "info balloon"
balloon: actual=1024

ubuntu@testinject19:~$ free
             total       used       free     shared    buffers     cached
Mem:       1003172     470796     532376          0      46636     345920
-/+ buffers/cache:      78240     924932
Swap:            0          0          0

有了balloon,如果guest需要更多的RAM,则可以给它增加一些内存。如果guest不需要那么多内存,可以通过balloon从中拿出一部分内存。这个过程,不需要启停虚拟机。

balloon driver像是一个特殊的process,运行在guest机器上,它可以扩大自己的内存,使得其他的应用程序的内存减少,也可以缩小内存,使得其他的应用程序内存增加。

guest中的balloon driver通过virtio channel和host进行交互,接收host发来的命令,比如发来的命令式减少内存,则balloon driver就扩大它的内存占有量。

然后balloon driver将自己占有的内存交回给host,使得host有了更多的内存。

对于libvirt而言,有currentMemory和maxMemory两种概念,maxMemory就是-m参数设定的,currentMemory就是balloon设定的。

Para-virtualized network interface cards (virtio_net)

-netdev tap,fd=32,id=hostnet0,vhost=on,vhostfd=37
-device virtio-net-pci,netdev=hostnet0,id=net0,mac=fa:16:3e:d1:2d:99,bus=pci.0,addr=0x3

Para-virtualized block devices (virtio_blk)

-drive file=/var/lib/nova/instances/1f8e6f7e-5a70-4780-89c1-464dc0e7f308/disk,if=none,id=drive-virtio-disk0,format=qcow2,cache=none
-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1

QEMU KVM Libvirt手册(8): 半虚拟化设备virtio的更多相关文章

  1. QEMU KVM Libvirt手册(7): 硬件虚拟化

    在openstack中,如果我们启动一个虚拟机,我们会看到非常复杂的参数 qemu-system-x86_64 -enable-kvm -name instance-00000024 -S -mach ...

  2. QEMU KVM Libvirt手册(11): Managing Storage

    When managing a VM Guest on the VM Host Server itself, it is possible to access the complete file sy ...

  3. QEMU KVM Libvirt手册(10):Managing Virtual Machines with libvirt

    libvirt is a library that provides a common API for managing popular virtualization solutions, among ...

  4. QEMU KVM libvirt 手册(1): 安装

    安装 对虚拟化的支持通常在BIOS中是禁掉的,必须开启才可以. 对于Intel CPU,我们可以通过下面的命令查看是否支持虚拟化. # grep "vmx" /proc/cpuin ...

  5. QEMU KVM libvirt手册(4) – images

    RAW raw是默认的格式,格式简单,容易转换为其他的格式.需要文件系统的支持才能支持sparse file 创建image # qemu-img create -f raw flat.img 10G ...

  6. QEMU KVM libvirt 手册(3) - Storage Media

    访问Hard Drive 使用-hda –hdb qemu-system-x86_64 -enable-kvm -name ubuntutest  -m 2048 -hda ubuntutest.im ...

  7. QEMU KVM Libvirt手册(10): KVM的各种限制

    Overcommits KVM allows for both memory and disk space overcommit. However, hard errors resulting fro ...

  8. QEMU KVM Libvirt手册(5) – snapshots

    前面讲了QEMU的qcow2格式的internal snapshot和external snapshot,这都是虚拟机文件格式的功能. 这是文件级别的. 还可以是文件系统级别的,比如很多文件系统支持s ...

  9. QEMU KVM libvirt手册(2): monitor

    Administrating Virtual Machines with QEMU Monitor When QEMU is running, a monitor console is provide ...

随机推荐

  1. docker简单介绍---部署私有docker仓库Registry

    1. 关于Registry 官方的Docker hub是一个用于管理公共镜像的好地方,我们可以在上面找到我们想要的镜像,也可以把我们自己的镜像推送上去.但是,有时候,我们的使用场景需要我们拥有一个私有 ...

  2. Helloworld——SpringMVC

    搭建环境:eclipse 这里需要配置Server runtime environment——Apache Tomcat 到官网下载 解压 在eclipse中: Window perferences ...

  3. java - day007 - 继承(2), 多态,面向对象,抽象类

    继承 新建子类对象是,先新建父类对象,并执行父类的构造方法, 默认执行父类的无参构造放方法 可以 手动调用父类的有参构造 super(参数 ) super super.xxx() 调用父类成员 一般重 ...

  4. [转]Go里面的unsafe包详解

    Golang的unsafe包是一个很特殊的包. 为什么这样说呢? 本文将详细解释. 来自go语言官方文档的警告 unsafe包的文档是这么说的: 导入unsafe的软件包可能不可移植,并且不受Go 1 ...

  5. 分布式队列神器 Celery

    Celery 是什么? Celery 是一个由 Python 编写的简单.灵活.可靠的用来处理大量信息的分布式系统,它同时提供操作和维护分布式系统所需的工具. Celery 专注于实时任务处理,支持任 ...

  6. php 通过curl header传值

    下面是自己整理的通过curl  header传值 方式是post $url = 'http://www.***.com';//此处为传值需要访问的地址 $header = array('token:J ...

  7. cmake编译opencv时指定cuda版本

    之前有网友提问说,基于cmake编译时如果切换cuda版本,比如我同时装了cuda8和cuda9,opencv总是找到cuda9,我想用cuda8怎么办?实际上,手头上要配置的工程是基于opencv3 ...

  8. 独立版Jexus配置SSL,支持https访问

    一.申请证书[腾讯免费证书] 二.验证DNS,即解析域名.记录类型选择 TXT ,主机记录与证书上的主机记录保持一致,记录值也与证书上的记录值保持一致 三.等待DNS验证与CA轮询,轮询成功后即可下载 ...

  9. Keep-Alive 是什么?

    Keep-Alive 是什么? 概观 默认情况下,HTTP链接通常在请求完成之后关闭.这意味着服务端在完成响应的交付之后便关闭了TCP链接.为了让链接保持打开,来满足多请求,可以使用keep-aliv ...

  10. python常见排序算法解析

    python——常见排序算法解析   算法是程序员的灵魂. 下面的博文是我整理的感觉还不错的算法实现 原理的理解是最重要的,我会常回来看看,并坚持每天刷leetcode 本篇主要实现九(八)大排序算法 ...