WIP:aryan/build #2

Draft
chopper wants to merge 7 commits from aryan/build into main
Showing only changes of commit 2cb1587b23 - Show all commits

View file

@ -5,7 +5,7 @@ import argparse
def vm_start(nographic=False): def vm_start(nographic=False):
home = Path.home() home = Path.home()
user = os.getlogin() user = os.getuser()
Outdated
Review

Documentation suggests using getuser

Documentation suggests using [getuser](https://docs.python.org/3/library/getpass.html#getpass.getuser)
image_src = "var/lib/debian.qcow2" image_src = "var/lib/debian.qcow2"
vm_storage_location = f"/home/arvp/virtual_machines/{user}.qcow2" vm_storage_location = f"/home/arvp/virtual_machines/{user}.qcow2"
image_dest = f"{home}/debian.qcow2" image_dest = f"{home}/debian.qcow2"
@ -16,19 +16,17 @@ def vm_start(nographic=False):
"-m", "2G", # ram allocation "-m", "2G", # ram allocation
Outdated
Review

Isn't this far too low? It should also be adjustable via argparse

Isn't this far too low? It should also be adjustable via argparse
"-nic", "user,hostfwd=tcp::5555-:22", #forward port 5555 in host to port 22 in vm "-nic", "user,hostfwd=tcp::5555-:22", #forward port 5555 in host to port 22 in vm
Outdated
Review

This port should be configurable, otherwise we can't run several vms at the same time. Best put it in argparse

This port should be configurable, otherwise we can't run several vms at the same time. Best put it in argparse
"-drive", "file=%s,media=disk,if=virtio" % image_dest, "-drive", "file=%s,media=disk,if=virtio" % image_dest,
# "-nographic",
# "-serial", "mon:stdio",
"-vga", "virtio", # i think this fixes resolution but idk yet
"-display", "sdl",
] ]
if nographic==True: if nographic:
Outdated
Review

What are these doing here?

What are these doing here?
initialize.append("-nographic") initialize.append("-nographic")
initialize.append("-serial") initialize.append("-serial")
initialize.append("mon:stdio") initialize.append("mon:stdio")
Review

Say I enable nographic. It seems like this display arg will conflict. Instead, it'd be better for these to be the else branch on the conditional below

Say I enable `nographic`. It seems like this display arg will conflict. Instead, it'd be better for these to be the else branch on the conditional below
else:
initialize.append("-vga")
initialize.append("virtio")
Outdated
Review

==True O.O

if nographic:

`==True` O.O `if nographic:`
initialize.append("-display")
initialize.append("sdl")
#copy the base image to a directory with everyones virtual machines. -n should not overwrite any existing vms. #copy the base image to a directory with everyones virtual machines. -n should not overwrite any existing vms.
#subprocess.run(["cp", "-n", image_src, vm_storage_location]) #subprocess.run(["cp", "-n", image_src, vm_storage_location])
Popen(initialize) Popen(initialize)