From owner-freebsd-virtualization@FreeBSD.ORG Sun Feb 9 21:11:02 2014 Return-Path: Delivered-To: freebsd-virtualization@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BABA9D02 for ; Sun, 9 Feb 2014 21:11:02 +0000 (UTC) Received: from mail-la0-x22f.google.com (mail-la0-x22f.google.com [IPv6:2a00:1450:4010:c03::22f]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 414F11815 for ; Sun, 9 Feb 2014 21:11:02 +0000 (UTC) Received: by mail-la0-f47.google.com with SMTP id hr17so4142713lab.20 for ; Sun, 09 Feb 2014 13:11:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:content-type; bh=s5JC3NM9n7tPNbDasxm38bQFSZ4pAzmld+nBmW6hOKw=; b=vKJguwOEG8PZf9BZHSaF8g83doTfTHs+C6NC/QN9qwa3s+Jkf+fVOI78UyxT5PdN9q vCbT19Tf5VOD+ZvxvxCz4L2lmQDa+o7NAyazIKbAxEEAyHDjBZ4mXrYBnbln9dMeQs6A tz10V2FYkBOoDtfWqtvpSUctKnvNvmyTq5ybmYxOgwn43k0G28Il6+ptpMEpHhLA8uxT yuFi8NojeXanLw0OOxyEuNWuVVClfOvi3EwZBEppHAbKQgfLfgELli/3LqBda/9cGVlg vKNkpxTYYqkrJpSIZ2guc8489brdRVFiROetSxF2EuqIStjcxnvfb5OVF4UUWAlagfHV BebA== MIME-Version: 1.0 X-Received: by 10.153.8.225 with SMTP id dn1mr19175901lad.17.1391980260256; Sun, 09 Feb 2014 13:11:00 -0800 (PST) Sender: crodr001@gmail.com Received: by 10.112.30.211 with HTTP; Sun, 9 Feb 2014 13:11:00 -0800 (PST) Date: Sun, 9 Feb 2014 13:11:00 -0800 X-Google-Sender-Auth: h7lhIUB0XzVnHp2vas7gy8hC8v8 Message-ID: Subject: Detect of BHyve VM was powered off or rebooted? From: Craig Rodrigues To: "freebsd-virtualization@freebsd.org" Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.17 X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Feb 2014 21:11:02 -0000 Hi, I posted some rc.d scripts that I am using to boot a BHyve VM and send the output to a serial console using the /dev/nmdm driver: http://lists.freebsd.org/pipermail/freebsd-virtualization/2014-January/002040.html It works quite well. There is some things I would like to improve, and would like some advice on the best way to do it. (1) If the VM was destroyed with bhyvectl --destroy --vm ${VM_NAME}, then I do not want to automatically restart the VM in the script. User should manually: service bhyvevm start (2) If the VM was powered down, via shutdown -p, or halt -p, then in my script I do not want to restart the VM in the script. User should manually: service bhyvevm start (3) If the VM was rebooted via "reboot" or "shutdown -r", then I *do* want the script to restart the VM. I think if I change my start_vm.sh script to do something like: ( while [ -e /dev/vmm/${VM} ]; do /usr/sbin/bhyve -c 16 -m 8G -A -H -P -g 0 -s 0:0,hostbridge -s 1:0,lpc -s 2:0,virtio-net,${TAP} -s 3:0,virtio-blk,${IMG} -l com1,${CONS_A} ${VM}" done ) & then this might cover cases (1) and (3), but what will cover case (2)? Thanks for any advice. -- Craig