Anyone can introduce some primers about qemu-kvm and kvm? - qemu

I am a fresh man in kvm,qemu-kvm and kvm are both very complicated now.
Anyone can introduce some primers about qemu-kvm and kvm?
thanks very much!

KVM stands for kernel based virtual machine. it enables you to create as many number of virtual machine as you like. These machine can be of two types LVM based or Non-LVM based.
Those machine which are LVM based you can take live backup for them. for non-lvm based VM you cannot take live backup i.e. they will be paused when you take backup for them. please refer KVM home page KVM Home Page.
QEMU is a generic and open source machine emulator and virtualizer.When used as a machine emulator, QEMU can run OSes and programs made for one machine (e.g. an ARM board) on a different machine (e.g. your own PC). By using dynamic translation, it achieves very good performance. When used as a virtualizer, QEMU achieves near native performances by executing the guest code directly on the host CPU. QEMU supports virtualization when executing under the Xen hypervisor or using the KVM kernel module in Linux. When using KVM, QEMU can virtualize x86, server and embedded PowerPC, and S390 guests.
For managing the KVM VM's you need to install Libvirt which is the virtualization library. It provides you the tools for starting, suspending, resuming, cloning, restarting, listing of virtual machine. Please refer Libvirt home page for more reference.
If you are working on some backup or recovery process then I suggest you to go through this excellent perl script as well it will give a fair idea of how the backup and snapshot is being taken for KVM VM's.
KVM based virtual machines are not complicated once you go through the theory of them and start implementing them. I believe once you start working on them you will find fun in managing them.

Putting in a nutshell
QEMU : An emulator which translates the instruction of guest operating system to host operating system. As you can guess that translation has a certain cost, you will not see Guest machine working as fast as host machine.
For more info see the QEMU wiki
KVM (Kernal Virtual Machine): A module in Kernel which support Virtual Machine (host operating system) in hardware. By support I mean that if your guest architecture is same as host architecture, then certainly there is no need to translate the instructions as they can directly be executed by host. For this modern hardware are equipped with special registers and storage location which is leveraged by KVM. Also KVM is a module, some driver is needed to use the KVM, which is qemu also.
For more info see the KVM section in the same wiki.
QEMU-KVM : As I above mentioned, KVM is a module only, qemu is needed (or other) to use KVM. When KVM is used with QEMU, control transfers from QEMU to KVM and vice-versa over the execution.

Talking about KVM is talking about virtualization technology or about kernel modules (kvm.ko, kvm-intel.ko or kvm-amd-ko). Sometimes KVM is mentioned as a virtual machine, this is not correct, because KVM does not provide virtualized hardware.
Source

Related

Booting a QorIQ PowerPC firmware in Qemu

I have a QorIQ (P2041) processor based IoT device firmware. I have uBoot, Kernel and initrd ramdisk. Whatever I do with qemu-system-ppc I can't get it to work. I suspect that qemu-system-ppc doesn't support QorIQ processors. Is there anyway for me to load and boot this firmware in Qemu or any other emulator?
U-Boot has configuration file qemu-ppce500_defconfig. You should be able to run the U-Boot built with this configuration using command
qemu-system-ppc -nographic -bios u-boot -M ppce500
The CPU can be specified via the -cpu parameter as e500mc.
To run your kernel it will need drivers for the hardware provided by the emulated machine like the E1000 network card and the NS16550 console.
Use the fdt command of U-Boot to get an overview of the available devices in the emulated machine.
Firmware binaries are generally very closely tied to the hardware they're built to run on -- they make assumptions about what hardware is available, what addresses in memory it can be found at, and so on. You need to use a firmware blob that corresponds to the hardware you're asking QEMU to emulate. Since QEMU doesn't emulate whatever your random IoT device is, you need to use a u-boot which matches the hardware QEMU actually has (as for example suggested in Xypron's answer).
Once you have booting firmware, you will likely still find you have exactly the same problem with the kernel -- it is built to run on one bit of hardware, and you're trying to run it on something different, and this simply won't work.

Is it feasible to utilize QEMU built-in gdbserver to debug a program running in the guest OS in QEMU?

I understand that QEMU built-in gdbserver can be used to debug kernel or bare-metal program. But I am curious that if it is possible to use QEMU built-in gdbserver to debug a program running in guest os in QEMU.
It is possible, but it won't be pleasant. Don't be surprised if execution bounces around as the kernel services external interrupts, and switches to other tasks. I'd recommend using a normal user-mode debugger inside the VM if possible.

Verifying CUDA-Capable GPU in Ubuntu

I downloaded and installed CUDA-7.5 and found that instruction that I need to check whether I have a CUDA-Capable GPU.
I did as
lin#lin-VirtualBox:/opt/caffe$ sudo update-pciids
Downloaded daily snapshot dated 2015-09-07 03:15:01
then why I type
lspci | grep -i nvidia
nothing comes out.
lin#lin-VirtualBox:/opt/caffe$ lspci | grep -i nvidia
lin#lin-VirtualBox:/opt/caffe$
I have NVIDIA graphic card GEFORCE GT750M.
What could be wrong?
My OS is Ubuntu14.04.
Thanks
It seems you are running in a VirtualBox VM (virtual machine) instance. With a typical VirtualBox setup, the graphics in the VM is virtualized; there is no physical GPU device present in the VM.
As a result, the GPU does not show up when you run lspci in the VM.
One possible approach to work around this would be to switch to a "baremetal" config; i.e. load Ubuntu directly on your laptop as the primary (or "host") OS, rather than in a VM. The GPU should show up that way.
Another possible approach would be to attempt to use VirtualBox PCI Passthrough to make the GPU "visible" in the VM. Whether or not this would work in a laptop scenario I don't know; there may be side effects of trying to pass through the laptop GPU to a VM; your laptop hypervisor and any other OS's would not have access to the GPU (or the laptop display) in this situation. I think there are a number of other requirements and restrictions with this approach. Your laptop hardware may or may not meet the requirements, and I think it is expected that the host OS uses some specific flavors of linux (kernel); you may have windows as the host OS on your laptop.
In any event, how to configure your machine with VirtualBox and/or PCI Passthrough is not a programming question, and I think is off-topic for SO. You might try askubuntu or another similar forum, for related questions.

Python3: How do I get a warning that server memory is running out?

I'm writing a program that manages data entered by users. I plan to open a test version to the public and have no idea how many users there may be.
I want my program to test when memory is getting low so that I know when to buy more server space and so that I can automatically restrict data entry when necessary. What's a good way to detect memory shortage? Allocate garbage space temporarily to get the exception? Is there a better way?
This may be best accomplished outside of your application using a performance monitoring tool. Windows Server can be configured to do this for you; see this question. There are other tools out there that help you monitor your servers, and I advise you to use an existing system unless you absolutely have to do this with Python.
If you must absolutely do this using Python, then have a look at the psutil library:
psutil (python system and process utilities) is a cross-platform
library for retrieving information on running processes and system
utilization (CPU, memory, disks, network) in Python. It is useful
mainly for system monitoring, profiling and limiting process resources
and management of running processes. It implements many
functionalities offered by command line tools such as: ps, top, lsof,
netstat, ifconfig, who, df, kill, free, nice, ionice, iostat, iotop,
uptime, pidof, tty, taskset, pmap. It currently supports Linux,
Windows, OSX, FreeBSD and Sun Solaris, both 32-bit and 64-bit
architectures, with Python versions from 2.4 to 3.4. Pypi is also
known to work.
You may combine this with the email package to send the alerts.

Can you Program/Test CUDA in a Virtual Machine?

I ask this as a programming and environment question. Can you test/program CUDA within a virtual machine accessing the physical GPU card?
I am buying a new (really nice system) to, in part, experiment with basic CUDA programming. The processor will be an Intel i7-4770 which supports VT-d (direct IO pass-through) OR a i7-4770K which does not. Will the VT-d support allow access to the GPU card from the VMs? (I have looked at Intel, motherboard mfg. sites, and docs on VMs but did not see an answer to this question.)
I plan to run Linux as my base operating system on the new development box with virtual machines (probably via QEMU/KVM) to test the software in other environments such as Windows and Mac OS. I other words, I would do the major development on the Linux box and then need to test on a virtual machine running on the same box.
But, will the VM OSs be able to access the GPU card for testing/development?
[First asked July 2013]
It depends on what NVIDIA card you're using. See for example: (this is in regards to Xen)
http://wiki.xen.org/wiki/XenVGAPassthroughTestedAdapters#Nvidia_display_adapters
The short answer is you probably would need to rely on modifying a consumer card as they link above as 'Australian crazy guy'.