简体   繁体   English

有什么方法可以在应用程序内部的虚拟机中运行Linux?

[英]Any way to run a Linux inside a virtual machine, inside my application?

I want to be able to distribute a Linux running inside my application. 我希望能够分发在我的应用程序中运行的Linux。 The reason is that I need to add software functionality which is most easily added inside a Linux container and distributed with the application. 原因是我需要添加最容易在Linux容器中添加并随应用程序一起分发的软件功能。

Is there any way to run a VM inside a C/C++ application on Windows, OSX, Linux? 是否可以在Windows,OSX,Linux上的C / C ++应用程序中运行VM?

Two frameworks come to mind: 我想到了两个框架:

  • User mode Linux runs the Linux kernel as an application. 用户模式Linux将Linux内核作为应用程序运行。 This give you ultimate control over launching and managing the virtual machine from within a Linux application. 这使您可以最终控制从Linux应用程序内部启动和管理虚拟机。
  • libvirt provides a toolkit for programmatically managing all manner of virtual machines. libvirt提供了一个工具包,用于以编程方式管理所有类型的虚拟机。

These may both requires a Linux host. 这些都可能需要Linux主机。 For other host operating systems, it may be necessary to manage the virtual machine manually -- or using ad hoc scripting. 对于其他主机操作系统,可能需要手动管理虚拟机-或使用临时脚本。

QEMU can run a VM and it can be compiled on Windows and Linux and OSX. QEMU可以运行VM,并且可以在Windows,Linux和OSX上进行编译。 http://wiki.qemu.org/Main_Page QEMU can be compiled as it is written in C++. http://wiki.qemu.org/Main_Page QEMU可以使用C ++进行编译。

So in theory, QEMU could be embedded in a C++ program and used to run a Linux VM. 因此,从理论上讲,QEMU可以嵌入C ++程序中并用于运行Linux VM。

An example QEMU running Puppy Linux http://www.erikveen.dds.nl/qemupuppy/ 运行Puppy Linux的示例QEMU http://www.erikveen.dds.nl/qemupuppy/

VirtualBox has an API for creating/running VMs. VirtualBox具有用于创建/运行VM的API。 The program Vagrant uses this to give developers a simple cross-platform way to develop. Vagrant程序使用此程序为开发人员提供了一种简单的跨平台开发方式。 You can run vagrant up from Windows, Linux or Windows, and it does the same thing. 您可以从Windows,Linux或Windows上运行vagrant up ,并且执行相同的操作。

You can also script adding ports to your VM, so your C++ program could say "VirtualBox, boot me this image", then just connect to a TCP port to talk to the "Linux program". 您也可以通过脚本编写将端口添加到VM的脚本,以便您的C ++程序可以显示“ VirtualBox,请引导我此映像”,然后只需连接到TCP端口即可与“ Linux程序”对话。 But debugging problems will be hard. 但是调试问题将很困难。

But if your goal is to sell a Linux program to non-Linux desktop people, it's probably best for you and your sanity to bite the bullet and port it to Windows/Mac. 但是,如果您的目标是将Linux程序出售给非Linux桌面用户,那么您和您的理智选择将子弹移植到Windows / Mac可能是最好的选择。 (Or go Cloud and sell it as a service.) (或转到Cloud并将其作为服务出售。)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何构建我的URL以将GraphQL请求从Windows计算机发送到在Linux计算机上的容器内运行的应用程序? - How to frame my URL to send GraphQL request to the application running inside a container on linux machine from windows machine? 有没有办法在Linux中将应用程序作为屏幕保护程序运行 - Is there any way to run an application as a screensaver in Linux 有没有办法让ubuntu中的任何按钮按下,甚至没有在我的C / C ++应用程序窗口中按下的按钮? - Is there an way to get any button pressed in ubuntu, even those not pressed inside my C/C++ application window? 在虚拟机中启用 VT-x - Enabling the VT-x inside a virtual machine 如何从我的 Windows 机器运行安装在 linux 机器上的 OpenGL 应用程序? - How can I run an OpenGL application installed on a linux machine from my windows machine? 是否有可以运行的OS命令来确定是否在基于Xen的虚拟机中运行 - Is there an OS command I can run to determine if running inside a Xen based virtual machine .NET应用程序使用在Linux上运行的Redis数据库(虚拟机) - .NET application using a Redis database that is running on linux (Virtual Machine) 哪种Linux发行版最适合在虚拟机中开发Mono应用程序? - Which Linux distribution is best for developing a Mono application in a virtual machine? 寻找一种检测我是否在虚拟机(Linux)中运行的好方法 - Looking for a nice way to detect if I am running in a Virtual Machine (Linux) 汇编器 output 无法在我的 Linux 机器上运行 - Assembler output does not run on my Linux machine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM