[libvirt] [PATCH] Remove all generated RPC files from GIT
by Daniel P. Berrange
commit 7a2fd256cb85dd9a9d6640d9faed0b66ca617411
Author: Daniel P. Berrange <berrange(a)redhat.com>
Date: Fri May 6 13:36:21 2011 +0100
Remove all generated files for remote protocol
Stop storing the generated files for the remote protocol client
and server in source control. The generated files will still be
included in the result of 'make dist' to avoid end-users needing
to generate the files
* daemon/Makefile.am: Removed generated files with
maintainer-clean target
* src/Makefile.am: Removed generated files with
maintainer-clean target. Always run 'rpcgen' if
generated files are missing
NB: hand edited diff to remove the huge deleted files
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index af71188..49e94d2 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -2,11 +2,7 @@
CLEANFILES =
-DAEMON_SOURCES = \
- libvirtd.c libvirtd.h \
- remote.c remote.h \
- dispatch.c dispatch.h \
- stream.c stream.h \
+DAEMON_GENERATED = \
remote_dispatch_prototypes.h \
remote_dispatch_table.h \
remote_dispatch_args.h \
@@ -14,9 +10,16 @@ DAEMON_SOURCES = \
qemu_dispatch_prototypes.h \
qemu_dispatch_table.h \
qemu_dispatch_args.h \
- qemu_dispatch_ret.h \
+ qemu_dispatch_ret.h
+
+DAEMON_SOURCES = \
+ libvirtd.c libvirtd.h \
+ remote.c remote.h \
+ dispatch.c dispatch.h \
+ stream.c stream.h \
../src/remote/remote_protocol.c \
- ../src/remote/qemu_protocol.c
+ ../src/remote/qemu_protocol.c \
+ $(DAEMON_GENERATED)
AVAHI_SOURCES = \
mdns.c mdns.h
@@ -201,17 +204,8 @@ uninstall-data-polkit::
endif
-remote.c: \
- remote_dispatch_prototypes.h \
- remote_dispatch_table.h \
- qemu_dispatch_prototypes.h \
- qemu_dispatch_table.h
-
-remote.h: \
- remote_dispatch_args.h \
- remote_dispatch_ret.h \
- qemu_dispatch_args.h \
- qemu_dispatch_ret.h
+remote.c: $(DAEMON_GENERATED)
+remote.h: $(DAEMON_GENERATED)
REMOTE_PROTOCOL = $(top_srcdir)/src/remote/remote_protocol.x
QEMU_PROTOCOL = $(top_srcdir)/src/remote/qemu_protocol.x
@@ -350,4 +344,4 @@ endif
CLEANFILES += $(BUILT_SOURCES) $(man8_MANS)
CLEANFILES += *.cov *.gcov .libs/*.gcda .libs/*.gcno *.gcno *.gcda
-MAINTAINERCLEANFILES = $(srcdir)/libvirtd.8.in
+MAINTAINERCLEANFILES = $(srcdir)/libvirtd.8.in $(DAEMON_GENERATED)
diff --git a/daemon/qemu_dispatch_args.h b/daemon/qemu_dispatch_args.h
deleted file mode 100644
index e278fa4..0000000
--- a/daemon/qemu_dispatch_args.h
+++ /dev/null
@@ -1,5 +0,0 @@
-/* Automatically generated by remote_generate_stubs.pl.
- * Do not edit this file. Any changes you make will be lost.
- */
-
- qemu_monitor_command_args val_qemu_monitor_command_args;
diff --git a/daemon/qemu_dispatch_prototypes.h b/daemon/qemu_dispatch_prototypes.h
deleted file mode 100644
index 4ec1ab4..0000000
--- a/daemon/qemu_dispatch_prototypes.h
+++ /dev/null
diff --git a/daemon/qemu_dispatch_ret.h b/daemon/qemu_dispatch_ret.h
deleted file mode 100644
index 492dcf9..0000000
--- a/daemon/qemu_dispatch_ret.h
+++ /dev/null
diff --git a/daemon/qemu_dispatch_table.h b/daemon/qemu_dispatch_table.h
deleted file mode 100644
index c196a3c..0000000
--- a/daemon/qemu_dispatch_table.h
+++ /dev/null
diff --git a/daemon/remote_dispatch_args.h b/daemon/remote_dispatch_args.h
deleted file mode 100644
index f9537d7..0000000
--- a/daemon/remote_dispatch_args.h
+++ /dev/null
diff --git a/daemon/remote_dispatch_prototypes.h b/daemon/remote_dispatch_prototypes.h
deleted file mode 100644
index cf2f38c..0000000
--- a/daemon/remote_dispatch_prototypes.h
+++ /dev/null
diff --git a/daemon/remote_dispatch_ret.h b/daemon/remote_dispatch_ret.h
deleted file mode 100644
index 114e832..0000000
--- a/daemon/remote_dispatch_ret.h
+++ /dev/null
diff --git a/daemon/remote_dispatch_table.h b/daemon/remote_dispatch_table.h
deleted file mode 100644
index b39f7c2..0000000
--- a/daemon/remote_dispatch_table.h
+++ /dev/null
diff --git a/src/Makefile.am b/src/Makefile.am
index 1eaa7d1..00c5e04 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -154,15 +154,22 @@ CONF_SOURCES = \
$(CPU_CONF_SOURCES)
# The remote RPC driver, covering domains, storage, networks, etc
-REMOTE_DRIVER_SOURCES = \
- gnutls_1_0_compat.h \
- remote/remote_driver.c remote/remote_driver.h \
+REMOTE_DRIVER_GENERATED = \
remote/remote_protocol.c \
remote/remote_protocol.h \
remote/qemu_protocol.c \
remote/qemu_protocol.h
-EXTRA_DIST += remote/remote_protocol.x remote/qemu_protocol.x \
+REMOTE_DRIVER_PROTOCOL = \
+ remote/remote_protocol.x \
+ remote/qemu_protocol.x
+
+REMOTE_DRIVER_SOURCES = \
+ gnutls_1_0_compat.h \
+ remote/remote_driver.c remote/remote_driver.h \
+ $(REMOTE_DRIVER_GENERATED)
+
+EXTRA_DIST += $(REMOTE_DRIVER_PROTOCOL) \
remote/rpcgen_fix.pl
# Ensure that we don't change the struct or member names or member ordering
@@ -528,68 +535,17 @@ libvirt_driver_remote_la_LDFLAGS += -module -avoid-version
endif
libvirt_driver_remote_la_SOURCES = $(REMOTE_DRIVER_SOURCES)
-if HAVE_RPCGEN
-#
-# Maintainer-only target for re-generating the derived .c/.h source
-# files, which are actually derived from the .x file.
-#
-# For committing protocol changes to GIT, the GLIBC rpcgen *must*
-# be used.
-#
-# Support for non-GLIB rpcgen is here as a convenience for
-# non-Linux people needing to test changes during dev.
-#
-rpcgen-normal:
- rm -f rp.c-t rp.h-t rp.c-t1 rp.c-t2 rp.h-t1
- $(RPCGEN) -h -o rp.h-t $(srcdir)/remote/remote_protocol.x
- $(RPCGEN) -c -o rp.c-t $(srcdir)/remote/remote_protocol.x
-if HAVE_GLIBC_RPCGEN
- perl -w $(srcdir)/remote/rpcgen_fix.pl rp.h-t > rp.h-t1
- perl -w $(srcdir)/remote/rpcgen_fix.pl rp.c-t > rp.c-t1
- (echo '#include <config.h>'; cat rp.c-t1) > rp.c-t2
- chmod 0444 rp.c-t2 rp.h-t1
- mv -f rp.h-t1 $(srcdir)/remote/remote_protocol.h
- mv -f rp.c-t2 $(srcdir)/remote/remote_protocol.c
- rm -f rp.c-t rp.h-t rp.c-t1
-else
- chmod 0444 rp.c-t rp.h-t
- mv -f rp.h-t $(srcdir)/remote/remote_protocol.h
- mv -f rp.c-t $(srcdir)/remote/remote_protocol.c
-endif
-
-rpcgen-qemu:
- rm -f rp_qemu.c-t rp_qemu.h-t rp_qemu.c-t1 rp_qemu.c-t2 rp_qemu.h-t1
- $(RPCGEN) -h -o rp_qemu.h-t $(srcdir)/remote/qemu_protocol.x
- $(RPCGEN) -c -o rp_qemu.c-t $(srcdir)/remote/qemu_protocol.x
-if HAVE_GLIBC_RPCGEN
- perl -w $(srcdir)/remote/rpcgen_fix.pl rp_qemu.h-t > rp_qemu.h-t1
- perl -w $(srcdir)/remote/rpcgen_fix.pl rp_qemu.c-t > rp_qemu.c-t1
- (echo '#include <config.h>'; cat rp_qemu.c-t1) > rp_qemu.c-t2
- chmod 0444 rp_qemu.c-t2 rp_qemu.h-t1
- mv -f rp_qemu.h-t1 $(srcdir)/remote/qemu_protocol.h
- mv -f rp_qemu.c-t2 $(srcdir)/remote/qemu_protocol.c
- rm -f rp_qemu.c-t rp_qemu.h-t rp_qemu.c-t1
-else
- chmod 0444 rp_qemu.c-t rp_qemu.h-t
- mv -f rp_qemu.h-t $(srcdir)/remote/qemu_protocol.h
- mv -f rp_qemu.c-t $(srcdir)/remote/qemu_protocol.c
-endif
-#
-# Maintainer-only target for re-generating the derived .c/.h source
-# files, which are actually derived from the .x file.
-#
-# For committing protocol changes to GIT, the GLIBC rpcgen *must*
-# be used.
-#
-# Support for non-GLIB rpcgen is here as a convenience for
-# non-Linux people needing to test changes during dev.
-#
-rpcgen: rpcgen-normal rpcgen-qemu
+remote/remote_driver.c: $(REMOTE_DRIVER_GENERATED)
-endif
+remote/%_protocol.c: remote/%_protocol.x remote/%_protocol.h
+ $(AM_V_GEN)perl -w $(srcdir)/remote/rpcgen_fix.pl $(RPCGEN) -c \
+ $< $@
+
+remote/%_protocol.h: remote/%_protocol.x
+ $(AM_V_GEN)perl -w $(srcdir)/remote/rpcgen_fix.pl $(RPCGEN) -h \
+ $< $@
-remote/remote_protocol.c: remote/remote_protocol.h
endif
if WITH_XEN
@@ -1339,3 +1295,4 @@ endif
CLEANFILES = *.gcov .libs/*.gcda .libs/*.gcno *.gcno *.gcda *.i *.s
DISTCLEANFILES = $(BUILT_SOURCES)
+MAINTAINERCLEANFILES = $(REMOTE_DRIVER_GENERATED)
diff --git a/src/remote/qemu_protocol.c b/src/remote/qemu_protocol.c
deleted file mode 100644
index 81916ed..0000000
--- a/src/remote/qemu_protocol.c
+++ /dev/null
diff --git a/src/remote/qemu_protocol.h b/src/remote/qemu_protocol.h
deleted file mode 100644
index b822187..0000000
--- a/src/remote/qemu_protocol.h
+++ /dev/null
diff --git a/src/remote/remote_protocol.c b/src/remote/remote_protocol.c
deleted file mode 100644
index 5604371..0000000
--- a/src/remote/remote_protocol.c
+++ /dev/null
diff --git a/src/remote/remote_protocol.h b/src/remote/remote_protocol.h
deleted file mode 100644
index d9bf151..0000000
--- a/src/remote/remote_protocol.h
+++ /dev/null
diff --git a/src/remote/rpcgen_fix.pl b/src/remote/rpcgen_fix.pl
index 3cf5479..d11bbd4 100644
--- a/src/remote/rpcgen_fix.pl
+++ b/src/remote/rpcgen_fix.pl
@@ -1,4 +1,6 @@
-# Fix XDR code (generated by rpcgen) so that it compiles
+#
+# Generate code for an XDR protocol, optionally applying
+# fixups to the glibc rpcgen code so that it compiles
# with warnings turned on.
#
# This code is evil. Arguably better would be just to compile
@@ -17,10 +19,35 @@ use strict;
my $in_function = 0;
my @function = ();
-while (<>) {
+my $rpcgen = shift;
+my $mode = shift;
+my $xdrdef = shift;
+my $target = shift;
+
+unlink $target;
+
+open RPCGEN, "-|", $rpcgen, $mode, $xdrdef
+ or die "cannot run $rpcgen $mode $xdrdef: $!";
+open TARGET, ">$target"
+ or die "cannot create $target: $!";
+
+my $fixup = $^O eq "linux";
+
+if ($mode eq "-c") {
+ print TARGET "#include <config.h>\n";
+}
+
+while (<RPCGEN>) {
+ # We only want to fixup the GLibc rpcgen output
+ # So just print data unchanged, if non-Linux
+ unless ($fixup) {
+ print TARGET;
+ next;
+ }
+
if (m/^{/) {
$in_function = 1;
- print;
+ print TARGET;
next;
}
@@ -79,13 +106,21 @@ while (<>) {
map { s/\bXDR_INLINE\b/(int32_t*)XDR_INLINE/; $_ }
@function;
- print (join ("", @function));
+ print TARGET (join ("", @function));
@function = ();
}
unless ($in_function) {
- print;
+ print TARGET;
} else {
push @function, $_;
}
}
+
+close TARGET
+ or die "cannot save $target: $!";
+close RPCGEN
+ or die "cannot shutdown $rpcgen: $!";
+
+chmod 0444, $target
+ or die "cannot set $target readonly: $!";
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
14 years
[libvirt] [PATCH 0/6] lxc: Improve startup debugging
by Cole Robinson
The following patches improve lxc container startup debugging, by logging
the lxc_controller and <init> commands to the domain log file.
To get there, we convert the commands to use virCommand.
Cole Robinson (6):
command: Add virCommandEnvAddFormat
lxc: driver: Convert emulator launching to virCommand
lxc: driver: Improve logging when launching emulator
command: Add virCommandExec helper
lxc: container: Convert <init> exec to virCommand
lxc: container: Build init cmd before we close stdout
src/libvirt_private.syms | 2 +
src/lxc/lxc_container.c | 68 ++++++++--------
src/lxc/lxc_driver.c | 200 +++++++++++++---------------------------------
src/util/command.c | 45 +++++++++-
src/util/command.h | 17 ++++
5 files changed, 146 insertions(+), 186 deletions(-)
--
1.7.4.4
14 years
[libvirt] [PATCH] Fix two uninitialized variable warnings
by Matthias Bolte
gcc only reports them when compiling with -O3.
---
src/util/interface.c | 2 +-
tools/virsh.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/util/interface.c b/src/util/interface.c
index 5e1987a..04a922c 100644
--- a/src/util/interface.c
+++ b/src/util/interface.c
@@ -91,7 +91,7 @@ ifaceGetFlags(const char *ifname, short *flags) {
int
ifaceIsUp(const char *ifname, bool *up) {
- short flags;
+ short flags = 0;
int rc = ifaceGetFlags(ifname, &flags);
if (rc)
diff --git a/tools/virsh.c b/tools/virsh.c
index 2b16714..8b5572c 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2857,7 +2857,7 @@ static bool
cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int count;
+ int count = 0;
bool ret = true;
int maximum = vshCommandOptBool(cmd, "maximum");
int config = vshCommandOptBool(cmd, "config");
--
1.7.0.4
14 years
[libvirt] [PATCH v2] Allow destroying QEMU VM even if a job is active
by Daniel P. Berrange
Introduce a virProcessKill function that can be safely called
even when the job mutex is held. This allows virDomainDestroy
to kill any VM even if it is asleep in a monitor job. The PID
will die and the thread asleep on the monitor will then wake
up releasing the job mutex.
* src/qemu/qemu_driver.c: Kill process before using qemuProcessStop
to ensure job is released
* src/qemu/qemu_process.c: Add virProcessKill for killing off
QEMU processes
---
src/qemu/qemu_driver.c | 7 ++++++
src/qemu/qemu_process.c | 49 +++++++++++++++++++++++++++++++++++++++-------
src/qemu/qemu_process.h | 2 +
3 files changed, 50 insertions(+), 8 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b3f9e00..e12dfd8 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1482,6 +1482,13 @@ static int qemudDomainDestroy(virDomainPtr dom) {
goto cleanup;
}
+ /* Although qemuProcessStop does this already, there may
+ * be an outstanding job active. We want to make sure we
+ * can kill the process even if a job is active. Killing
+ * it now means the job will be released
+ */
+ qemuProcessKill(vm);
+
if (qemuDomainObjBeginJobWithDriver(driver, vm) < 0)
goto cleanup;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 4c2bb84..285d1e8 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2369,6 +2369,46 @@ cleanup:
}
+void qemuProcessKill(virDomainObjPtr vm)
+{
+ int i;
+ int rc;
+ VIR_DEBUG("vm=%s pid=%d", vm->def->name, vm->pid);
+
+ if (!virDomainObjIsActive(vm)) {
+ VIR_DEBUG("VM '%s' not active", vm->def->name);
+ return;
+ }
+
+ /* This loop sends SIGTERM, then waits a few iterations
+ * (1.6 seconds) to see if it dies. If still alive then
+ * it does SIGKILL, and waits a few more iterations (1.6
+ * seconds more) to confirm that it has really gone.
+ */
+ for (i = 0 ; i < 15 ; i++) {
+ int signum;
+ if (i == 0)
+ signum = SIGTERM;
+ else if (i == 8)
+ signum = SIGKILL;
+ else
+ signum = 0; /* Just check for existence */
+
+ rc = virKillProcess(vm->pid, signum);
+ if (rc < 0) {
+ if (rc != -ERSCH) {
+ char ebuf[1024];
+ VIR_WARN("Failed to kill process %d %s",
+ vm->pid, virStrerror(errno, ebuf, sizeof ebuf));
+ }
+ break;
+ }
+
+ usleep(200 * 1000);
+ }
+}
+
+
void qemuProcessStop(struct qemud_driver *driver,
virDomainObjPtr vm,
int migrated)
@@ -2436,13 +2476,6 @@ void qemuProcessStop(struct qemud_driver *driver,
}
}
- /* This will safely handle a non-running guest with pid=0 or pid=-1*/
- if (virKillProcess(vm->pid, 0) == 0 &&
- virKillProcess(vm->pid, SIGTERM) < 0)
- virReportSystemError(errno,
- _("Failed to send SIGTERM to %s (%d)"),
- vm->def->name, vm->pid);
-
if (priv->mon)
qemuMonitorClose(priv->mon);
@@ -2454,7 +2487,7 @@ void qemuProcessStop(struct qemud_driver *driver,
}
/* shut it off for sure */
- virKillProcess(vm->pid, SIGKILL);
+ qemuProcessKill(vm);
/* now that we know it's stopped call the hook if present */
if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index f1ab599..d8afab0 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -49,4 +49,6 @@ void qemuProcessStop(struct qemud_driver *driver,
virDomainObjPtr vm,
int migrated);
+void qemuProcessKill(virDomainObjPtr vm);
+
#endif /* __QEMU_PROCESS_H__ */
--
1.7.4.4
14 years
[libvirt] [PATCH v2] Add support for YAJL version 2 API/ABI
by Daniel P. Berrange
Version 2.0.0 or yajl changed API. It is fairly trivial for us to
cope with both APIs in libvirt, so adapt.
* configure.ac: Probe for yajl2 API
* src/util/json.c: Conditional support for yajl2 API
---
configure.ac | 8 ++++++
src/util/json.c | 74 +++++++++++++++++++++++++++++++++++++++++-------------
2 files changed, 64 insertions(+), 18 deletions(-)
diff --git a/configure.ac b/configure.ac
index dcec371..62c0560 100644
--- a/configure.ac
+++ b/configure.ac
@@ -878,6 +878,7 @@ AC_ARG_WITH([yajl],
YAJL_CFLAGS=
YAJL_LIBS=
+with_yajl2=no
if test "x$with_yajl" != "xno"; then
if test "x$with_yajl" != "xyes" && test "x$with_yajl" != "xcheck"; then
YAJL_CFLAGS="-I$with_yajl/include"
@@ -898,6 +899,9 @@ if test "x$with_yajl" != "xno"; then
AC_CHECK_LIB([yajl], [yajl_parse],[
YAJL_LIBS="$YAJL_LIBS -lyajl"
with_yajl=yes
+ AC_CHECK_LIB([yajl], [yajl_tree_parse],[
+ with_yajl2=yes
+ ],[])
],[
if test "x$with_yajl" = "xcheck" ; then
with_yajl=no
@@ -914,6 +918,10 @@ if test "x$with_yajl" != "xno"; then
AC_DEFINE_UNQUOTED([HAVE_YAJL], 1,
[whether YAJL is available for JSON parsing/formatting])
fi
+ if test "x$with_yajl2" = "xyes" ; then
+ AC_DEFINE_UNQUOTED([HAVE_YAJL2], 1,
+ [whether YAJL has API version 2])
+ fi
fi
AM_CONDITIONAL([HAVE_YAJL], [test "x$with_yajl" = "xyes"])
AC_SUBST([YAJL_CFLAGS])
diff --git a/src/util/json.c b/src/util/json.c
index df4771d..8bbb87b 100644
--- a/src/util/json.c
+++ b/src/util/json.c
@@ -32,6 +32,13 @@
#if HAVE_YAJL
# include <yajl/yajl_gen.h>
# include <yajl/yajl_parse.h>
+
+#ifdef HAVE_YAJL2
+#define yajl_size_t size_t
+#else
+#define yajl_size_t unsigned int
+#endif
+
#endif
/* XXX fixme */
@@ -672,7 +679,7 @@ static int virJSONParserInsertValue(virJSONParserPtr parser,
return 0;
}
-static int virJSONParserHandleNull(void * ctx)
+static int virJSONParserHandleNull(void *ctx)
{
virJSONParserPtr parser = ctx;
virJSONValuePtr value = virJSONValueNewNull();
@@ -690,7 +697,7 @@ static int virJSONParserHandleNull(void * ctx)
return 1;
}
-static int virJSONParserHandleBoolean(void * ctx, int boolean_)
+static int virJSONParserHandleBoolean(void *ctx, int boolean_)
{
virJSONParserPtr parser = ctx;
virJSONValuePtr value = virJSONValueNewBoolean(boolean_);
@@ -708,9 +715,9 @@ static int virJSONParserHandleBoolean(void * ctx, int boolean_)
return 1;
}
-static int virJSONParserHandleNumber(void * ctx,
- const char * s,
- unsigned int l)
+static int virJSONParserHandleNumber(void *ctx,
+ const char *s,
+ yajl_size_t l)
{
virJSONParserPtr parser = ctx;
char *str = strndup(s, l);
@@ -734,9 +741,9 @@ static int virJSONParserHandleNumber(void * ctx,
return 1;
}
-static int virJSONParserHandleString(void * ctx,
- const unsigned char * stringVal,
- unsigned int stringLen)
+static int virJSONParserHandleString(void *ctx,
+ const unsigned char *stringVal,
+ yajl_size_t stringLen)
{
virJSONParserPtr parser = ctx;
virJSONValuePtr value = virJSONValueNewStringLen((const char *)stringVal,
@@ -755,9 +762,9 @@ static int virJSONParserHandleString(void * ctx,
return 1;
}
-static int virJSONParserHandleMapKey(void * ctx,
- const unsigned char * stringVal,
- unsigned int stringLen)
+static int virJSONParserHandleMapKey(void *ctx,
+ const unsigned char *stringVal,
+ yajl_size_t stringLen)
{
virJSONParserPtr parser = ctx;
virJSONParserStatePtr state;
@@ -776,7 +783,7 @@ static int virJSONParserHandleMapKey(void * ctx,
return 1;
}
-static int virJSONParserHandleStartMap(void * ctx)
+static int virJSONParserHandleStartMap(void *ctx)
{
virJSONParserPtr parser = ctx;
virJSONValuePtr value = virJSONValueNewObject();
@@ -803,7 +810,7 @@ static int virJSONParserHandleStartMap(void * ctx)
}
-static int virJSONParserHandleEndMap(void * ctx)
+static int virJSONParserHandleEndMap(void *ctx)
{
virJSONParserPtr parser = ctx;
virJSONParserStatePtr state;
@@ -827,7 +834,7 @@ static int virJSONParserHandleEndMap(void * ctx)
return 1;
}
-static int virJSONParserHandleStartArray(void * ctx)
+static int virJSONParserHandleStartArray(void *ctx)
{
virJSONParserPtr parser = ctx;
virJSONValuePtr value = virJSONValueNewArray();
@@ -853,7 +860,7 @@ static int virJSONParserHandleStartArray(void * ctx)
return 1;
}
-static int virJSONParserHandleEndArray(void * ctx)
+static int virJSONParserHandleEndArray(void *ctx)
{
virJSONParserPtr parser = ctx;
virJSONParserStatePtr state;
@@ -895,14 +902,29 @@ static const yajl_callbacks parserCallbacks = {
/* XXX add an incremental streaming parser - yajl trivially supports it */
virJSONValuePtr virJSONValueFromString(const char *jsonstring)
{
- yajl_parser_config cfg = { 1, 1 };
yajl_handle hand;
virJSONParser parser = { NULL, NULL, 0 };
virJSONValuePtr ret = NULL;
+#ifndef HAVE_YAJL2
+ yajl_parser_config cfg = { 1, 1 };
+#endif
VIR_DEBUG("string=%s", jsonstring);
+#ifdef HAVE_YAJL2
+ hand = yajl_alloc(&parserCallbacks, NULL, &parser);
+ if (hand) {
+ yajl_config(hand, yajl_allow_comments, 1);
+ yajl_config(hand, yajl_dont_validate_strings, 0);
+ }
+#else
hand = yajl_alloc(&parserCallbacks, &cfg, NULL, &parser);
+#endif
+ if (!hand) {
+ virJSONError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Unable to create JSON parser"));
+ goto cleanup;
+ }
if (yajl_parse(hand,
(const unsigned char *)jsonstring,
@@ -1003,15 +1025,31 @@ static int virJSONValueToStringOne(virJSONValuePtr object,
char *virJSONValueToString(virJSONValuePtr object)
{
- yajl_gen_config conf = { 0, " " }; /* Turns off pretty printing since QEMU can't cope */
yajl_gen g;
const unsigned char *str;
char *ret = NULL;
- unsigned int len;
+ yajl_size_t len;
+#ifndef HAVE_YAJL2
+ yajl_gen_config conf = { 0, " " }; /* Turns off pretty printing since QEMU can't cope */
+#endif
VIR_DEBUG("object=%p", object);
+#ifdef HAVE_YAJL2
+ g = yajl_gen_alloc(NULL);
+ if (g) {
+ yajl_gen_config(g, yajl_gen_beautify, 0);
+ yajl_gen_config(g, yajl_gen_indent_string, " ");
+ yajl_gen_config(g, yajl_gen_validate_utf8, 1);
+ }
+#else
g = yajl_gen_alloc(&conf, NULL);
+#endif
+ if (!g) {
+ virJSONError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Unable to create JSON formatter"));
+ goto cleanup;
+ }
if (virJSONValueToStringOne(object, g) < 0) {
virReportOOMError();
--
1.7.4.4
14 years
[libvirt] [PATCH v3 0/8] Add support for taking screenshots of domain console
by Michal Privoznik
This series adds support for taking screenshots of a running domain console.
The iohelper was added a new argument - delete file after transfer. This is
needed, because the screenshot is written to file and asynchronously transferred
to client.
New API is accessible via virsh screenshot <domain> <path>;
For now, we just save the file in format as returned by hypervisor:
PPM for Qemu, PNG for VirtualBox.
diff to v2:
- rebase
Michal Privoznik (8):
screenshot: Defining the public API
screenshot: Defining the internal API
screenshot: Implementing the public API
screenshot: Implementing the remote protocol
screenshot: Expose the new API in virsh
virFDStream: Add option for delete file after it's opening
qemu: Implement the driver methods
vbox: Implement the driver methods
daemon/remote.c | 57 +++++++++++++++++++++
daemon/remote_generator.pl | 2 +
include/libvirt/libvirt.h.in | 7 +++
src/driver.h | 5 ++
src/esx/esx_driver.c | 1 +
src/fdstream.c | 29 ++++++++---
src/fdstream.h | 6 ++-
src/libvirt.c | 56 ++++++++++++++++++++
src/libvirt_public.syms | 5 ++
src/libxl/libxl_driver.c | 1 +
src/lxc/lxc_driver.c | 4 +-
src/openvz/openvz_driver.c | 1 +
src/phyp/phyp_driver.c | 1 +
src/qemu/qemu_driver.c | 82 ++++++++++++++++++++++++++++++-
src/qemu/qemu_monitor.c | 20 +++++++
src/qemu/qemu_monitor.h | 3 +
src/qemu/qemu_monitor_json.c | 23 ++++++++
src/qemu/qemu_monitor_json.h | 4 ++
src/qemu/qemu_monitor_text.c | 31 +++++++++++
src/qemu/qemu_monitor_text.h | 2 +
src/remote/remote_driver.c | 39 ++++++++++++++
src/remote/remote_protocol.x | 12 ++++-
src/remote_protocol-structs | 7 +++
src/storage/storage_driver.c | 4 +-
src/test/test_driver.c | 1 +
src/uml/uml_driver.c | 4 +-
src/util/iohelper.c | 12 ++++-
src/vbox/vbox_tmpl.c | 114 ++++++++++++++++++++++++++++++++++++++++++
src/vmware/vmware_driver.c | 1 +
src/xen/xen_driver.c | 4 +-
src/xen/xen_driver.h | 1 +
src/xen/xen_hypervisor.c | 1 +
src/xen/xen_inotify.c | 1 +
src/xen/xend_internal.c | 1 +
src/xen/xm_internal.c | 1 +
src/xen/xs_internal.c | 1 +
src/xenapi/xenapi_driver.c | 1 +
tools/virsh.c | 90 +++++++++++++++++++++++++++++++++
tools/virsh.pod | 4 ++
39 files changed, 621 insertions(+), 18 deletions(-)
--
1.7.5.rc3
14 years
[libvirt] [TCK] [PATCH] Switch to installation of FC14 image and other fixes
by Stefan Berger
This patch fixes the creation of VM images. Previously, FC12 images were
created but the files necessary for FC12 image creation are no longer
available in the public repositories. This patch now switches it to
create FC14 images. To get such a new image one may want to remove all
content in /var/cache/libvirt-tck. I takes a long time for the image to
install, though.
The new FC14 image takes a lot longer to boot. Rather than waiting a
fixed timeout during which the VM presumably has booted it is now
waiting for the VM to become pingable and then starts the actual tests.
Also, the name of the DHCP lease file used by dnsmasq has changed.
Rather than hardcoding its name, try to pick it up from the running
dnsmasq process's parameters. Fall back to the old name if the name of
the leasefile could be determined via 'ps aux'.
Signed-off-by: Stefan Berger <stefanb(a)linux.vnet.ibm.com>
---
conf/default.cfg | 12 ++--
conf/ks.cfg | 3 -
lib/Sys/Virt/TCK/NetworkHelpers.pm | 84 +++++++++++++++++++++++++++---
scripts/nwfilter/090-install-image.t | 11 ++-
scripts/nwfilter/100-ping-still-working.t | 5 -
scripts/nwfilter/210-no-mac-spoofing.t | 5 -
scripts/nwfilter/220-no-ip-spoofing.t | 5 -
scripts/nwfilter/230-no-mac-broadcast.t | 5 -
scripts/nwfilter/240-no-arp-spoofing.t | 5 -
scripts/nwfilter/300-vsitype.t | 3 -
10 files changed, 104 insertions(+), 34 deletions(-)
Index: libvirt-tck/lib/Sys/Virt/TCK/NetworkHelpers.pm
===================================================================
--- libvirt-tck.orig/lib/Sys/Virt/TCK/NetworkHelpers.pm
+++ libvirt-tck/lib/Sys/Virt/TCK/NetworkHelpers.pm
@@ -11,12 +11,76 @@ sub get_first_macaddress {
sub get_ip_from_leases{
my $mac = shift;
- my $tmp = `grep $mac /var/lib/dnsmasq/dnsmasq.leases`;
+ my $leasefile = `ps x | sed -n "s/.*dnsmasq.*default.*dhcp-leasefile=\\([/.[:alnum:]]*\\).*/\\1/p"`;
+ if ( $leasefile eq "" ) {
+ $leasefile = "/var/lib/dnsmasq/dnsmasq.leases";
+ }
+ diag "leasefile is ${leasefile}";
+ my $tmp = `grep $mac $leasefile`;
my @fields = split(/ /, $tmp);
my $ip = $fields[2];
return $ip;
}
+sub wait_for_vm_if_up {
+ my $mac = shift;
+ my $timeout = shift;
+ my $ipaddr = "";
+ my $tmp = "";
+
+ while ( $timeout > 0 ) {
+ $ipaddr = get_ip_from_leases($mac);
+ if ( $ipaddr != "" ) {
+ last;
+ }
+ sleep(1);
+ $timeout -= 1;
+ diag "... waiting for the VM's DHCP lease to show up..."
+ }
+
+ if ( $ipaddr != "" ) {
+ while ( $timeout > 0 ) {
+ $tmp = `ping $ipaddr -c 1 -W 2`;
+ if ( $tmp =~ "100% packet loss" ) {
+ $timeout -= 2;
+ } else {
+ sleep(5);
+ return $ipaddr;
+ }
+ diag "... waiting for the VM to become pingable..."
+ }
+ }
+ return 0;
+}
+
+sub wait_for_vm_if_down {
+ my $mac = shift;
+ my $timeout = shift;
+ my $ipaddr = "";
+ my $tmp = "";
+
+ $ipaddr = get_ip_from_leases($mac);
+ if ( $ipaddr == "" ) {
+ diag "Could not get the IP address of the VM.";
+ return 0;
+ }
+
+ while ( $timeout > 0 ) {
+ $tmp = `ping $ipaddr -c 1 -W 2`;
+ if ( $tmp =~ "100% packet loss" ) {
+ diag "VM is off the network now.";
+ sleep(5);
+ return 1;
+ }
+ $timeout -= 2;
+ sleep(2);
+ diag "... waiting for the VM to be off the network ($timeout) ... "
+ }
+ return 0;
+}
+
+
+
sub build_cdrom_ks_image {
my $tck = shift;
@@ -139,11 +203,19 @@ sub prepare_test_disk_and_vm{
my $dom = $conn->define_domain($guest->as_xml);
diag "Starting installation domain";
$dom->create;
- diag "wait for installation to finish .. ";
- while($dom->is_active()) {
- sleep(10);
- diag ".. to view progress connect to virtual machine ${domain_name} .. ";
- }
+ # Wait for the interface to come up; this may take a good while
+ my $guestip = wait_for_vm_if_up(get_first_macaddress($dom), 600);
+ if ( $guestip eq "" ) {
+ diag "Installation domain did not show an IP address. Destroying VM.";
+ $dom->destroy();
+ } else {
+ diag "IP address of installating VM is $guestip";
+ # wait until the installation is done -- may take a long time
+ if (!wait_for_vm_if_down(get_first_macaddress($dom), 7200)) {
+ diag "Installation did not complete in time. Destroying VM.";
+ $dom->destroy();
+ }
+ }
# cleanup install domain
$dom->undefine;
$dom = undef;
Index: libvirt-tck/conf/default.cfg
===================================================================
--- libvirt-tck.orig/conf/default.cfg
+++ libvirt-tck/conf/default.cfg
@@ -52,25 +52,25 @@ ks = /etc/libvirt-tck/ks.cfg
# empty sparse root FS will be created
#
kernels = (
- # Fedora 11 i686 PAE has pv_ops, so one kernel can do both Xen and KVM guests here
+ # Fedora 14 i686 PAE has pv_ops, so one kernel can do both Xen and KVM guests here
{
arch = i686
ostype = (
hvm
xen
)
- kernel = http://download.fedora.redhat.com/pub/fedora/linux/releases/11/Fedora/i38...
- initrd = http://download.fedora.redhat.com/pub/fedora/linux/releases/11/Fedora/i38...
+ kernel = http://download.fedora.redhat.com/pub/fedora/linux/releases/14/Fedora/i38...
+ initrd = http://download.fedora.redhat.com/pub/fedora/linux/releases/14/Fedora/i38...
}
- # Fedora 11 x86_64 has pv_ops, so one kernel can do both Xen and KVM guests here
+ # Fedora 14 x86_64 has pv_ops, so one kernel can do both Xen and KVM guests here
{
arch = x86_64
ostype = (
hvm
xen
)
- kernel = http://download.fedora.redhat.com/pub/fedora/linux/releases/11/Fedora/x86...
- initrd = http://download.fedora.redhat.com/pub/fedora/linux/releases/11/Fedora/x86...
+ kernel = http://download.fedora.redhat.com/pub/fedora/linux/releases/14/Fedora/x86...
+ initrd = http://download.fedora.redhat.com/pub/fedora/linux/releases/14/Fedora/x86...
}
# User mode linux i686 needs custom kernel + root filesystem
{
Index: libvirt-tck/conf/ks.cfg
===================================================================
--- libvirt-tck.orig/conf/ks.cfg
+++ libvirt-tck/conf/ks.cfg
@@ -1,6 +1,6 @@
install
text
-url --url=http://ftp-stud.hs-esslingen.de/Mirrors/fedora.redhat.com/linux/releases/12/Fedora/i386/os/
+url --url=http://download.fedora.redhat.com/pub/fedora/linux/releases/14/Fedora/i386/os/
lang en_US.UTF-8
keyboard de-latin1-nodeadkeys
network --device eth0 --bootproto dhcp
@@ -27,3 +27,4 @@ poweroff
@base
@core
@hardware-support
+%end
Index: libvirt-tck/scripts/nwfilter/100-ping-still-working.t
===================================================================
--- libvirt-tck.orig/scripts/nwfilter/100-ping-still-working.t
+++ libvirt-tck/scripts/nwfilter/100-ping-still-working.t
@@ -46,7 +46,7 @@ END {
# create first domain and start it
diag "Trying domain lookup by name";
my $dom1;
-my $dom_name ="tckf12nwtest";
+my $dom_name ="tck-fedora-nwtest";
$dom1 = prepare_test_disk_and_vm($tck, $conn, $dom_name);
$dom1->create();
@@ -63,8 +63,7 @@ ok($dom1->get_id() > 0, "running domain
my $mac1 = get_first_macaddress($dom1);
diag "mac is $mac1";
-sleep(30);
-my $guestip1 = get_ip_from_leases($mac1);
+my $guestip1 = wait_for_vm_if_up($mac1, 60);
diag "ip is $guestip1";
# check ebtables entry
Index: libvirt-tck/scripts/nwfilter/210-no-mac-spoofing.t
===================================================================
--- libvirt-tck.orig/scripts/nwfilter/210-no-mac-spoofing.t
+++ libvirt-tck/scripts/nwfilter/210-no-mac-spoofing.t
@@ -44,7 +44,7 @@ END {
# create first domain and start it
-my $dom_name ="tckf12nwtest";
+my $dom_name ="tck-fedora-nwtest";
my $dom1;
$dom1 = prepare_test_disk_and_vm($tck, $conn, $dom_name);
@@ -58,8 +58,7 @@ diag $xml;
my $mac1 = get_first_macaddress($dom1);
diag "mac is $mac1";
-sleep(30);
-my $guestip1 = get_ip_from_leases($mac1);
+my $guestip1 = wait_for_vm_if_up($mac1, 60);
diag "ip is $guestip1";
# check ebtables entry
Index: libvirt-tck/scripts/nwfilter/220-no-ip-spoofing.t
===================================================================
--- libvirt-tck.orig/scripts/nwfilter/220-no-ip-spoofing.t
+++ libvirt-tck/scripts/nwfilter/220-no-ip-spoofing.t
@@ -44,7 +44,7 @@ END {
# looking up domain
my $dom1;
-my $dom_name ="tckf12nwtest";
+my $dom_name ="tck-fedora-nwtest";
$dom1 = prepare_test_disk_and_vm($tck, $conn, $dom_name);
$dom1->create();
@@ -55,8 +55,7 @@ diag $xml;
my $mac1 = get_first_macaddress($dom1);
diag "mac is $mac1";
-sleep(30);
-my $guestip1 = get_ip_from_leases($mac1);
+my $guestip1 = wait_for_vm_if_up($mac1, 60);
diag "ip is $guestip1";
# check ebtables entry
Index: libvirt-tck/scripts/nwfilter/230-no-mac-broadcast.t
===================================================================
--- libvirt-tck.orig/scripts/nwfilter/230-no-mac-broadcast.t
+++ libvirt-tck/scripts/nwfilter/230-no-mac-broadcast.t
@@ -43,7 +43,7 @@ END {
# create first domain and start it
my $dom1;
-my $dom_name ="tckf12nwtest";
+my $dom_name ="tck-fedora-nwtest";
$dom1 = prepare_test_disk_and_vm($tck, $conn, $dom_name);
$dom1->create();
@@ -54,8 +54,7 @@ diag $xml;
my $mac1 = get_first_macaddress($dom1);
diag "mac is $mac1";
-sleep(30);
-my $guestip1 = get_ip_from_leases($mac1);
+my $guestip1 = wait_for_vm_if_up($mac1, 60);
diag "ip is $guestip1";
# check ebtables entry
Index: libvirt-tck/scripts/nwfilter/240-no-arp-spoofing.t
===================================================================
--- libvirt-tck.orig/scripts/nwfilter/240-no-arp-spoofing.t
+++ libvirt-tck/scripts/nwfilter/240-no-arp-spoofing.t
@@ -45,7 +45,7 @@ END {
# creating domain
my $dom1;
-my $dom_name ="tckf12nwtest";
+my $dom_name ="tck-fedora-nwtest";
$dom1 = prepare_test_disk_and_vm($tck, $conn, $dom_name);
$dom1->create();
@@ -56,8 +56,7 @@ diag $xml;
my $mac1 = get_first_macaddress($dom1);
diag "mac is $mac1";
-sleep(30);
-my $guestip1 = get_ip_from_leases($mac1);
+my $guestip1 = wait_for_vm_if_up($mac1, 60);
diag "ip is $guestip1";
# check ebtables entry
Index: libvirt-tck/scripts/nwfilter/090-install-image.t
===================================================================
--- libvirt-tck.orig/scripts/nwfilter/090-install-image.t
+++ libvirt-tck/scripts/nwfilter/090-install-image.t
@@ -19,7 +19,7 @@ network/000-install-image.t - install ne
=head1 DESCRIPTION
-The test case creates and install a 2GB fedora virtual
+The test case creates and install a 2GB fedora virtual
disk via kickstart file from the network.
=cut
@@ -41,15 +41,16 @@ END { $tck->cleanup if $tck; }
use File::Spec::Functions qw(catfile catdir rootdir);
# variables which may need to be adapted
-my $dom_name ="tckf12nwtest";
+my $dom_name ="tck-fedora-nwtest";
my $testdom = prepare_test_disk_and_vm($tck, $conn, $dom_name);
$testdom->create();
ok($testdom->get_id() > 0, "running domain has an ID > 0");
-sleep(20);
+
+my $mac1 = get_first_macaddress($testdom);
+diag "mac is $mac1";
+my $guestip1 = wait_for_vm_if_up($mac1, 60);
shutdown_vm_gracefully($testdom);
exit 0;
-
-
Index: libvirt-tck/scripts/nwfilter/300-vsitype.t
===================================================================
--- libvirt-tck.orig/scripts/nwfilter/300-vsitype.t
+++ libvirt-tck/scripts/nwfilter/300-vsitype.t
@@ -43,6 +43,7 @@ END {
SKIP: {
skip "lldptool not present", 3 unless -e "/usr/sbin/lldptool";
+ skip "eth2 not available", 3 unless `ifconfig eth2` =~ "Link encap:";
# creating domain
my $dom1;
@@ -58,7 +59,7 @@ SKIP: {
my $mac1 = get_first_macaddress($dom1);
diag "mac is $mac1";
- sleep(30);
+ wait_for_vm_if_up($mac1, 60);
# check vsi information
diag "Verifying VSI information using lldptool";
14 years
[libvirt] [PATCH v3 0/4] vcpupin: configure inactive domains' CPU affinity setting
by Taku Izumi
Hi all,
This patchset enables us to configure inactive domains' CPU affinity setting.
v2 -> v3:
- rebase
*[PATCH 1/4] vcpupin: inroduce a new libvir API (virDomainPinVcpuFlags)
*[PATCH 2/4] vcpupin: implement the code to address the new API in the qemu driver
*[PATCH 3/4] vcpupin: implement the remote protocol to address the new API
*[PATCH 4/4] vcpupin: add the new options to "virsh vcpupin" command
Best regards,
Taku Izumi
14 years
[libvirt] [PATCH] apparmor: Fix uninitalized variable warning in virt-aa-helper
by Matthias Bolte
---
src/security/virt-aa-helper.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index a4e8549..e481095 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -245,7 +245,7 @@ update_include_file(const char *include_file, const char *included_files,
bool append)
{
int rc = -1;
- int plen, flen;
+ int plen, flen = 0;
int fd;
char *pcontent = NULL;
char *existing = NULL;
--
1.7.0.4
14 years