Start of hostinfo daemon / play with APR.
authorRichard W.M. Jones <rjones@redhat.com>
Tue, 16 Jun 2009 14:16:19 +0000 (15:16 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Tue, 16 Jun 2009 14:16:19 +0000 (15:16 +0100)
.gitignore
README
configure.ac
hostinfod/Makefile.am
hostinfod/main.c [new file with mode: 0644]

index 4402410..2dac601 100644 (file)
@@ -1,4 +1,6 @@
+.deps
 *~
+*.o
 Makefile
 Makefile.in
 aclocal.m4
@@ -9,6 +11,8 @@ config.h.in
 config.log
 config.status
 configure
+depcomp
+hostinfod/hostinfod
 install-sh
 missing
 stamp-h1
diff --git a/README b/README
index e69de29..cd91204 100644 (file)
--- a/README
+++ b/README
@@ -0,0 +1,73 @@
+virt-hostinfo
+Copyright (C) 2009 Red Hat Inc.
+----------------------------------------------------------------------
+
+This is a project designed to allow controlled access to host
+information from virtual machines.  It is proposed as a new feature
+for Fedora 12, and you can read more about it on this web page:
+
+http://fedoraproject.org/wiki/Features/Hostinfo
+
+
+Requirements
+----------------------------------------------------------------------
+
+- APR (Apache Portable Runtime) 1.3
+
+
+Build
+----------------------------------------------------------------------
+
+On the host:
+
+  ./configure
+  make
+  sudo make install
+
+There is nothing to build or install in the guest.
+
+
+Host configuration
+----------------------------------------------------------------------
+
+You can edit the text configuration files under /etc/hostinfod by
+hand.  Please read the hostinfod(8) manual page.
+
+For graphical configuration, use virt-manager.
+
+To create new guests with access to host information, use
+virt-install.
+
+
+Accessing host information from guests
+----------------------------------------------------------------------
+
+No special software is required inside the guest.  Simply connect to
+the serial port[1] (eg. /dev/ttyS1 or COM2) using your favorite serial
+terminal software and send commands.
+
+The protocol is a simple, line-based, text protocol.  No special
+libraries are needed to use it from programs or by hand.  The commands
+that you can send are documented in the hostinfod(8) manual page.
+
+If you get no response on the serial port at all, check on the host
+side that the guest is allowed access (see /etc/hostinfod/).  Also
+check that the serial port has been set up in libvirt:
+
+  virsh dumpxml DOMAIN
+
+(should show a <serial/> clause)
+
+Also check that hostinfod (the daemon) is running on the host.
+
+Note that serial port settings like speed, parity etc. make no
+difference for these emulated serial ports, so that won't be a factor.
+
+If you get an answer from the hostinfo daemon, but it indicates a
+permissions error, check on the host side that the guest is allowed to
+access the particular resource (see /etc/hostinfod/).
+
+[1] _Which_ serial port can vary - you need to either try them one by
+one or ask the host administrator to tell you.  We try to stay on the
+second serial port (ttyS1 or COM2) but there are some configurations
+where we get bumped up or down to other serial ports.
index 8afb6b4..ba55b09 100644 (file)
@@ -33,6 +33,9 @@ AM_PROG_CC_C_O
 dnl Check support for 64 bit file offsets.
 AC_SYS_LARGEFILE
 
+dnl Check for required packages using pkg-config.
+PKG_CHECK_MODULES([HOSTINFOD],[apr-1 >= 1.3])
+
 dnl Produce output files.
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_FILES([Makefile hostinfod/Makefile])
index 79fb071..838c667 100644 (file)
@@ -14,3 +14,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+sbin_PROGRAMS = hostinfod
+
+hostinfod_SOURCES = main.c
+hostinfod_CFLAGS = -Wall $(HOSTINFOD_CFLAGS)
+hostinfod_LDADD = $(HOSTINFOD_LIBS)
diff --git a/hostinfod/main.c b/hostinfod/main.c
new file mode 100644 (file)
index 0000000..bb915ca
--- /dev/null
@@ -0,0 +1,81 @@
+/* virt-hostinfo
+ * Copyright (C) 2009 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <apr_general.h>
+#include <apr_network_io.h>
+#include <apr_getopt.h>
+
+static void usage (void);
+
+int
+main (int argc, char *argv[])
+{
+  static const apr_getopt_option_t options[] = {
+    { "help", '?', FALSE, "display help" },
+    { NULL, 0, 0, NULL },
+  };
+  apr_status_t r;
+  apr_pool_t *mp;
+  apr_getopt_t *opt;
+  int c;
+  const char *optarg;
+        
+  apr_initialize ();
+  apr_pool_create (&mp, NULL);
+
+  apr_getopt_init (&opt, mp, argc, argv);
+
+  while ((r = apr_getopt_long (opt, options, &c, &optarg)) == APR_SUCCESS) {
+    switch (c) {
+    case '?':
+      usage ();
+      exit (0);
+    default:
+      abort ();
+    }
+  }
+  if (r != APR_EOF) {
+    fprintf (stderr, "%s: unknown command line option\n", argv[0]);
+    exit (1);
+  }
+
+  apr_terminate ();
+  return 0;
+}
+
+static void
+usage (void)
+{
+  printf ("hostinfod (virt-hostinfo daemon)\n"
+         "Copyright (C) 2009 Red Hat Inc.\n"
+         "\n"
+         "Usage:\n"
+         "  hostinfod [-d] [-f]\n"
+         "\n"
+         "Options:\n"
+         "  --help     Display full usage\n"
+         "  -d         Enable verbose debug messages\n"
+         "  -f         Run in the foreground (don't fork)\n");
+}