This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Wilma456's profile picture

VirtualOS - A virtual Machine for CC (Now with GUI)

Started by Wilma456, 03 September 2017 - 01:03 PM
Wilma456 #1
Posted 03 September 2017 - 03:03 PM
With VirtualOS you can run CraftOS in a virtual Machine.

VirtualOS (Commandline)What do you need?
You need the bios.lua and the rom folder from the CraftOS Version you wish to run. If you use the same CraftOS Version that you want to run, you can use the normal /rom Folder. You can find the latest bios and rom Here. If you search for older Versions look here

Download:
wget https://gitlab.com/Wilma456/Computercraft/raw/master/Programs/virtualos.lua virtualos
Or with Packman/Minepack

Usage:
It's very simple, if you has everything that you need:
virtualos  --biosPath=/bios.lua --romPath=/rom --rootPath=/drive
biosPath is the Path to the bios.lua that you wish to run
romPath is the Path to the rom folder
rootPath is the path to the virtual / of the VM
Just replace the Path with your local path.

Optional Options
–label=label Set the Computer label
–id=id Set the Computer ID
–notime os.time() will always return 7
–noday os.day() will always return 1
–titel=titel The titel in Multishell
–oldnative term.native is a table and not a function (Needed for CraftOS 1.5)
–host=host Set _HOST (Cannot start with "ComputerCraft")
–ccversion=version Set _CC_VERSION
–mcversion=version Set _MC_VERSION
–nohttp Disable http API
–sharePath=Path Path of a shared Folder
–shareName Filename of the shared Folder in the VM
–noper Disable Peripherals
–diskapi Enable disk API (Only needed for CraftOS 1.2)
–diskmount Give VM acces to all disks
–noepoch os.epoch() will always return 111600000
–noturtle Disable Turtle API
–nopocket Disable Pocket API
–nocomand Disable Commands API
–noclear The Screen is not cleared after shutting down the VM

Current Version: 4.2
VirtualOS Manager (GUI)
This is a GUI for VirtualOS wich download bios and rom automatic. It is very esay to use and it's mostly selfexplaining.

Instalation:
pastebin run B05YGPPy
Or with Packman/Minepack

Current Version: 3.0
Sandboxingterm.native() from the VM return the term.current() of the host.

All Events are sandboxed. The VM has no acces to the Events of the Host expected Events like char, key mouse_click.
The timer/alarm Event is only trigered, if the Timer/Alarm was set in the VM. All http Events are only trigered, if the request came from the VM.

If you want to queue a Event from Outside the VM, you need to run this:
os.queueEvent("VirtualOS_Event","char","a")
This will queue the char Event in all VMs
Edited on 11 June 2018 - 02:40 PM
Dave-ee Jones #2
Posted 04 September 2017 - 01:49 AM
Wasn't there a thing that said you aren't allowed to run virtual machines in virtual machines? :P/>

Technically MC could be considered a virtual machine..then CC running in that is another..
Lupus590 #3
Posted 04 September 2017 - 12:12 PM
Wasn't there a thing that said you aren't allowed to run virtual machines in virtual machines? :P/>

Technically MC could be considered a virtual machine..then CC running in that is another..

If your server is running on a blade than that's another VM, if the thing about the universe being a simulation is true than that's another too.
Edited on 04 September 2017 - 10:12 AM
Dave-ee Jones #4
Posted 04 September 2017 - 12:39 PM
Wasn't there a thing that said you aren't allowed to run virtual machines in virtual machines? :P/>

Technically MC could be considered a virtual machine..then CC running in that is another..

If your server is running on a blade than that's another VM, if the thing about the universe being a simulation is true than that's another too.

The Matrix getting into your head, haha.
Mumbai #5
Posted 09 September 2017 - 06:16 PM
haha the BTC / LTC / blah *Tc of cc
Wilma456 #6
Posted 11 September 2017 - 05:21 PM
I had VirtualOS updated to Version 2.0 which fixed bugs and add new options to run.

And I had made a GUI for easy use.
Dave-ee Jones #7
Posted 15 September 2017 - 03:17 AM
+1. It works surprisingly well, though the GUI manager could be a bit more..GUI-ey. :P/>

I'd be happy to try make one for you? OR, you can use my new GUI API. Haven't released it yet, though I could (it's basically done, but I'm figuring out what else I can add).

Mind you, you don't need to make a new GUI, as it works and is sufficient.
Edited on 15 September 2017 - 01:17 AM
Wilma456 #8
Posted 15 September 2017 - 04:23 PM
What features do you miss in the GUI?
Dave-ee Jones #9
Posted 19 September 2017 - 01:40 AM
What features do you miss in the GUI?

Good question. As I said, it works, and works well, but it's not the nicest GUI to look at (not saying it has to be). It's up to you whether you want to make it look nice and fancy, but this works just fine.
Wilma456 #10
Posted 20 September 2017 - 04:04 PM
I have Updated VirtualOS and VirtualOS Manager:

VirtualOS 3.0:
-All Events are now sandboxed
-The VM can no longer overide tables from the Host
-Add Suport for shared folder

VirtualOS Manager 2.0:
-Add CraftOS Version 1.0-1.4
-Check Name if of VM is valid when creating
-Add About Page
-Renamed list.lua to drivelist.lua in /var/virtualos-manager to ensure, that ls willwork on CraftOS 1.8 in thie folder. You need to rename it when upgrading.
Wilma456 #11
Posted 13 October 2017 - 06:45 PM
Another Update:

VirtualOS 4.0:
-You can give VMs now acces to the disk
-You can disable turtle, pocket and commandsapi now
-The return of os.getComputerID() is now always round
-You can disable Peripherals

VirtualOS Manager 3.0:
-Add a GUI the configure the settings of a VM
-You can now copy VMs
CRUGG #12
Posted 29 March 2018 - 07:46 PM
Is there a way to install the command line version in 1.7.10?
Lupus590 #13
Posted 29 March 2018 - 08:15 PM
Is there a way to install the command line version in 1.7.10?

http://www.computercraft.info/forums2/index.php?/topic/22036-wget-program-file-downloader-gui-much-wow/
ardera #14
Posted 01 April 2018 - 05:10 PM
Nice program, although it's not perfectly safe:

You can still get the original _G by calling getfenv(0), also I'm pretty sure calling os.queueEvent("timer", nil) will result in an "attempt to index nil" error in your code.
I also found a way to get some code run in the parent coroutine, in global env:

--# the function that should be run in the main coroutine in _G environment
local hackyfunction = function()
  print("Hello World")
end
setfenv(hackyfunction, getfenv(0)) --# set the environment of hackfunction to _G

local t = setmetatable({}, {__eq = function()
  hackyfunction()
  return false
end})
os.queueEvent("VirtualOS_Event", t)
coroutine.yield(t)
(Your event manager will compare the 2nd argument in the os.queueEvent call with the argument in coroutine.yield, which will trigger the __eq metamethod. This is done outside the VM, so __eq and thus "hackyfunction" will be run in the parent coroutine.)

Also, you can access the filesystem root directory by appending some "/../" before your paths. (Fix: replace fs.combine(sPath, "") with fs.combine("/", sPath))

But please don't get irritated by my criticism: Other than that it's one of the best Lua sandboxes I've seen, also it's really hard to build a perfect sandbox.


PS: I hope this doesn't get flagged as malicious code, it really isn't. I'm not deleting any user files etc.
Edited on 01 April 2018 - 03:19 PM
Wilma456 #15
Posted 02 April 2018 - 05:05 PM
Thank you for reporting the Bugs. I try to fix it. But too of your Bugs can't be reproduced by me: os.queueEvent("timer", nil) doen't crash the program. Just nothing happens.

function test()
  print(_HOST)
  fs.open("/bug","w")
end

local t = setmetatable({}, {__eq = function()
  test()
  return false
end})
os.queueEvent("VirtualOS_Event", t)
coroutine.yield(t)
This code just hang up forever and need to be killed. Nothing hapens. Nothing is print and the file bug is not created. The only Bugs who works for me are getfenv(0) and "/../" (but your Fix doen't work). I try to fix it.
ardera #16
Posted 03 April 2018 - 03:05 PM
But too of your Bugs can't be reproduced by me: os.queueEvent("timer", nil) doen't crash the program. Just nothing happens.
-snip-
This code just hang up forever and need to be killed. Nothing hapens. Nothing is print and the file bug is not created. The only Bugs who works for me are getfenv(0) and "/../" (but your Fix doen't work). I try to fix it.
Oh yeah I didn't realise you also wrapped os.queueEvent. That explains why these 2 don't work.
Wilma456 #17
Posted 14 May 2018 - 04:03 PM
I had now fixed the getfenv() bug in VirtualOS 4.2. It*s not the nicest fix but it works.

The fs Bug is still working. I try to fix that.