Re: How to launch a bhyve vm as normal user,without being root

From: Odhiambo Washington <odhiambo_at_gmail.com>
Date: Tue, 18 Jun 2024 06:53:11 UTC
######/usr/local/etc/doas.conf#########################
permit :wheel
permit nopass keepenv :wheel
permit alice as root
permit keepenv bob as root
permit cindy as root cmd pkg args update
permit cindy as root cmd pkg args upgrade
permit nolog david as root cmd id
permit www as root cmd pfctl
permit nopass *wash* as root cmd bhyve

####### /usr/local/bhyve-vms/scripts/debian.sh##############
#!/usr/bin/env bash
if ! kldstat | grep -w vmm.ko
then
        kldload -v vmm
fi
if ! kldstat | grep -w nmdm.ko
then
        kldload -v nmdm
fi
/usr/sbin/bhyve -S -c sockets=2,cores=2,threads=2 -m 4G -w -H -A \
-s 0,hostbridge \
-s 4,ahci-hd,/usr/local/bhyve-vms/Debian/debian.img,bootindex=1 \
-s 5,virtio-net,tap3 \
-s 7,virtio-9p,sharename=/ \
-s 8,hda,play=/dev/dsp,rec=/dev/dsp \
-s 29,fbuf,tcp=0.0.0.0:5904,w=1600,h=950 \
-s 30,xhci,tablet \
-s 31,lpc -l com1,stdio \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
debian

And all I do is `doas /usr/local/bhyve-vms/scripts/debian.sh`.


On Mon, Jun 17, 2024 at 6:46 PM Mario Marietto <marietto2008@gmail.com>
wrote:

> Can you paste here the contents of doas.conf and debian.sh ? thanks.
>
> On Mon, Jun 17, 2024 at 5:35 PM Odhiambo Washington <odhiambo@gmail.com>
> wrote:
>
>>
>>
>> On Mon, Jun 17, 2024 at 5:13 PM Mario Marietto <marietto2008@gmail.com>
>> wrote:
>>
>>> Nice idea,but it does not work :
>>>
>>
>> It worked for me!
>>
>> I created a bash script file named debian.sh which contained all the
>> bhyve args to create the VM, then I just did:
>>
>> doas debian.sh
>>
>> And I actually successfully installed the VM and it's running
>>
>>
>> --
>> Best regards,
>> Odhiambo WASHINGTON,
>> Nairobi,KE
>> +254 7 3200 0004/+254 7 2274 3223
>>  In an Internet failure case, the #1 suspect is a constant: DNS.
>> "Oh, the cruft.", egrep -v '^$|^.*#' ¯\_(ツ)_/¯ :-)
>> [How to ask smart questions:
>> http://www.catb.org/~esr/faqs/smart-questions.html]
>>
>
>
> --
> Mario.
>


-- 
Best regards,
Odhiambo WASHINGTON,
Nairobi,KE
+254 7 3200 0004/+254 7 2274 3223
 In an Internet failure case, the #1 suspect is a constant: DNS.
"Oh, the cruft.", egrep -v '^$|^.*#' ¯\_(ツ)_/¯ :-)
[How to ask smart questions:
http://www.catb.org/~esr/faqs/smart-questions.html]