[libvirt] [PATCH v3] 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. --- docs/Makefile.am | 1 + libvirt.spec.in | 1 + src/test/test_driver.c | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/docs/Makefile.am b/docs/Makefile.am index 7583772..b5d7575 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -287,6 +287,7 @@ install-data-local: for file in $(devhelphtml) $(devhelppng) $(devhelpcss); do \ $(INSTALL) -m 0644 $(srcdir)/$${file} $(DESTDIR)$(DEVHELP_DIR) ; \ done + $(INSTALL_DATA) $(srcdir)/../docs/libvirtLogo.png $(DESTDIR)$(pkgdatadir) uninstall-local: for h in $(apihtml); do rm $(DESTDIR)$(HTML_DIR)/$$h; done diff --git a/libvirt.spec.in b/libvirt.spec.in index 2da0558..34b3f9c 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -1941,6 +1941,7 @@ fi %{_datadir}/libvirt/schemas/storagevol.rng %{_datadir}/libvirt/cpu_map.xml +%{_datadir}/libvirt/libvirtLogo.png %if %{with_systemd} %{_unitdir}/libvirt-guests.service diff --git a/src/test/test_driver.c b/src/test/test_driver.c index c5fffb9..4dbd775 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -39,11 +39,13 @@ #include "virutil.h" #include "viruuid.h" #include "capabilities.h" +#include "configmake.h" #include "viralloc.h" #include "network_conf.h" #include "interface_conf.h" #include "domain_conf.h" #include "domain_event.h" +#include "fdstream.h" #include "storage_conf.h" #include "node_device_conf.h" #include "virxml.h" @@ -5773,6 +5775,27 @@ cleanup: 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 = { .no = VIR_DRV_TEST, @@ -5843,6 +5866,7 @@ static virDriver testDriver = { .domainEventDeregisterAny = testDomainEventDeregisterAny, /* 0.8.0 */ .isAlive = testIsAlive, /* 0.9.8 */ .nodeGetCPUMap = testNodeGetCPUMap, /* 1.0.0 */ + .domainScreenshot = testDomainScreenshot, /* 1.0.5 */ }; static virNetworkDriver testNetworkDriver = { -- 1.8.1.5

On Tue, Apr 02, 2013 at 01:52:39PM +0200, Michal Privoznik wrote:
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. --- docs/Makefile.am | 1 + libvirt.spec.in | 1 + src/test/test_driver.c | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+)
diff --git a/docs/Makefile.am b/docs/Makefile.am index 7583772..b5d7575 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -287,6 +287,7 @@ install-data-local: for file in $(devhelphtml) $(devhelppng) $(devhelpcss); do \ $(INSTALL) -m 0644 $(srcdir)/$${file} $(DESTDIR)$(DEVHELP_DIR) ; \ done + $(INSTALL_DATA) $(srcdir)/../docs/libvirtLogo.png $(DESTDIR)$(pkgdatadir)
Huh, with '$(srcdir)' you're in 'docs' already, so why are you doing '../docs/' ? Regards, 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 :|

On 02.04.2013 13:56, Daniel P. Berrange wrote:
On Tue, Apr 02, 2013 at 01:52:39PM +0200, Michal Privoznik wrote:
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. --- docs/Makefile.am | 1 + libvirt.spec.in | 1 + src/test/test_driver.c | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+)
diff --git a/docs/Makefile.am b/docs/Makefile.am index 7583772..b5d7575 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -287,6 +287,7 @@ install-data-local: for file in $(devhelphtml) $(devhelppng) $(devhelpcss); do \ $(INSTALL) -m 0644 $(srcdir)/$${file} $(DESTDIR)$(DEVHELP_DIR) ; \ done + $(INSTALL_DATA) $(srcdir)/../docs/libvirtLogo.png $(DESTDIR)$(pkgdatadir)
Huh, with '$(srcdir)' you're in 'docs' already, so why are you doing '../docs/' ?
Dunno. My mind must had a blackout :) Fixed. and pushed among with mingw spec file changes. Michal

On 04/02/2013 05:52 AM, Michal Privoznik wrote:
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. --- docs/Makefile.am | 1 + libvirt.spec.in | 1 + src/test/test_driver.c | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+)
+++ b/libvirt.spec.in @@ -1941,6 +1941,7 @@ fi %{_datadir}/libvirt/schemas/storagevol.rng
%{_datadir}/libvirt/cpu_map.xml +%{_datadir}/libvirt/libvirtLogo.png
mingw-libvirt.spec.in needs the same change. ACK if you fix that and Daniel's comment about a simpler Makefile.am. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Michal Privoznik