What is qemu in linux

QEMU User space emulator¶

The following OS are supported in user space emulation:

Features¶

QEMU user space emulation has the following notable features:

System call translation:

QEMU includes a generic system call translator. This means that the parameters of the system calls can be converted to fix endianness and 32/64-bit mismatches between hosts and targets. IOCTLs can be converted too.

POSIX signal handling:

QEMU can redirect to the running program all signals coming from the host (such as SIGALRM ), as well as synthesize signals from virtual CPU exceptions (for example SIGFPE when the program executes a division by zero).

QEMU relies on the host kernel to emulate most signal system calls, for example to emulate the signal mask. On Linux, QEMU supports both normal and real-time signals.

On Linux, QEMU can emulate the clone syscall and create a real host thread (with a separate virtual CPU) for each emulated thread. Note that not all targets currently emulate atomic operations correctly. x86 and Arm use a global lock in order to preserve their semantics.

QEMU was conceived so that ultimately it can emulate itself. Although it is not very useful, it is an important test to show the power of the emulator.

Linux User space emulator¶

Command line options¶

qemu-i386 [-h] [-d] [-L path] [-s size] [-cpu model] [-g port] [-B offset] [-R size] program [arguments. ] 

Set the x86 elf interpreter prefix (default=/usr/local/qemu-i386)

Set the x86 stack size in bytes (default=524288)

Select CPU model (-cpu help for list and additional feature selection)

Set environment var to value.

Remove var from the environment.

Offset guest address by the specified number of bytes. This is useful when the address region required by guest applications is reserved on the host. This option is currently only supported on some hosts.

Pre-allocate a guest virtual address space of the given size (in bytes). «G», «M», and «k» suffixes may be used when specifying the size.

Activate logging of the specified items (use ‘-d help’ for a list of log items)

Act as if the host page size was ‘pagesize’ bytes

Wait gdb connection to port

Run the emulation with one guest instruction per translation block. This slows down emulation a lot, but can be useful in some situations, such as when trying to analyse the logs produced by the -d option.

This is a deprecated synonym for the -one-insn-per-tb option.

Print system calls and arguments similar to the ‘strace’ program (NOTE: the actual ‘strace’ program will not work because the user space emulator hasn’t implemented ptrace). At the moment this is incomplete. All system calls that don’t have a specific argument format are printed with information for six arguments. Many flag-style arguments don’t have decoders and will show up as numbers.

Читайте также:  Intel graphics for linux mint

Other binaries¶

  • user mode (Alpha)
    • qemu-alpha TODO.
    • qemu-armeb TODO.
    • qemu-arm is also capable of running Arm «Angel» semihosted ELF binaries (as implemented by the arm-elf and arm-eabi Newlib/GDB configurations), and arm-uclinux bFLT format binaries.
    • qemu-m68k is capable of running semihosted binaries using the BDM (m5xxx-ram-hosted.ld) or m68k-sim (sim.ld) syscall interfaces, and coldfire uClinux bFLT format binaries.

    The binary format is detected automatically.

    • qemu-cris TODO.
    • qemu-i386 TODO.
    • qemu-x86_64 TODO.
    • qemu-microblaze TODO.
    • qemu-mips executes 32-bit big endian MIPS binaries (MIPS O32 ABI).
    • qemu-mipsel executes 32-bit little endian MIPS binaries (MIPS O32 ABI).
    • qemu-mips64 executes 64-bit big endian MIPS binaries (MIPS N64 ABI).
    • qemu-mips64el executes 64-bit little endian MIPS binaries (MIPS N64 ABI).
    • qemu-mipsn32 executes 32-bit big endian MIPS binaries (MIPS N32 ABI).
    • qemu-mipsn32el executes 32-bit little endian MIPS binaries (MIPS N32 ABI).
    • qemu-nios2 TODO.
    • qemu-ppc64 TODO.
    • qemu-ppc TODO.
    • qemu-sh4eb TODO.
    • qemu-sh4 TODO.
    • qemu-sparc can execute Sparc32 binaries (Sparc32 CPU, 32 bit ABI).
    • qemu-sparc32plus can execute Sparc32 and SPARC32PLUS binaries (Sparc64 CPU, 32 bit ABI).
    • qemu-sparc64 can execute some Sparc64 (Sparc64 CPU, 64 bit ABI) and SPARC32PLUS binaries (Sparc64 CPU, 32 bit ABI).

    BSD User space emulator¶

    BSD Status¶

    Quick Start¶

    In order to launch a BSD process, QEMU needs the process executable itself and all the target dynamic libraries used by it.

      On Sparc64, you can just try to launch any process by using the native libraries:

    Command line options¶

    qemu-sparc64 [-h] [-d] [-L path] [-s size] [-bsd type] program [arguments. ] 

    Set the library root path (default=/)

    Set the stack size in bytes (default=524288)

    Start with an empty environment. Without this option, the initial environment is a copy of the caller’s environment.

    Set environment var to value.

    Remove var from the environment.

    Set the type of the emulated BSD Operating system. Valid values are FreeBSD, NetBSD and OpenBSD (default).

    Activate logging of the specified items (use ‘-d help’ for a list of log items)

    Act as if the host page size was ‘pagesize’ bytes

    Run the emulation with one guest instruction per translation block. This slows down emulation a lot, but can be useful in some situations, such as when trying to analyse the logs produced by the -d option.

    This is a deprecated synonym for the -one-insn-per-tb option.

    © Copyright 2023, The QEMU Project Developers.

    This documentation is for QEMU version 8.0.50.

    Источник

    Installation / QemuEmulator

    QEMU creates a virtual machine, similar to VMWare, Virtualbox, KVM, and Xen. It allows you to run one operating system from within another operating system. The operating systems can be the same ones, or different. Your memory resources will be divided between your native (host) OS and your virtual machine (guest) OS. You will therefore notice a decrease in performance of activities in both the host OS and the guest OS.

    Therefore, if you plan to use QEMU only to create a Windows virtual environment in order to run Windows programs, consider using one of several free Linux SoftwareEquivalents instead. If you need to run only a single Windows program, also consider using Wine instead of QEMU. Running a virtual machine environment such as QEMU will slow down your computer noticeably.

    Also consider trying a QEMU interface, such as Qemulator, or the package qemu-launcher.

    Another QEMU GUI is virt-manager. It manages virtual machines not only for QEMU, but also for kvm and xen, in a consistent fashion (through libvirt).

    What is QEMU ?

    • User mode emulation: QEMU can launch individual Linux processes compiled for one CPU on another CPU.
    • Full system emulation: QEMU can emulate a full system, including the processor and peripherals. This enables testing and debugging of system code in a contained (and quarantined) virtual system. It can even be used to host several virtual machines simultaneously on a single server (given enough host processor power and RAM).

    As QEMU requires no host kernel patches to run, it is safe and easy to use.

    Why use an emulator?

    QEMU emulates everything, including the CPU, so it is slower than the host system. Hardware acceleration will not be as effective for a software OS emulator. Nevertheless, it is a pretty good way of testing a distribution, without having to repartition your drive or set up new hardware.

    Preparation of the QEMU virtual environment

    • QEMU is available as a standard package in the Universe repository. (There are on how to install packages elsewhere in this guide. Unlike some other virtualization systems (like VMWare), separate kernel modules are not needed.
    • Download the Ubuntu ISO file you wish to install into a virtual QEMU environment.
    • Recent QEMU versions support networking out of the box. There is a «linux-test» add-on at QEMU’s site, a one-line script. Alternatively, run this command before starting the emulator: sudo /sbin/ip addr add 172.20.0.1/12 dev eth0
    • A virtual disk is needed for the virtual machine. A virtual disk is made by creating a file of a size appropriately large to contain the full guest OS:

    qemu-img create ubuntu-test 3G

    The ‘qemu-img command (included in the QEMU package) creates a 3Gb image named ‘ubuntu-test’. (qemu-img also supports other compressed and VMWare compatible disk-image formats.)

    Another way of creating such images is using the standard dd utility:

    dd of=ubuntu-test bs=1024 seek=4194304 count=0

    This will create a 4GB file named ubuntu-test to use as a disk. bs is the blocksize, seek is the number of bytes to skip from start of the file being created (a multiple of 1048576 (or 1024K) ). In this case the image would be 4GB. If you wish to get a number to create another size, multiply the number of GB desired by 1024^2 or 1048576. So , 10GB would be 10×1048576 = 10485760.

    Installation of an operating system from ISO to the QEMU environment

    We are ready to install the guest OS. Download, for example, the latest development version of Ubuntu. Assuming your ISO image is named ubuntu-6.10-desktop-i386.iso for example:

    • This command instructs QEMU to use hda as the empty disk file. It uses Ubuntu ISO file as if installing from the CDROM, and sets the amount of memory to use in the virtual machine to be 192Mb. It then instructs to boot from the CDROM.

    A word of caution: giving too much memory to the virtual system will make your native host machine start swapping to disk, which will slow things down a lot. On the other hand, giving it too little memory will make the virtual machine start swapping, which will slow things down as well. Clearly, the more RAM you have, the better.

    • At the end, it will try to reboot the machine, but this will fail.
    • Exit the emulator (type «quit» in the emulator console), then rerun:

    qemu -hda ubuntu-test -cdrom ubuntu-6.10-desktop-i386.iso -m 192

    • Follow the directions from the installer and create a user. The installer will then fetch updates and add additional packages. This may take between one and two hours, depending on your system configuration and options chosen.
    • At one point, it will register all documentation for the help system.
    • Graphics display and adapter setup is very easy; the only question is what video modes to support. Leave this at the defaults; the virtual video hardware may not support higher resolutions than those already set.

    Installing QEMU in Windows

    The reason to install QEMU in Windows is so that you can run an Ubuntu Server in a virtual machine. Such a virtual machine can be copied and moved.

    At this time, it is best to download the source and then compile QEMU in Windows using these instructions. Once QEMU is running in Windows, usage is the same as in Linux.

    Usage

    First of all, running an OS on emulated hardware is not screamingly, insanely fast. Don’t expect to run anything demanding on this system, other than for testing purposes. That said, even on fairly underpowered hardware, it is certainly fast enough to test a distribution, perhaps install some packages, see how it all fits together.

    This is also a good tool for increased security system management. QEMU can have a read-only disk image with a separate write-back file, so one use would be to test the installation of an intrusive packages (or test your own packages to make sure they don’t break the system) without actually touching your real system. If it turns out it breaks the system, just remove the write-back file and it never happened.

    If you have a very fast network connection, you may want to remove the -cdrom parameter for future invocations of QEMU and comment out the line starting with deb cdrom: (insert a # sign at the beginning) from the command line:

    sudo nano /etc/apt/sources.list

    Installation/QemuEmulator (последним исправлял пользователь ug-uyst-s-0003 2011-05-16 15:29:45)

    The material on this wiki is available under a free license, see Copyright / License for details
    You can contribute to this wiki, see Wiki Guide for details

    Источник

Оцените статью
Adblock
detector