On Wed, Apr 21, 2010 at 12:01:20PM -0400, Chris Lalancette wrote:
Add the library entry point for the new
virDomainQemuMonitorCommand()
entry point. Because this is not part of the "normal" libvirt API,
it gets it's own header file, library file, and will eventually
get it's own over-the-wire protocol later in the series.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
include/libvirt/Makefile.am | 1 +
include/libvirt/libvirt-qemu.h | 30 ++++++++++++++
src/Makefile.am | 8 +++-
src/libvirt-qemu.c | 88 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 126 insertions(+), 1 deletions(-)
create mode 100644 include/libvirt/libvirt-qemu.h
create mode 100644 src/libvirt-qemu.c
diff --git a/include/libvirt/Makefile.am b/include/libvirt/Makefile.am
index 8589dc5..b2c2b76 100644
--- a/include/libvirt/Makefile.am
+++ b/include/libvirt/Makefile.am
@@ -3,6 +3,7 @@
virincdir = $(includedir)/libvirt
virinc_HEADERS = libvirt.h \
+ libvirt-qemu.h \
virterror.h
install-exec-hook:
diff --git a/include/libvirt/libvirt-qemu.h b/include/libvirt/libvirt-qemu.h
new file mode 100644
index 0000000..1170196
--- /dev/null
+++ b/include/libvirt/libvirt-qemu.h
@@ -0,0 +1,30 @@
+/* -*- c -*-
+ * libvirt_qemu.h:
+ * Summary: qemu specific interfaces
+ * Description: Provides the interfaces of the libvirt library to handle
+ * qemu specific methods
+ *
+ * Copy: Copyright (C) 2010 Red Hat, Inc.
+ *
+ * See COPYING.LIB for the License of this software
+ *
+ * Author: Chris Lalancette <clalance(a)redhat.com>
+ */
+
+#ifndef __VIR_QEMU_H__
+# define __VIR_QEMU_H__
+
+# include "libvirt.h"
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+int virDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd,
+ char **result, unsigned int flags);
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif /* __VIR_QEMU_H__ */
diff --git a/src/Makefile.am b/src/Makefile.am
index 66dc349..c57a7b8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -32,7 +32,7 @@ if WITH_NETWORK
UUID=$(shell uuidgen 2>/dev/null)
endif
-lib_LTLIBRARIES = libvirt.la
+lib_LTLIBRARIES = libvirt.la libvirt-qemu.la
moddir = $(libdir)/libvirt/drivers
mod_LTLIBRARIES =
@@ -947,6 +947,12 @@ libvirt_test_la_LIBADD = $(libvirt_la_LIBADD)
libvirt_test_la_LDFLAGS = $(test_LDFLAGS)
libvirt_test_la_CFLAGS = $(COVERAGE_CFLAGS)
+libvirt_qemu_la_SOURCES = libvirt-qemu.c
+libvirt_qemu_la_LDFLAGS = $(CYGWIN_EXTRA_LDFLAGS) $(MINGW_EXTRA_LDFLAGS)
+libvirt_qemu_la_CFLAGS = $(COVERAGE_CFLAGS)
+libvirt_qemu_la_LIBADD = libvirt_util.la libvirt_driver_qemu.la \
+ libvirt_driver_remote.la $(CYGWIN_EXTRA_LIBADD) \
+ ../gnulib/lib/libgnu.la
This is still going to cause duplicate copies of the code to be
statically linked in. If you just mention 'libvirt.la', then it
should dynamically link to the libvirt.so with no duplication.
You may need to export some more private symbols but that's not
a big issue.
diff --git a/src/libvirt-qemu.c b/src/libvirt-qemu.c
new file mode 100644
index 0000000..e6a4cc4
--- /dev/null
+++ b/src/libvirt-qemu.c
@@ -0,0 +1,88 @@
+#include <config.h>
+
+#include "virterror_internal.h"
+#include "logging.h"
+#include "datatypes.h"
+#include "libvirt/libvirt-qemu.h"
+
+/**
+ * virLibConnError:
+ * @conn: the connection if available
+ * @error: the error number
+ * @info: extra information string
+ *
+ * Handle an error at the connection level
+ */
+static void
+virLibConnError(virConnectPtr conn, virErrorNumber error, const char *info)
+{
+ const char *errmsg;
+
+ if (error == VIR_ERR_OK)
+ return;
+
+ errmsg = virErrorMsg(error, info);
+ virRaiseError(conn, NULL, NULL, VIR_FROM_NONE, error, VIR_ERR_ERROR,
+ errmsg, info, NULL, 0, 0, errmsg, info);
+}
I know this is just a cut+paste from libvirt.c, but it could be
replaced with a macro
#define virLibConnError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_NONE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
which means source file/function/line info is preserved.
Regards,
Daniel
--
|: Red Hat, Engineering, London -o-
http://people.redhat.com/berrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org -o-
http://deltacloud.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|