KVM max vcpu allocation

本文探讨了KVM在内核空间如何响应ioctl系统调用来确定最大vCPU分配,详细介绍了从kvm_dev_ioctl到kvm_dev_ioctl_check_extension的调用流程,并指出了相关宏的定义位置,以及KVM字符设备操作的注册过程。
摘要由CSDN通过智能技术生成
From https://kernel.org/doc/Documentation/virtual/kvm/api.txt we can see, 


"The maximum possible value for max_vcpus can be retrieved using the 
KVM_CAP_MAX_VCPUS of the KVM_CHECK_EXTENSION ioctl() at run-time. 


If the KVM_CAP_NR_VCPUS does not exist, you should assume that max_vcpus is 4 
cpus max. 
If the KVM_CAP_MAX_VCPUS does not exist, you should assume that max_vcpus is 
same as the value returned from KVM_CAP_NR_VCPUS." 


The following c program is written according to the documentation above to retrieve KVM max vcpu directly from KVM and should give the same result as virsh maxvcpus kvm does. When given a arg "Recommended", it returns the recommended max vcpus. 


#include <stdio.h> 
#include <fcntl.h> 
#include <linux/kvm.h> 


static int kvmMaxVCPUs(int type) { 
int maxvcpus
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值