Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Aug 2018 17:53:36 +0100
From:      Allan Jude <allanjude@FreeBSD.org>
To:        freebsd-virtualization@freebsd.org, "Rodney W. Grimes" <freebsd-rwg@pdx.rh.CN85.dnsmgr.net>
Cc:        Matt Churchyard <matt.churchyard@userve.net>, "freebsd-virtualization@freebsd.org" <freebsd-virtualization@freebsd.org>
Subject:   Re: Checking bhyve supported features (sysctls)
Message-ID:  <BC22EE63-357B-47F5-9121-A73B59633FE9@FreeBSD.org>
In-Reply-To: <201808161628.w7GGS52P054505@pdx.rh.CN85.dnsmgr.net>
References:  <201808161628.w7GGS52P054505@pdx.rh.CN85.dnsmgr.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On August 16, 2018 5:28:05 PM GMT+01:00, "Rodney W=2E Grimes" <freebsd-rwg@=
pdx=2Erh=2ECN85=2Ednsmgr=2Enet> wrote:
>>=20
>> Text manually wrapped to 80, any broken quoting is my fault - rwg
>>=20
>> > > Hello,
>> > >=20
>> > > I'm looking for better ways to check for  bhyve support /
>available
>> > > features without trying to scan through dmesg output=2E
>> >=20
>> > >Yes, it would be very good to remove that, as it usually tries
>> > >to grep a non-existent file /var/run/dmesg=2Eboot that is not
>> > >created until after vm_bhyve has been called from
>/usr/local/etc/rc=2Ed
>> > >when you have things set to autostartup >in /etc/rc=2Econf
>> >=20
>> >=20
>> > >=20
>> > > I notice that the following 2 sysctl's appear to be set to 1 as
>soon=20
>> > > as the vmm module is loaded
>> > >=20
>> > > hw=2Evmm=2Evmx=2Einitialized: 1
>> > > hw=2Evmm=2Evmx=2Ecap=2Eunrestricted_guest: 1
>> > >=20
>> > > Will these be available on both Intel & AMD processors as a way
>> > > to determine if the module has loaded successfully and can run
>guests?
>> > >=20
>> > > I also see the below sysctl related to iommu=2E
>> > >=20
>> > > hw=2Evmm=2Eiommu=2Einitialized
>> > >=20
>> > > Again, will this be set to 1 as soon as the module is loaded if
>> > > iommu is supported, or only when it is used?
>> > > There also seems to be a vmm=2Eamdvi=2Eenable sysctl=2E
>> > > Would both these need checking or is vmm=2Eiommu enough to
>> > > determine support on any processor=2E
>> >=20
>> > >Probalby the safest way for a shell script to decide if bhyve is
>> > >up and running is to stat /dev/vmm, if that exists then the
>modules
>> > >have loaded and initialized and bhyve should be ready to process
>guests=2E
>> >=20
>> > Hmm, I don't get /dev/vmm unless I actually have running guests=2E
>>=20
>> I'll investigate that, I was pretty sure that you should get this
>> as soon as the vmm=2Eko module is finished initialzing, but you might
>> be right in that it takes a first vm to cause its creation=2E
>> Confirmed, /dev/vmm does not exist until the first vm
>> is created=2E
>>=20
>> >=20
>> > >sysctl's mentiond above would be a poor way to make this
>determination=2E
>> >=20
>> > It would be nice if sysctls were better documented=2E
>>=20
>> Agreed=2E
>>=20
>> > If vmx=2Einitialized is set once vmm has successfully loaded, I can't
>see a better way of checking for bhyve support (assuming it's not Intel
>specific)=2E This entry definitely exists and is set to 0 if you load the
>module on a non-supported system, and set to 1 as soon as vmm loads on
>my Intel test system=2E
>>=20
>> Given its undocumented status you would be relying on an
>> undocumented feature that could change in either name or
>> behavior, and that is not desirable=2E
>>=20
>> Let me see if I can come up with something else=2E
>
>I looked at the code for bhyvectl, bhyveload and
>byhve=2E  They do not actually try to decide if vmm
>is supported or not, they simply process the error
>from a vm_create() or vm_open() call and exit
>with an error code if they can not handle it
>(some of the code can handle a vm_create failure
>if infact we are trying to create a vm that
>already exists)=2E
>
>If you want to maintain full compatibility a similiar
>stratergy may be in order=2E
>
>Why is it that vm-bhyve specifically needs to know
>if the kernel has vmm support or not?
>Cant it just be written to handle the errors returned
>if the supported functions do not exist?

I think the question vm-bhyve wants to answer is: does the CPU have the re=
quired features to run a multicore VM=2E

These or similar sysctls do seem to be the correct way to communicate that=
 support=2E
--=20
Allan Jude



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BC22EE63-357B-47F5-9121-A73B59633FE9>