From nobody Mon Feb 9 11:46:58 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1486912704137252.34484660999829; Sun, 12 Feb 2017 07:18:24 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1CFDwgH007221; Sun, 12 Feb 2017 10:13:58 -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 v1CFD4wJ024789 for ; Sun, 12 Feb 2017 10:13:04 -0500 Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1CFD4Ue013017 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Sun, 12 Feb 2017 10:13:04 -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 58BC283F38 for ; Sun, 12 Feb 2017 15:13:03 +0000 (UTC) Received: by mail-lf0-f66.google.com with SMTP id q89so6567548lfi.1 for ; Sun, 12 Feb 2017 07:13:02 -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.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Feb 2017 07:13:00 -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=ic4MWW3LlpqKFtJUxJMj2FQuW7bNDo1twxaMWbkEQv8=; b=Rl1ze7wt/V3VcXNdtfwzy7kHdmDaFmwbFXD/Uwa8ZdJ0OqGLLaFR1noLEMBI0e+sEo o6fxwfQqDr9FVSkC2F5mAR+3tEHoui/N4HnCW/YO0qmvgF9eSdjkfzL6ZPfEK/Rm6C8v n6x24/LxFTZlMkYdoexZ54wmBX8IcR6hgqfW4qA9NmAvoujvoZ6ETS612BMIbUPOrEfy 9LGXTLppVAVx5b9kRkKSH1dHF0PQPzDxxOS+8svulqRPzfeVXiDixcSlQW7nA+gK4Zpp 4x2AqNTzfRRKYXz3TwnZGIE+5coBSeebTdImlTsdM67br/wPO7OaGkF29SrAYvvqg1U2 Chgw== 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=ic4MWW3LlpqKFtJUxJMj2FQuW7bNDo1twxaMWbkEQv8=; b=G2k2UyAuQg8DmygDcp+C94YnWLfzXHRJ3sru2aVI0mB5oPOJiLPkIk6Be/hvMvwhVV j/RC0x/S4KE+RqDy7WakWzedjMP0ZZsv2FOiqG49eEl/e2DmEfjgQhcDIPrAT3sXEo0m TS6T1LpBxIG0kPxQv8HHvMb9CVKJjNoVDZ2DJytXqgyhCOWEqD2fc93+1XHjLLLiRLTB BkreY6F940M2MLx6Tyt/ZGhk3vSFqD3nWb3SIvK6em94VEyXX6KYG/3p3LbAHF0+3HTg 4fsHOeigoCAiXS0+JtHrmJsvKUd7bXbhNKIfP6zz7jDPf3cAnaYF0pV8WVXxgDANuM2V njzA== X-Gm-Message-State: AMke39nxD+oP8yeeahAc4w9+/kTqU6GcrMzi3AURkPlAuxP2ibG0Qt4pE39yqkLzNyRLFA== X-Received: by 10.46.9.134 with SMTP id 128mr1363227ljj.133.1486912380645; Sun, 12 Feb 2017 07:13:00 -0800 (PST) From: Roman Bogorodskiy To: libvir-list@redhat.com Date: Sun, 12 Feb 2017 19:12:33 +0400 Message-Id: <20170212151234.25936-6-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.27]); Sun, 12 Feb 2017 15:13:03 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sun, 12 Feb 2017 15:13:03 +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.27 X-loop: libvir-list@redhat.com Cc: Fabian Freyer , Roman Bogorodskiy Subject: [libvirt] [PATCH 5/6] bhyve: add video support 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 bhyve supports 'gop' video device that allows clients to connect to VMs using VNC clients. This commit adds support for that to the bhyve driver: - Introducr 'gop' video device type - Add capabilities probing for the 'fbuf' device that's responsible for graphics - Update command builder routines to let users configure domain's VNC via gop graphics. Signed-off-by: Roman Bogorodskiy --- docs/formatdomain.html.in | 3 +- docs/schemas/domaincommon.rng | 1 + po/POTFILES.in | 1 + src/bhyve/bhyve_capabilities.c | 40 +++++++++++++++ src/bhyve/bhyve_capabilities.h | 1 + src/bhyve/bhyve_command.c | 100 ++++++++++++++++++++++++++++++++= ++++ src/bhyve/bhyve_device.c | 11 ++++ src/conf/domain_conf.c | 5 +- src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 9 ++-- src/qemu/qemu_domain_address.c | 1 + tests/domaincapsschemadata/full.xml | 1 + 12 files changed, 169 insertions(+), 5 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 0a115f5dc..b853a7245 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5812,8 +5812,9 @@ qemu-kvm -net nic,model=3D? /dev/null

The model element has a mandatory type attribute which takes the value "vga", "cirrus", "vmvga", "xen", - "vbox", "qxl" (since 0.8.6) or + "vbox", "qxl" (since 0.8.6), "virtio" (since 1.3.0) + or "gop" (since 3.1.0) depending on the hypervisor features available.

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index d715bff29..3e3793ea0 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3152,6 +3152,7 @@ xen vbox virtio + gop diff --git a/po/POTFILES.in b/po/POTFILES.in index 365ea662f..c6d350da7 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -12,6 +12,7 @@ gnulib/lib/getopt.c gnulib/lib/regcomp.c src/access/viraccessdriverpolkit.c src/access/viraccessmanager.c +src/bhyve/bhyve_capabilities.c src/bhyve/bhyve_command.c src/bhyve/bhyve_device.c src/bhyve/bhyve_domain.c diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c index 9dec66b11..5539d2978 100644 --- a/src/bhyve/bhyve_capabilities.c +++ b/src/bhyve/bhyve_capabilities.c @@ -117,6 +117,7 @@ virBhyveDomainCapsBuild(const char *emulatorbin, virDomainVirtType virttype) { virDomainCapsPtr caps =3D NULL; + unsigned int bhyve_caps =3D 0; DIR *dir; struct dirent *entry; const char *firmware_dir =3D "/usr/local/share/uefi-firmware"; @@ -125,6 +126,12 @@ virBhyveDomainCapsBuild(const char *emulatorbin, if (!(caps =3D virDomainCapsNew(emulatorbin, machine, arch, virttype))) goto cleanup; =20 + if (virBhyveProbeCaps(&bhyve_caps)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed probing capabilities")); + goto cleanup; + } + caps->os.supported =3D true; caps->os.loader.supported =3D true; VIR_DOMAIN_CAPS_ENUM_SET(caps->os.loader.type, @@ -155,6 +162,12 @@ virBhyveDomainCapsBuild(const char *emulatorbin, VIR_DOMAIN_DISK_BUS_SATA, VIR_DOMAIN_DISK_BUS_VIRTIO); =20 + if (bhyve_caps & BHYVE_CAP_FBUF) { + caps->graphics.supported =3D true; + caps->video.supported =3D true; + VIR_DOMAIN_CAPS_ENUM_SET(caps->graphics.type, VIR_DOMAIN_GRAPHICS_= TYPE_VNC); + VIR_DOMAIN_CAPS_ENUM_SET(caps->video.modelType, VIR_DOMAIN_VIDEO_T= YPE_GOP); + } cleanup: VIR_DIR_CLOSE(dir); return caps; @@ -289,6 +302,30 @@ bhyveProbeCapsLPC_Bootrom(unsigned int *caps, char *bi= nary) return ret; } =20 + +static int +bhyveProbeCapsFramebuffer(unsigned int *caps, char *binary) +{ + char *error; + virCommandPtr cmd =3D NULL; + int ret =3D -1, exit; + + cmd =3D virCommandNew(binary); + virCommandAddArgList(cmd, "-s", "0,fbuf", NULL); + virCommandSetErrorBuffer(cmd, &error); + if (virCommandRun(cmd, &exit) < 0) + goto cleanup; + + if (strstr(error, "pci slot 0:0: unknown device \"fbuf\"") =3D=3D NULL) + *caps |=3D BHYVE_CAP_FBUF; + + ret =3D 0; + cleanup: + VIR_FREE(error); + virCommandFree(cmd); + return ret; +} + int virBhyveProbeCaps(unsigned int *caps) { @@ -313,6 +350,9 @@ virBhyveProbeCaps(unsigned int *caps) if ((ret =3D bhyveProbeCapsLPC_Bootrom(caps, binary))) goto out; =20 + if ((ret =3D bhyveProbeCapsFramebuffer(caps, binary))) + goto out; + out: VIR_FREE(binary); return ret; diff --git a/src/bhyve/bhyve_capabilities.h b/src/bhyve/bhyve_capabilities.h index 746c77181..8fb97d730 100644 --- a/src/bhyve/bhyve_capabilities.h +++ b/src/bhyve/bhyve_capabilities.h @@ -41,6 +41,7 @@ typedef enum { BHYVE_CAP_AHCI32SLOT =3D 1 << 1, BHYVE_CAP_NET_E1000 =3D 1 << 2, BHYVE_CAP_LPC_BOOTROM =3D 1 << 3, + BHYVE_CAP_FBUF =3D 1 << 4, } virBhyveCapsFlags; =20 int virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps); diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 450800920..ec7a71572 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -290,6 +290,94 @@ bhyveBuildLPCArgStr(const virDomainDef *def ATTRIBUTE_= UNUSED, return 0; } =20 +static int +bhyveBuildGraphicsArgStr(const virDomainDef *def ATTRIBUTE_UNUSED, + virDomainGraphicsDefPtr graphics, + virDomainVideoDefPtr video, + virConnectPtr conn, + virCommandPtr cmd) +{ + virBuffer opt =3D VIR_BUFFER_INITIALIZER; + virDomainGraphicsListenDefPtr glisten =3D NULL; + bool escapeAddr; + + if (!(bhyveDriverGetCaps(conn) & BHYVE_CAP_LPC_BOOTROM) || + def->os.bootloader || + !def->os.loader) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Graphics are only supported" + " when booting using UEFI")); + return -1; + } + + if (!(bhyveDriverGetCaps(conn) & BHYVE_CAP_FBUF)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Bhyve version does not support framebuffer")); + return -1; + } + + if (graphics->type !=3D VIR_DOMAIN_GRAPHICS_TYPE_VNC) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Only VNC supported")); + return -1; + } + + if (!(glisten =3D virDomainGraphicsGetListen(graphics, 0))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing listen element")); + goto error; + } + + virBufferAsprintf(&opt, "%d:%d,fbuf", video->info.addr.pci.slot, video= ->info.addr.pci.function); + + switch (glisten->type) { + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: + virBufferAddLit(&opt, ",tcp=3D"); + + if (!graphics->data.vnc.autoport && + (graphics->data.vnc.port < 5900 || + graphics->data.vnc.port > 65535)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("vnc port must be in range [5900,65535]")); + goto error; + } + + if (graphics->data.vnc.auth.passwd) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("vnc password auth not supported")); + goto error; + } else { + /* Bhyve doesn't support VNC Auth yet, so print a warning abo= ut + * unauthenticated VNC sessions */ + VIR_WARN("%s", _("Security warning: currently VNC auth is not" + " supported.")); + } + + if (glisten->address) { + escapeAddr =3D strchr(glisten->address, ':') !=3D NULL; + if (escapeAddr) + virBufferAsprintf(&opt, "[%s]", glisten->address); + else + virBufferAdd(&opt, glisten->address, -1); + } + + virBufferAsprintf(&opt, ":%d", graphics->data.vnc.port); + break; + default: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Unsupported listen type")); + } + + virCommandAddArg(cmd, "-s"); + virCommandAddArgBuffer(cmd, &opt); + return 0; + + error: + virBufferFreeAndReset(&opt); + return -1; +} + virCommandPtr virBhyveProcessBuildBhyveCmd(virConnectPtr conn, virDomainDefPtr def, bool dryRun) @@ -413,6 +501,18 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn, } } =20 + if (def->ngraphics && def->nvideos) { + if (def->ngraphics =3D=3D 1 && def->nvideos =3D=3D 1) { + if (bhyveBuildGraphicsArgStr(def, def->graphics[0], def->video= s[0], conn, cmd) < 0) + goto error; + add_lpc =3D true; + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Multiple graphics devices are not supported"= )); + goto error; + } + } + if (add_lpc || def->nserials) bhyveBuildLPCArgStr(def, cmd); =20 diff --git a/src/bhyve/bhyve_device.c b/src/bhyve/bhyve_device.c index 55ce631ec..a3a263b7e 100644 --- a/src/bhyve/bhyve_device.c +++ b/src/bhyve/bhyve_device.c @@ -145,6 +145,17 @@ bhyveAssignDevicePCISlots(virDomainDefPtr def, goto error; } =20 + for (i =3D 0; i < def->nvideos; i++) { + if (!virDeviceInfoPCIAddressWanted(&def->videos[i]->info)) + continue; + if (virDomainPCIAddressReserveNextAddr(addrs, + &def->videos[i]->info, + VIR_PCI_CONNECT_TYPE_PCI_DE= VICE, + -1) < 0) + goto error; + } + + return 0; =20 error: diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1bc72a4e9..77fe87582 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -545,7 +545,8 @@ VIR_ENUM_IMPL(virDomainVideo, VIR_DOMAIN_VIDEO_TYPE_LAS= T, "vbox", "qxl", "parallels", - "virtio") + "virtio", + "gop") =20 VIR_ENUM_IMPL(virDomainInput, VIR_DOMAIN_INPUT_TYPE_LAST, "mouse", @@ -13018,6 +13019,8 @@ virDomainVideoDefaultType(const virDomainDef *def) return VIR_DOMAIN_VIDEO_TYPE_VGA; else return VIR_DOMAIN_VIDEO_TYPE_PARALLELS; + case VIR_DOMAIN_VIRT_BHYVE: + return VIR_DOMAIN_VIDEO_TYPE_GOP; default: return -1; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index dd79206f6..0876eabbf 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1335,6 +1335,7 @@ typedef enum { VIR_DOMAIN_VIDEO_TYPE_QXL, VIR_DOMAIN_VIDEO_TYPE_PARALLELS, /* pseudo device for VNC in container= s */ VIR_DOMAIN_VIDEO_TYPE_VIRTIO, + VIR_DOMAIN_VIDEO_TYPE_GOP, =20 VIR_DOMAIN_VIDEO_TYPE_LAST } virDomainVideoType; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c00a47a91..aabdcdcee 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -100,7 +100,8 @@ VIR_ENUM_IMPL(qemuVideo, VIR_DOMAIN_VIDEO_TYPE_LAST, "", /* don't support vbox */ "qxl", "", /* don't support parallels */ - "" /* no need for virtio */); + "", /* no need for virtio */ + "" /* don't support gop */); =20 VIR_ENUM_DECL(qemuDeviceVideo) =20 @@ -112,7 +113,8 @@ VIR_ENUM_IMPL(qemuDeviceVideo, VIR_DOMAIN_VIDEO_TYPE_LA= ST, "", /* don't support vbox */ "qxl-vga", "", /* don't support parallels */ - "virtio-vga"); + "virtio-vga", + "" /* don't support gop */); =20 VIR_ENUM_DECL(qemuDeviceVideoSecondary) =20 @@ -124,7 +126,8 @@ VIR_ENUM_IMPL(qemuDeviceVideoSecondary, VIR_DOMAIN_VIDE= O_TYPE_LAST, "", /* don't support vbox */ "qxl", "", /* don't support parallels */ - "virtio-gpu-pci"); + "virtio-gpu-pci", + "" /* don't support gop */); =20 VIR_ENUM_DECL(qemuSoundCodec) =20 diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 70482f224..e22adacb2 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -741,6 +741,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDevic= eDefPtr dev, case VIR_DOMAIN_VIDEO_TYPE_PARALLELS: return pciFlags; =20 + case VIR_DOMAIN_VIDEO_TYPE_GOP: case VIR_DOMAIN_VIDEO_TYPE_LAST: return 0; } diff --git a/tests/domaincapsschemadata/full.xml b/tests/domaincapsschemada= ta/full.xml index 6abd4995a..6a676253c 100644 --- a/tests/domaincapsschemadata/full.xml +++ b/tests/domaincapsschemadata/full.xml @@ -70,6 +70,7 @@ qxl parallels virtio + gop --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list