On Mon, Oct 24, 2011 at 02:56:36PM -0600, Eric Blake wrote:
On 10/21/2011 06:55 AM, Daniel P. Berrange wrote:
>From: "Daniel P. Berrange"<berrange(a)redhat.com>
>
>The virDomainOpenGraphics API allows a libvirt client to pass in
>a file descriptor for an open socket pair, and get it connected
>to the graphics display of the guest. This is limited to working
>with local libvirt hypervisors conencted over a UNIX domain
s/conencted/connected/
>socket, since it will use UNIX FD passing
>
>* include/libvirt/libvirt.h.in: Define virDomainOpenGraphics
>* src/driver.h: Define driver for virDomainOpenGraphics
>* src/libvirt_public.syms, src/libvirt.c: Entry point for
> virDomainOpenGraphics
>---
> include/libvirt/libvirt.h.in | 9 ++++++
> src/driver.h | 6 ++++
> src/libvirt.c | 66 ++++++++++++++++++++++++++++++++++++++++++
> src/libvirt_public.syms | 1 +
> 4 files changed, 82 insertions(+), 0 deletions(-)
>
>+++ b/src/libvirt.c
>@@ -16975,3 +16975,69 @@ error:
> virDispatchError(dom->conn);
> return -1;
> }
>+
>+
>+/**
>+ * virDomainOpenGraphics:
>+ * @dom: pointer to domain object
>+ * @fd: file descriptor to attach graphics to
>+ * @idx: index of graphics config to open
Swap these two lines to match parameter order.
>+ * @flags: flags to control open operation
>+ *
>+ * This will attempt to connect the file descriptor @fd, to
>+ * the graphics backend of @dom. If @dom has multiple graphics
>+ * backends configured, then @idx will determine which one is
>+ * opened, starting from @idx 0.
>+ *
>+ * To disable any authentication, pass the VIR_DOMAIN_OPEN_GRAPHICS_SKIPAUTH
>+ * constant for @flags.
>+ *
>+ * The caller should use an anonymous socketpair to open
>+ * @fd before invocation.
>+ *
>+ * This method can only be used when connected to a local
>+ * libvirt hypervisor, over a UNIX domain socket. Attempts
>+ * to use this method over a TCP connection will always fail
>+ *
>+ * Returns 0 on success, -1 on failure
>+ */
>+int virDomainOpenGraphics(virDomainPtr dom,
>+ unsigned int idx,
>+ int fd,
>+ unsigned int flags)
>+{
>+ VIR_DOMAIN_DEBUG(dom, "idx=%u, fd=%d, flags=%x",
>+ idx, fd, flags);
>+
>+ virResetLastError();
>+
>+ if (!VIR_IS_DOMAIN(dom)) {
>+ virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
>+ virDispatchError(NULL);
>+ return -1;
>+ }
>+
>+ if (fd< 0) {
>+ virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
>+ goto error;
>+ }
Should we also fstat() and validate that fd is a socket fd?
Ok, I guess we can.
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|