Re: [PATCH] test: Return Libvirt logo as domain screenshot

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

 



On 03/29/2013 03:52 PM, Michal Privoznik wrote:
> This is just a bare Easter Egg. Whenever user run virDomainScreenshot
> over a domain in test driver, he'll get the Libvirt PNG logo in return.

Cute idea, and handy for easier testing of screenshot API.

> +static char *
> +testDomainScreenshot(virDomainPtr dom ATTRIBUTE_UNUSED,
> +                     virStreamPtr st,
> +                     unsigned int screen ATTRIBUTE_UNUSED,
> +                     unsigned int flags)
> +{
> +    char *ret = NULL;
> +
> +    virCheckFlags(0, NULL);
> +
> +    if (virFDStreamOpenFile(st, PKGDATADIR "/libvirtLogo.png", 0, 0, O_RDONLY < 0))
> +        goto cleanup;
> +
> +    ret = strdup("image/png");

Missing an OOM check, in which case you also end up leaking an
incomplete stream.  I'd swap the strdup to happen first so you don't
have to clean up a stream.

> @@ -5843,6 +5864,7 @@ static virDriver testDriver = {
>      .domainEventDeregisterAny = testDomainEventDeregisterAny, /* 0.8.0 */
>      .isAlive = testIsAlive, /* 0.9.8 */
>      .nodeGetCPUMap = testNodeGetCPUMap, /* 1.0.0 */
> +    .domainScreenshot = testDomainScreenshot, /* 1.0.4 */

That's pushing it; this is probably post-release material.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

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