Re: [PATCH v4 3/8] screenshot: Implementing the public API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 12, 2011 at 06:29:10PM +0200, Michal Privoznik wrote:
> * src/libvirt.c: new function virDomainScreenshot
> ---
>  src/libvirt.c |   60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 60 insertions(+), 0 deletions(-)
> 
> diff --git a/src/libvirt.c b/src/libvirt.c
> index 7564db0..914618d 100644
> --- a/src/libvirt.c
> +++ b/src/libvirt.c
> @@ -2444,6 +2444,66 @@ error:
>  }
>  
>  /**
> + * virDomainScreenshot:
> + * @domain: a domain object
> + * @stream: stream to use as output
> + * @screen: monitor ID to take screenshot from
> + * @flags: extra flags, currently unused
> + *
> + * Take a screenshot of current domain console as a stream. The image format
> + * is hypervisor specific. Moreover, some hypervisors supports multiple
> + * displays per domain. These can be distinguished by @screen argument.

Need to document the semantics of 'screen' wrt to multiple devices
and multiple outputs.

> + *
> + * This call sets up a stream; subsequent use of stream API is necessary
> + * to transfer actual data, determine how much data is successfully
> + * transfered, and detect any errors.
> + *
> + * Returns a string representing the mime-type of the image format, or
> + * NULL upon error. The caller must free() the returned value.
> + */
> +char *
> +virDomainScreenshot(virDomainPtr domain,
> +                    virStreamPtr stream,
> +                    unsigned int screen,
> +                    unsigned int flags)
> +{
> +    VIR_DOMAIN_DEBUG(domain, "stream=%p flags=%u", stream, flags);
> +
> +    virResetLastError();
> +
> +    if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
> +        virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
> +        virDispatchError(NULL);
> +        return NULL;
> +    }
> +    if (!VIR_IS_STREAM(stream)) {
> +        virLibConnError(VIR_ERR_INVALID_STREAM, __FUNCTION__);
> +        return NULL;
> +    }
> +    if (domain->conn->flags & VIR_CONNECT_RO ||
> +        stream->conn->flags & VIR_CONNECT_RO) {
> +        virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
> +        goto error;
> +    }
> +
> +    if (domain->conn->driver->domainScreenshot) {
> +        char * ret;
> +        ret = domain->conn->driver->domainScreenshot(domain, stream,
> +                                                     screen, flags);
> +
> +        if (ret == NULL)
> +            goto error;
> +        return ret;
> +    }
> +
> +    virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
> +
> +error:
> +    virDispatchError(domain->conn);
> +    return NULL;
> +}


ACK

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 :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]