Browse Source

spice-streaming-agent package creation

Signed-off-by: virtbuilder_pel7x64builder0 <virtbuilder@powerel.org>
master
virtbuilder_pel7x64builder0 6 years ago
parent
commit
d063c6525e
  1. 36
      SOURCES/0001-start-streaming-check-num_codecs.patch
  2. 33
      SOURCES/0002-LoadPlugin-call-dlclose-upon-failure.patch
  3. 38
      SOURCES/0003-main-better-cleanup-when-XOpenDisplay-or-XFixesQuery.patch
  4. 34
      SOURCES/0004-jpeg-Do-not-use-next_output_byte-buf_empty_output_bu.patch
  5. 97
      SPECS/spice-streaming-agent.spec

36
SOURCES/0001-start-streaming-check-num_codecs.patch

@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
From 5aaaa5bd91261a6b61fcaa75585f8446b9eeb036 Mon Sep 17 00:00:00 2001
From: Uri Lublin <uril@redhat.com>
Date: Tue, 31 Jul 2018 16:18:15 +0300
Subject: [PATCH 1/4] start streaming: check num_codecs

The server sends StreamMsgStartStop to tell spice-streaming-agent
to start streaming and a list of available codecs.

The first uint8_t is the number of codecs.
Each following uint8_t is a codec.

This patch checks that the number of codecs in the message, as
reported by the server, is not too large.
---
src/spice-streaming-agent.cpp | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
index 1121f35..9ebbf5d 100644
--- a/src/spice-streaming-agent.cpp
+++ b/src/spice-streaming-agent.cpp
@@ -95,6 +95,11 @@ static void handle_stream_start_stop(StreamPort &stream_port, uint32_t len)
syslog(LOG_INFO, "GOT START_STOP message -- request to %s streaming\n",
streaming_requested ? "START" : "STOP");
client_codecs.clear();
+ const int mnc = len - 1; /* max num codecs, see struct StreamMsgStartStop */
+ if (msg[0] > mnc) {
+ throw std::runtime_error("num_codecs=" + std::to_string(msg[0]) +
+ " > max_num_codecs=" + std::to_string(mnc));
+ }
for (int i = 1; i <= msg[0]; ++i) {
client_codecs.insert((SpiceVideoCodecType) msg[i]);
}
--
2.17.1

33
SOURCES/0002-LoadPlugin-call-dlclose-upon-failure.patch

@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
From 9a7ba6b16e608054f910a76d28e14fd85a00dec3 Mon Sep 17 00:00:00 2001
From: Uri Lublin <uril@redhat.com>
Date: Wed, 1 Aug 2018 11:03:04 +0300
Subject: [PATCH 2/4] LoadPlugin: call dlclose upon failure

Signed-off-by: Uri Lublin <uril@redhat.com>
---
src/concrete-agent.cpp | 2 ++
1 file changed, 2 insertions(+)

diff --git a/src/concrete-agent.cpp b/src/concrete-agent.cpp
index ca666d7..1f8b4b4 100644
--- a/src/concrete-agent.cpp
+++ b/src/concrete-agent.cpp
@@ -88,6 +88,7 @@ void ConcreteAgent::LoadPlugin(const std::string &plugin_filename)
if (!version) {
syslog(LOG_ERR, "error loading plugin %s: no version information",
plugin_filename.c_str());
+ dlclose(dl);
return;
}
if (!PluginVersionIsCompatible(*version)) {
@@ -95,6 +96,7 @@ void ConcreteAgent::LoadPlugin(const std::string &plugin_filename)
"error loading plugin %s: plugin interface version %u.%u not accepted",
plugin_filename.c_str(),
MajorVersion(*version), MinorVersion(*version));
+ dlclose(dl);
return;
}
--
2.17.1

38
SOURCES/0003-main-better-cleanup-when-XOpenDisplay-or-XFixesQuery.patch

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
From d85f863389cf5e36623aad0eb79818e888e15e66 Mon Sep 17 00:00:00 2001
From: Uri Lublin <uril@redhat.com>
Date: Tue, 31 Jul 2018 17:15:09 +0300
Subject: [PATCH 3/4] main: better cleanup when XOpenDisplay or XFixesQuery
fail

close f_log if needed.
close X display if needed.
---
src/spice-streaming-agent.cpp | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
index 9ebbf5d..f342ebf 100644
--- a/src/spice-streaming-agent.cpp
+++ b/src/spice-streaming-agent.cpp
@@ -517,11 +517,18 @@ int main(int argc, char* argv[])
Display *display = XOpenDisplay(NULL);
if (display == NULL) {
+ if (f_log) {
+ fclose(f_log);
+ }
syslog(LOG_ERR, "failed to open display\n");
return EXIT_FAILURE;
}
int event_base, error_base;
if (!XFixesQueryExtension(display, &event_base, &error_base)) {
+ if (f_log) {
+ fclose(f_log);
+ }
+ XCloseDisplay(display);
syslog(LOG_ERR, "XFixesQueryExtension failed\n");
return EXIT_FAILURE;
}
--
2.17.1

34
SOURCES/0004-jpeg-Do-not-use-next_output_byte-buf_empty_output_bu.patch

@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
From 0605440f7344d9d6d1b047992fbadcd256f2c301 Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <fziglio@redhat.com>
Date: Tue, 17 Jul 2018 16:24:06 +0100
Subject: [PATCH 4/4] jpeg: Do not use next_output_byte buf_empty_output_buffer

The pointer is not updated to the last byte used so using it
to compute the bytes written into the buffer we ignore some bytes
causing some image corruptions.
Note that also free_in_buffer is not updated to last written byte.
When buf_empty_output_buffer is called the buffer is full so use the
size of it instead of relying on next_output_byte or free_in_buffer.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
---
src/jpeg.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/jpeg.cpp b/src/jpeg.cpp
index ceee359..5f6d128 100644
--- a/src/jpeg.cpp
+++ b/src/jpeg.cpp
@@ -23,7 +23,7 @@ struct JpegBuffer: public jpeg_destination_mgr
static boolean buf_empty_output_buffer(j_compress_ptr cinfo)
{
JpegBuffer *buf = (JpegBuffer *) cinfo->dest;
- size_t size = buf->next_output_byte - &buf->buffer[0];
+ size_t size = buf->buffer.size();
buf->buffer.resize(buf->buffer.capacity() * 2);
buf->next_output_byte = &buf->buffer[0] + size;
buf->free_in_buffer = buf->buffer.size() - size;
--
2.17.1

97
SPECS/spice-streaming-agent.spec

@ -0,0 +1,97 @@ @@ -0,0 +1,97 @@
Name: spice-streaming-agent
Version: 0.2
Release: 3%{?dist}
Summary: SPICE streaming agent
Group: Applications/System
License: ASL 2.0
URL: https://www.redhat.com
Source0: %{name}-%{version}.tar.xz

Patch1: 0001-start-streaming-check-num_codecs.patch
Patch2: 0002-LoadPlugin-call-dlclose-upon-failure.patch
Patch3: 0003-main-better-cleanup-when-XOpenDisplay-or-XFixesQuery.patch
Patch4: 0004-jpeg-Do-not-use-next_output_byte-buf_empty_output_bu.patch

BuildRequires: spice-protocol >= 0.12.14
BuildRequires: libX11-devel libXfixes-devel
BuildRequires: libjpeg-turbo-devel
BuildRequires: catch-devel
BuildRequires: pkgconfig(udev)
# we need /usr/sbin/semanage program which is available on different
# packages depending on distribution
Requires(post): /usr/sbin/semanage
Requires(postun): /usr/sbin/semanage

ExclusiveArch: x86_64

%description
An agent, running on a guest, sending video streams of the X display to a
remote client (over SPICE).

%package devel
Requires: spice-protocol >= 0.12.14
Requires: pkgconfig
Summary: SPICE streaming agent development files

%description devel
This package contains necessary header files to build SPICE streaming
agent plugins.

%prep
%setup -q
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1

%build
%configure --enable-tests --with-udevrulesdir=%{_udevrulesdir}
make %{?_smp_mflags} V=1

%check
make check

%install
make install DESTDIR=%{buildroot} V=1
if test -d "%{buildroot}/%{_libdir}/%{name}/plugins"; then
find %{buildroot}/%{_libdir}/%{name}/plugins -name '*.la' -delete
fi

%post
semanage fcontext -a -t xserver_exec_t %{_bindir}/spice-streaming-agent 2>/dev/null || :
restorecon %{_bindir}/spice-streaming-agent || :

%postun
if [ $1 -eq 0 ] ; then # final removal
semanage fcontext -d -t xserver_exec_t %{_bindir}/spice-streaming-agent 2>/dev/null || :
fi


%files
%doc COPYING NEWS README
%{_udevrulesdir}/90-spice-guest-streaming.rules
%{_bindir}/spice-streaming-agent
%{_sysconfdir}/xdg/autostart/spice-streaming.desktop
%{_datadir}/gdm/greeter/autostart/spice-streaming.desktop

%files devel
%defattr(-,root,root,-)
%{_includedir}
%{_libdir}/pkgconfig

%changelog
* Wed Aug 1 2018 Uri Lublin <uril@redhat.com> - 0.2-3
- Fix coverity issue
Related: rhbz#1479294

* Wed Aug 1 2018 Uri Lublin <uril@redhat.com> - 0.2-2
- Fix coverity issues
- Fix mjpeg encoder
Related: rhbz#1479294

* Thu May 31 2018 Uri Lublin <uril@redhat.com> - 0.2-1
- First release
Related: rhbz#1479294

* Wed Aug 16 2017 Frediano Ziglio <fziglio@redhat.com> - 0.1-1
- Initial package (pre-release)
Loading…
Cancel
Save