[libvirt] [PATCH] test: Return Libvirt logo as domain screenshot
Eric Blake
eblake at redhat.com
Fri Mar 29 22:05:15 UTC 2013
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130329/268aa921/attachment-0001.sig>
More information about the libvir-list
mailing list