[libvirt] [PATCH] virsh: silence compiler warning
by Eric Blake
gcc warns:
virsh.c:1879: warning: '0' flag ignored with '-' flag in gnu_printf format
* tools/virsh.c (cmdDomjobinfo): Delete useless flag.
---
tools/virsh.c | 18 +++++++++---------
1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index a6a637d..65487ed 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1876,27 +1876,27 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, "%-17s %-12llu ms\n", _("Time remaining:"), info.timeRemaining);
if (info.dataTotal || info.dataRemaining || info.dataProcessed) {
val = prettyCapacity(info.dataProcessed, &unit);
- vshPrint(ctl, "%-17s %-0.3lf %s\n", _("Data processed:"), val, unit);
+ vshPrint(ctl, "%-17s %-.3lf %s\n", _("Data processed:"), val, unit);
val = prettyCapacity(info.dataRemaining, &unit);
- vshPrint(ctl, "%-17s %-0.3lf %s\n", _("Data remaining:"), val, unit);
+ vshPrint(ctl, "%-17s %-.3lf %s\n", _("Data remaining:"), val, unit);
val = prettyCapacity(info.dataTotal, &unit);
- vshPrint(ctl, "%-17s %-0.3lf %s\n", _("Data total:"), val, unit);
+ vshPrint(ctl, "%-17s %-.3lf %s\n", _("Data total:"), val, unit);
}
if (info.memTotal || info.memRemaining || info.memProcessed) {
val = prettyCapacity(info.memProcessed, &unit);
- vshPrint(ctl, "%-17s %-0.3lf %s\n", _("Memory processed:"), val, unit);
+ vshPrint(ctl, "%-17s %-.3lf %s\n", _("Memory processed:"), val, unit);
val = prettyCapacity(info.memRemaining, &unit);
- vshPrint(ctl, "%-17s %-0.3lf %s\n", _("Memory remaining:"), val, unit);
+ vshPrint(ctl, "%-17s %-.3lf %s\n", _("Memory remaining:"), val, unit);
val = prettyCapacity(info.memTotal, &unit);
- vshPrint(ctl, "%-17s %-0.3lf %s\n", _("Memory total:"), val, unit);
+ vshPrint(ctl, "%-17s %-.3lf %s\n", _("Memory total:"), val, unit);
}
if (info.fileTotal || info.fileRemaining || info.fileProcessed) {
val = prettyCapacity(info.fileProcessed, &unit);
- vshPrint(ctl, "%-17s %-0.3lf %s\n", _("File processed:"), val, unit);
+ vshPrint(ctl, "%-17s %-.3lf %s\n", _("File processed:"), val, unit);
val = prettyCapacity(info.fileRemaining, &unit);
- vshPrint(ctl, "%-17s %-0.3lf %s\n", _("File remaining:"), val, unit);
+ vshPrint(ctl, "%-17s %-.3lf %s\n", _("File remaining:"), val, unit);
val = prettyCapacity(info.fileTotal, &unit);
- vshPrint(ctl, "%-17s %-0.3lf %s\n", _("File total:"), val, unit);
+ vshPrint(ctl, "%-17s %-.3lf %s\n", _("File total:"), val, unit);
}
} else {
ret = FALSE;
--
1.6.6.1
14 years, 10 months
[libvirt] [PATCH] Add TCK script for host USB device hotplug/unplug
by Daniel P. Berrange
This adds support for testing host USB device hotplug/unplug in
libvirt drivers. This currently fails in all known libvirt
drivers :-) The QEMU driver only support the hotplug action,
not unplug, hence the failure.
Since the TCK can't assume there are any host USB devices that
can be safely messed around with, the person running the test
suite must first list one or more devices in the config file.
If no devices are listed, the test will automatically skip
all parts, rather than failing.
* conf/default.cfg: Config entry to specify USB devices that the
TCK can mess around with
* lib/Sys/Virt/TCK.pm: API for getting a host USB device from
the config
* scripts/domain/240-usb-host-hotplug.t: Test case for USB
device hotplug/unplug.
---
conf/default.cfg | 13 +++++
lib/Sys/Virt/TCK.pm | 18 +++++++
scripts/domain/240-usb-host-hotplug.t | 89 +++++++++++++++++++++++++++++++++
3 files changed, 120 insertions(+), 0 deletions(-)
create mode 100644 scripts/domain/240-usb-host-hotplug.t
diff --git a/conf/default.cfg b/conf/default.cfg
index 556225e..f9c2b5c 100644
--- a/conf/default.cfg
+++ b/conf/default.cfg
@@ -99,3 +99,16 @@ kernels = (
# ostype = exe
# }
)
+
+# Host USB devices that the test suite can safely mess around with
+# without risk of breaking the host OS
+host_usb_devices = (
+# Must list either vendor+product, or bus+dev, or both
+# {
+# vendor = 0x0627
+# product = 0x0001
+# bus = 001
+# device = 002
+# }
+# Can list more than one USB device if many are available
+)
diff --git a/lib/Sys/Virt/TCK.pm b/lib/Sys/Virt/TCK.pm
index 9e6b554..ce03935 100644
--- a/lib/Sys/Virt/TCK.pm
+++ b/lib/Sys/Virt/TCK.pm
@@ -769,4 +769,22 @@ sub xpath {
return $xp->find($path);
}
+sub get_host_usb_device {
+ my $self = shift;
+ my $devindex = @_ ? shift : 0;
+
+ my $devs = $self->config("host_usb_devices", []);
+
+ if ($devindex > $#{$devs}) {
+ return ();
+ }
+
+ my $bus = $self->config("host_usb_devices/[$devindex]/bus", undef);
+ my $device = $self->config("host_usb_devices/[$devindex]/device", undef);
+ my $vendor = $self->config("host_usb_devices/[$devindex]/vendor", undef);
+ my $product = $self->config("host_usb_devices/[$devindex]/product", undef);
+
+ return ($bus, $device, $vendor, $product);
+}
+
1;
diff --git a/scripts/domain/240-usb-host-hotplug.t b/scripts/domain/240-usb-host-hotplug.t
new file mode 100644
index 0000000..4729300
--- /dev/null
+++ b/scripts/domain/240-usb-host-hotplug.t
@@ -0,0 +1,89 @@
+# -*- perl -*-
+#
+# Copyright (C) 2009 Red Hat
+# Copyright (C) 2009 Daniel P. Berrange
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
+
+=pod
+
+=head1 NAME
+
+domain/240-usb-host-hotplug.t - verify hot plug & unplug of a host USB device
+
+=head1 DESCRIPTION
+
+The test case validates that it is possible to hotplug a usb
+host device to a running domain, and then unplug it again.
+This requires that the TCK configuration file have at least
+one host USB device listed.
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests => 5;
+
+use Sys::Virt::TCK;
+use Test::Exception;
+
+my $tck = Sys::Virt::TCK->new();
+my $conn = eval { $tck->setup(); };
+BAIL_OUT "failed to setup test harness: $@" if $@;
+END {
+ $tck->cleanup if $tck;
+}
+
+
+my $xml = $tck->generic_domain("tck")->as_xml;
+
+diag "Creating a new transient domain";
+my $dom;
+ok_domain(sub { $dom = $conn->create_domain($xml) }, "created transient domain object");
+
+
+my ($bus, $device, $vendor, $product) = $tck->get_host_usb_device();
+
+SKIP: {
+ # Must have one of the pairs at least
+ unless (($bus && $device) || ($vendor && $product)) {
+ skip "No host usb device available in configuration file", 4;
+ }
+
+ my $devxml = "<hostdev mode='subsystem' type='usb'>\n" .
+ "<source>\n";
+ if ($bus && $device) {
+ $devxml .= "<address bus='$bus' device='$device'/>\n"
+ }
+ if ($vendor && $product) {
+ $devxml .= "<vendor id='$vendor'/>\n";
+ $devxml .= "<product id='$product'/>\n";
+ }
+ $devxml .= "</source>\n" .
+ "</hostdev>\n";
+
+ my $initialxml = $dom->get_xml_description;
+
+ diag "Attaching the new dev $devxml";
+ lives_ok(sub { $dom->attach_device($devxml); }, "USB dev has been attached");
+
+ my $newxml = $dom->get_xml_description;
+ ok($newxml =~ m|<hostdev|, "new XML has extra USB dev present");
+
+ diag "Detaching the new dev $devxml";
+ lives_ok(sub { $dom->detach_device($devxml); }, "USB dev has been detached");
+
+
+ my $finalxml = $dom->get_xml_description;
+
+ is($initialxml, $finalxml, "final XML has removed the disk")
+}
+
--
1.6.5.2
14 years, 10 months
[libvirt] [PATCH] esx: don't ignore failure on close
by Eric Blake
Another warning caught by coverity. Continue to perform best-effort
closing and resource release, but warn the caller about the failure.
* src/esx/esx_driver.c (esxClose): Return an error on failure to
close.
---
src/esx/esx_driver.c | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index e125a09..45b389f 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -2,6 +2,7 @@
/*
* esx_driver.c: core driver methods for managing VMware ESX hosts
*
+ * Copyright (C) 2010 Red Hat, Inc.
* Copyright (C) 2009, 2010 Matthias Bolte <matthias.bolte(a)googlemail.com>
* Copyright (C) 2009 Maximilian Wilhelm <max(a)rfc2324.org>
*
@@ -559,16 +560,19 @@ static int
esxClose(virConnectPtr conn)
{
esxPrivate *priv = conn->privateData;
+ int result = 0;
- esxVI_EnsureSession(priv->host);
-
- esxVI_Logout(priv->host);
+ if (esxVI_EnsureSession(priv->host) < 0 ||
+ esxVI_Logout(priv->host) < 0) {
+ result = -1;
+ }
esxVI_Context_Free(&priv->host);
if (priv->vCenter != NULL) {
- esxVI_EnsureSession(priv->vCenter);
-
- esxVI_Logout(priv->vCenter);
+ if (esxVI_EnsureSession(priv->vCenter) < 0 ||
+ esxVI_Logout(priv->vCenter) < 0) {
+ result = -1;
+ }
esxVI_Context_Free(&priv->vCenter);
}
@@ -579,7 +583,7 @@ esxClose(virConnectPtr conn)
conn->privateData = NULL;
- return 0;
+ return result;
}
--
1.6.6.1
14 years, 10 months
[libvirt] [PATCH 1/2] Use AC_SEARCH_LIBS to find the library to use for dlopen().
by Diego Elio Pettenò
Instead of using AC_CHECK_LIB and hardcoding -ldl, search for the library
needed to get dlopen() and then use the cached value.
---
configure.ac | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 5b1eb5f..a3f28c4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1705,7 +1705,7 @@ if test "x$with_driver_modules" = "xyes" ; then
old_libs="$LIBS"
fail=0
AC_CHECK_HEADER([dlfcn.h],[],[fail=1])
- AC_CHECK_LIB([dl], [dlopen],[],[fail=1])
+ AC_SEARCH_LIBS([dlopen], [dl], [], [fail=1])
test $fail = 1 &&
AC_MSG_ERROR([You must have dlfcn.h / dlopen() support to build driver modules])
@@ -1714,7 +1714,7 @@ if test "x$with_driver_modules" = "xyes" ; then
fi
if test "$with_driver_modules" = "yes"; then
DRIVER_MODULES_CFLAGS="-export-dynamic"
- DRIVER_MODULES_LIBS="-ldl"
+ DRIVER_MODULES_LIBS="$ac_cv_search_dlopen"
AC_DEFINE_UNQUOTED([WITH_DRIVER_MODULES], 1, [whether to build drivers as modules])
fi
AM_CONDITIONAL([WITH_DRIVER_MODULES], [test "$with_driver_modules" != "no"])
--
1.7.0
14 years, 10 months
[libvirt] [PATCH] HACKING: add a section on preprocessor conventions
by Eric Blake
* HACKING: Document recently-discussed style issues.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Turn recent discussions:
https://www.redhat.com/archives/libvir-list/2010-March/msg00058.html
https://www.redhat.com/archives/libvir-list/2010-March/msg00120.html
into policy, so I don't keep debating style points ;)
Can wait till after 0.7.7 (particularly since the vararg macro
series is also waiting).
HACKING | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/HACKING b/HACKING
index be8725d..50b24ee 100644
--- a/HACKING
+++ b/HACKING
@@ -102,6 +102,17 @@ Usually they're in macro definitions or strings, and should be converted
anyhow.
+Preprocessor
+============
+For variadic macros, stick with C99 syntax:
+
+#define vshPrint(_ctl, ...) fprintf(stdout, __VA_ARGS__)
+
+Use parenthesis when checking if a macro is defined:
+
+#if defined(HAVE_POSIX_FALLOCATE) && !defined(HAVE_FALLOCATE)
+
+
C types
=======
Use the right type.
--
1.6.6.1
14 years, 10 months
[libvirt] Update on 0.7.7 release schedule
by Daniel Veillard
As you can have noticed we still have patches queued up and not yet
pushed, plus added a new interface yesterday. I'm travelling all of this
week, so my bandwidth is limited. Plus February is a short month and
we skipped a bit for 0.7.6, so time to validate and push patches has
been shorter than usual.
So I suggest to still push patches today and tomorrow for features,
and start the freeze on thusday evening, and delaying the release to mid
of next week.
But still try to keep the expected cycle for 0.7.8 with a freeze on
March 19 and a release on the 26 :-)
Hope this doesn't disrupt other people schedules !
Daniel
--
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/
14 years, 10 months
[libvirt] [PATCH] Fix detection of errors in QEMU device_add command
by Daniel P. Berrange
The code assumed that 'device_add' returned an empty string upon
success. This is not true, it sometimes prints random debug info.
THus we need to check for an explicit fail string
* src/qemu/qemu_monitor_text.c: Fix error checking of the device_add
monitor command
---
src/qemu/qemu_monitor_text.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 7604ae8..c60e840 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -2122,9 +2122,11 @@ int qemuMonitorTextAddDevice(qemuMonitorPtr mon,
goto cleanup;
}
- if (STRNEQ(reply, "")) {
+ /* If the command failed qemu prints:
+ * Could not add ... */
+ if (strstr(reply, "Could not add ")) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
- _("adding %s device failed: %s"), devicestr, reply);
+ _("adding %s device failed"), devicestr);
goto cleanup;
}
--
1.6.5.2
14 years, 10 months
[libvirt] [PATCH] Fix safezero()
by Jiri Denemark
Various safezero() implementations used either -1, errno or -errno
return values. This patch fixes them all to return -1 and set errno
appropriately.
There was also a bug in size parameter passed to safewrite() which could
result in an attempt to write gigabytes out of a megabyte buffer.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/storage/storage_backend.c | 4 ++--
src/util/util.c | 16 +++++++++-------
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 3742493..849f01b 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -316,7 +316,7 @@ static int createRawFileOpHook(int fd, void *data) {
if ((r = safezero(fd, 0, hdata->vol->allocation - remain,
bytes)) != 0) {
ret = errno;
- virReportSystemError(r, _("cannot fill file '%s'"),
+ virReportSystemError(errno, _("cannot fill file '%s'"),
hdata->vol->target.path);
goto cleanup;
}
@@ -327,7 +327,7 @@ static int createRawFileOpHook(int fd, void *data) {
if ((r = safezero(fd, 0, 0, remain)) != 0) {
ret = errno;
- virReportSystemError(r, _("cannot fill file '%s'"),
+ virReportSystemError(errno, _("cannot fill file '%s'"),
hdata->vol->target.path);
goto cleanup;
}
diff --git a/src/util/util.c b/src/util/util.c
index cf7bba5..34c585d 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -146,11 +146,11 @@ int safezero(int fd, int flags ATTRIBUTE_UNUSED, off_t offset, off_t len)
*/
r = ftruncate(fd, offset + len);
if (r < 0)
- return -errno;
+ return -1;
buf = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset);
if (buf == MAP_FAILED)
- return -errno;
+ return -1;
memset(buf, 0, len);
munmap(buf, len);
@@ -167,24 +167,26 @@ int safezero(int fd, int flags ATTRIBUTE_UNUSED, off_t offset, off_t len)
unsigned long long remain, bytes;
if (lseek(fd, offset, SEEK_SET) < 0)
- return errno;
+ return -1;
/* Split up the write in small chunks so as not to allocate lots of RAM */
remain = len;
bytes = 1024 * 1024;
r = VIR_ALLOC_N(buf, bytes);
- if (r < 0)
- return -ENOMEM;
+ if (r < 0) {
+ errno = ENOMEM;
+ return -1;
+ }
while (remain) {
if (bytes > remain)
bytes = remain;
- r = safewrite(fd, buf, len);
+ r = safewrite(fd, buf, bytes);
if (r < 0) {
VIR_FREE(buf);
- return r;
+ return -1;
}
/* safewrite() guarantees all data will be written */
--
1.7.0
14 years, 10 months