From nobody Mon Feb 9 12:42:41 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 1486912602836371.4707913210101; Sun, 12 Feb 2017 07:16:42 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1CFD24V059109; Sun, 12 Feb 2017 10:13:02 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1CFD1in024764 for ; Sun, 12 Feb 2017 10:13:01 -0500 Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1CFD1S5012985 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Sun, 12 Feb 2017 10:13:01 -0500 Received: from mail-lf0-f66.google.com (mail-lf0-f66.google.com [209.85.215.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D82494E4D1 for ; Sun, 12 Feb 2017 15:12:59 +0000 (UTC) Received: by mail-lf0-f66.google.com with SMTP id q89so6567498lfi.1 for ; Sun, 12 Feb 2017 07:12:58 -0800 (PST) Received: from kloomba.my.domain ([95.104.139.40]) by smtp.gmail.com with ESMTPSA id h9sm1414489ljb.51.2017.02.12.07.12.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Feb 2017 07:12:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Z6uoxWHrC6ylE+Uxi0sc2GBF+a1ph1jtnvMdge2kAds=; b=d//kZ1+RSoMory6QehIkq4YzmlE28FefUlrBUPP48J1RXIG5H36MLYDk2rW85aV3e2 hxeE1qafLkoZLrX+2pPdst2+Hump2ns7l0qk6wksz9Pgy8e6oT9iJFvgPLmceQQQ6ZjR vl06tG1MvwBYa9/z4VH+LzQA9LaQYyRf3CG9C+FYO2CF/keUHBH+vBY1pD6pC/LXDyzT 4tJMzeFy9Y927TLZZySruHrGr3m+kkJCEbT7apFJp3JYV8ktDthCQy8f8EAhHHiSImwF Qcv77L0BDu+SnMvp45Yjv4RjDlDthMKzLgSidBML8E+aPjHpSbzXxnhzRahvLdi9xhA1 h+Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Z6uoxWHrC6ylE+Uxi0sc2GBF+a1ph1jtnvMdge2kAds=; b=CZmJ62wi4cwk9vm/viE4j9QzfebgUkEYybqp0eLqgU6I3qHnzGksQgqpWf9WxwmrN+ 4Hle17r7FsvKYEuezS+LHpTY2oS6R0T+bmN3OPF7q2zdL9ZJivjtKEpzDqToBYmcYIgn /P4yljc/bVDsGwaWt0VEW02OTQyn49cYmlQgJZukn6D8sm3hIhIwHfedpcBx/3NSD+3T OosBGPHM5Uy0JgTEx8+CnhansFX5AQq3eglGjsD6vK8uhA65pNgt8NwpVUlcxzPpbXXP RCvZl4JCjtFijWO1Ae9GruWLgZfGJF+RAo8cJ2hUSso0W/8+YFWK5oKkIG3Ev5ZHZ1IR vWrw== X-Gm-Message-State: AMke39lqKAf3Qh18UAk/ktu5XirGbLRslmJhHuakOM8J3R/U1wNFvfBKx/B2VXq+jkDEMA== X-Received: by 10.46.80.89 with SMTP id v25mr1548904ljd.109.1486912377084; Sun, 12 Feb 2017 07:12:57 -0800 (PST) From: Roman Bogorodskiy To: libvir-list@redhat.com Date: Sun, 12 Feb 2017 19:12:30 +0400 Message-Id: <20170212151234.25936-3-bogorodskiy@gmail.com> In-Reply-To: <20170212151234.25936-1-bogorodskiy@gmail.com> References: <20170212151234.25936-1-bogorodskiy@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 12 Feb 2017 15:13:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 12 Feb 2017 15:13:00 +0000 (UTC) for IP:'209.85.215.66' DOMAIN:'mail-lf0-f66.google.com' HELO:'mail-lf0-f66.google.com' FROM:'bogorodskiy@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.67 (BAYES_50, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.215.66 mail-lf0-f66.google.com 209.85.215.66 mail-lf0-f66.google.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-loop: libvir-list@redhat.com Cc: Fabian Freyer , Roman Bogorodskiy Subject: [libvirt] [PATCH 2/6] bhyve: add support for booting from UEFI X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Fabian Freyer Allow to boot using UEFI rather than using an external boot loader such as bhyveload or grub-bhyve. Also, make LPC PCI-ISA bridge handling more flexible as now it's needed not only for serial ports, but for bootrom as well. Signed-off-by: Roman Bogorodskiy --- src/bhyve/bhyve_command.c | 30 +++++++++++++++++++++++++- src/bhyve/bhyve_driver.c | 27 +++++++++++++++++++---- src/bhyve/bhyve_process.c | 55 +++++++++++++++++++++++++------------------= ---- 3 files changed, 81 insertions(+), 31 deletions(-) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index e7131625c..450800920 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -163,7 +163,6 @@ bhyveBuildConsoleArgStr(const virDomainDef *def, virCom= mandPtr cmd) return -1; } =20 - virCommandAddArgList(cmd, "-s", "1,lpc", NULL); virCommandAddArg(cmd, "-l"); virCommandAddArgFormat(cmd, "com%d,%s", chr->target.port + 1, chr->source->data.file.pa= th); @@ -283,6 +282,14 @@ bhyveBuildVirtIODiskArgStr(const virDomainDef *def ATT= RIBUTE_UNUSED, return 0; } =20 +static int +bhyveBuildLPCArgStr(const virDomainDef *def ATTRIBUTE_UNUSED, + virCommandPtr cmd) +{ + virCommandAddArgList(cmd, "-s", "1,lpc", NULL); + return 0; +} + virCommandPtr virBhyveProcessBuildBhyveCmd(virConnectPtr conn, virDomainDefPtr def, bool dryRun) @@ -296,6 +303,7 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn, * vm0 */ size_t i; + bool add_lpc =3D false; =20 virCommandPtr cmd =3D virCommandNew(BHYVE); =20 @@ -350,6 +358,21 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn, virCommandAddArg(cmd, "-P"); /* vmexit from guest on pause */ =20 virCommandAddArgList(cmd, "-s", "0:0,hostbridge", NULL); + + if (def->os.bootloader =3D=3D NULL && + def->os.loader) { + if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_LPC_BOOTROM)) { + virCommandAddArg(cmd, "-l"); + virCommandAddArgFormat(cmd, "bootrom,%s", def->os.loader->path= ); + add_lpc =3D true; + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Installed bhyve binary does not support " + "UEFI loader")); + goto error; + } + } + /* Devices */ for (i =3D 0; i < def->ncontrollers; i++) { virDomainControllerDefPtr controller =3D def->controllers[i]; @@ -389,8 +412,13 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn, goto error; } } + + if (add_lpc || def->nserials) + bhyveBuildLPCArgStr(def, cmd); + if (bhyveBuildConsoleArgStr(def, cmd) < 0) goto error; + virCommandAddArg(cmd, def->name); =20 return cmd; diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index f4ccef32b..0f9961ae0 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -734,15 +734,34 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn, if (bhyveDomainAssignAddresses(def, NULL) < 0) goto cleanup; =20 - if (!(loadcmd =3D virBhyveProcessBuildLoadCmd(conn, def, "= ", + if (def->os.bootloader =3D=3D NULL && + def->os.loader) { + + if ((def->os.loader->readonly !=3D VIR_TRISTATE_BOOL_YES) + || (def->os.loader->type !=3D VIR_DOMAIN_LOADER_TYPE_PFLASH)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Only read-only pflash is supported.")); + goto cleanup; + } + + if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_LPC_BOOTROM) =3D=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Installed bhyve binary does not support " + "bootrom")); + goto cleanup; + } + } else { + if (!(loadcmd =3D virBhyveProcessBuildLoadCmd(conn, def, "", NULL))) - goto cleanup; + goto cleanup; + + virBufferAdd(&buf, virCommandToString(loadcmd), -1); + virBufferAddChar(&buf, '\n'); + } =20 if (!(cmd =3D virBhyveProcessBuildBhyveCmd(conn, def, true))) goto cleanup; =20 - virBufferAdd(&buf, virCommandToString(loadcmd), -1); - virBufferAddChar(&buf, '\n'); virBufferAdd(&buf, virCommandToString(cmd), -1); =20 if (virBufferCheckError(&buf) < 0) diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c index 9d8097676..a97e300ff 100644 --- a/src/bhyve/bhyve_process.c +++ b/src/bhyve/bhyve_process.c @@ -165,38 +165,41 @@ virBhyveProcessStart(virConnectPtr conn, virCommandSetPidFile(cmd, privconn->pidfile); virCommandDaemonize(cmd); =20 - /* Now bhyve command is constructed, meaning the - * domain is ready to be started, so we can build - * and execute bhyveload command */ - rc =3D virBhyveFormatDevMapFile(vm->def->name, &devmap_file); - if (rc < 0) - goto cleanup; + if (vm->def->os.loader =3D=3D NULL) { + /* Now bhyve command is constructed, meaning the + * domain is ready to be started, so we can build + * and execute bhyveload command */ =20 - if (!(load_cmd =3D virBhyveProcessBuildLoadCmd(conn, vm->def, devmap_f= ile, - &devicemap))) - goto cleanup; - virCommandSetOutputFD(load_cmd, &logfd); - virCommandSetErrorFD(load_cmd, &logfd); + rc =3D virBhyveFormatDevMapFile(vm->def->name, &devmap_file); + if (rc < 0) + goto cleanup; =20 - if (devicemap !=3D NULL) { - rc =3D virFileWriteStr(devmap_file, devicemap, 0644); - if (rc) { - virReportSystemError(errno, - _("Cannot write device.map '%s'"), - devmap_file); + if (!(load_cmd =3D virBhyveProcessBuildLoadCmd(conn, vm->def, devm= ap_file, + &devicemap))) goto cleanup; + virCommandSetOutputFD(load_cmd, &logfd); + virCommandSetErrorFD(load_cmd, &logfd); + + if (devicemap !=3D NULL) { + rc =3D virFileWriteStr(devmap_file, devicemap, 0644); + if (rc) { + virReportSystemError(errno, + _("Cannot write device.map '%s'"), + devmap_file); + goto cleanup; + } } - } =20 - /* Log generated command line */ - virCommandWriteArgLog(load_cmd, logfd); - if ((pos =3D lseek(logfd, 0, SEEK_END)) < 0) - VIR_WARN("Unable to seek to end of logfile: %s", - virStrerror(errno, ebuf, sizeof(ebuf))); + /* Log generated command line */ + virCommandWriteArgLog(load_cmd, logfd); + if ((pos =3D lseek(logfd, 0, SEEK_END)) < 0) + VIR_WARN("Unable to seek to end of logfile: %s", + virStrerror(errno, ebuf, sizeof(ebuf))); =20 - VIR_DEBUG("Loading domain '%s'", vm->def->name); - if (virCommandRun(load_cmd, NULL) < 0) - goto cleanup; + VIR_DEBUG("Loading domain '%s'", vm->def->name); + if (virCommandRun(load_cmd, NULL) < 0) + goto cleanup; + } =20 /* Now we can start the domain */ VIR_DEBUG("Starting domain '%s'", vm->def->name); --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list