From owner-freebsd-virtualization@FreeBSD.ORG Wed Mar 5 13:00:40 2014 Return-Path: Delivered-To: freebsd-virtualization@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C8FA9FD2 for ; Wed, 5 Mar 2014 13:00:40 +0000 (UTC) Received: from mail-la0-x233.google.com (mail-la0-x233.google.com [IPv6:2a00:1450:4010:c03::233]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4F4C5693 for ; Wed, 5 Mar 2014 13:00:40 +0000 (UTC) Received: by mail-la0-f51.google.com with SMTP id pv20so674168lab.10 for ; Wed, 05 Mar 2014 05:00:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=h2jD00iW41NWBEYpZ0+49gGNwMnrt2JSnvYwTU3ZbL8=; b=VQBSGpWgDtPZs1Yr634XAuiWwYXMCXqcf9nPW6+dqyw40JmxG9LzvmDjP3rC1myCaH MRKEvUTSq5RhDEu7y7vW7L1RIRkfF+NK+ia1VkyNHjz2w2BmvwQcymg2qTVHPR8Yw9ot lHvvB4EX2U9GYbDPUZMa+QDFckoDkZ2Uj7rWQMmORd5Tu9RY3yLFTxqgIAkBAYdTFsc8 0ndcIgpaQo3R5S+0bOK+xxfridRxwlyBViXAAplmweXgCqqb5/AagERH8c8kP3OapOSk yBiN4c18P1BoiZmEO0zN9e6GeyL8qc7DFNZm2k0zXjhjSXJ9PGL6lY4yGVlWHSb9byMT rDOQ== X-Received: by 10.152.20.1 with SMTP id j1mr142283lae.83.1394024438380; Wed, 05 Mar 2014 05:00:38 -0800 (PST) Received: from dev.san.ru (dev.san.ru. [88.147.129.60]) by mx.google.com with ESMTPSA id x5sm2581706lbk.5.2014.03.05.05.00.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Mar 2014 05:00:37 -0800 (PST) Sender: Roman Bogorodskiy Date: Wed, 5 Mar 2014 17:00:32 +0400 From: Roman Bogorodskiy To: freebsd-virtualization@freebsd.org Subject: bhyve: allow specifiying tty by fd Message-ID: <20140305130030.GA40560@dev.san.ru> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="gBBFr7Ir9EOA20Yy" Content-Disposition: inline User-Agent: Mutt/1.5.22 (2013-10-16) 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: Wed, 05 Mar 2014 13:00:40 -0000 --gBBFr7Ir9EOA20Yy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, Currently bhyve(8) allows to specify either stdio or device path as a TTY device. However, it could be useful to specify a TTY device by file descriptor, e.g. when bhyve is being executed in an automated way by other application, so a result of openpty(3) could be passed to it. Attached a poc patch for that. It allows to specify fd this way: bhyve -s 31,lpc -l com1,fd=19 vm0 Roman Bogorodskiy --gBBFr7Ir9EOA20Yy Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="bhyve_tty_fd.diff" Index: bhyve.8 =================================================================== --- bhyve.8 (revision 262780) +++ bhyve.8 (working copy) @@ -184,6 +184,8 @@ the bhyve process. .It Pa /dev/xxx Use the host TTY device for serial port I/O. +.It Li fd=N +Use a specified file descriptor of the TTY device. .El .Pp Pass-through devices: Index: uart_emul.c =================================================================== --- uart_emul.c (revision 262780) +++ uart_emul.c (working copy) @@ -585,7 +585,11 @@ retval = -1; - fd = open(opts, O_RDWR); + if (!strncmp(opts, "fd=", 3)) { + fd = atoi(opts+3); + } else { + fd = open(opts, O_RDWR); + } if (fd > 0 && isatty(fd)) { sc->tty.fd = fd; sc->tty.opened = true; --gBBFr7Ir9EOA20Yy--