86 lines
2.4 KiB
Diff
86 lines
2.4 KiB
Diff
|
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
|
||
|
|