[libvirt] virt-manager, debug error, question
by Jason Helfman
Hi,
I am getting this error when I run virt-manager in FreeBSD:
[Fri, 19 Aug 2011 09:32:14 virt-manager 24762] DEBUG (engine:555) No
inspection thread because libguestfs is too old, not available, or libvirt
is not thread safe.
libguestfs isn't ported to FreeBSD, however I was wondering about the thread
safe for libvirt. Is there a way to "enable" this, or is the software
telling me it really is not thread safe, and can't be.
[jhelfman@eggman ~/ports/devel/libvirt/work/libvirt-0.9.4]$ ./configure --help |grep thread
--enable-threads={posix|solaris|pth|win32}
specify multithreading API
--disable-threads build without multithread safety
--enable-test-locking thread locking tests using CIL [default=no]
Thanks,
Jason
--
Jason Helfman
System Administrator
experts-exchange.com
http://www.experts-exchange.com/M_4830110.html
E4AD 7CF1 1396 27F6 79DD 4342 5E92 AD66 8C8C FBA5
13 years, 4 months
[libvirt] [PATCH] virsh: properly interleave shared stdout and stderr
by Eric Blake
Without this patch, invoking 'virsh >file 2>&1' results in
error messages appearing before normal output, even if they
occurred later in time than the normal output (since stderr
is unbuffered, but stdout waits until a full buffer).
* tools/virsh.c (print_job_progress, vshError): Flush between
stream transitions.
* tests/undefine: Test it.
---
This fixes the bug I mentioned here:
https://www.redhat.com/archives/libvir-list/2011-August/msg00891.html
tests/undefine | 5 +----
tools/virsh.c | 8 ++++++++
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/tests/undefine b/tests/undefine
index 6c821ad..22d6c14 100755
--- a/tests/undefine
+++ b/tests/undefine
@@ -58,17 +58,14 @@ compare exp out || fail=1
# Succeed, now: first shut down, then undefine, both via name.
$abs_top_builddir/tools/virsh -q -c test:///default \
- 'shutdown test; undefine test; dominfo test' > out 2> err
+ 'shutdown test; undefine test; dominfo test' > out 2>&1
test $? = 1 || fail=1
cat <<\EOF > expout || fail=1
Domain test is being shutdown
Domain test has been undefined
-EOF
-cat <<\EOF > experr || fail=1
error: failed to get domain 'test'
error: Domain not found
EOF
compare expout out || fail=1
-compare experr err || fail=1
(exit $fail); exit $fail
diff --git a/tools/virsh.c b/tools/virsh.c
index 1c67150..7d849ec 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -4956,7 +4956,10 @@ print_job_progress(const char *label, unsigned long long remaining,
}
}
+ /* see comments in vshError about why we must flush */
+ fflush(stdout);
fprintf(stderr, "\r%s: [%3d %%]", label, progress);
+ fflush(stderr);
}
static bool
@@ -14336,6 +14339,10 @@ vshError(vshControl *ctl, const char *format, ...)
va_end(ap);
}
+ /* Most output is to stdout, but if someone ran virsh 2>&1, then
+ * printing to stderr will not interleave correctly with stdout
+ * unless we flush between every transition between streams. */
+ fflush(stdout);
fputs(_("error: "), stderr);
va_start(ap, format);
@@ -14345,6 +14352,7 @@ vshError(vshControl *ctl, const char *format, ...)
va_end(ap);
fprintf(stderr, "%s\n", NULLSTR(str));
+ fflush(stderr);
VIR_FREE(str);
}
--
1.7.4.4
13 years, 4 months
[libvirt] xml style?
by Eric Blake
When writing an attribute in xml, which style is preferred?
<element attr='single'/>
<element attr="double"/>
We are currently rather split-brain in libvirt, among three general
areas: test programs under tests/*data/*, documentation under
docs/*.html.in, and RNG schemas under docs/schemas/*. In all cases,
both styles are present, but in different proportions:
$ git grep '="' tests/*data |wc
48 163 4276
$ git grep "='" tests/*data |wc
5994 21336 526402
$ git grep '="' docs/schemas/ |wc
1522 4599 103050
$ git grep "='" docs/schemas/ |wc
566 1699 33005
$ git grep '="' docs/*.in |wc
1288 6436 114146
$ git grep "='" docs/*.in |wc
611 2242 42950
Is it worth a cleanup patch that settles on one particular style, or
even a syntax check that forces style compliance?
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
13 years, 4 months
[libvirt] [PATCHv2 1/2] virsh: add virsh snapshot-current --name
by Eric Blake
Sometimes, full XML is too much; since most snapshot commands
operate on a snapshot name, there should be an easy way to get
at the current snapshot's name.
* tools/virsh.c (cmdSnapshotCurrent): Add an option.
* tools/virsh.pod (snapshot-current): Document it.
---
v2: use xpath instead of strstr; replaces:
https://www.redhat.com/archives/libvir-list/2011-August/msg00329.html
tools/virsh.c | 29 ++++++++++++++++++++++++++---
tools/virsh.pod | 4 +++-
2 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index bffec1d..fd64020 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -12034,6 +12034,7 @@ static const vshCmdInfo info_snapshot_current[] = {
static const vshCmdOptDef opts_snapshot_current[] = {
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
+ {"name", VSH_OT_BOOL, 0, N_("list the name, rather than the full xml")},
{NULL, 0, 0, NULL}
};
@@ -12044,6 +12045,7 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd)
bool ret = false;
int current;
virDomainSnapshotPtr snapshot = NULL;
+ char *xml = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
@@ -12056,7 +12058,7 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd)
if (current < 0)
goto cleanup;
else if (current) {
- char *xml;
+ char *name = NULL;
if (!(snapshot = virDomainSnapshotCurrent(dom, 0)))
goto cleanup;
@@ -12065,13 +12067,34 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd)
if (!xml)
goto cleanup;
- vshPrint(ctl, "%s", xml);
- VIR_FREE(xml);
+ if (vshCommandOptBool(cmd, "name")) {
+ xmlDocPtr xmldoc = NULL;
+ xmlXPathContextPtr ctxt = NULL;
+
+ xmldoc = xmlReadDoc((const xmlChar *) xml, "domainsnapshot.xml",
+ NULL, XML_PARSE_NOENT | XML_PARSE_NONET |
+ XML_PARSE_NOWARNING);
+ if (!xmldoc)
+ goto cleanup;
+ ctxt = xmlXPathNewContext(xmldoc);
+ if (!ctxt) {
+ xmlFreeDoc(xmldoc);
+ }
+
+ name = virXPathString("string(/domainsnapshot/name)", ctxt);
+ xmlXPathFreeContext(ctxt);
+ xmlFreeDoc(xmldoc);
+ if (!name)
+ goto cleanup;
+ }
+
+ vshPrint(ctl, "%s", name ? name : xml);
}
ret = true;
cleanup:
+ VIR_FREE(xml);
if (snapshot)
virDomainSnapshotFree(snapshot);
if (dom)
diff --git a/tools/virsh.pod b/tools/virsh.pod
index ec778bf..53376d6 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1569,9 +1569,11 @@ Create a snapshot for domain I<domain> with the given <name> and
value. If I<--print-xml> is specified, then XML appropriate for
I<snapshot-create> is output, rather than actually creating a snapshot.
-=item B<snapshot-current> I<domain>
+=item B<snapshot-current> I<domain> [I<--name>]
Output the snapshot XML for the domain's current snapshot (if any).
+If I<--name> is specified, just list the snapshot name instead of the
+full xml.
=item B<snapshot-list> I<domain>
--
1.7.4.4
13 years, 4 months
[libvirt] [PATCH 0/3] xml simplifications
by Eric Blake
I noticed this while working on my snapshot stuff. There was lots
of copy and paste going on in virsh.c, and it felt awful to not
be able to represent the same idea in fewer lines, so I fixed it.
This will probably mean I have to rebase the entire snapshot series,
since it will introduce several conflicts in at least virsh.c; oh well.
Eric Blake (3):
maint: treat more libxml2 functions as free-like
xml: add another convenience function
maint: simplify lots of libxml2 clients
cfg.mk | 2 +
src/conf/domain_conf.c | 20 +------
src/conf/storage_conf.c | 8 +---
src/cpu/cpu.c | 18 +-----
src/esx/esx_vi.c | 17 ++-----
src/libvirt_private.syms | 2 -
src/qemu/qemu_migration.c | 9 +---
src/security/virt-aa-helper.c | 12 +----
src/test/test_driver.c | 13 +----
src/util/xml.c | 53 +++++-------------
src/util/xml.h | 84 +++++++++++++++++++++++++---
tests/cputest.c | 9 +---
tools/virsh.c | 120 +++++++++--------------------------------
13 files changed, 135 insertions(+), 232 deletions(-)
--
1.7.4.4
13 years, 4 months
[libvirt] Allow to undefine a running domain
by Osier Yang
Per API virDomainUndefineFlags' doc says, if a domain is running,
it will be converted to transient, but keep running. However,
the drivers prohibit one undefining a running domain.
This patch series modify the internal domainUndefineFlags function
of all drivers (except some driver don't need to check if the
domain is running, it's handled by the underlying hypervisor, such
as ESX and XEND).
The principle is:
1) Set vm->persistent = 0 for a running domain
2) domainDestroy and domainShutdown will take care of remove the
domain obj from the hash table.
[PATCH 1/8] libxl: Allow to undefine a running domain
[PATCH 2/8] lxc: Allow to undefine a running domain
[PATCH 3/8] openvz: Allow to undefine a running domain
[PATCH 4/8] qemu: Allow to undefine a running domain
[PATCH 5/8] test: Allow to undefine a running domain
[PATCH 6/8] uml: Allow to undefine a running domain
[PATCH 7/8] vmware: Allow to undefine a running domain
[PATCH 8/8] xen: Allow to undefine a running domain (xm_internal)
Split the patches for easy reviewing, will merge when committing
if need.
Regards
Osier
13 years, 4 months
[libvirt] [PATCH] qemu: Get memory balloon info correctly for text monitor
by Osier Yang
* src/qemu/qemu_monitor_text.c: BALLOON_PREFIX was defined as
"balloon: actual=", which cause "actual=" is stripped early before
the real parsing. This patch changes BALLOON_PREFIX into "balloon: ",
and modifies related functions, also renames
"qemuMonitorParseExtraBalloonInfo" to "qemuMonitorParseBalloonInfo",
as after the changing, it parses all the info returned by "info balloon".
---
src/qemu/qemu_monitor_text.c | 47 +++++++++++++++++++++++++----------------
1 files changed, 29 insertions(+), 18 deletions(-)
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 7bf733d..d17d863 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -547,8 +547,12 @@ static int parseMemoryStat(char **text, unsigned int tag,
return 0;
}
- /* Convert bytes to kilobytes for libvirt */
switch (tag) {
+ /* Convert megabytes to kilobytes for libvirt */
+ case VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON:
+ value = value << 10;
+ break;
+ /* Convert bytes to kilobytes for libvirt */
case VIR_DOMAIN_MEMORY_STAT_SWAP_IN:
case VIR_DOMAIN_MEMORY_STAT_SWAP_OUT:
case VIR_DOMAIN_MEMORY_STAT_UNUSED:
@@ -565,15 +569,17 @@ static int parseMemoryStat(char **text, unsigned int tag,
/* The reply from the 'info balloon' command may contain additional memory
* statistics in the form: '[,<tag>=<val>]*'
*/
-static int qemuMonitorParseExtraBalloonInfo(char *text,
- virDomainMemoryStatPtr stats,
- unsigned int nr_stats)
+static int qemuMonitorParseBalloonInfo(char *text,
+ virDomainMemoryStatPtr stats,
+ unsigned int nr_stats)
{
char *p = text;
unsigned int nr_stats_found = 0;
while (*p && nr_stats_found < nr_stats) {
- if (parseMemoryStat(&p, VIR_DOMAIN_MEMORY_STAT_SWAP_IN,
+ if (parseMemoryStat(&p, VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON,
+ "actual=", &stats[nr_stats_found]) ||
+ parseMemoryStat(&p, VIR_DOMAIN_MEMORY_STAT_SWAP_IN,
",mem_swapped_in=", &stats[nr_stats_found]) ||
parseMemoryStat(&p, VIR_DOMAIN_MEMORY_STAT_SWAP_OUT,
",mem_swapped_out=", &stats[nr_stats_found]) ||
@@ -584,9 +590,7 @@ static int qemuMonitorParseExtraBalloonInfo(char *text,
parseMemoryStat(&p, VIR_DOMAIN_MEMORY_STAT_UNUSED,
",free_mem=", &stats[nr_stats_found]) ||
parseMemoryStat(&p, VIR_DOMAIN_MEMORY_STAT_AVAILABLE,
- ",total_mem=", &stats[nr_stats_found]) ||
- parseMemoryStat(&p, VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON,
- ",actual=", &stats[nr_stats_found]))
+ ",total_mem=", &stats[nr_stats_found]))
nr_stats_found++;
/* Skip to the next label. When *p is ',' the last match attempt
@@ -602,7 +606,7 @@ static int qemuMonitorParseExtraBalloonInfo(char *text,
/* The reply from QEMU contains 'ballon: actual=421' where value is in MB */
-#define BALLOON_PREFIX "balloon: actual="
+#define BALLOON_PREFIX "balloon: "
/*
* Returns: 0 if balloon not supported, +1 if balloon query worked
@@ -625,13 +629,22 @@ int qemuMonitorTextGetBalloonInfo(qemuMonitorPtr mon,
unsigned int memMB;
char *end;
offset += strlen(BALLOON_PREFIX);
- if (virStrToLong_ui(offset, &end, 10, &memMB) < 0) {
- qemuReportError(VIR_ERR_OPERATION_FAILED,
- _("could not parse memory balloon allocation from '%s'"), reply);
- goto cleanup;
+
+ if (STRPREFIX(offset, "actual=")) {
+ offset += strlen("actual=");
+
+ if (virStrToLong_ui(offset, &end, 10, &memMB) < 0) {
+ qemuReportError(VIR_ERR_OPERATION_FAILED,
+ _("could not parse memory balloon allocation from '%s'"), reply);
+ goto cleanup;
+ }
+ *currmem = memMB * 1024;
+ ret = 1;
+ } else {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unexpected balloon information '%s'"), reply);
+ ret = -1;
}
- *currmem = memMB * 1024;
- ret = 1;
} else {
/* We don't raise an error here, since its to be expected that
* many QEMU's don't support ballooning
@@ -660,9 +673,7 @@ int qemuMonitorTextGetMemoryStats(qemuMonitorPtr mon,
if ((offset = strstr(reply, BALLOON_PREFIX)) != NULL) {
offset += strlen(BALLOON_PREFIX);
- if ((offset = strchr(offset, ',')) != NULL) {
- ret = qemuMonitorParseExtraBalloonInfo(offset, stats, nr_stats);
- }
+ ret = qemuMonitorParseBalloonInfo(offset, stats, nr_stats);
}
VIR_FREE(reply);
--
1.7.6
13 years, 4 months
[libvirt] [PATCH] build: fix compilation on mingw64
by Eric Blake
* .gnulib: Update to latest, for getcwd fixes.
---
Spurred by a gnulib bug report by Marc-André Lureau.
Fedora currently uses the mingw32 cross-compiler, but is aiming to
switch to the mingw64 cross-compiler; once that is done, failure
to upgrade gnulib would trip up cross-compilation during ./autobuild.sh.
* .gnulib 4470580...56d6664 (21):
> getcwd: fix test failures on mingw
> getcwd-lgpl: fix m4 to match relaxed test for BSD
> getcwd: fix compilation on mingw64
> pipe2: silence compiler warning
> autoupdate
> relocatable-prog: fix link error
> getaddrinfo: fix sh typo in gai_strerrorA decl checking
> base64: Reference latest RFC.
> * build-aux/bootstrap (slurp): Remove obsolescent gettext.m4 patch.
> po/Makefile.in.in: fix make -q problem
> configmake: fix make -q problem
> git-version-gen: correct the advice in a comment
> base64: fix off-by-one buffer size bug
> closein: correct comments
> More tests for 'fseeko'.
> ChangeLog: fix wrong attribution in last commit
> fseeko: remove unneeded hack
> fseeko: fix bug on glibc
> unictype/base: Fix interoperability with preinstalled libunistring.
> iswblank: Detect declaration correctly.
> tcgetsid: Detect declaration correctly.
.gnulib | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/.gnulib b/.gnulib
index 4470580..56d6664 160000
--- a/.gnulib
+++ b/.gnulib
@@ -1 +1 @@
-Subproject commit 4470580881a7b821b52fb5635102ef3e27aa5af4
+Subproject commit 56d6664559f449af25f0d331457b014b02324d65
--
1.7.4.4
13 years, 4 months