[libvirt] [RFC PATCH 0/2] Add some systemtap probes to RPC code
by Daniel P. Berrange
Trying to investigate & debug the keepalive series I decided we
needed a better way to trace the RPC protocol than the regular
debug messages. Ideally we'd have a wireshark dissector but that
seems like it will be an awful lot of work todo. So instead I
have added a few systemtap probes to the RPC call which fire
everytime an RPC message is queued for dispatch, or a completed
RPC message is read off the wire
Now I can see all communications using a script like this
# cat > watch.stp <<EOF
function msginfo(prefix, prog, version, proc, type, status, serial)
{
if (type == 0)
typestr = "call"
else if (type == 1)
typestr = "reply"
else if (type == 2)
typestr = "message"
else if (type == 3)
typestr = "stream"
else
typestr = "unknown"
if (status == 0)
statusstr = "ok"
else if (status == 1)
statusstr = "error"
else if (status == 2)
statusstr = "continue"
else
statusstr = "unknown"
printf("%s program: %-10d version: %d procedure: %-4d type: %u:%-9s status: %u:%-9s serial: %-4d\n",
prefix, prog, version, proc, type, typestr, status, statusstr, serial);
}
probe libvirt.rpc.server_msg_rx {
msginfo(">S", prog, vers, proc, type, status, serial)
}
probe libvirt.rpc.server_msg_tx {
msginfo("<S", prog, vers, proc, type, status, serial)
}
probe libvirt.rpc.client_msg_rx {
msginfo("<C", prog, vers, proc, type, status, serial)
}
probe libvirt.rpc.client_msg_tx {
msginfo(">C", prog, vers, proc, type, status, serial)
}
EOF
# stap watch.stp
>C program: 536903814 version: 1 procedure: 66 type: 0:call status: 0:ok serial: 0
>S program: 536903814 version: 1 procedure: 66 type: 0:call status: 0:ok serial: 0
<S program: 536903814 version: 1 procedure: 66 type: 1:reply status: 0:ok serial: 0
<C program: 536903814 version: 1 procedure: 66 type: 1:reply status: 0:ok serial: 0
>C program: 536903814 version: 1 procedure: 1 type: 0:call status: 0:ok serial: 1
>S program: 536903814 version: 1 procedure: 1 type: 0:call status: 0:ok serial: 1
<S program: 536903814 version: 1 procedure: 1 type: 1:reply status: 0:ok serial: 1
<C program: 536903814 version: 1 procedure: 1 type: 1:reply status: 0:ok serial: 1
>C program: 536903814 version: 1 procedure: 110 type: 0:call status: 0:ok serial: 2
>S program: 536903814 version: 1 procedure: 110 type: 0:call status: 0:ok serial: 2
<S program: 536903814 version: 1 procedure: 110 type: 1:reply status: 0:ok serial: 2
<C program: 536903814 version: 1 procedure: 110 type: 1:reply status: 0:ok serial: 2
>C program: 536903814 version: 1 procedure: 23 type: 0:call status: 0:ok serial: 3
>S program: 536903814 version: 1 procedure: 23 type: 0:call status: 0:ok serial: 3
<S program: 536903814 version: 1 procedure: 23 type: 1:reply status: 0:ok serial: 3
<C program: 536903814 version: 1 procedure: 23 type: 1:reply status: 0:ok serial: 3
>C program: 536903814 version: 1 procedure: 19 type: 0:call status: 0:ok serial: 4
>S program: 536903814 version: 1 procedure: 19 type: 0:call status: 0:ok serial: 4
<S program: 536903814 version: 1 procedure: 19 type: 1:reply status: 0:ok serial: 4
<C program: 536903814 version: 1 procedure: 19 type: 1:reply status: 0:ok serial: 4
>C program: 536903814 version: 1 procedure: 16 type: 0:call status: 0:ok serial: 5
>S program: 536903814 version: 1 procedure: 16 type: 0:call status: 0:ok serial: 5
<S program: 536903814 version: 1 procedure: 16 type: 1:reply status: 0:ok serial: 5
<C program: 536903814 version: 1 procedure: 16 type: 1:reply status: 0:ok serial: 5
>C program: 536903814 version: 1 procedure: 151 type: 0:call status: 0:ok serial: 6
>S program: 536903814 version: 1 procedure: 151 type: 0:call status: 0:ok serial: 6
<S program: 536903814 version: 1 procedure: 151 type: 1:reply status: 0:ok serial: 6
<C program: 536903814 version: 1 procedure: 151 type: 1:reply status: 0:ok serial: 6
>C program: 536903814 version: 1 procedure: 15 type: 0:call status: 0:ok serial: 7
>S program: 536903814 version: 1 procedure: 15 type: 0:call status: 0:ok serial: 7
<S program: 536903814 version: 1 procedure: 15 type: 1:reply status: 0:ok serial: 7
<C program: 536903814 version: 1 procedure: 15 type: 1:reply status: 0:ok serial: 7
>C program: 536903814 version: 1 procedure: 183 type: 0:call status: 0:ok serial: 8
>S program: 536903814 version: 1 procedure: 183 type: 0:call status: 0:ok serial: 8
<S program: 536903814 version: 1 procedure: 183 type: 1:reply status: 0:ok serial: 8
<C program: 536903814 version: 1 procedure: 183 type: 1:reply status: 0:ok serial: 8
>C program: 536903814 version: 1 procedure: 122 type: 0:call status: 0:ok serial: 9
>S program: 536903814 version: 1 procedure: 122 type: 0:call status: 0:ok serial: 9
<S program: 536903814 version: 1 procedure: 122 type: 1:reply status: 0:ok serial: 9
<C program: 536903814 version: 1 procedure: 122 type: 1:reply status: 0:ok serial: 9
>C program: 536903814 version: 1 procedure: 121 type: 0:call status: 0:ok serial: 10
>S program: 536903814 version: 1 procedure: 121 type: 0:call status: 0:ok serial: 10
<S program: 536903814 version: 1 procedure: 121 type: 1:reply status: 0:ok serial: 10
<C program: 536903814 version: 1 procedure: 121 type: 1:reply status: 0:ok serial: 10
>C program: 536903814 version: 1 procedure: 2 type: 0:call status: 0:ok serial: 11
>S program: 536903814 version: 1 procedure: 2 type: 0:call status: 0:ok serial: 11
<S program: 536903814 version: 1 procedure: 2 type: 1:reply status: 0:ok serial: 11
<C program: 536903814 version: 1 procedure: 2 type: 1:reply status: 0:ok serial: 11
Is the trace information resulting from 'virsh dominfo $VM'
An RPC call shoudl result in 4 messages, tx by client, rx
by server, tx by server and rx by client. An async event
will only result in 2 messages, tx by server, rx by client
and so on.
A further enhancement I want to make is to make the rpc
generator script, spit out a systemtap function for
converting procedure numbers into function/event names,
as well as adding helper functions for converting program
type and status numbers into friendly strings
13 years, 1 month
[libvirt] [PATCH] Improve the daemon man page
by Daniel Veillard
Add informations about the handling of USR2 and fatal signals
and document the default log location.
diff --git a/daemon/libvirtd.pod.in b/daemon/libvirtd.pod.in
index 6e699b8..269e81f 100644
--- a/daemon/libvirtd.pod.in
+++ b/daemon/libvirtd.pod.in
@@ -69,6 +69,10 @@ Display version information then exit.
=head1 SIGNALS
On receipt of B<SIGHUP> libvirtd will reload its configuration.
+On receipt of B<SIGUSR2> or other fatal signals like B<SIGFPE>,
+B<SIGSEGV>, B<SIGILL>, B<SIGABRT> or B<SIGBUS>, libvirtd will dump
+its internal debug message buffer content to the default log output,
+usually B<@localstatedir(a)/log/libvirt/libvirtd.log>
=head1 FILES
@@ -105,6 +109,11 @@ The TLS B<Server> private key libvirtd will use.
The PID file to use, unless overridden by the B<-p>|B<--pid-file> option.
+=item F<@localstatedir(a)/log/libvirt/libvirtd.log>
+
+The default file where libvirtd will save its logs, this can be overriden
+from the B<@sysconfdir(a)/libvirtd.conf> configuration file.
+
=back
=head1 EXAMPLES
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
13 years, 1 month
[libvirt] [PATCH] build: Add missing <package> and <c:include> in gir
by Marc-André Lureau
This is required for generating source-level bindings, for vala
---
libvirt-gconfig/Makefile.am | 2 ++
libvirt-glib/Makefile.am | 2 ++
libvirt-gobject/Makefile.am | 2 ++
3 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index 6f1c628..180d5ee 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -72,6 +72,8 @@ LibvirtGConfig-1.0.gir: libvirt-gconfig-1.0.la $(G_IR_SCANNER) Makefile.am
-I$(top_builddir) \
--verbose \
--pkg=gobject-2.0 \
+ --c-include="libvirt-gconfig/libvirt-gconfig.h" \
+ --pkg-export=libvirt-gconfig-1.0 \
$(srcdir)/libvirt-gconfig.h \
$(GCONFIG_SOURCE_FILES:%=$(srcdir)/%) \
$(GCONFIG_HEADER_FILES:%=$(srcdir)/%)
diff --git a/libvirt-glib/Makefile.am b/libvirt-glib/Makefile.am
index 4da0a84..0638a64 100644
--- a/libvirt-glib/Makefile.am
+++ b/libvirt-glib/Makefile.am
@@ -53,6 +53,8 @@ LibvirtGLib-1.0.gir: libvirt-glib-1.0.la $(G_IR_SCANNER) Makefile.am
-I$(srcdir) \
--pkg=glib-2.0 \
--pkg=gthread-2.0 \
+ --c-include="libvirt-glib/libvirt-glib.h" \
+ --pkg-export=libvirt-glib-1.0 \
$(libvirt_glib_1_0_la_SOURCES:%=$(srcdir)/%)
girdir = $(datadir)/gir-1.0
diff --git a/libvirt-gobject/Makefile.am b/libvirt-gobject/Makefile.am
index a50878f..9430d40 100644
--- a/libvirt-gobject/Makefile.am
+++ b/libvirt-gobject/Makefile.am
@@ -117,6 +117,8 @@ LibvirtGObject-1.0.gir: libvirt-gobject-1.0.la $(G_IR_SCANNER) Makefile.am
--verbose \
--pkg=gobject-2.0 \
--pkg=gthread-2.0 \
+ --c-include="libvirt-gobject/libvirt-gobject.h" \
+ --pkg-export=libvirt-gobject-1.0 \
$(srcdir)/libvirt-gobject.h \
$(GOBJECT_SOURCE_FILES:%=$(srcdir)/%) \
$(GOBJECT_HEADER_FILES:%=$(srcdir)/%) \
--
1.7.6.2
13 years, 1 month
[libvirt] [PATCH 1/1] [RFC] Parallels Server Bare Metal driver stub
by Dmitry Mishin
Parallels Server Bare Metal is a virtualization solution which allows to run
both Containers (OpenVZ-like) and virtual machines (like any other hardware
hypervisor).
This patch implements initial driver stub with almost no functionality except an
ability to open and close driver. At the same time it contains initialization of
Parallels API and clearly demonstrates supposed approach to future driver
implementation. In particular, I suppose to use parallels-virtualization-sdk
library provisioned with the PSBM distribution (and separately also) for PSBM's
virtual servers management.
Signed-off-by: Dmitry Mishin <dim(a)parallels.com>
---
autobuild.sh | 1 +
configure.ac | 21 +++++
include/libvirt/virterror.h | 1 +
src/Makefile.am | 22 +++++
src/README | 1 +
src/driver.h | 1 +
src/libvirt.c | 9 ++
src/psbm/psbm_api.c | 117 ++++++++++++++++++++++++
src/psbm/psbm_api.h | 59 ++++++++++++
src/psbm/psbm_driver.c | 208 +++++++++++++++++++++++++++++++++++++++++++
src/psbm/psbm_driver.h | 32 +++++++
src/psbm/psbm_private.h | 49 ++++++++++
src/util/virterror.c | 3 +
13 files changed, 524 insertions(+), 0 deletions(-)
create mode 100644 src/psbm/psbm_api.c
create mode 100644 src/psbm/psbm_api.h
create mode 100644 src/psbm/psbm_driver.c
create mode 100644 src/psbm/psbm_driver.h
create mode 100644 src/psbm/psbm_private.h
diff --git a/autobuild.sh b/autobuild.sh
index 491f1b8..f552343 100755
--- a/autobuild.sh
+++ b/autobuild.sh
@@ -81,6 +81,7 @@ if [ -x /usr/bin/i686-pc-mingw32-gcc ]; then
--without-uml \
--without-vbox \
--without-openvz \
+ --without-psbm \
--without-phyp \
--without-netcf \
--without-audit \
diff --git a/configure.ac b/configure.ac
index df19445..7cff4f5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -283,6 +283,8 @@ AC_ARG_WITH([uml],
AC_HELP_STRING([--with-uml], [add UML support @<:@default=check@:>@]),[],[with_uml=check])
AC_ARG_WITH([openvz],
AC_HELP_STRING([--with-openvz], [add OpenVZ support @<:@default=check@:>@]),[],[with_openvz=check])
+AC_ARG_WITH([psbm],
+ AC_HELP_STRING([--with-psbm], [add PSBM support @<:@default=no@:>@]),[],[with_psbm=no])
AC_ARG_WITH([vmware],
AC_HELP_STRING([--with-vmware], [add VMware support @<:@default=yes@:>@]),[],[with_vmware=yes])
AC_ARG_WITH([libssh2],
@@ -385,6 +387,24 @@ AM_CONDITIONAL([WITH_OPENVZ], [test "$with_openvz" = "yes"])
dnl
+dnl Checks for the PSBM driver
+dnl
+
+if test "$with_psbm" = "check"; then
+ with_psbm=$with_linux
+fi
+
+if test "$with_psbm" = "yes" && test "$with_linux" = "no"; then
+ AC_MSG_ERROR([The PSBM driver can be enabled on Linux only.])
+fi
+
+if test "$with_psbm" = "yes"; then
+ AC_DEFINE_UNQUOTED([WITH_PSBM], 1, [whether PSBM driver is enabled])
+fi
+AM_CONDITIONAL([WITH_PSBM], [test "$with_psbm" = "yes"])
+
+
+dnl
dnl Checks for the VMware Workstation/Player driver
dnl
@@ -2504,6 +2524,7 @@ AC_MSG_NOTICE([ Xen: $with_xen])
AC_MSG_NOTICE([ QEMU: $with_qemu])
AC_MSG_NOTICE([ UML: $with_uml])
AC_MSG_NOTICE([ OpenVZ: $with_openvz])
+AC_MSG_NOTICE([ PSBM: $with_psbm])
AC_MSG_NOTICE([ VMware: $with_vmware])
AC_MSG_NOTICE([ VBox: $with_vbox])
AC_MSG_NOTICE([ XenAPI: $with_xenapi])
diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index 0aae622..858e051 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -83,6 +83,7 @@ typedef enum {
VIR_FROM_LIBXL = 41, /* Error from libxenlight driver */
VIR_FROM_LOCKING = 42, /* Error from lock manager */
VIR_FROM_HYPERV = 43, /* Error from Hyper-V driver */
+ VIR_FROM_PSBM = 44, /* Error from PSBM driver */
} virErrorDomain;
diff --git a/src/Makefile.am b/src/Makefile.am
index 738ee91..99f4995 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -320,6 +320,11 @@ OPENVZ_DRIVER_SOURCES = \
openvz/openvz_conf.c openvz/openvz_conf.h \
openvz/openvz_driver.c openvz/openvz_driver.h
+PSBM_DRIVER_SOURCES = \
+ psbm/psbm_driver.c psbm/psbm_driver.h \
+ psbm/psbm_api.c psbm/psbm_api.h \
+ psbm/psbm_private.h
+
VMWARE_DRIVER_SOURCES = \
vmware/vmware_driver.c vmware/vmware_driver.h \
vmware/vmware_conf.c vmware/vmware_conf.h
@@ -684,6 +689,22 @@ endif
libvirt_driver_openvz_la_SOURCES = $(OPENVZ_DRIVER_SOURCES)
endif
+if WITH_PSBM
+if WITH_DRIVER_MODULES
+mod_LTLIBRARIES += libvirt_driver_psbm.la
+else
+noinst_LTLIBRARIES += libvirt_driver_psbm.la
+libvirt_la_BUILT_LIBADD += libvirt_driver_psbm.la
+endif
+libvirt_driver_psbm_la_CFLAGS = \
+ -I@top_srcdir@/src/conf $(AM_CFLAGS)
+if WITH_DRIVER_MODULES
+libvirt_driver_psbm_la_LIBADD = ../gnulib/lib/libgnu.la
+libvirt_driver_psbm_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS)
+endif
+libvirt_driver_psbm_la_SOURCES = $(PSBM_DRIVER_SOURCES)
+endif
+
if WITH_VMWARE
if WITH_DRIVER_MODULES
mod_LTLIBRARIES += libvirt_driver_vmware.la
@@ -1078,6 +1099,7 @@ EXTRA_DIST += \
$(LXC_DRIVER_SOURCES) \
$(UML_DRIVER_SOURCES) \
$(OPENVZ_DRIVER_SOURCES) \
+ $(PSBM_DRIVER_SOURCES) \
$(PHYP_DRIVER_SOURCES) \
$(VBOX_DRIVER_SOURCES) \
$(XENAPI_DRIVER_SOURCES) \
diff --git a/src/README b/src/README
index 00d11d1..02c3f9c 100644
--- a/src/README
+++ b/src/README
@@ -29,6 +29,7 @@ Then there are the hypervisor implementations:
* hyperv/ - Microsoft Hyper-V support using WinRM
* lxc/ - Linux Native Containers
* openvz/ - OpenVZ containers using cli tools
+ * psbm/ - Parallels Server Bare Metal using SDK API
* phyp/ - IBM Power Hypervisor using CLI tools over SSH
* qemu/ - QEMU / KVM using qemu CLI/monitor
* remote/ - Generic libvirt native RPC client
diff --git a/src/driver.h b/src/driver.h
index 3792003..ad97790 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -30,6 +30,7 @@ typedef enum {
VIR_DRV_VMWARE = 13,
VIR_DRV_LIBXL = 14,
VIR_DRV_HYPERV = 15,
+ VIR_DRV_PSBM = 16,
} virDrvNo;
diff --git a/src/libvirt.c b/src/libvirt.c
index 8f94b11..59eb368 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -55,6 +55,9 @@
# ifdef WITH_OPENVZ
# include "openvz/openvz_driver.h"
# endif
+# ifdef WITH_PSBM
+# include "psbm/psbm_driver.h"
+# endif
# ifdef WITH_VMWARE
# include "vmware/vmware_driver.h"
# endif
@@ -447,6 +450,9 @@ virInitialize(void)
# ifdef WITH_OPENVZ
virDriverLoadModule("openvz");
# endif
+# ifdef WITH_PSBM
+ virDriverLoadModule("psbm");
+# endif
# ifdef WITH_VMWARE
virDriverLoadModule("vmware");
# endif
@@ -475,6 +481,9 @@ virInitialize(void)
# ifdef WITH_OPENVZ
if (openvzRegister() == -1) return -1;
# endif
+# ifdef WITH_PSBM
+ if (psbmRegister() == -1) return -1;
+# endif
# ifdef WITH_VMWARE
if (vmwareRegister() == -1) return -1;
# endif
diff --git a/src/psbm/psbm_api.c b/src/psbm/psbm_api.c
new file mode 100644
index 0000000..b5a89f1
--- /dev/null
+++ b/src/psbm/psbm_api.c
@@ -0,0 +1,117 @@
+/*
+ * psbm_api.c: core driver methods for managing PSBM virtual servers
+ *
+ * Copyright (C) 2011 Parallels, 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
+ *
+ * Authors:
+ * Dmitry Mishin <dim(a)parallels.com>
+ *
+ */
+
+#include <config.h>
+
+#include <sys/utsname.h>
+#include <dlfcn.h>
+
+#include "psbm_api.h"
+#include "virterror_internal.h"
+
+#ifdef PRL_SDK_WRAP_FOR_EACH_ITERATOR
+ #undef PRL_SDK_WRAP_FOR_EACH_ITERATOR
+ #undef PRL_SDK_WRAP_FOR_EACH_DEPR_ITERATOR
+#endif
+#define PRL_SDK_WRAP_FOR_EACH_ITERATOR( name ) \
+ name##wrap##_Ptr name;
+#define PRL_SDK_WRAP_FOR_EACH_DEPR_ITERATOR( name ) \
+ name##wrap##_Ptr name;
+
+PRL_SDK_WRAP_FOR_EACH()
+
+#ifdef PRL_SDK_WRAP_FOR_EACH_ITERATOR
+ #undef PRL_SDK_WRAP_FOR_EACH_ITERATOR
+ #undef PRL_SDK_WRAP_FOR_EACH_DEPR_ITERATOR
+#endif
+
+
+int psbmApiInit(struct psbm_driver *driver)
+{
+ const char *libname = "libprl_sdk.so";
+ void *handle = NULL;
+ PRL_RESULT res;
+
+ handle = dlopen(libname, RTLD_LAZY);
+ if (!handle) {
+ psbmError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to load SDK library %s %s"), libname, dlerror());
+ return VIR_ERR_INTERNAL_ERROR;
+ }
+
+#define PRL_SDK_WRAP_FOR_EACH_ITERATOR(name) \
+ if (!(name = (name##wrap##_Ptr)dlsym(handle, #name))) { \
+ psbmError(VIR_ERR_INTERNAL_ERROR, \
+ _("Failed to locate SDK symbol '%s' on initialization"), #name); \
+ }
+
+#define PRL_SDK_WRAP_FOR_EACH_DEPR_ITERATOR(name) \
+ if (!(name = (name##wrap##_Ptr)dlsym(handle, #name))) { \
+ }
+
+ PRL_SDK_WRAP_FOR_EACH();
+#undef PRL_SDK_WRAP_FOR_EACH_DEPR_ITERATOR
+#undef PRL_SDK_WRAP_FOR_EACH_ITERATOR
+
+ res = PrlApi_Init(PARALLELS_API_VER);
+ if (PRL_FAILED(res)) {
+ psbmError(VIR_ERR_OPERATION_FAILED,
+ _("Can't initialize Parallels SDK"));
+ dlclose(handle);
+ return VIR_ERR_OPERATION_FAILED;
+ }
+
+ driver->handle = handle;
+ return VIR_ERR_OK;
+}
+
+int psbmApiDeinit(struct psbm_driver *driver)
+{
+ if (driver->handle) {
+ PrlApi_Deinit();
+
+ if (dlclose(driver->handle)) {
+ psbmError(VIR_ERR_SYSTEM_ERROR, _("Can't unload Parallels SDK"));
+ return VIR_ERR_SYSTEM_ERROR;
+ }
+ }
+
+#ifdef PRL_SDK_WRAP_FOR_EACH_ITERATOR
+# undef PRL_SDK_WRAP_FOR_EACH_ITERATOR
+# undef PRL_SDK_WRAP_FOR_EACH_DEPR_ITERATOR
+#endif
+
+#define PRL_SDK_WRAP_FOR_EACH_ITERATOR(name) \
+ name = 0;
+#define PRL_SDK_WRAP_FOR_EACH_DEPR_ITERATOR(name) \
+ name = 0;
+
+PRL_SDK_WRAP_FOR_EACH()
+
+#undef PRL_SDK_WRAP_FOR_EACH_ITERATOR
+#undef PRL_SDK_WRAP_FOR_EACH_DEPR_ITERATOR
+
+ driver->handle = NULL;
+ return VIR_ERR_OK;
+}
diff --git a/src/psbm/psbm_api.h b/src/psbm/psbm_api.h
new file mode 100644
index 0000000..8793bc6
--- /dev/null
+++ b/src/psbm/psbm_api.h
@@ -0,0 +1,59 @@
+/*
+ * psbm_api.h: SDK API methods for managing PSBM virtual servers
+ *
+ * Copyright (C) 2011 Parallels, 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
+ *
+ * Authors:
+ * Dmitry Mishin <dim(a)parallels.com>
+ *
+ */
+
+
+#ifndef _PSBM_API_H_
+#define _PSBM_API_H_
+
+/* necessary for dynamic loading of Parallels SDK library define */
+#define DYN_API_WRAP
+
+#include <parallels-virtualization-sdk/Parallels.h>
+#include <parallels-virtualization-sdk/PrlApiMacro.h>
+
+#include "internal.h"
+#include "psbm_private.h"
+
+#ifdef PRL_SDK_WRAP_FOR_EACH_ITERATOR
+ #undef PRL_SDK_WRAP_FOR_EACH_ITERATOR
+ #undef PRL_SDK_WRAP_FOR_EACH_DEPR_ITERATOR
+#endif
+#define PRL_SDK_WRAP_FOR_EACH_ITERATOR( name ) \
+ extern name##wrap##_Ptr name;
+#define PRL_SDK_WRAP_FOR_EACH_DEPR_ITERATOR( name ) \
+ extern name##wrap##_Ptr name;
+
+PRL_SDK_WRAP_FOR_EACH()
+
+#ifdef PRL_SDK_WRAP_FOR_EACH_ITERATOR
+ #undef PRL_SDK_WRAP_FOR_EACH_ITERATOR
+ #undef PRL_SDK_WRAP_FOR_EACH_DEPR_ITERATOR
+#endif
+
+
+/* Library initialization/deinitialization */
+int psbmApiInit(struct psbm_driver *driver);
+int psbmApiDeinit(struct psbm_driver *driver);
+
+#endif /* _PSBM_API_H_ */
diff --git a/src/psbm/psbm_driver.c b/src/psbm/psbm_driver.c
new file mode 100644
index 0000000..183d5ba
--- /dev/null
+++ b/src/psbm/psbm_driver.c
@@ -0,0 +1,208 @@
+/*
+ * psbm_driver.c: core driver methods for managing PSBM virtual servers
+ *
+ * Copyright (C) 2011 Parallels, 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
+ *
+ * Authors:
+ * Dmitry Mishin <dim(a)parallels.com>
+ *
+ */
+
+#include <config.h>
+
+#include <sys/utsname.h>
+
+#include "psbm_driver.h"
+#include "psbm_api.h"
+#include "virterror_internal.h"
+#include "datatypes.h"
+#include "memory.h"
+#include "nodeinfo.h"
+
+static void psbmDriverLock(struct psbm_driver *driver)
+{
+ virMutexLock(&driver->lock);
+}
+
+static void psbmDriverUnlock(struct psbm_driver *driver)
+{
+ virMutexUnlock(&driver->lock);
+}
+
+static void psbmFreeDriver(struct psbm_driver *driver)
+{
+ if (!driver)
+ return;
+
+ virDomainObjListDeinit(&driver->domains);
+ virCapabilitiesFree(driver->caps);
+ VIR_FREE(driver);
+}
+
+static virCapsPtr psbmCapsInit(void)
+{
+ struct utsname utsname;
+ virCapsPtr caps;
+ virCapsGuestPtr guest;
+
+ uname(&utsname);
+
+ if ((caps = virCapabilitiesNew(utsname.machine,
+ 0, 0)) == NULL)
+ goto no_memory;
+
+ if (nodeCapsInitNUMA(caps) < 0)
+ goto no_memory;
+
+ virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x52, 0x54, 0x00 });
+
+ if ((guest = virCapabilitiesAddGuest(caps,
+ "exe",
+ utsname.machine,
+ sizeof(int) == 4 ? 32 : 8,
+ NULL,
+ NULL,
+ 0,
+ NULL)) == NULL)
+ goto no_memory;
+
+ if (virCapabilitiesAddGuestDomain(guest,
+ "psbm",
+ NULL,
+ NULL,
+ 0,
+ NULL) == NULL)
+ goto no_memory;
+
+ caps->defaultInitPath = "/sbin/init";
+
+ return caps;
+no_memory:
+ virCapabilitiesFree(caps);
+ return NULL;
+}
+
+
+static virDrvOpenStatus psbmOpen(virConnectPtr conn,
+ virConnectAuthPtr auth ATTRIBUTE_UNUSED,
+ unsigned int flags)
+{
+ struct psbm_driver *driver;
+
+ virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
+
+ /* Decline if the URI is NULL or the scheme is not 'psbm' */
+ if (conn->uri == NULL || conn->uri->scheme == NULL ||
+ STRCASENEQ(conn->uri->scheme, "psbm"))
+ return VIR_DRV_OPEN_DECLINED;
+
+
+ /* If path isn't /system, then they typoed, so tell them correct path */
+ if (conn->uri->path == NULL ||
+ STRNEQ (conn->uri->path, "/system")) {
+ psbmError(VIR_ERR_INTERNAL_ERROR,
+ _("unexpected PSBM URI path '%s', try psbm:///system"),
+ conn->uri->path);
+ return VIR_DRV_OPEN_ERROR;
+ }
+
+ /* We now know the URI is definitely for this driver, so beyond
+ * here, don't return DECLINED, always use ERROR */
+
+ if (VIR_ALLOC(driver) < 0) {
+ virReportOOMError();
+ return VIR_DRV_OPEN_ERROR;
+ }
+
+ if (virDomainObjListInit(&driver->domains) < 0)
+ goto cleanup;
+
+ if (!(driver->caps = psbmCapsInit()))
+ goto cleanup;
+
+ /* load Parallels SDK library, resolve symbols, initialize it */
+ if (psbmApiInit(driver) != VIR_ERR_OK)
+ goto cleanup;
+
+ conn->privateData = driver;
+
+ return VIR_DRV_OPEN_SUCCESS;
+
+cleanup:
+ psbmFreeDriver(driver);
+ return VIR_DRV_OPEN_ERROR;
+};
+
+static int psbmClose(virConnectPtr conn) {
+ struct psbm_driver *driver = conn->privateData;
+ int err;
+
+ err = psbmApiDeinit(driver);
+ if (err != VIR_ERR_OK)
+ return err;
+
+ psbmFreeDriver(driver);
+ conn->privateData = NULL;
+
+ return 0;
+}
+
+static const char *psbmGetType(virConnectPtr conn ATTRIBUTE_UNUSED) {
+ return "PSBM";
+}
+
+static int psbmGetVersion(virConnectPtr conn, unsigned long *version) {
+ struct psbm_driver *driver = conn->privateData;
+ psbmDriverLock(driver);
+ *version = driver->version;
+ psbmDriverUnlock(driver);
+ return 0;
+}
+
+static int psbmListDomains(virConnectPtr conn ATTRIBUTE_UNUSED,
+ int *ids ATTRIBUTE_UNUSED , int nids ATTRIBUTE_UNUSED) {
+ /* FIXME implement via API */
+ return -1;
+}
+
+static int psbmNumDomains(virConnectPtr conn) {
+ struct psbm_driver *driver = conn->privateData;
+ int n;
+
+ psbmDriverLock(driver);
+ n = virDomainObjListNumOfDomains(&driver->domains, 1);
+ psbmDriverUnlock(driver);
+
+ return n;
+}
+
+static virDriver psbmDriver = {
+ .no = VIR_DRV_PSBM,
+ .name = "PSBM",
+ .open = psbmOpen, /* 0.3.1 */
+ .close = psbmClose, /* 0.3.1 */
+ .type = psbmGetType, /* 0.3.1 */
+ .version = psbmGetVersion, /* 0.3.1 */
+ .nodeGetInfo = nodeGetInfo, /* 0.3.1 */
+ .listDomains = psbmListDomains, /* 0.3.1 */
+ .numOfDomains = psbmNumDomains, /* 0.3.1 */
+};
+
+int psbmRegister(void) {
+ virRegisterDriver(&psbmDriver);
+ return 0;
+}
diff --git a/src/psbm/psbm_driver.h b/src/psbm/psbm_driver.h
new file mode 100644
index 0000000..aff171c
--- /dev/null
+++ b/src/psbm/psbm_driver.h
@@ -0,0 +1,32 @@
+/*
+ * psbm_driver.h: core driver methods for managing PSBM virtual servers
+ *
+ * Copyright (C) 2011 Parallels, 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
+ *
+ * Authors:
+ * Dmitry Mishin <dim(a)parallels.com>
+ *
+ */
+
+#ifndef _PSBM_DRIVER_H_
+#define _PSBM_DRIVER_H_
+
+#include "internal.h"
+
+int psbmRegister(void);
+
+#endif /* _PSBM_DRIVER_H_ */
diff --git a/src/psbm/psbm_private.h b/src/psbm/psbm_private.h
new file mode 100644
index 0000000..6994feb
--- /dev/null
+++ b/src/psbm/psbm_private.h
@@ -0,0 +1,49 @@
+/*
+ * psbm_private.h: internal definitions for PSBM driver
+ *
+ * Copyright (C) 2011 Parallels, 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
+ *
+ * Authors:
+ * Dmitry Mishin <dim(a)parallels.com>
+ *
+ */
+
+#ifndef _PSBM_PRIVATE_H_
+#define _PSBM_PRIVATE_H_
+
+#include "internal.h"
+#include "threads.h"
+#include "capabilities.h"
+#include "domain_conf.h"
+
+
+#define VIR_FROM_THIS VIR_FROM_PSBM
+
+# define psbmError(code, ...) \
+ virReportErrorHelper(VIR_FROM_PSBM, code, __FILE__, \
+ __FUNCTION__, __LINE__, __VA_ARGS__)
+
+struct psbm_driver {
+ virMutex lock;
+
+ virCapsPtr caps;
+ virDomainObjList domains;
+ int version;
+ void *handle;
+};
+
+#endif /* _PSBM_PRIVATE_H_ */
diff --git a/src/util/virterror.c b/src/util/virterror.c
index 26c4981..73f2618 100644
--- a/src/util/virterror.c
+++ b/src/util/virterror.c
@@ -100,6 +100,9 @@ static const char *virErrorDomainName(virErrorDomain domain) {
case VIR_FROM_OPENVZ:
dom = "OpenVZ ";
break;
+ case VIR_FROM_PSBM:
+ dom = "PSBM ";
+ break;
case VIR_FROM_VMWARE:
dom = "VMware ";
break;
--
1.7.3.4
13 years, 1 month
[libvirt] [PATCH] qemu: Check for outstanding async job too
by Michal Privoznik
Currently, qemuDomainGetXMLDesc and qemudDomainGetInfo check for
outstanding synchronous job before (eventual) monitor entering.
However, there can be already async job set, e.g. migration.
---
src/qemu/qemu_domain.c | 12 +++++++++---
src/qemu/qemu_domain.h | 2 ++
src/qemu/qemu_driver.c | 4 ++--
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 320a35c..d3ad192 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -696,11 +696,17 @@ qemuDomainObjDiscardAsyncJob(struct qemud_driver *driver, virDomainObjPtr obj)
}
static bool
-qemuDomainJobAllowed(qemuDomainObjPrivatePtr priv, enum qemuDomainJob job)
+qemuDomainNestedJobAllowed(qemuDomainObjPrivatePtr priv, enum qemuDomainJob job)
{
return !priv->job.asyncJob || (priv->job.mask & JOB_MASK(job)) != 0;
}
+bool
+qemuDomainJobAllowed(qemuDomainObjPrivatePtr priv, enum qemuDomainJob job)
+{
+ return !priv->job.active && qemuDomainNestedJobAllowed(priv, job);
+}
+
/* Give up waiting for mutex after 30 seconds */
#define QEMU_JOB_WAIT_TIME (1000ull * 30)
@@ -736,7 +742,7 @@ retry:
goto error;
}
- while (!nested && !qemuDomainJobAllowed(priv, job)) {
+ while (!nested && !qemuDomainNestedJobAllowed(priv, job)) {
if (virCondWaitUntil(&priv->job.asyncCond, &obj->lock, then) < 0)
goto error;
}
@@ -748,7 +754,7 @@ retry:
/* No job is active but a new async job could have been started while obj
* was unlocked, so we need to recheck it. */
- if (!nested && !qemuDomainJobAllowed(priv, job))
+ if (!nested && !qemuDomainNestedJobAllowed(priv, job))
goto retry;
qemuDomainObjResetJob(priv);
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 3b09419..cdf1375 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -277,4 +277,6 @@ void qemuDomainSetFakeReboot(struct qemud_driver *driver,
virDomainObjPtr vm,
bool value);
+bool qemuDomainJobAllowed(qemuDomainObjPrivatePtr priv,
+ enum qemuDomainJob job);
#endif /* __QEMU_DOMAIN_H__ */
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ffa8b4c..a094fcc 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2019,7 +2019,7 @@ static int qemudDomainGetInfo(virDomainPtr dom,
if ((vm->def->memballoon != NULL) &&
(vm->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE)) {
info->memory = vm->def->mem.max_balloon;
- } else if (!priv->job.active) {
+ } else if (qemuDomainJobAllowed(priv, QEMU_JOB_QUERY)) {
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
goto cleanup;
if (!virDomainObjIsActive(vm))
@@ -4351,7 +4351,7 @@ static char *qemuDomainGetXMLDesc(virDomainPtr dom,
qemuDomainObjPrivatePtr priv = vm->privateData;
/* Don't delay if someone's using the monitor, just use
* existing most recent data instead */
- if (!priv->job.active) {
+ if (qemuDomainJobAllowed(priv, QEMU_JOB_QUERY)) {
if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_QUERY) < 0)
goto cleanup;
--
1.7.3.4
13 years, 1 month
[libvirt] [PATCH] qemu: qxl devices don't support multifunction yet
by Marc-André Lureau
This is a workaround for QXL bug RHBZ#728174.
---
src/qemu/qemu_command.c | 33 +++++++++++---------
.../qemuxml2argv-graphics-spice-qxl-vga.args | 2 +-
tests/qemuxml2argvtest.c | 3 +-
3 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c7c183a..1bb136d 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1350,7 +1350,8 @@ qemuUsbId(virBufferPtr buf, int idx)
static int
qemuBuildDeviceAddressStr(virBufferPtr buf,
virDomainDeviceInfoPtr info,
- virBitmapPtr qemuCaps)
+ virBitmapPtr qemuCaps,
+ bool multiFunc)
{
if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
if (info->addr.pci.domain != 0) {
@@ -1389,7 +1390,7 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
virBufferAsprintf(buf, ",bus=pci.0");
else
virBufferAsprintf(buf, ",bus=pci");
- if (qemuCapsGet(qemuCaps, QEMU_CAPS_PCI_MULTIFUNCTION))
+ if (qemuCapsGet(qemuCaps, QEMU_CAPS_PCI_MULTIFUNCTION) && multiFunc)
virBufferAsprintf(buf, ",multifunction=on,addr=0x%x.0x%x",
info->addr.pci.slot, info->addr.pci.function);
else
@@ -1697,7 +1698,7 @@ qemuBuildDriveDevStr(virDomainDiskDefPtr disk,
virBufferAsprintf(&opt, ",event_idx=%s",
virDomainVirtioEventIdxTypeToString(disk->event_idx));
}
- qemuBuildDeviceAddressStr(&opt, &disk->info, qemuCaps);
+ qemuBuildDeviceAddressStr(&opt, &disk->info, qemuCaps, true);
break;
case VIR_DOMAIN_DISK_BUS_USB:
virBufferAddLit(&opt, "usb-storage");
@@ -1776,7 +1777,7 @@ qemuBuildFSDevStr(virDomainFSDefPtr fs,
virBufferAsprintf(&opt, ",id=%s", fs->info.alias);
virBufferAsprintf(&opt, ",fsdev=%s%s", QEMU_FSDEV_HOST_PREFIX, fs->info.alias);
virBufferAsprintf(&opt, ",mount_tag=%s", fs->dst);
- qemuBuildDeviceAddressStr(&opt, &fs->info, qemuCaps);
+ qemuBuildDeviceAddressStr(&opt, &fs->info, qemuCaps, true);
if (virBufferError(&opt)) {
virReportOOMError();
@@ -1904,7 +1905,7 @@ qemuBuildControllerDevStr(virDomainControllerDefPtr def,
goto error;
}
- if (qemuBuildDeviceAddressStr(&buf, &def->info, qemuCaps) < 0)
+ if (qemuBuildDeviceAddressStr(&buf, &def->info, qemuCaps, true) < 0)
goto error;
if (virBufferError(&buf)) {
@@ -2007,7 +2008,7 @@ qemuBuildNicDevStr(virDomainNetDefPtr net,
net->mac[0], net->mac[1],
net->mac[2], net->mac[3],
net->mac[4], net->mac[5]);
- if (qemuBuildDeviceAddressStr(&buf, &net->info, qemuCaps) < 0)
+ if (qemuBuildDeviceAddressStr(&buf, &net->info, qemuCaps, true) < 0)
goto error;
if (bootindex && qemuCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX))
virBufferAsprintf(&buf, ",bootindex=%d", bootindex);
@@ -2141,7 +2142,7 @@ qemuBuildWatchdogDevStr(virDomainWatchdogDefPtr dev,
}
virBufferAsprintf(&buf, "%s,id=%s", model, dev->info.alias);
- if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps) < 0)
+ if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps, true) < 0)
goto error;
if (virBufferError(&buf)) {
@@ -2165,7 +2166,7 @@ qemuBuildMemballoonDevStr(virDomainMemballoonDefPtr dev,
virBufferAddLit(&buf, "virtio-balloon-pci");
virBufferAsprintf(&buf, ",id=%s", dev->info.alias);
- if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps) < 0)
+ if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps, true) < 0)
goto error;
if (virBufferError(&buf)) {
@@ -2191,7 +2192,7 @@ qemuBuildUSBInputDevStr(virDomainInputDefPtr dev,
dev->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ?
"usb-mouse" : "usb-tablet", dev->info.alias);
- if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps) < 0)
+ if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps, true) < 0)
goto error;
if (virBufferError(&buf)) {
@@ -2229,7 +2230,7 @@ qemuBuildSoundDevStr(virDomainSoundDefPtr sound,
model = "intel-hda";
virBufferAsprintf(&buf, "%s,id=%s", model, sound->info.alias);
- if (qemuBuildDeviceAddressStr(&buf, &sound->info, qemuCaps) < 0)
+ if (qemuBuildDeviceAddressStr(&buf, &sound->info, qemuCaps, true) < 0)
goto error;
if (virBufferError(&buf)) {
@@ -2272,6 +2273,7 @@ qemuBuildVideoDevStr(virDomainVideoDefPtr video,
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
const char *model = qemuVideoTypeToString(video->type);
+ bool multiFunc = true;
if (!model) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
@@ -2291,9 +2293,10 @@ qemuBuildVideoDevStr(virDomainVideoDefPtr video,
/* QEMU accepts bytes for vram_size. */
virBufferAsprintf(&buf, ",vram_size=%u", video->vram * 1024);
+ multiFunc = false;
}
- if (qemuBuildDeviceAddressStr(&buf, &video->info, qemuCaps) < 0)
+ if (qemuBuildDeviceAddressStr(&buf, &video->info, qemuCaps, multiFunc) < 0)
goto error;
if (virBufferError(&buf)) {
@@ -2350,7 +2353,7 @@ qemuBuildPCIHostdevDevStr(virDomainHostdevDefPtr dev, const char *configfd,
virBufferAsprintf(&buf, ",configfd=%s", configfd);
if (dev->bootIndex)
virBufferAsprintf(&buf, ",bootindex=%d", dev->bootIndex);
- if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps) < 0)
+ if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps, true) < 0)
goto error;
if (virBufferError(&buf)) {
@@ -2405,7 +2408,7 @@ qemuBuildRedirdevDevStr(virDomainRedirdevDefPtr dev,
dev->info.alias,
dev->info.alias);
- if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps) < 0)
+ if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps, true) < 0)
goto error;
if (virBufferError(&buf)) {
@@ -2438,7 +2441,7 @@ qemuBuildUSBHostdevDevStr(virDomainHostdevDefPtr dev,
dev->source.subsys.u.usb.device,
dev->info.alias);
- if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps) < 0)
+ if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps, true) < 0)
goto error;
if (virBufferError(&buf)) {
@@ -2475,7 +2478,7 @@ qemuBuildHubDevStr(virDomainHubDefPtr dev,
virBufferAddLit(&buf, "usb-hub");
virBufferAsprintf(&buf, ",id=%s", dev->info.alias);
- if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps) < 0)
+ if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps, true) < 0)
goto error;
if (virBufferError(&buf)) {
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.args
index 18013a5..5cd36f8 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.args
@@ -4,4 +4,4 @@ unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda \
/dev/HostVG/QEMUGuest1 -usb -spice port=5903,tls-port=5904,addr=127.0.0.1,\
x509-dir=/etc/pki/libvirt-spice,tls-channel=main,plaintext-channel=inputs -vga \
qxl -global qxl-vga.vram_size=33554432 -device qxl,id=video1,vram_size=67108864,bus=pci.0,addr=0x4 \
--device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,multifunction=on,addr=0x3.0x0
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 335af4a..a453511 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -402,7 +402,8 @@ mymain(void)
DO_TEST("graphics-spice-qxl-vga", false,
QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE,
- QEMU_CAPS_DEVICE_QXL_VGA);
+ QEMU_CAPS_DEVICE_QXL_VGA,
+ QEMU_CAPS_PCI_MULTIFUNCTION);
DO_TEST("input-usbmouse", false, NONE);
DO_TEST("input-usbtablet", false, NONE);
--
1.7.6
13 years, 1 month
[libvirt] [PATCH v2 1/4] api: Add public api for 'reset'
by Xu He Jie
Add new public api for 'reset'.
It can reset domain immediately without any guest shutdown.
Signed-off-by: Xu He Jie <xuhj(a)linux.vnet.ibm.com>
---
include/libvirt/libvirt.h.in | 3 ++
src/driver.h | 4 +++
src/libvirt.c | 50 ++++++++++++++++++++++++++++++++++++++++++
src/libvirt_public.syms | 1 +
4 files changed, 58 insertions(+), 0 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index afeb83f..a3c581d 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1031,6 +1031,9 @@ virDomainPtr virDomainLookupByUUIDString (virConnectPtr conn,
int virDomainShutdown (virDomainPtr domain);
int virDomainReboot (virDomainPtr domain,
unsigned int flags);
+int virDomainReset (virDomainPtr domain,
+ unsigned int flags);
+
int virDomainDestroy (virDomainPtr domain);
int virDomainDestroyFlags (virDomainPtr domain,
unsigned int flags);
diff --git a/src/driver.h b/src/driver.h
index 7dcab8f..f85a1b1 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -124,6 +124,9 @@ typedef int
(*virDrvDomainReboot) (virDomainPtr domain,
unsigned int flags);
typedef int
+ (*virDrvDomainReset) (virDomainPtr domain,
+ unsigned int flags);
+typedef int
(*virDrvDomainDestroy) (virDomainPtr domain);
typedef int
(*virDrvDomainDestroyFlags) (virDomainPtr domain,
@@ -759,6 +762,7 @@ struct _virDriver {
virDrvDomainResume domainResume;
virDrvDomainShutdown domainShutdown;
virDrvDomainReboot domainReboot;
+ virDrvDomainReset domainReset;
virDrvDomainDestroy domainDestroy;
virDrvDomainDestroyFlags domainDestroyFlags;
virDrvDomainGetOSType domainGetOSType;
diff --git a/src/libvirt.c b/src/libvirt.c
index 38fcfbc..7fcbda4 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -3017,6 +3017,56 @@ error:
}
/**
+ * virDomainReset:
+ * @domain: a domain object
+ * @flags: extra flags for the reboot operation, not used yet
+ *
+ * Reset a domain immediately without any guest OS shutdown.
+ * Reset emulates the power reset of a button on a machine, i.e.
+ * All hardware see the RST line set and reinitialize their internal state.
+ *
+ * Note that the risk of data loss caused by reset without any
+ * guest OS shutdown.
+ *
+ * Returns 0 in case of success and -1 in case of failure.
+ */
+int
+virDomainReset(virDomainPtr domain, unsigned int flags)
+{
+ virConnectPtr conn;
+
+ VIR_DOMAIN_DEBUG(domain, "flags=%x", flags);
+
+ virResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virDispatchError(NULL);
+ return -1;
+ }
+ if (domain->conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
+ }
+
+ conn = domain->conn;
+
+ if (conn->driver->domainReset) {
+ int ret;
+ ret = conn->driver->domainReset (domain, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ virDispatchError(domain->conn);
+ return -1;
+}
+
+/**
* virDomainGetName:
* @domain: a domain object
*
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index cef14f0..9e6f104 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -492,6 +492,7 @@ LIBVIRT_0.9.5 {
LIBVIRT_0.9.7 {
global:
virDomainSnapshotGetParent;
+ virDomainReset;
} LIBVIRT_0.9.5;
# .... define new API here using predicted next version number ....
--
1.7.4.1
13 years, 1 month
[libvirt] [PATCH 1/4] api: Add new public api for 'reset'
by Xu He Jie
Add new public api for 'reset'.
It can reset domain immediately without any guest shutdown.
Signed-off-by: Xu He Jie <xuhj(a)linux.vnet.ibm.com>
---
include/libvirt/libvirt.h.in | 2 +
src/driver.h | 3 ++
src/libvirt.c | 44 ++++++++++++++++++++++++++++++++++++++++++
src/libvirt_public.syms | 5 ++++
4 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 39155a6..3d60023 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1031,6 +1031,8 @@ virDomainPtr virDomainLookupByUUIDString (virConnectPtr conn,
int virDomainShutdown (virDomainPtr domain);
int virDomainReboot (virDomainPtr domain,
unsigned int flags);
+int virDomainReset (virDomainPtr domain);
+
int virDomainDestroy (virDomainPtr domain);
int virDomainDestroyFlags (virDomainPtr domain,
unsigned int flags);
diff --git a/src/driver.h b/src/driver.h
index 3792003..fd0d3a1 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -124,6 +124,8 @@ typedef int
(*virDrvDomainReboot) (virDomainPtr domain,
unsigned int flags);
typedef int
+ (*virDrvDomainReset) (virDomainPtr domain);
+typedef int
(*virDrvDomainDestroy) (virDomainPtr domain);
typedef int
(*virDrvDomainDestroyFlags) (virDomainPtr domain,
@@ -755,6 +757,7 @@ struct _virDriver {
virDrvDomainResume domainResume;
virDrvDomainShutdown domainShutdown;
virDrvDomainReboot domainReboot;
+ virDrvDomainReset domainReset;
virDrvDomainDestroy domainDestroy;
virDrvDomainDestroyFlags domainDestroyFlags;
virDrvDomainGetOSType domainGetOSType;
diff --git a/src/libvirt.c b/src/libvirt.c
index 8f94b11..3c5cd5e 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -3017,6 +3017,50 @@ error:
}
/**
+ * virDomainReset:
+ * @domain: a domain object
+ *
+ * Reset a domain immediately without any guest shutdown
+ *
+ * Returns 0 in case of success and -1 in case of failure.
+ */
+int
+virDomainReset(virDomainPtr domain)
+{
+ virConnectPtr conn;
+
+ VIR_DOMAIN_DEBUG(domain);
+
+ virResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virDispatchError(NULL);
+ return -1;
+ }
+ if (domain->conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
+ }
+
+ conn = domain->conn;
+
+ if (conn->driver->domainReset) {
+ int ret;
+ ret = conn->driver->domainReset (domain);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ virDispatchError(domain->conn);
+ return -1;
+}
+
+/**
* virDomainGetName:
* @domain: a domain object
*
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 8a6d55a..dffa33f 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -489,4 +489,9 @@ LIBVIRT_0.9.5 {
virDomainSnapshotGetName;
} LIBVIRT_0.9.4;
+LIBVIRT_0.9.7 {
+ global:
+ virDomainReset;
+} LIBVIRT_0.9.5;
+
# .... define new API here using predicted next version number ....
--
1.7.4.1
13 years, 1 month