LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-01-2011, 08:23 AM   #1
theKbStockpiler
Member
 
Registered: Sep 2009
Location: Central New York
Distribution: RPM Distros,Mostly Mandrake Forks;Drake Tools/Utilities all the way!GO MAGEIA!!!
Posts: 968

Rep: Reputation: 53
Emulators and Virtual machines


I'm interested in a basic to intermediate understanding of these two subjects. Is anyone aware of a decent guide or tutorial on these subjects or maybe a few underlining concepts explained? Emulators don't emulate the CPU, correct?

Thanks................in...............advance!
 
Old 06-01-2011, 08:53 AM   #2
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292
If you read this you should get it:
http://en.wikipedia.org/wiki/Virtual_machine

In one statement: an emulator is a virtual machine that emulates a non-native architecture.
 
1 members found this post helpful.
Old 06-01-2011, 08:54 AM   #3
MrCode
Member
 
Registered: Aug 2009
Location: Oregon, USA
Distribution: Arch
Posts: 864
Blog Entries: 31

Rep: Reputation: 148Reputation: 148
Quote:
Emulators don't emulate the CPU, correct?
…other way around.

Emulators simulate absolutely everything in software: the CPU, audio/video adapters, I/O, etc.

Virtual machines, on the other hand, try to run as much code "natively" as possible. This is probably implementation dependent, but VirtualBox tries to run guest kernel code in x86 privilege ring 1 (as opposed to ring 0, where host kernel code runs; ring 1 is primarily unused in other contexts), unless hardware virtualization extensions such as Intel VT-x are enabled, in which case the VM gets an entirely new context space with the same four privilege rings as the host (resulting in practically zero raw processing overhead). I/O/device access is still emulated/redirected through the hypervisor, however (we wouldn't want our guest to trash the host's access to hardware ).

This is just my very basic understanding of it I got from reading the VirtualBox tech docs, so I don't claim that it's complete (or even entirely correct).
 
1 members found this post helpful.
Old 06-01-2011, 08:59 AM   #4
camorri
LQ 5k Club
 
Registered: Nov 2002
Location: Somewhere inside 9.9 million sq. km. Canada
Distribution: Slackware 14.1, 14.2, current, slackware-arm-currnet
Posts: 5,707

Rep: Reputation: 690Reputation: 690Reputation: 690Reputation: 690Reputation: 690Reputation: 690
This link will give you a good understanding of Virtual Box.

-->http://www.virtualbox.org/manual/ch01.html
 
1 members found this post helpful.
Old 06-01-2011, 01:40 PM   #5
theKbStockpiler
Member
 
Registered: Sep 2009
Location: Central New York
Distribution: RPM Distros,Mostly Mandrake Forks;Drake Tools/Utilities all the way!GO MAGEIA!!!
Posts: 968

Original Poster
Rep: Reputation: 53
Thanks for the Replies!

I will read the links and see where I am from there. I expected that System calls would have to be intercepted and modified but the guides don't seem to go into that much detail which is strange.

Thanks again!
 
Old 06-01-2011, 01:44 PM   #6
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 722Reputation: 722Reputation: 722Reputation: 722Reputation: 722Reputation: 722Reputation: 722
Quote:
Originally Posted by theKbStockpiler View Post
I will read the links and see where I am from there. I expected that System calls would have to be intercepted and modified but the guides don't seem to go into that much detail which is strange.
What system calls? Are you talking about virtual machines that try to run the software on the native hardware or about true emulators?
 
Old 06-01-2011, 02:40 PM   #7
theKbStockpiler
Member
 
Registered: Sep 2009
Location: Central New York
Distribution: RPM Distros,Mostly Mandrake Forks;Drake Tools/Utilities all the way!GO MAGEIA!!!
Posts: 968

Original Poster
Rep: Reputation: 53
I don't have a clue MTK

I was just throwing that one out there but an explanation that is comprehensive must include the frame work of the like. I understand that O.S's have different system calls so that would have to be addressed some how. I will dig a little further myself to refine my questions.
 
Old 06-01-2011, 02:53 PM   #8
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 722Reputation: 722Reputation: 722Reputation: 722Reputation: 722Reputation: 722Reputation: 722
Quote:
Originally Posted by theKbStockpiler View Post
I was just throwing that one out there but an explanation that is comprehensive must include the frame work of the like. I understand that O.S's have different system calls so that would have to be addressed some how. I will dig a little further myself to refine my questions.
A true emulator doesn't have anything to do with system calls. All it does is implement in software the logic that's normally implemented in silicon and circuit boards. If the logic is the same the same as the hardware supported by an OS, that OS will work in it.

One thing that I think you're confused about is that the emulator somehow controls the OS inside it. This is not true. It doesn't need to even have an OS in it, just any machine code for the emulated CPU (for example, virtual machines for programming languages and game console emulators don't run an OS). And it doesn't have to emulate a physical piece of hardware, you can think of any hypothetical machine you like and implement it as an emulator.
 
Old 06-01-2011, 03:09 PM   #9
MrCode
Member
 
Registered: Aug 2009
Location: Oregon, USA
Distribution: Arch
Posts: 864
Blog Entries: 31

Rep: Reputation: 148Reputation: 148
Quote:
Originally Posted by theKbStockpiler
I expected that System calls would have to be intercepted and modified
That only really applies to VMs (not emulators). As I said in my post above, with VirtualBox, system calls (which consist of instructions that would normally be run in privilege ring 0 natively) are actually redirected/made to run in ring 1 (otherwise unused) instead. User mode code (ring 3) still runs in ring 3, though. Everything still runs "natively", in a sense, but it's still subject to the limitation of being run under another OS (and hence can only take so much CPU time, among other restrictions).

Emulators, on the other hand, simulate executing individual instructions. As MTK said above, all an emulator does is implement a CPU's register/instruction set/cache(s)(?)/other components completely in software (possibly along with other peripherals, such as audio/video controllers).

From a user's standpoint, the main difference between them is that a) emulators are typically slower than "semi-native" virtual machines, and b) since an emulator completely emulates an instruction set, you can run any program written/compiled into that instruction set in it as if it's absolutely no different from the actual, physical hardware. VMs have the restriction of being limited to the architecture the hypervisor runs on, whereas emulators don't, because they don't really have a "hypervisor" concept; they're "running" code in their own completely isolated environment, so to speak.

I hope I'm making some kind of sense here, and I hope I'm not majorly butchering the concepts.

EDIT: I suppose I should add that with virtual machines, if the CPU has hardware virtualization extensions, and they're enabled in the hypervisor's settings, then that provides the VM a new context space which (with Intel VT-x, anyway) is called "VMX non-root mode" (as opposed to "VMX root mode" where host code runs). This is essentially a new "space" where VM guest code runs that has the same four code privilege levels as root mode, but has an additional control structure to intercept certain instructions (such as I/O requests) and redirect them to the hypervisor. (AFAIK )

Last edited by MrCode; 06-01-2011 at 03:23 PM. Reason: Added bit about VT-x
 
Old 06-01-2011, 04:00 PM   #10
theKbStockpiler
Member
 
Registered: Sep 2009
Location: Central New York
Distribution: RPM Distros,Mostly Mandrake Forks;Drake Tools/Utilities all the way!GO MAGEIA!!!
Posts: 968

Original Poster
Rep: Reputation: 53
I don't know enough about it to have a converstation at this point.



Lets say I have code for MS sitting in a file.For it to be executed on Linux something would have to present it to the kernel (loose interpretation) in the Elf format. The CPU is fed the code that it is not written for it. I assume the machine code is different from MS to Linux. The CPU could have a different instruction set also. I don't see a big problem with the hardware because this is where drivers come in and we all know this is a black art. If there was a way around the driver issue with an emulator I would think that drivers would not be such an issue and WINE could execute a game without crashing the O.S. on a regular basis.

So to reiterate from the paragraph above ,I really don't have an overview of what goes on with a emulator or a v.machine, the process of it executing.

Thanks again!
 
Old 06-01-2011, 04:18 PM   #11
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 722Reputation: 722Reputation: 722Reputation: 722Reputation: 722Reputation: 722Reputation: 722
Running Windows apps on Linux has nothing to do with emulators and VMs. Do you know what WINE stands for?

Also, the CPU architecture is the same for Windows and Linux. After all, it's called the CPU architecture, not the OS architecture.

The reason Windows apps don't work on Linux is becasue they are in a different format that the Linux kernel doesn't understand, and it has different system calls that Linux doesn't understand. Also, Linux has a totally different design and is missing many concepts that Windows program assume.

Basically, FORGET ABOUT THE OS. IT HAS NOTHING TO DO WITH THIS SUBJECT.

Last edited by MTK358; 06-01-2011 at 04:24 PM.
 
1 members found this post helpful.
Old 06-01-2011, 04:18 PM   #12
jefro
Moderator
 
Registered: Mar 2008
Posts: 20,666

Rep: Reputation: 3333Reputation: 3333Reputation: 3333Reputation: 3333Reputation: 3333Reputation: 3333Reputation: 3333Reputation: 3333Reputation: 3333Reputation: 3333Reputation: 3333
I think you are confusing the deal.

Your "code" has nothing to do with a VM for this discussion.

A VM of any kind is a computer, just like one you buy at the store. Forget everything else. It is a computer to you and your OS.

Now your "code" has to have an OS to run, with one exception. That exception is a special program that adapts Windows programs to run in linux. Wine and crossover products and a few others use software to basically fool the code into thinking it is running in windows.

In all other cases you install Windows into a virtual machine (remember it is a real machine for this discussion) and then install the code and run. You would have two computers running at the same time sharing one real computer.

As to how the sharing is done is the emulate and virtual both hardware and software supported.


Suffice it to say that a modern good desktop can fully support a virtual machine in hardware and the software program to create almost a real computer.
 
1 members found this post helpful.
Old 06-03-2011, 07:25 PM   #13
theKbStockpiler
Member
 
Registered: Sep 2009
Location: Central New York
Distribution: RPM Distros,Mostly Mandrake Forks;Drake Tools/Utilities all the way!GO MAGEIA!!!
Posts: 968

Original Poster
Rep: Reputation: 53
Another approach

The hardware is obviously "the hardware" so it is absurd to imagine that the physical makeup of the computer would change. Hardware must be implemented through the host O.S. and then ultimately with the use of drivers. The guest applications code must be "converted" or possible implemented in an inverted concept so the host CPU and manipulate the code. I intuitively believe the the guest application would fill in arguments of the VM/Emulators code and than this code would be executed by the host CPU/O.S.

This software that the guest application is treating as hardware, are there files that take the place of the hardware or is the guest application data being used to altering the original code? So instead of a CPU or a input/output means the guest sends data to a file. The VM/Emulator does something and then this new modified data is nativity executed by the host CPU. I would think that the VM/Emulator would inspect code of the guest , convert it and then hand it over to the host. I do understand the abstractions but they operate as magic. I apologize for being redundant but this is an important concept with "virtually" no info on the web about it. If I could find an explanation that uses processes and files and who they belong to it would not be abstracted. A Virtual Machine process must include,

Host hardware
Host and or guest O.S
Host storage for Files.(no hardware no files.)
Process must not belong to guest
Separation of host OS to guest application via the Virtual machine/Emulator

In other words does anyone know the anatomy of an Emulator/Virtual Machine and the other files that it creates and or uses?

Last edited by theKbStockpiler; 06-03-2011 at 07:34 PM.
 
Old 06-03-2011, 07:40 PM   #14
MrCode
Member
 
Registered: Aug 2009
Location: Oregon, USA
Distribution: Arch
Posts: 864
Blog Entries: 31

Rep: Reputation: 148Reputation: 148
Quote:
This software that the guest application is treating as hardware, are there files that take the place of the hardware or is the guest application data being used to altering the original code? So instead of a CPU or a input/output means the guest sends data to a file.
Not quite…put simply, what happens is that at the instruction level (think assembly), those instructions that the guest runs which would normally trigger some kind of hardware action (I/O, IRQ servicing, etc.) are actually routed to what's called the "hypervisor" (which is a part of the actual VM software), which then safely performs the intended action in a "virtual" context on the host. For example, if a guest requests I/O to/from its virtual "disk", that request is redirected to the hypervisor so that it can read/write to/from the disk image in the host filesystem instead. The same thing applies to other hardware: audio, video, HIDs, and other devices.

With an emulator, everything is simulated completely in software, including the individual CPU instructions. So, there's no real risk of something going wrong with the host, since none of the code is actually running natively; every instruction is simulated by the emulation software, including those that would normally trigger hardware actions.

Again, hopefully I didn't butcher something up there; my own understanding of the differences is somewhat fuzzy, but hopefully you can see my point here… :-\

Last edited by MrCode; 06-03-2011 at 07:44 PM.
 
Old 06-03-2011, 08:29 PM   #15
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 722Reputation: 722Reputation: 722Reputation: 722Reputation: 722Reputation: 722Reputation: 722
Quote:
Originally Posted by theKbStockpiler View Post
Hardware must be implemented through the host O.S. and then ultimately with the use of drivers. The guest applications code must be "converted" or possible implemented in an inverted concept so the host CPU and manipulate the code. I intuitively believe the the guest application would fill in arguments of the VM/Emulators code and than this code would be executed by the host CPU/O.S.

This software that the guest application is treating as hardware, are there files that take the place of the hardware or is the guest application data being used to altering the original code? So instead of a CPU or a input/output means the guest sends data to a file.
I don't understand what you mean at all here, especially the "file" thing.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Connect two virtual linux machines via virtual USB or serial WebBeing Linux - General 4 07-22-2008 07:26 AM
Virtual Machines badsheriff Linux - Newbie 9 07-20-2008 04:44 PM
Udev breaks virtual terminal emulators MS3FGX Slackware 7 01-26-2006 09:22 AM
virtual cd rom emulators? mnm_mc Linux - Software 4 12-31-2005 07:17 PM
Virtual Machines Berticus Linux - Newbie 8 10-18-2005 12:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration