Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Aug 2014 15:18:23 -0400
From:      Allan Jude <allanjude@freebsd.org>
To:        freebsd-virtualization@freebsd.org
Subject:   Re: libvirt and rebooting of a bhyve VM
Message-ID:  <53F3A2FF.3070600@freebsd.org>
In-Reply-To: <CAG=rPVdBDC48Ug34Qc-%2BBXY_W4q-=1mAQz5vq9nqPXCR4bfcHw@mail.gmail.com>
References:  <CAG=rPVcGFSnMcMdrNtWjUtHUc0RLXps-t9WwzokNtyHQwWDfFQ@mail.gmail.com> <20140819154035.GA62903@kloomba> <EBFA02E4-AF67-4988-BF3F-5DB9F7D4BC76@jnielsen.net> <53F37A6F.90405@freebsd.org> <CAG=rPVdBDC48Ug34Qc-%2BBXY_W4q-=1mAQz5vq9nqPXCR4bfcHw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--vHJKRCJ2PrgNhNC40E7X5EAGSidkeQXug
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On 2014-08-19 15:04, Craig Rodrigues wrote:
> On Tue, Aug 19, 2014 at 9:25 AM, Allan Jude <allanjude@freebsd.org> wro=
te:
>>
>> Yes, this revision adds the ability to 'reboot'. This does not exit
>> bhyve at all, so there is no exit level
>>
>> You can 'reboot' a bhyve externally using:
>> bhyvectl --force-reset --vm=3Dxxx
>>
>> or force a poweroff with: bhyvectl --force-reset --vm=3Dxxx
>>
>> SIGTERM simulates an ACPI shutdown
>>
>>
>> the bhyvectl --destroy is to clean up, the instance remains even after=
 a
>> clean shutdown. In the past, it had to be destroyed and recreated to
>> start the VM again, although now with reboot support, that may not be
>> required.
>=20
> Thanks for that information.  It's very useful.
> There doesn't seem to be a bhyvectl man page.  Do you have the
> bandwidth to write one up and check it into the tree?
> That would be very helpful.
>=20
> I ran some experiments with bhyvectl --force-reset and
> --force-poweroff.  They work as expected.
> There doesn't seem to be a bhyvectl command which simulates ACPI shutdo=
wn.
>=20
> If I have the name of the bhyve VM, is there a way that I can obtain
> the pid of the bhyve process which started
> the VM, so I can send it a SIGTERM, or do I need to keep track of that
> myself when starting the bhyve process?
>=20

The name of the vm is in the title of the bhyve process, but yes, it
would be nice to expose the ACPI style shutdown via bhyvectl
--graceful-shutdown or something

>=20
>>
>>
>> the bhyvectl --destroy is to clean up, the instance remains even after=
 a
>> clean shutdown. In the past, it had to be destroyed and recreated to
>> start the VM again, although now with reboot support, that may not be
>> required.
>=20
> You are right, calling bhyvectl --destroy does not seem to be required.=

> I ran some experiments:
>=20
>=20
> DOESN'T WORK
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>     bhyvectl --destroy ......
>     bhyveload  .....
>     while true; do
>            byve ......
>            if [ $? -ne 0 ]; then
>                 break
>            fi
>    done
>=20
> if I do a shutdown -r inside the VM, then when the VM reboots, I get:
>=20
> Assertion failed: (error =3D=3D 0), function fbsdrun_addcpu, file
> /usr/src/usr.sbin/bhyve/bhyverun.c, line 266.
>=20
>=20
>=20
>=20
> WORKING
> =3D=3D=3D=3D=3D=3D=3D=3D
>     bhyvectl --destroy ......
>     while true; do
>            bhyveload  .....
>            byve ......
>            if [ $? -ne 0 ]; then
>                 break
>            fi
>    done
>=20
>=20
> This combination seems to work fine.  I can do "shutdown -r" inside
> the VM, and it reboots fine.
> I can also do "shutdown -p", and the VM shuts down.
>=20
> So I think vmrun.sh can be changed to accomodate this new behavior,
> and make it more clear
> to people writing scripts on top of bhyve.
> --
> Craig
> _______________________________________________
> freebsd-virtualization@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
> To unsubscribe, send any mail to "freebsd-virtualization-unsubscribe@fr=
eebsd.org"
>=20

The question is, inside the while loop, after bhyve exits, does
/dev/vmm/<vmname> still exist?

Depending what you are doing, you may want to destroy it. If you
actually want to fully destroy and recreate the vm, you want to destroy
it. If you want to change the amount of ram or devices etc, you might
need to destroy it, etc.



--=20
Allan Jude


--vHJKRCJ2PrgNhNC40E7X5EAGSidkeQXug
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (MingW32)

iQIcBAEBAgAGBQJT86MBAAoJEJrBFpNRJZKfEeQQAJpB/TB/X8ZylLpuv5E4yxF3
U6+0Yz/KVhjshdxqv2/vo6Lt/NQu42iVccKF4DQq0VVwtXKmfBDWSrPXsLi9dm4J
4gCpMH+HfvFQ3aqPkJTgeOpzzrepHk8SSJHHSWTCvXwX3C8ZngXndp+nYfb3gCI5
SWlE2zWbLMS7kmC8M4AsBK37c46ICATzv9VfM+ofew3vpYpU3qlpygtA3AABvFfD
+SP34UbDp2+i6EldwYEHM5iR4f2JKCRbE/4dDoyREK6rasWb8PFcTIRDrbbIdG/K
XPSuXfAhMfJ5+5Oqd7aV0wvrY1cJxQMaGNLGUNmzqoa+/6cMbcvQ8vn8m5eSVgPO
fc3fzBicbZm3SFz0dBJ1zFZsLja1T/2LOnEfYrgX4zpkYCXPXBr0/lLp8EQrR4rl
MBbm8asIb/yk43wVRi4OpYbxtUlJFK2gKfrG2ghyO16yG86LxlIFtfNBbV+N5HeC
h34pvlufuQ595Z8OrOzZqEZaGubkSb8qR8TGdrj5bbjx6zPQxhBEn/NwlS2FMENU
Fv7UrBfw7R4cBWaQDIkZS/qsEoJvQzQIkNUGm8m7ykAtAYN4LTQOIwX9f8EUm/pD
h5CJawYL79uAZLhfwLqG9YhemFFZWPpRZ5xKTBa2VRwB9itzwxPWFFGYYtRiP2LE
Wcy1mbUF9uWl3y+I8Udx
=CPBh
-----END PGP SIGNATURE-----

--vHJKRCJ2PrgNhNC40E7X5EAGSidkeQXug--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53F3A2FF.3070600>