Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the principle of KVM Virtualization

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "what is the principle of KVM virtualization". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the principle of KVM virtualization".

Kvm this structure contains vCPU, memory, APIC,IRQ,MMU,Event event management and other information. The information in this structure is mainly used inside the kvm virtual machine to track the status of the virtual machine.

For a kvm, it corresponds to a thread.

Kvm makes full use of hardware virtualization technology. Check the information through cat / proc/cpuinfo. If it is an intel processor, load kvm-intel.ko.

Creating a virtual machine in user mode sets up and manages kvm to the / dev/kvm character device through ioctl.

Struct kvm {

Spinlock_t mmu_lock

Spinlock_t requests_lock

Struct rw_semaphore slots_lock

Struct mm_struct * mm; / * userspace tied to this vm * /

Int nmemslots

Struct kvm_memory_slot memslots [KVM _ MEMORY_SLOTS +

KVM_PRIVATE_MEM_SLOTS]

# ifdef CONFIG_KVM_APIC_ARCHITECTURE

U32 bsp_vcpu_id

Struct kvm_vcpu * bsp_vcpu

# endif

Struct kvm_vcpu * vcpuss [KVM _ MAX_VCPUS]

Atomic_t online_vcpus

Struct list_head vm_list

Struct mutex lock

Struct kvm_io_bus mmio_bus

Struct kvm_io_bus pio_bus

# ifdef CONFIG_HAVE_KVM_EVENTFD

Struct {

Spinlock_t lock

Struct list_head items

} irqfds

Struct list_head ioeventfds

# endif

Struct kvm_vm_stat stat

Struct kvm_arch arch

Atomic_t users_count

# ifdef KVM_COALESCED_MMIO_PAGE_OFFSET

Struct kvm_coalesced_mmio_dev * coalesced_mmio_dev

Struct kvm_coalesced_mmio_ring * coalesced_mmio_ring

# endif

Struct mutex irq_lock

# ifdef CONFIG_HAVE_KVM_IRQCHIP

Struct list_head irq_routing; / * of kvm_kernel_irq_routing_entry * /

Struct hlist_head mask_notifier_list

# endif

# ifdef KVM_ARCH_WANT_MMU_NOTIFIER

Struct mmu_notifier mmu_notifier

Unsigned long mmu_notifier_seq

Long mmu_notifier_count

# endif

}

Struct kvm_vm_stat stat; is the page table, MMU and other run-time status information in the KVM virtual machine.

All the members of the kvm_x86_ops structure are function pointers, and different functions are done for their respective systems in two different modules, kvm-intel.ko and kvm-amd.ko. The KVM subsystem code will perform the actual hardware operation through this structure function.

For the fd of kvm, the vCPU of KVM can be created through the KVM_CREATE_VCPU instruction word, and the operation to obtain the vcpu_fd,vcpu_fd is mainly included in kvm_vcpu_fops. The implementation method of kvm_vcpu_fops is as follows:

Static struct file_operations kvm_vcpu_fops = {

.release = kvm_vcpu_release

.unloaded _ ioctl = kvm_vcpu_ioctl

.compat _ ioctl = kvm_vcpu_ioctl

.mmap = kvm_vcpu_mmap

}

Thank you for reading, these are the contents of "what is the principle of KVM Virtualization". After the study of this article, I believe you have a deeper understanding of what the principle of KVM Virtualization is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report