New upstream release 0.8.1

This commit is contained in:
Hans de Goede 2011-07-18 08:35:29 +02:00
parent 6ccc771729
commit d3cc086706
9 changed files with 7 additions and 434 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
/spice-vdagent-0.6.3.tar.bz2
/spice-vdagent-0.8.0.tar.bz2
/spice-vdagent-0.8.1.tar.bz2

View File

@ -1,93 +0,0 @@
From 5814222821a5e41e610633b73d6e739be7c4cbad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
Date: Fri, 20 May 2011 03:03:05 +0200
Subject: [linux-vdagent PATCH 1/4] Attempt to reconnect to system socket
every second when daemonized
https://bugzilla.redhat.com/show_bug.cgi?id=681797
---
src/udscs.c | 6 ++++--
src/vdagent.c | 31 +++++++++++++++++++++----------
2 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/src/udscs.c b/src/udscs.c
index c451855..6f1328e 100644
--- a/src/udscs.c
+++ b/src/udscs.c
@@ -182,8 +182,10 @@ struct udscs_connection *udscs_connect(const char *socketname,
snprintf(address.sun_path, sizeof(address.sun_path), "%s", socketname);
c = connect(conn->fd, (struct sockaddr *)&address, sizeof(address));
if (c != 0) {
- fprintf(conn->errfile, "connect %s: %s\n", socketname,
- strerror(errno));
+ if (conn->logfile) {
+ fprintf(conn->logfile, "connect %s: %s\n", socketname,
+ strerror(errno));
+ }
free(conn);
return NULL;
}
diff --git a/src/vdagent.c b/src/vdagent.c
index 3569cdb..2b69865 100644
--- a/src/vdagent.c
+++ b/src/vdagent.c
@@ -76,6 +76,20 @@ void daemon_read_complete(struct udscs_connection **connp,
}
}
+int client_setup(int reconnect)
+{
+ while (1) {
+ client = udscs_connect(VDAGENTD_SOCKET, daemon_read_complete, NULL,
+ vdagentd_messages, VDAGENTD_NO_MESSAGES,
+ verbose ? logfile : NULL, logfile);
+ if (client || !reconnect) {
+ break;
+ }
+ sleep(1);
+ }
+ return client == NULL;
+}
+
static void usage(FILE *fp)
{
fprintf(fp,
@@ -168,21 +182,16 @@ int main(int argc, char *argv[])
if (do_daemonize)
daemonize();
- client = udscs_connect(VDAGENTD_SOCKET, daemon_read_complete, NULL,
- vdagentd_messages, VDAGENTD_NO_MESSAGES,
- verbose? logfile:NULL, logfile);
- if (!client) {
- if (logfile != stderr)
- fclose(logfile);
- return 1;
+ if (client_setup(do_daemonize)) {
+ retval = 1;
+ goto finish;
}
x11 = vdagent_x11_create(client, logfile, verbose);
if (!x11) {
udscs_destroy_connection(&client);
- if (logfile != stderr)
- fclose(logfile);
- return 1;
+ retval = 1;
+ goto finish;
}
while (client && !quit) {
@@ -212,6 +221,8 @@ int main(int argc, char *argv[])
vdagent_x11_destroy(x11);
udscs_destroy_connection(&client);
+
+finish:
if (logfile != stderr)
fclose(logfile);
--
1.7.5.1

View File

@ -1,84 +0,0 @@
From a65884e6b6894c56492771b0a1bbb8458941a991 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
Date: Thu, 16 Jun 2011 13:10:55 +0200
Subject: [linux-vdagent PATCH 2/4] vdagents: add VDAGENTD_VERSION message
Disconnects vdagent if version mismatch.
---
src/vdagent.c | 12 ++++++++++++
src/vdagentd-proto-strings.h | 1 +
src/vdagentd-proto.h | 1 +
src/vdagentd.c | 3 +++
4 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/src/vdagent.c b/src/vdagent.c
index 2b69865..db18617 100644
--- a/src/vdagent.c
+++ b/src/vdagent.c
@@ -19,6 +19,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -68,6 +72,14 @@ void daemon_read_complete(struct udscs_connection **connp,
vdagent_x11_clipboard_release(x11, header->arg1);
free(data);
break;
+ case VDAGENTD_VERSION:
+ if (strcmp(data, VERSION) != 0) {
+ fprintf(logfile,
+ "Fatal vdagentd version mismatch: got %s expected %s\n",
+ data, VERSION);
+ udscs_destroy_connection(connp);
+ }
+ break;
default:
if (verbose)
fprintf(logfile, "Unknown message from vdagentd type: %d\n",
diff --git a/src/vdagentd-proto-strings.h b/src/vdagentd-proto-strings.h
index 02adf01..f39e25b 100644
--- a/src/vdagentd-proto-strings.h
+++ b/src/vdagentd-proto-strings.h
@@ -29,6 +29,7 @@ static const char * const vdagentd_messages[] = {
"clipboard request",
"clipboard data",
"clipboard release",
+ "version",
};
#endif
diff --git a/src/vdagentd-proto.h b/src/vdagentd-proto.h
index e570d2b..9d96540 100644
--- a/src/vdagentd-proto.h
+++ b/src/vdagentd-proto.h
@@ -33,6 +33,7 @@ enum {
VDAGENTD_CLIPBOARD_REQUEST, /* arg1: selection, arg 2 = type */
VDAGENTD_CLIPBOARD_DATA, /* arg1: sel, arg 2: type, data: data */
VDAGENTD_CLIPBOARD_RELEASE, /* arg1: selection */
+ VDAGENTD_VERSION, /* daemon -> client, data: version string */
VDAGENTD_NO_MESSAGES /* Must always be last */
};
diff --git a/src/vdagentd.c b/src/vdagentd.c
index be6ef1f..3c05ef0 100644
--- a/src/vdagentd.c
+++ b/src/vdagentd.c
@@ -522,6 +522,9 @@ void agent_connect(struct udscs_connection *conn)
udscs_set_user_data(conn, (void *)agent_data);
update_active_session_connection();
+ udscs_write(conn, VDAGENTD_VERSION, 0, 0,
+ (uint8_t *)VERSION, strlen(VERSION) + 1);
+
if (mon_config)
udscs_write(conn, VDAGENTD_MONITORS_CONFIG, 0, 0,
(uint8_t *)mon_config, sizeof(VDAgentMonitorsConfig) +
--
1.7.5.1

View File

@ -1,85 +0,0 @@
From b5f8b3c39df91767391832d0b6f0b12a880c2b0d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
Date: Thu, 16 Jun 2011 12:39:38 +0200
Subject: [linux-vdagent PATCH 3/4] vdagent: check for portdev existence and
leave if not
---
src/vdagent.c | 28 ++++++++++++++++++++++++----
1 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/src/vdagent.c b/src/vdagent.c
index db18617..c40cf5f 100644
--- a/src/vdagent.c
+++ b/src/vdagent.c
@@ -39,6 +39,7 @@
#include "vdagentd-proto-strings.h"
#include "vdagent-x11.h"
+static const char *portdev = "/dev/virtio-ports/com.redhat.spice.0";
static int verbose = 0;
static struct vdagent_x11 *x11 = NULL;
static struct udscs_connection *client = NULL;
@@ -107,9 +108,11 @@ static void usage(FILE *fp)
fprintf(fp,
"vdagent -- spice agent xorg client\n"
"options:\n"
- " -h print this text\n"
- " -d log debug messages\n"
- " -x don't daemonize (and log to logfile)\n");
+ " -h print this text\n"
+ " -d log debug messages\n"
+ " -s <port> set virtio serial port [%s]\n"
+ " -x don't daemonize (and log to logfile)\n",
+ portdev);
}
static void quit_handler(int sig)
@@ -138,6 +141,13 @@ void daemonize(void)
}
}
+static int file_test(const char *path)
+{
+ struct stat buffer;
+
+ return stat(path, &buffer);
+}
+
int main(int argc, char *argv[])
{
fd_set readfds, writefds;
@@ -147,12 +157,15 @@ int main(int argc, char *argv[])
struct sigaction act;
for (;;) {
- if (-1 == (c = getopt(argc, argv, "-dxh")))
+ if (-1 == (c = getopt(argc, argv, "-dxhs:")))
break;
switch (c) {
case 'd':
verbose++;
break;
+ case 's':
+ portdev = optarg;
+ break;
case 'x':
do_daemonize = 0;
break;
@@ -191,6 +204,13 @@ int main(int argc, char *argv[])
fprintf(stderr, "Could not get home directory, logging to stderr\n");
}
+ if (file_test(portdev) != 0) {
+ fprintf(logfile, "Missing virtio device: %s\n",
+ portdev, strerror(errno));
+ retval = 1;
+ goto finish;
+ }
+
if (do_daemonize)
daemonize();
--
1.7.5.1

View File

@ -1,73 +0,0 @@
From 39b256e9f11c5cc7115a214654fda8891bfb473f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
Date: Thu, 16 Jun 2011 13:34:47 +0200
Subject: [linux-vdagent PATCH 4/4] vdagent: reexec ourself on version
mismatch
---
src/vdagent.c | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/src/vdagent.c b/src/vdagent.c
index c40cf5f..5bf0452 100644
--- a/src/vdagent.c
+++ b/src/vdagent.c
@@ -45,6 +45,7 @@ static struct vdagent_x11 *x11 = NULL;
static struct udscs_connection *client = NULL;
static FILE *logfile = NULL;
static int quit = 0;
+static int version_mismatch = 0;
void daemon_read_complete(struct udscs_connection **connp,
struct udscs_message_header *header, uint8_t *data)
@@ -79,6 +80,7 @@ void daemon_read_complete(struct udscs_connection **connp,
"Fatal vdagentd version mismatch: got %s expected %s\n",
data, VERSION);
udscs_destroy_connection(connp);
+ version_mismatch = 1;
}
break;
default:
@@ -148,6 +150,15 @@ static int file_test(const char *path)
return stat(path, &buffer);
}
+static void cleanup(void)
+{
+ vdagent_x11_destroy(x11);
+ udscs_destroy_connection(&client);
+
+ if (logfile != stderr)
+ fclose(logfile);
+}
+
int main(int argc, char *argv[])
{
fd_set readfds, writefds;
@@ -214,6 +225,14 @@ int main(int argc, char *argv[])
if (do_daemonize)
daemonize();
+reconnect:
+ if (version_mismatch) {
+ fprintf(logfile, "Version mismatch, restarting\n");
+ cleanup();
+ sleep(1);
+ execvp(argv[0], argv);
+ }
+
if (client_setup(do_daemonize)) {
retval = 1;
goto finish;
@@ -253,6 +272,8 @@ int main(int argc, char *argv[])
vdagent_x11_destroy(x11);
udscs_destroy_connection(&client);
+ if (!quit)
+ goto reconnect;
finish:
if (logfile != stderr)
--
1.7.5.1

View File

@ -1,47 +0,0 @@
From e1c0ba33dff4f937b9c0f8f5bae42f2787691654 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Fri, 15 Jul 2011 11:40:46 +0200
Subject: [linux-vdagent PATCH] vdagent: Fix double free on re-exec
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This is caused by me fixing a memleak in the non re-exec reconnect patch
of Marc-André's original patch before merging it.
---
src/vdagent.c | 12 ++----------
1 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/src/vdagent.c b/src/vdagent.c
index 5bf0452..5371ca2 100644
--- a/src/vdagent.c
+++ b/src/vdagent.c
@@ -150,15 +150,6 @@ static int file_test(const char *path)
return stat(path, &buffer);
}
-static void cleanup(void)
-{
- vdagent_x11_destroy(x11);
- udscs_destroy_connection(&client);
-
- if (logfile != stderr)
- fclose(logfile);
-}
-
int main(int argc, char *argv[])
{
fd_set readfds, writefds;
@@ -228,7 +219,8 @@ int main(int argc, char *argv[])
reconnect:
if (version_mismatch) {
fprintf(logfile, "Version mismatch, restarting\n");
- cleanup();
+ if (logfile != stderr)
+ fclose(logfile);
sleep(1);
execvp(argv[0], argv);
}
--
1.7.5.1

View File

@ -1,31 +0,0 @@
From 56fc8d0cc19dae7170fb515e5264c7db7df5773f Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Fri, 15 Jul 2011 11:52:42 +0200
Subject: [linux-vdagent PATCH] vdagent: Respond to SIGTERM in the connect to
daemon loop
---
src/vdagent.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/vdagent.c b/src/vdagent.c
index 5371ca2..f0d3b32 100644
--- a/src/vdagent.c
+++ b/src/vdagent.c
@@ -93,11 +93,11 @@ void daemon_read_complete(struct udscs_connection **connp,
int client_setup(int reconnect)
{
- while (1) {
+ while (!quit) {
client = udscs_connect(VDAGENTD_SOCKET, daemon_read_complete, NULL,
vdagentd_messages, VDAGENTD_NO_MESSAGES,
verbose ? logfile : NULL, logfile);
- if (client || !reconnect) {
+ if (client || !reconnect || quit) {
break;
}
sleep(1);
--
1.7.5.1

View File

@ -1 +1 @@
0695e200494612a2da770e34297d86ee spice-vdagent-0.8.0.tar.bz2
279c59bc3c21081ed354fbdd5c757688 spice-vdagent-0.8.1.tar.bz2

View File

@ -1,18 +1,11 @@
Name: spice-vdagent
Version: 0.8.0
Release: 2%{?dist}
Version: 0.8.1
Release: 1%{?dist}
Summary: Agent for Spice guests
Group: Applications/System
License: GPLv3+
URL: http://spice-space.org/
Source0: http://spice-space.org/download/releases/%{name}-%{version}.tar.bz2
Patch1: 0001-Attempt-to-reconnect-to-system-socket-every-second-w.patch
Patch2: 0002-vdagents-add-VDAGENTD_VERSION-message.patch
Patch3: 0003-vdagent-check-for-portdev-existence-and-leave-if-not.patch
Patch4: 0004-vdagent-reexec-ourself-on-version-mismatch.patch
Patch5: 0005-vdagent-Fix-double-free-on-re-exec.patch
Patch6: 0006-vdagent-Respond-to-SIGTERM-in-the-connect-to-daemon-.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: dbus-devel spice-protocol libXrandr-devel libXfixes-devel
BuildRequires: desktop-file-utils
Requires: ConsoleKit
@ -36,12 +29,6 @@ Features:
%prep
%setup -q
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%build
@ -50,14 +37,9 @@ make %{?_smp_mflags}
%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
%clean
rm -rf $RPM_BUILD_ROOT
%post
/sbin/chkconfig --add spice-vdagentd
@ -89,6 +71,9 @@ fi
%changelog
* Mon Jul 18 2011 Hans de Goede <hdegoede@redhat.com> 0.8.1-1
- New upstream release 0.8.1
* Fri Jul 15 2011 Hans de Goede <hdegoede@redhat.com> 0.8.0-2
- Make the per session agent process automatically reconnect to the system
spice-vdagentd when the system daemon gets restarted