What exactly is QEMU? Emulator? VM? - virtual-machine

I am trying to make a use of QEMU in my embedded software development process. I think it will be useful for me to run my code without having to touch the hardware. Especially when the software is sitting in the user-space of Linux. Now, I am trying to get my head wrapped around the big concepts in QEMU.
At what point is QEMU virtualizing the hardware? Can I assume it virtualizes x86 when the host platform is also x86 with virtualization technology built into the processor?
In other words, can I assume QEMU is emulating the hardware when the target platform is not the same as host platform?

It's a general-purpose emulator software (type 2 hypervisor) which can use virtualization when the target and hosts are of the same architecture. In Linux you need to enable the KVM kernel module to be able to use the virtualization technology of the processor.

Related

Bootloader Written for Java

Is there a boot loader written for booting Java virtual machine without an operating system? As far as I know Java virtual machine can run on a machine by itself, without help of an operating system.
Java defines the guest language, not the host / JVM.
You'd need a JVM written to run on bare-metal of whatever machine you want to run it on. (i.e. to be an OS kernel as well as a JVM, handling interrupts and so on). So there isn't something generic called "Java" that a bootloader could load.
The mainstream JVMs like OpenJDK / HotSpot are not written to work as kernels, only to run under some existing mainstream OSes. But as you found, there are some: Can you run JVM on a computer with no operating system?
Even for a specific platform, the things a kernel needs a bootloader to do may depend on the kernel. There are a few standards, like multiboot for x86, that define a kernel file format that bootloaders like GRUB know how to recognize and load, but otherwise you'd probably expect a bare-metal JVM to come with its own custom bootloader, especially if it's for a platform other than an x86 PC. Or perhaps be bootable as an "EFI application".

How can I use QEMU to simulate mixed platforms?

Backgournd
There is a lot of documentation about using QEMU for simulating a system of particular architecture (a "platform").
For example, x86, ARM or RISCV system.
The first step is to configure QEMU target-list, for example ./configure --target-list=riscv32-softmmu.
It's also possible to provide multiple targets in the target-list, but apparently that builds an independent simulation for each specified platform.
My goal, however, is to simulate a system with mixed targets: an x86 machine which also hosts a RISCV embedded processor over PCI.
Obviously I need to implement a QEMU PCI device which would host the RISCV device on the x86 platform, and
I have a good idea how to implement a generic PCI device.
However, I'm not sure about the best approach to simulate both x86 and RISCV together on the same QEMU simulation.
One approach is to run two instances of QEMU (as two separate processes) and use some sort of IPC for communicating between the x86 and the RISCV simulation.
Another possible (?) approach could be to build RISCV QEMU as a loadable library and load it from x86 QEMU.
Perhaps it's even possible to have a single QEMU application that simulates both x86 and RISCV?
Yet another approach is not to use QEMU for simulating the RISCV device. I could implement a QEMU PCI device that completely encapsulates a RISCV simulation such as tiny-emu, but I would rather use QEMU for both x86 and RISCV.
My questions are:
Are there some guidelines or examples for a mixed-target QEMU project?
I've searched for examples but only found references to using QEMU as a single platform simulation, where first you choose which platform you would like to run.
What would be the best approach for simulating a mixed platform in QEMU? Separate QEMU processes with IPC? Or is there a way to configure QEMU in such a way that it could simulates a mixed platform?
Related
https://lists.gnu.org/archive/html/qemu-devel/2021-12/msg01969.html
QEMU does not support running multiple target architectures in the same QEMU process. (This is something we would in theory like to be able to do, but it would require a lot of reworking of core parts of QEMU which assume that the target architecture is known at compile time. So far nobody has felt it important enough to put in the significant development effort needed.)
So if you want to do this you'll need to somehow stitch together a QEMU process for the primary architecture with some other process to do the secondary architecture (QEMU or otherwise). This has been done (for instance Xilinx have an out-of-tree QEMU-based system that does this kind of thing with multiple QEMU processes) but I'm not aware of any easy off-the-shelf frameworks or setups to do it. I suspect that figuring out how time/clocks interact between the two simulations is one of the tricky aspects.
There is another option
you can start 2 QEMU processes and connect them through socket
Then you can create run script that start both of them in your order
its less "clock" accurate but good enough for virtual your HW
The other option is https://wiki.qemu.org/Features/MultiProcessQEMU
but you will need some hacking this experimental code
Use renode. It not only provides easy multi cpu simulation, but also hdl and multimachine simulation synchronozed in a single process.

Is there a QNX virtual machine for QEMU

I am developing on a Windows machine but I have to test it on a PowerPC running QNX. I don't have constant access to the PowerPC, and I just can use it for some test. I was wondering if I could debug my code on a QNX virtual machine on QEMU emulating the PowerPC.
I have found the QEMU binaries for Windows here but I can not find the QNX VM for QEMU. Has anyone done this before?
You don't want your target platform to be PPC all the time. Build your software for x86, test it and recompile it for PPC when you have access to the device. Just make sure your code is portable.
Use VMWare Player or Workstation to install QNX and configure your tools to use the virtual machine for build and debug. That will speed up your development process dramatically!

install vxworks on vortex 86d

I wonder by any chance is there a way to install vxworks on vdx86d(vdx6354)? I searched a lot on the net and did not find NO to this question, but no manual or help could be find by me. anybody did this before and know how to do it?
VxWorks certainly runs on PC architecture x86 targets; there is probably already a suitable 80486 BSP that will suit this board. You can search for a suitable BSP here. There is only one BSP explicitly listed for 486 targetted at VxWorks 5.4/Tornado 2.0 - so it is as antique as 486 architecture itself. VxWorks 6.9 however has a single unified BSP for x86 which will no doubt work with your board.
VxWorks is not "installed" as such in the same way as a GPOS such as Linux or Windows; rather you link your application with the VxWorks libraries to create an application image that runs directly on boot. How the bootstrap process works varies between architectures and hardware implementation, but as a generic PC architecture board, booting a VxWorks application on your board will be the same as any other PC target. As such what you need to look for are directions on booting VxWorks on PC architecture rather then being specific about your actual board.
On PC architecture you can boot from mass-storage, or from a network server. Booting via a network connection is the normal method during debug/development. A great deal of the information available is for older versions of VxWorks. However it seems that it is possible to boot VxWorks via a VxWorks specific bootstrap, or from a generic PC bootloader such a s U-Boot.
Ultimately Wind River Support is probably a good starting point.

open virtual switch supporeted platform

I heard that it has been ported to multiple virtualization platforms and switching chipsets? what does the virtualization platforms and switching chipsets mean here? what is the difference between them?
another question is :can we install the openvswitch on the bare metal switch or router?I mean can we install it on just hardware without any operating system?
From OVS FAQ, which is readily available with a Google search:
Q: What virtualization platforms can use Open vSwitch?
A: Open vSwitch can currently run on any Linux-based virtualization
platform (kernel 2.6.32 and newer), including: KVM, VirtualBox, Xen,
Xen Cloud Platform, XenServer. As of Linux 3.3 it is part of the
mainline kernel. The bulk of the code is written in platform-
independent C and is easily ported to other environments. We welcome
inquires about integrating Open vSwitch with other virtualization
platforms.
Q: How can I try Open vSwitch?
A: The Open vSwitch source code can be built on a Linux system. You can
build and experiment with Open vSwitch on any Linux machine.
Packages for various Linux distributions are available on many
platforms, including: Debian, Ubuntu, Fedora.
You may also download and run a virtualization platform that already
has Open vSwitch integrated. For example, download a recent ISO for
XenServer or Xen Cloud Platform. Be aware that the version
integrated with a particular platform may not be the most recent Open
vSwitch release.
Q: Does Open vSwitch only work on Linux?
A: No, Open vSwitch has been ported to a number of different operating
systems and hardware platforms. Most of the development work occurs
on Linux, but the code should be portable to any POSIX system. We've
seen Open vSwitch ported to a number of different platforms,
including FreeBSD, Windows, and even non-POSIX embedded systems.
By definition, the Open vSwitch Linux kernel module only works on
Linux and will provide the highest performance. However, a userspace
datapath is available that should be very portable.
Q: What's involved with porting Open vSwitch to a new platform or switching ASIC?
A: The PORTING document describes how one would go about
porting Open vSwitch to a new operating system or hardware platform.
Comparison of virtualzation platforms: https://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software
Regarding your last question: You need an underlying OS (e.g. Linux)
Another easy way to experiment with sdn , openvswitch and open flow is mininet.
They have a vm you can download and use with virtualbox, vmware etc
http://mininet.org/
http://mininet.org/download