test: Return Libvirt logo as domain screenshot

This is just a bare Easter Egg. Whenever a user runs virDomainScreenshot
over a domain in test driver, he'll get the Libvirt PNG logo in return.
This commit is contained in:
Michal Privoznik 2013-03-29 22:25:13 +01:00
parent 6f7e4ea359
commit 5e5ca84e31
4 changed files with 28 additions and 0 deletions

View File

@ -287,6 +287,7 @@ install-data-local:
for file in $(devhelphtml) $(devhelppng) $(devhelpcss); do \ for file in $(devhelphtml) $(devhelppng) $(devhelpcss); do \
$(INSTALL) -m 0644 $(srcdir)/$${file} $(DESTDIR)$(DEVHELP_DIR) ; \ $(INSTALL) -m 0644 $(srcdir)/$${file} $(DESTDIR)$(DEVHELP_DIR) ; \
done done
$(INSTALL_DATA) $(srcdir)/libvirtLogo.png $(DESTDIR)$(pkgdatadir)
uninstall-local: uninstall-local:
for h in $(apihtml); do rm $(DESTDIR)$(HTML_DIR)/$$h; done for h in $(apihtml); do rm $(DESTDIR)$(HTML_DIR)/$$h; done

View File

@ -1941,6 +1941,7 @@ fi
%{_datadir}/libvirt/schemas/storagevol.rng %{_datadir}/libvirt/schemas/storagevol.rng
%{_datadir}/libvirt/cpu_map.xml %{_datadir}/libvirt/cpu_map.xml
%{_datadir}/libvirt/libvirtLogo.png
%if %{with_systemd} %if %{with_systemd}
%{_unitdir}/libvirt-guests.service %{_unitdir}/libvirt-guests.service

View File

@ -221,6 +221,7 @@ rm -rf $RPM_BUILD_ROOT%{mingw64_libexecdir}/libvirt-guests.sh
%{mingw32_datadir}/libvirt/api/libvirt-qemu-api.xml %{mingw32_datadir}/libvirt/api/libvirt-qemu-api.xml
%{mingw32_datadir}/libvirt/cpu_map.xml %{mingw32_datadir}/libvirt/cpu_map.xml
%{mingw32_datadir}/libvirt/libvirtLogo.png
%{mingw32_datadir}/locale/*/LC_MESSAGES/libvirt.mo %{mingw32_datadir}/locale/*/LC_MESSAGES/libvirt.mo
@ -280,6 +281,7 @@ rm -rf $RPM_BUILD_ROOT%{mingw64_libexecdir}/libvirt-guests.sh
%{mingw64_datadir}/libvirt/api/libvirt-qemu-api.xml %{mingw64_datadir}/libvirt/api/libvirt-qemu-api.xml
%{mingw64_datadir}/libvirt/cpu_map.xml %{mingw64_datadir}/libvirt/cpu_map.xml
%{mingw64_datadir}/libvirt/libvirtLogo.png
%{mingw64_datadir}/locale/*/LC_MESSAGES/libvirt.mo %{mingw64_datadir}/locale/*/LC_MESSAGES/libvirt.mo

View File

@ -39,11 +39,13 @@
#include "virutil.h" #include "virutil.h"
#include "viruuid.h" #include "viruuid.h"
#include "capabilities.h" #include "capabilities.h"
#include "configmake.h"
#include "viralloc.h" #include "viralloc.h"
#include "network_conf.h" #include "network_conf.h"
#include "interface_conf.h" #include "interface_conf.h"
#include "domain_conf.h" #include "domain_conf.h"
#include "domain_event.h" #include "domain_event.h"
#include "fdstream.h"
#include "storage_conf.h" #include "storage_conf.h"
#include "node_device_conf.h" #include "node_device_conf.h"
#include "virxml.h" #include "virxml.h"
@ -5773,6 +5775,27 @@ cleanup:
return ret; return ret;
} }
static char *
testDomainScreenshot(virDomainPtr dom ATTRIBUTE_UNUSED,
virStreamPtr st,
unsigned int screen ATTRIBUTE_UNUSED,
unsigned int flags)
{
char *ret = NULL;
virCheckFlags(0, NULL);
if (!(ret = strdup("image/png"))) {
virReportOOMError();
return NULL;
}
if (virFDStreamOpenFile(st, PKGDATADIR "/libvirtLogo.png", 0, 0, O_RDONLY < 0))
VIR_FREE(ret);
return ret;
}
static virDriver testDriver = { static virDriver testDriver = {
.no = VIR_DRV_TEST, .no = VIR_DRV_TEST,
@ -5843,6 +5866,7 @@ static virDriver testDriver = {
.domainEventDeregisterAny = testDomainEventDeregisterAny, /* 0.8.0 */ .domainEventDeregisterAny = testDomainEventDeregisterAny, /* 0.8.0 */
.isAlive = testIsAlive, /* 0.9.8 */ .isAlive = testIsAlive, /* 0.9.8 */
.nodeGetCPUMap = testNodeGetCPUMap, /* 1.0.0 */ .nodeGetCPUMap = testNodeGetCPUMap, /* 1.0.0 */
.domainScreenshot = testDomainScreenshot, /* 1.0.5 */
}; };
static virNetworkDriver testNetworkDriver = { static virNetworkDriver testNetworkDriver = {