]> xenbits.xensource.com Git - libvirt.git/commitdiff
Qemu Monitor API entry point.
authorChris Lalancette <clalance@redhat.com>
Tue, 13 Apr 2010 18:02:46 +0000 (14:02 -0400)
committerChris Lalancette <clalance@redhat.com>
Fri, 23 Jul 2010 21:30:14 +0000 (17:30 -0400)
Add the library entry point for the new virDomainQemuMonitorCommand()
entry point.  Because this is not part of the "normal" libvirt API,
it gets its own header file, library file, and will eventually
get its own over-the-wire protocol later in the series.

Changes since v1:
 - Go back to using the virDriver table for qemuDomainMonitorCommand, due to
   linking issues
 - Added versioning information to the libvirt-qemu.so

Changes since v2:
 - None

Changes since v3:
 - Add LGPL header to libvirt-qemu.c
 - Make virLibConnError and virLibDomainError macros instead of function calls

Changes since v4:
 - Move exported symbols to libvirt_qemu.syms

Signed-off-by: Chris Lalancette <clalance@redhat.com>
20 files changed:
configure.ac
include/libvirt/Makefile.am
include/libvirt/libvirt-qemu.h [new file with mode: 0644]
src/Makefile.am
src/driver.h
src/esx/esx_driver.c
src/libvirt-qemu.c [new file with mode: 0644]
src/libvirt_private.syms
src/libvirt_qemu.syms [new file with mode: 0644]
src/lxc/lxc_driver.c
src/opennebula/one_driver.c
src/openvz/openvz_driver.c
src/phyp/phyp_driver.c
src/qemu/qemu_driver.c
src/remote/remote_driver.c
src/test/test_driver.c
src/uml/uml_driver.c
src/vbox/vbox_tmpl.c
src/xen/xen_driver.c
src/xenapi/xenapi_driver.c

index eece723262416232c104e82abbc4d0cf2090e532..08b7eb60ab952ea2f8c2c726e81c90e7134af96d 100644 (file)
@@ -1833,6 +1833,7 @@ CYGWIN_EXTRA_PYTHON_LIBADD=
 MINGW_EXTRA_LDFLAGS=
 WIN32_EXTRA_CFLAGS=
 LIBVIRT_SYMBOL_FILE=libvirt.syms
+LIBVIRT_QEMU_SYMBOL_FILE=libvirt_qemu.syms
 case "$host" in
   *-*-cygwin*)
     CYGWIN_EXTRA_LDFLAGS="-no-undefined"
@@ -1872,6 +1873,7 @@ AC_SUBST([CYGWIN_EXTRA_PYTHON_LIBADD])
 AC_SUBST([MINGW_EXTRA_LDFLAGS])
 AC_SUBST([WIN32_EXTRA_CFLAGS])
 AC_SUBST([LIBVIRT_SYMBOL_FILE])
+AC_SUBST([LIBVIRT_QEMU_SYMBOL_FILE])
 AC_SUBST([VERSION_SCRIPT_FLAGS])
 
 
index 8589dc56f01f4203e3bf92eed69767f53a56fd00..b2c2b7671811fde9378713993fdeddd5bc1e85c3 100644 (file)
@@ -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 (file)
index 0000000..d21fd92
--- /dev/null
@@ -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@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__ */
index c8fad28fbcbb85f8865a82f756eead896e982bb7..4150a037dfbfceca61b78c5b05ceb81c7596c7bb 100644 (file)
@@ -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 =
@@ -1028,6 +1028,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 = $(VERSION_SCRIPT_FLAGS)$(LIBVIRT_QEMU_SYMBOL_FILE) \
+                          -version-info $(LIBVIRT_VERSION_INFO) \
+                          $(CYGWIN_EXTRA_LDFLAGS) $(MINGW_EXTRA_LDFLAGS)
+libvirt_qemu_la_CFLAGS = $(COVERAGE_CFLAGS)
+libvirt_qemu_la_LIBADD = libvirt.la $(CYGWIN_EXTRA_LIBADD)
 
 libexec_PROGRAMS =
 
index 22e3db60e6cbb86fb92183d27cb4d80513b1029c..e443c1c559b113cb4f84ad2aa37e3ef59114faca 100644 (file)
@@ -457,6 +457,11 @@ typedef int
     (*virDrvDomainSnapshotDelete)(virDomainSnapshotPtr snapshot,
                                   unsigned int flags);
 
+typedef int
+    (*virDrvQemuDomainMonitorCommand)(virDomainPtr domain, const char *cmd,
+                                      char **result, unsigned int flags);
+
+
 
 /**
  * _virDriver:
@@ -569,6 +574,7 @@ struct _virDriver {
     virDrvDomainSnapshotCurrent domainSnapshotCurrent;
     virDrvDomainRevertToSnapshot domainRevertToSnapshot;
     virDrvDomainSnapshotDelete domainSnapshotDelete;
+    virDrvQemuDomainMonitorCommand qemuDomainMonitorCommand;
 };
 
 typedef int
index acf89089e827647045feca93945b279fd817fbfa..227e6a950ff34f30a3137f32326baef82b646e63 100644 (file)
@@ -3759,6 +3759,7 @@ static virDriver esxDriver = {
     esxDomainSnapshotCurrent,        /* domainSnapshotCurrent */
     esxDomainRevertToSnapshot,       /* domainRevertToSnapshot */
     esxDomainSnapshotDelete,         /* domainSnapshotDelete */
+    NULL,                            /* qemuDomainMonitorCommand */
 };
 
 
diff --git a/src/libvirt-qemu.c b/src/libvirt-qemu.c
new file mode 100644 (file)
index 0000000..2c418f8
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * libvirt-qemu.c: Interfaces for the libvirt library to handle qemu-specific
+ *                 APIs.
+ *
+ * Copyright (C) 2010 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: Chris Lalancette <clalance@redhat.com>
+ */
+
+#include <config.h>
+
+#include "virterror_internal.h"
+#include "logging.h"
+#include "datatypes.h"
+#include "libvirt/libvirt-qemu.h"
+
+#define virLibConnError(conn, error, info)                               \
+    virReportErrorHelper(conn, VIR_FROM_NONE, error, NULL, __FUNCTION__, \
+                         __LINE__, info)
+
+#define virLibDomainError(domain, error, info)                          \
+    virReportErrorHelper(NULL, VIR_FROM_DOM, error, NULL, __FUNCTION__, \
+                         __LINE__, info)
+
+int
+virDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd,
+                            char **result, unsigned int flags)
+{
+    virConnectPtr conn;
+
+    DEBUG("domain=%p, cmd=%s, result=%p, flags=%u", domain, cmd, result, flags);
+
+    virResetLastError();
+
+    if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+        virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+        virDispatchError(NULL);
+        return -1;
+    }
+
+    conn = domain->conn;
+
+    if (result == NULL) {
+        virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
+        goto error;
+    }
+
+    if (conn->flags & VIR_CONNECT_RO) {
+        virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+        goto error;
+    }
+
+    if (conn->driver->qemuDomainMonitorCommand) {
+        int ret;
+        ret = conn->driver->qemuDomainMonitorCommand(domain, cmd, result,
+                                                     flags);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virLibConnError(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+    virDispatchError(conn);
+    return -1;
+}
index 3573da17a9c8a4fd67911d9185cf0cce0705b9eb..6b83cb984cecae3f09c0ec89bb6f511b4ee8045a 100644 (file)
@@ -736,6 +736,7 @@ virReportSystemErrorFull;
 virReportOOMErrorFull;
 virStrerror;
 virSetError;
+virDispatchError;
 
 
 # xml.h
diff --git a/src/libvirt_qemu.syms b/src/libvirt_qemu.syms
new file mode 100644 (file)
index 0000000..5702d36
--- /dev/null
@@ -0,0 +1,16 @@
+#
+# Officially exported symbols, for which header
+# file definitions are installed in /usr/include/libvirt
+# from libvirt-qemu.h
+#
+# Versions here are *fixed* to match the libvirt version
+# at which the symbol was introduced. This ensures that
+# a new client app requiring symbol foo() can't accidentally
+# run with old libvirt-qemu.so not providing foo() - the global
+# soname version info can't enforce this since we never
+# change the soname
+#
+LIBVIRT_QEMU_0.8.3 {
+    global:
+        virDomainQemuMonitorCommand;
+};
index 462bc9cc2a2a97f23331cd5bfe0074c37ad822d5..4fc1ecd17a372e003d946c3f5859b8cd44ced49c 100644 (file)
@@ -2635,6 +2635,7 @@ static virDriver lxcDriver = {
     NULL, /* domainSnapshotCurrent */
     NULL, /* domainRevertToSnapshot */
     NULL, /* domainSnapshotDelete */
+    NULL, /* qemuDomainMonitorCommand */
 };
 
 static virStateDriver lxcStateDriver = {
index 9d7b415bacf3385fa006ec382b56908b17b72156..e70f17bc2b3de8e574e0b53cf46fd7e833e7ff98 100644 (file)
@@ -817,6 +817,7 @@ static virDriver oneDriver = {
     NULL, /* domainSnapshotCurrent */
     NULL, /* domainRevertToSnapshot */
     NULL, /* domainSnapshotDelete */
+    NULL, /* qemuDomainMonitorCommand */
 };
 
 static virStateDriver oneStateDriver = {
index f7da1be9d1715dc2cf8154a641c4fab1df9f5f98..98381fbad86529d62575677db74654b852f4ff9d 100644 (file)
@@ -1570,6 +1570,7 @@ static virDriver openvzDriver = {
     NULL, /* domainSnapshotCurrent */
     NULL, /* domainRevertToSnapshot */
     NULL, /* domainSnapshotDelete */
+    NULL, /* qemuDomainMonitorCommand */
 };
 
 int openvzRegister(void) {
index ee1e21b82e0cad18cf34ac204a47424d5789264a..e4afc5a9417919069dca9c015f4b81ecabdc80e6 100644 (file)
@@ -3990,6 +3990,7 @@ static virDriver phypDriver = {
     NULL,                       /* domainSnapshotCurrent */
     NULL,                       /* domainRevertToSnapshot */
     NULL,                       /* domainSnapshotDelete */
+    NULL,                       /* qemuMonitorCommand */
 };
 
 static virStorageDriver phypStorageDriver = {
index 9e4802777cda13c60cd1d83be8b65c782b8322d1..aae4e002cce955a31ec6a70868132eb556524883 100644 (file)
@@ -12660,6 +12660,7 @@ static virDriver qemuDriver = {
     qemuDomainSnapshotCurrent, /* domainSnapshotCurrent */
     qemuDomainRevertToSnapshot, /* domainRevertToSnapshot */
     qemuDomainSnapshotDelete, /* domainSnapshotDelete */
+    NULL, /* qemuDomainMonitorCommand */
 };
 
 
index c9129b126bcff349e51bdfb688525a68f50f8b17..afa8f11e60c7b8ec7e85ea328ca4a59ddcd51b97 100644 (file)
@@ -10302,6 +10302,7 @@ static virDriver remote_driver = {
     remoteDomainSnapshotCurrent, /* domainSnapshotCurrent */
     remoteDomainRevertToSnapshot, /* domainRevertToSnapshot */
     remoteDomainSnapshotDelete, /* domainSnapshotDelete */
+    NULL, /* qemuDomainMonitorCommand */
 };
 
 static virNetworkDriver network_driver = {
index 5b6f47efac4fc253983f071f14330282e4e0134c..6c06cbc2730d85eb18b80b12861fb6a89ec2fbc7 100644 (file)
@@ -5322,6 +5322,7 @@ static virDriver testDriver = {
     NULL, /* domainSnapshotCurrent */
     NULL, /* domainRevertToSnapshot */
     NULL, /* domainSnapshotDelete */
+    NULL, /* qemuDomainMonitorCommand */
 };
 
 static virNetworkDriver testNetworkDriver = {
index 1e0f5acf11ff16a4c59d015a4aa37a4b43de13f0..04493ba999cb66d3ac024fc2ea943991e1780583 100644 (file)
@@ -1952,6 +1952,7 @@ static virDriver umlDriver = {
     NULL, /* domainSnapshotCurrent */
     NULL, /* domainRevertToSnapshot */
     NULL, /* domainSnapshotDelete */
+    NULL, /* qemuDomainMonitorCommand */
 };
 
 
index 0e0013bf71205168c880c8b6cbac5153fdb8cee6..edc7a7239474c996d7005d18fc04f01d89c73914 100644 (file)
@@ -8248,6 +8248,7 @@ virDriver NAME(Driver) = {
     vboxDomainSnapshotCurrent, /* domainSnapshotCurrent */
     vboxDomainRevertToSnapshot, /* domainRevertToSnapshot */
     vboxDomainSnapshotDelete, /* domainSnapshotDelete */
+    NULL, /* qemuDomainMonitorCommand */
 };
 
 virNetworkDriver NAME(NetworkDriver) = {
index 3dd673b64eef1360b7a4b5721e95a65fbb1dbcae..b55e4945308d01e13025c316ed6b52b9c444404b 100644 (file)
@@ -2004,6 +2004,7 @@ static virDriver xenUnifiedDriver = {
     NULL, /* domainSnapshotCurrent */
     NULL, /* domainRevertToSnapshot */
     NULL, /* domainSnapshotDelete */
+    NULL, /* qemuDomainMonitorCommand */
 };
 
 /**
index cefcf3b8e5effcc2655e6a53059f19fb32a8ef72..e38564863389293b8139d5aea8b0cc63203db37c 100644 (file)
@@ -1814,6 +1814,7 @@ static virDriver xenapiDriver = {
     NULL, /* domainSnapshotCurrent */
     NULL, /* domainRevertToSnapshot */
     NULL, /* domainSnapshotDelete */
+    NULL, /* qemuDomainMonitorCommand */
 };
 
 /**