From: Stefan Bader <stefan.bader@canonical.com>
To: jfehlig@suse.com
Cc: libvir-list@redhat.com, xen-devel@lists.xenproject.org
Subject: [PATCH] libxl: Implement basic video device selection
Date: Tue, 1 Jul 2014 09:58:18 +0200 [thread overview]
Message-ID: <1404201498-6673-1-git-send-email-stefan.bader@canonical.com> (raw)
In-Reply-To: <5387B626.3040407@suse.com>
being as bad with timely responses. Ok, so how about the following?
One note: it could be the STRDUP's are not strictly needed. But
to me it felt wrong to have two places refer to the same strings
(as MakeVFB copies the struct containing the pointers). If this
is not needed, then all changes now in MakeVFB probably can be
dropped (except setting the keyboard layout, maybe; which I
might miss ;)).
-Stefan
>From a95db265fa4c1a231e7c2d70baa360c6a0500e3b Mon Sep 17 00:00:00 2001
From: Stefan Bader <stefan.bader@canonical.com>
Date: Thu, 27 Mar 2014 16:01:18 +0100
Subject: [PATCH] libxl: Implement basic video device selection
This started as an investigation into an issue where libvirt (using the
libxl driver) and the Xen host, like an old couple, could not agree on
who is responsible for selecting the VNC port to use.
Things usually (and a bit surprisingly) did work because, just like that
old couple, they had the same idea on what to do by default. However it
was possible that this ended up in a big argument.
The problem is that display information exists in two different places:
in the vfbs list and in the build info. And for launching the device model,
only the latter is used. But that never gets initialized from libvirt. So
Xen allows the device model to select a default port while libvirt thinks
it has told Xen that this is done by libvirt (though the vfbs config).
While fixing that, I made a stab at actually evaluating the configuration
of the video device. So that it is now possible to at least decide between
a Cirrus or standard VGA emulation and to modify the VRAM within certain
limits using libvirt.
[v2: Check return code of VIR_STRDUP and fix indentation]
[v3: Split out VRAM fixup and return error for unsupported video type]
[v4: Re-arrange code and move VFB setup into libxlMakeVfbList]
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
---
src/libxl/libxl_conf.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 61 insertions(+), 2 deletions(-)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 8eeaf82..43cabcf 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -1098,10 +1098,21 @@ libxlMakeVfbList(virPortAllocatorPtr graphicsports,
libxl_domain_build_info *b_info = &d_config->b_info;
libxl_device_vfb vfb = d_config->vfbs[0];
- if (libxl_defbool_val(vfb.vnc.enable))
+ if (libxl_defbool_val(vfb.vnc.enable)) {
memcpy(&b_info->u.hvm.vnc, &vfb.vnc, sizeof(libxl_vnc_info));
- else if (libxl_defbool_val(vfb.sdl.enable))
+ if (VIR_STRDUP(b_info->u.hvm.vnc.listen, vfb.vnc.listen) < 0)
+ goto error;
+ if (VIR_STRDUP(b_info->u.hvm.vnc.passwd, vfb.vnc.passwd) < 0)
+ goto error;
+ } else if (libxl_defbool_val(vfb.sdl.enable)) {
memcpy(&b_info->u.hvm.sdl, &vfb.sdl, sizeof(libxl_sdl_info));
+ if (VIR_STRDUP(b_info->u.hvm.sdl.display, vfb.sdl.display) < 0)
+ goto error;
+ if (VIR_STRDUP(b_info->u.hvm.sdl.xauthority, vfb.sdl.xauthority) < 0)
+ goto error;
+ }
+ if (VIR_STRDUP(b_info->u.hvm.keymap, vfb.keymap) < 0)
+ goto error;
}
return 0;
@@ -1363,6 +1374,45 @@ libxlMakeCapabilities(libxl_ctx *ctx)
return NULL;
}
+static int
+libxlMakeVideo(virDomainDefPtr def, libxl_domain_config *d_config)
+{
+ libxl_domain_build_info *b_info = &d_config->b_info;
+
+ if (d_config->c_info.type != LIBXL_DOMAIN_TYPE_HVM)
+ return 0;
+
+ /*
+ * Take the first defined video device (graphics card) to display
+ * on the first graphics device (display).
+ * Right now only type and vram info is used and anything beside
+ * type xen and vga is mapped to cirrus.
+ */
+ if (def->nvideos) {
+ switch (def->videos[0]->type) {
+ case VIR_DOMAIN_VIDEO_TYPE_VGA:
+ case VIR_DOMAIN_VIDEO_TYPE_XEN:
+ b_info->u.hvm.vga.kind = LIBXL_VGA_INTERFACE_TYPE_STD;
+ break;
+ case VIR_DOMAIN_VIDEO_TYPE_CIRRUS:
+ b_info->u.hvm.vga.kind = LIBXL_VGA_INTERFACE_TYPE_CIRRUS;
+ break;
+ default:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ "%s",
+ _("video type not supported by libxl"));
+ return -1;
+ }
+ b_info->video_memkb = def->videos[0]->vram ?
+ def->videos[0]->vram :
+ LIBXL_MEMKB_DEFAULT;
+ } else {
+ libxl_defbool_set(&b_info->u.hvm.nographic, 1);
+ }
+
+ return 0;
+}
+
int
libxlBuildDomainConfig(virPortAllocatorPtr graphicsports,
virDomainDefPtr def,
@@ -1389,6 +1439,15 @@ libxlBuildDomainConfig(virPortAllocatorPtr graphicsports,
if (libxlMakePCIList(def, d_config) < 0)
return -1;
+ /*
+ * Now that any potential VFBs are defined, it is time to update the
+ * build info with the data of the primary display. Some day libxl
+ * might implicitely do so but as it does not right now, better be
+ * explicit.
+ */
+ if (libxlMakeVideo(def, d_config) < 0)
+ return -1;
+
d_config->on_reboot = def->onReboot;
d_config->on_poweroff = def->onPoweroff;
d_config->on_crash = def->onCrash;
--
1.7.9.5
next parent reply other threads:[~2014-07-01 7:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <5387B626.3040407@suse.com>
2014-07-01 7:58 ` Stefan Bader [this message]
2014-07-16 21:05 ` [PATCH] libxl: Implement basic video device selection Jim Fehlig
[not found] ` <53C6E91E.9010500@suse.com>
2014-07-16 21:16 ` [libvirt] " Eric Blake
2014-07-17 9:30 ` Stefan Bader
2014-07-17 21:31 ` Jim Fehlig
2014-09-18 13:55 Stefan Bader
[not found] <1411048512-13045-1-git-send-email-stefan.bader@canonical.com>
2014-09-19 3:01 ` Jim Fehlig
2014-09-19 12:52 ` Stefan Bader
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1404201498-6673-1-git-send-email-stefan.bader@canonical.com \
--to=stefan.bader@canonical.com \
--cc=jfehlig@suse.com \
--cc=libvir-list@redhat.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).