[libvirt] [PATCH v2] vbox: Let configure detect/set the XPCOMC directory
by Matthias Bolte
This allows the user to give an explicit path to configure
./configure --with-vbox=/path/to/virtualbox
instead of having the VirtualBox driver probe a set of possible
paths at runtime. If no explicit path is specified then configure
probes the set of "known" paths.
https://bugzilla.redhat.com/show_bug.cgi?id=609185
---
v2:
- address Eric's comments
- wrap AC_HELP_STRING at 80 columns
- replace the if/else with a for loop, much nicer, indeed :)
- use AC_DEFINE_UNQUOTED instead of AC_SUBST to define VBOX_XPCOMC_DIR
configure.ac | 60 +++++++++++++++++++++++++++++++++++++++++++-
src/vbox/vbox_XPCOMCGlue.c | 22 ++--------------
2 files changed, 62 insertions(+), 20 deletions(-)
diff --git a/configure.ac b/configure.ac
index 691ef69..cab01c2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -232,7 +232,9 @@ AC_ARG_WITH([phyp],
AC_ARG_WITH([xenapi],
AC_HELP_STRING([--with-xenapi], [add XenAPI support @<:@default=check@:>@]),[],[with_xenapi=check])
AC_ARG_WITH([vbox],
- AC_HELP_STRING([--with-vbox], [add VirtualBox support @<:@default=yes@:>@]),[],[with_vbox=yes])
+ AC_HELP_STRING([--with-vbox=@<:@PFX@:>@],
+ [VirtualBox XPCOMC location @<:@default=check@:>@]),[],
+ [with_vbox=check])
AC_ARG_WITH([lxc],
AC_HELP_STRING([--with-lxc], [add Linux Container support @<:@default=check@:>@]),[],[with_lxc=check])
AC_ARG_WITH([one],
@@ -315,6 +317,62 @@ if test "$with_openvz" = "yes"; then
fi
AM_CONDITIONAL([WITH_OPENVZ], [test "$with_openvz" = "yes"])
+
+dnl
+dnl check for VirtualBox XPCOMC location
+dnl
+
+vbox_xpcomc_dir=
+
+if test "x$with_vbox" = "xyes" || test "x$with_vbox" = "xcheck"; then
+ AC_MSG_CHECKING([for VirtualBox XPCOMC location])
+
+ for vbox in \
+ /usr/lib/virtualbox/VBoxXPCOMC.so \
+ /usr/lib/VirtualBox/VBoxXPCOMC.so \
+ /opt/virtualbox/VBoxXPCOMC.so \
+ /opt/VirtualBox/VBoxXPCOMC.so \
+ /opt/virtualbox/i386/VBoxXPCOMC.so \
+ /opt/VirtualBox/i386/VBoxXPCOMC.so \
+ /opt/virtualbox/amd64/VBoxXPCOMC.so \
+ /opt/VirtualBox/amd64/VBoxXPCOMC.so \
+ /usr/local/lib/virtualbox/VBoxXPCOMC.so \
+ /usr/local/lib/VirtualBox/VBoxXPCOMC.so \
+ /Application/VirtualBox.app/Contents/MacOS/VBoxXPCOMC.dylib \
+ ; do
+ if test -f "$vbox"; then
+ vbox_xpcomc_dir=`AS_DIRNAME(["$vbox"])`
+ break
+ fi
+ done
+
+ if test -n "$vbox_xpcomc_dir"; then
+ AC_MSG_RESULT([$vbox_xpcomc_dir])
+ with_vbox=yes
+ else
+ if test "x$with_vbox" = "xcheck"; then
+ AC_MSG_RESULT([not found, disabling VirtualBox driver])
+ with_vbox=no
+ else
+ AC_MSG_RESULT([not found])
+ AC_MSG_ERROR([VirtualBox XPCOMC is required for the VirtualBox driver])
+ fi
+ fi
+else
+ if test "x$with_vbox" != "xno"; then
+ if test -f ${with_vbox}/VBoxXPCOMC.so || \
+ test -f ${with_vbox}/VBoxXPCOMC.dylib; then
+ vbox_xpcomc_dir=$with_vbox
+ with_vbox=yes
+ else
+ AC_MSG_ERROR([$with_vbox does not contain VirtualBox XPCOMC])
+ fi
+ fi
+fi
+
+AC_DEFINE_UNQUOTED([VBOX_XPCOMC_DIR], ["$vbox_xpcomc_dir"],
+ [Location of directory containing VirtualBox XPCOMC library])
+
if test "x$with_vbox" = "xyes"; then
AC_SEARCH_LIBS([dlopen], [dl], [], [AC_MSG_ERROR([Unable to find dlopen()])])
case $ac_cv_search_dlopen in
diff --git a/src/vbox/vbox_XPCOMCGlue.c b/src/vbox/vbox_XPCOMCGlue.c
index 0987c1b..fcae0cb 100644
--- a/src/vbox/vbox_XPCOMCGlue.c
+++ b/src/vbox/vbox_XPCOMCGlue.c
@@ -192,28 +192,12 @@ int VBoxCGlueInit(void)
return tryLoadOne(pszHome, 0);
/*
- * Try the known standard locations.
+ * Try the configured location.
*/
g_szVBoxErrMsg[0] = '\0';
-#if defined(__gnu__linux__) || defined(__linux__)
- if (tryLoadOne("/opt/VirtualBox", 1) == 0)
- return 0;
- if (tryLoadOne("/usr/lib/virtualbox", 1) == 0)
- return 0;
-#elif defined(__sun__)
- if (tryLoadOne("/opt/VirtualBox/amd64", 1) == 0)
- return 0;
- if (tryLoadOne("/opt/VirtualBox/i386", 1) == 0)
- return 0;
-#elif defined(__APPLE__)
- if (tryLoadOne("/Application/VirtualBox.app/Contents/MacOS", 1) == 0)
- return 0;
-#elif defined(__FreeBSD__)
- if (tryLoadOne("/usr/local/lib/virtualbox", 1) == 0)
+
+ if (tryLoadOne(VBOX_XPCOMC_DIR, 1) == 0)
return 0;
-#else
-# error "port me"
-#endif
/*
* Finally try the dynamic linker search path.
--
1.7.0.4
14 years, 4 months
[libvirt] [PATCHv2 2/2] virsh: add new --details option to vol-list
by Justin Clift
This patch adds a new --details option to the virsh vol-list
command, making its output more useful to people who use virsh
for significant lengths of time.
Addresses BZ # 605543
https://bugzilla.redhat.com/show_bug.cgi?id=605543
---
This new version of the patch uses the existing virsh output format
when the --details option isn't given, maintaining backwards
compatibility for existing scripts. When the new --details
option is given though, the additional info is displayed and all
columns are sized to their widest string.
Output from the new option (hopefully this doesn't wrap):
virsh # vol-list default
Name Path
-----------------------------------------
CentOS-5.5-x86_64-bin-DVD-1of2.iso /var/lib/libvirt/images/CentOS-5.5-x86_64-bin-DVD-1of2.iso
CentOS-5.5-x86_64-bin-DVD-2of2.iso /var/lib/libvirt/images/CentOS-5.5-x86_64-bin-DVD-2of2.iso
virsh # vol-list default --details
Name Path Type Capacity Allocation
---------------------------------------------------------------------------------------------------------------------------
CentOS-5.5-x86_64-bin-DVD-1of2.iso /var/lib/libvirt/images/CentOS-5.5-x86_64-bin-DVD-1of2.iso file 4.09 GB 4.10 GB
CentOS-5.5-x86_64-bin-DVD-2of2.iso /var/lib/libvirt/images/CentOS-5.5-x86_64-bin-DVD-2of2.iso file 412.33 MB 412.74 MB
virsh # vol-list tmp
Name Path
-----------------------------------------
disk1.img /tmp/images/disk1.img
disk2.img /tmp/images/disk2.img
disk3.img /tmp/images/disk3.img
disk4.img /tmp/images/disk4.img
disk5.img /tmp/images/disk5.img
disk6.img /tmp/images/disk6.img
virsh # vol-list tmp --details
Name Path Type Capacity Allocation
------------------------------------------------------------
disk1.img /tmp/images/disk1.img file 20.00 GB 136.00 KB
disk2.img /tmp/images/disk2.img file 20.00 GB 136.00 KB
disk3.img /tmp/images/disk3.img file 20.00 GB 136.00 KB
disk4.img /tmp/images/disk4.img file 20.00 GB 136.00 KB
disk5.img /tmp/images/disk5.img file 20.00 GB 136.00 KB
disk6.img /tmp/images/disk6.img file 20.00 GB 136.00 KB
virsh #
Much nicer to use when pools have a bunch of luns in them. :)
tools/virsh.c | 225 ++++++++++++++++++++++++++++++++++++++++++++++++------
tools/virsh.pod | 4 +-
2 files changed, 203 insertions(+), 26 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 7261d19..2a9c353 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -6075,67 +6075,242 @@ static const vshCmdInfo info_vol_list[] = {
static const vshCmdOptDef opts_vol_list[] = {
{"pool", VSH_OT_DATA, VSH_OFLAG_REQ, N_("pool name or uuid")},
+ {"details", VSH_OT_BOOL, 0, N_("display extended details for volumes")},
{NULL, 0, 0, NULL}
};
static int
cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
+ virStorageVolInfo volumeInfo;
virStoragePoolPtr pool;
- int maxactive = 0, i;
+ int details = vshCommandOptBool(cmd, "details");
+ int maxAlloc = 0, maxCap = 0, maxName = 0;
+ int maxPath = 0, maxType = 0;
+ int numVolumes = 0, i;
+ int stringLength = 0;
+ double val;
+ const char *unit;
char **activeNames = NULL;
+ struct volInfoText {
+ char *allocation;
+ char *capacity;
+ char *path;
+ char *type;
+ };
+ struct volInfoText **volInfoTexts;
+ /* Check the connection to libvirtd daemon is still working */
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
return FALSE;
+ /* Look up the pool information given to us by the user */
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
return FALSE;
- maxactive = virStoragePoolNumOfVolumes(pool);
- if (maxactive < 0) {
+ /* Determine the number of volumes in the pool */
+ numVolumes = virStoragePoolNumOfVolumes(pool);
+ if (numVolumes < 0) {
virStoragePoolFree(pool);
vshError(ctl, "%s", _("Failed to list active vols"));
return FALSE;
}
- if (maxactive) {
- activeNames = vshMalloc(ctl, sizeof(char *) * maxactive);
- if ((maxactive = virStoragePoolListVolumes(pool, activeNames,
- maxactive)) < 0) {
+ /* Retrieve the list of volume names in the pool */
+ if (numVolumes) {
+ activeNames = vshMalloc(ctl, sizeof(char *) * numVolumes);
+ if ((numVolumes = virStoragePoolListVolumes(pool, activeNames,
+ numVolumes)) < 0) {
vshError(ctl, "%s", _("Failed to list active vols"));
VIR_FREE(activeNames);
virStoragePoolFree(pool);
return FALSE;
}
- qsort(&activeNames[0], maxactive, sizeof(char *), namesorter);
+ /* Sort the volume names */
+ qsort(&activeNames[0], numVolumes, sizeof(char *), namesorter);
}
- vshPrintExtra(ctl, "%-20s %-40s\n", _("Name"), _("Path"));
- vshPrintExtra(ctl, "-----------------------------------------\n");
- for (i = 0; i < maxactive; i++) {
- virStorageVolPtr vol = virStorageVolLookupByName(pool, activeNames[i]);
- char *path;
+ /* Set aside memory for volume information pointers */
+ volInfoTexts = vshMalloc(ctl, sizeof(struct volInfoText *) * numVolumes);
- /* this kind of work with vols is not atomic operation */
- if (!vol) {
- VIR_FREE(activeNames[i]);
- continue;
+ /* Collect the rest of the volume information for display */
+ for (i = 0; i < numVolumes; i++) {
+ /* Retrieve volume info */
+ virStorageVolPtr vol = virStorageVolLookupByName(pool,
+ activeNames[i]);
+
+ /* Allocate memory for one row of volume info */
+ volInfoTexts[i] = vshMalloc(ctl, sizeof(struct volInfoText));
+
+ /* Retrieve the volume path */
+ if ((volInfoTexts[i]->path = virStorageVolGetPath(vol)) == NULL) {
+ /* Something went wrong retrieving a volume path, cope with it */
+ volInfoTexts[i]->path = vshStrdup(ctl, _("unknown"));
}
- if ((path = virStorageVolGetPath(vol)) == NULL) {
- virStorageVolFree(vol);
- continue;
+ /* Retrieve volume type and sizing information */
+ if (virStorageVolGetInfo(vol, &volumeInfo) != 0) {
+ /* Something went wrong retrieving volume info, cope with it */
+ volInfoTexts[i]->allocation = vshStrdup(ctl, _("unknown"));
+ volInfoTexts[i]->capacity = vshStrdup(ctl, _("unknown"));
+ volInfoTexts[i]->type = vshStrdup(ctl, _("unknown"));
+ } else {
+ /* Convert the returned volume info into output strings */
+ virBuffer bufStr = VIR_BUFFER_INITIALIZER;
+
+ /* Volume type */
+ if (volumeInfo.type == VIR_STORAGE_VOL_FILE)
+ volInfoTexts[i]->type = vshStrdup(ctl, _("file"));
+ else
+ volInfoTexts[i]->type = vshStrdup(ctl, _("block"));
+
+ // The capacity value to output
+ val = prettyCapacity(volumeInfo.capacity, &unit);
+ virBufferVSprintf(&bufStr, "%.2lf %s", val, unit);
+ volInfoTexts[i]->capacity =
+ vshStrdup(ctl, virBufferContentAndReset(&bufStr));
+
+ // The allocation value to output
+ val = prettyCapacity(volumeInfo.allocation, &unit);
+ virBufferVSprintf(&bufStr, "%.2lf %s", val, unit);
+ volInfoTexts[i]->allocation =
+ vshStrdup(ctl, virBufferContentAndReset(&bufStr));
}
+ /** Remember the longest output size of each string, **
+ ** so we can use a printf style output format template **
+ ** later on for both the header and volume info rows **/
+
+ /* Keep the length of name string if longest so far */
+ stringLength = strlen(activeNames[i]);
+ if (stringLength > maxName)
+ maxName = stringLength;
- vshPrint(ctl, "%-20s %-40s\n",
- virStorageVolGetName(vol),
- path);
- VIR_FREE(path);
+ /* Keep the length of path string if longest so far */
+ stringLength = strlen(volInfoTexts[i]->path);
+ if (stringLength > maxPath)
+ maxPath = stringLength;
+
+ /* Keep the length of type string if longest so far */
+ stringLength = strlen(volInfoTexts[i]->type);
+ if (stringLength > maxType)
+ maxType = stringLength;
+
+ /* Keep the length of capacity string if longest so far */
+ stringLength = strlen(volInfoTexts[i]->capacity);
+ if (stringLength > maxCap)
+ maxCap = stringLength;
+
+ /* Keep the length of allocation string if longest so far */
+ stringLength = strlen(volInfoTexts[i]->allocation);
+ if (stringLength > maxAlloc)
+ maxAlloc = stringLength;
+
+ /* Cleanup memory allocation */
virStorageVolFree(vol);
- VIR_FREE(activeNames[i]);
}
+
+ /** If the --details option wasn't selected, we output the volume **
+ ** info using the fixed string format from previous versions to **
+ ** maintain backward compatibility. **/
+
+ /* Output basic info then return if --details option not selected */
+ if (!details) {
+ /* The old output format */
+ vshPrintExtra(ctl, "%-20s %-40s\n", _("Name"), _("Path"));
+ vshPrintExtra(ctl, "-----------------------------------------\n");
+ for (i = 0; i < numVolumes; i++) {
+ vshPrint(ctl, "%-20s %-40s\n", activeNames[i],
+ volInfoTexts[i]->path);
+
+ /* Cleanup the memory for this volume row */
+ VIR_FREE(volInfoTexts[i]->path);
+ VIR_FREE(volInfoTexts[i]->type);
+ VIR_FREE(volInfoTexts[i]->capacity);
+ VIR_FREE(volInfoTexts[i]->allocation);
+ VIR_FREE(volInfoTexts[i]);
+ }
+
+ /* Cleanup remaining memory and return */
+ VIR_FREE(volInfoTexts);
+ VIR_FREE(activeNames);
+ virStoragePoolFree(pool);
+ return TRUE;
+ }
+
+ /** We only get here if the --details option was selected. **
+ ** Column now resize to the longest string to be output. **/
+
+ /* Determine the length of the header strings. These must be
+ * calculated because we may be outputing a translated heading
+ */
+ /* Use the length of name header string if it's longest */
+ stringLength = strlen(_("Name"));
+ if (stringLength > maxName)
+ maxName = stringLength;
+
+ /* Use the length of path header string if it's longest */
+ stringLength = strlen(_("Path"));
+ if (stringLength > maxPath)
+ maxPath = stringLength;
+
+ /* Use the length of type header string if it's longest */
+ stringLength = strlen(_("Type"));
+ if (stringLength > maxType)
+ maxType = stringLength;
+
+ /* Use the length of capacity header string if it's longest */
+ stringLength = strlen(_("Capacity"));
+ if (stringLength > maxCap)
+ maxCap = stringLength;
+
+ /* Use the length of allocation header string if it's longest */
+ stringLength = strlen(_("Allocation"));
+ if (stringLength > maxAlloc)
+ maxAlloc = stringLength;
+
+ /* Display the string lengths for debugging */
+ vshDebug(ctl, 5, "Longest name string = %d chars\n", maxName);
+ vshDebug(ctl, 5, "Longest path string = %d chars\n", maxPath);
+ vshDebug(ctl, 5, "Longest type string = %d chars\n", maxType);
+ vshDebug(ctl, 5, "Longest capacity string = %d chars\n", maxCap);
+ vshDebug(ctl, 5, "Longest allocation string = %d chars\n", maxAlloc);
+
+ /* Create the output template */
+ char *outputStr;
+ virBuffer bufStr = VIR_BUFFER_INITIALIZER;
+ virBufferVSprintf(&bufStr, "%%-%us %%-%us %%-%us %%-%us %%-%us\n",
+ maxName, maxPath, maxType, maxCap, maxAlloc);
+ outputStr = virBufferContentAndReset(&bufStr);
+
+ /* Display the header */
+ vshPrint(ctl, outputStr, _("Name"), _("Path"), _("Type"),
+ ("Capacity"), _("Allocation"));
+ for (i = maxName + maxPath + maxType + maxCap + maxAlloc + 8; i > 0; i--)
+ vshPrintExtra(ctl, "-");
+ vshPrintExtra(ctl, "\n");
+
+ /* Display the volume info rows */
+ for (i = 0; i < numVolumes; i++) {
+ vshPrint(ctl, outputStr,
+ activeNames[i],
+ volInfoTexts[i]->path,
+ volInfoTexts[i]->type,
+ volInfoTexts[i]->capacity,
+ volInfoTexts[i]->allocation);
+
+ /* Cleanup the memory for this volume row */
+ VIR_FREE(volInfoTexts[i]->path);
+ VIR_FREE(volInfoTexts[i]->type);
+ VIR_FREE(volInfoTexts[i]->capacity);
+ VIR_FREE(volInfoTexts[i]->allocation);
+ VIR_FREE(volInfoTexts[i]);
+ }
+
+ /* Cleanup remaining memory */
+ VIR_FREE(outputStr);
+ VIR_FREE(volInfoTexts);
VIR_FREE(activeNames);
virStoragePoolFree(pool);
return TRUE;
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 7c75edc..a217cba 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -839,10 +839,12 @@ Returns basic information about the given storage volume.
I<--pool> I<pool-or-uuid> is the name or UUID of the storage pool the volume is in.
I<vol-name-or-key-or-path> is the name or key or path of the volume to return information for.
-=item B<vol-list> I<--pool> I<pool-or-uuid>
+=item B<vol-list> [optional I<--pool>] I<pool-or-uuid> optional I<--details>
Return the list of volumes in the given storage pool.
I<--pool> I<pool-or-uuid> is the name or UUID of the storage pool.
+The I<--details> option instructs virsh to additionally display volume
+type and capacity related information where available.
=item B<vol-pool> [optional I<--uuid>] I<vol-key-or-path>
--
1.7.0.1
14 years, 4 months
[libvirt] [PATCH] util: virExec: Dispatch all errors raised after fork
by Cole Robinson
Any error message raised after the process has forked needs
to be followed by virDispatchError, otherwise we have no chance of
ever seeing it. This was selectively done for hook functions in the past,
but really applies to all post-fork errors.
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
src/util/util.c | 26 ++++++++++++++------------
1 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/src/util/util.c b/src/util/util.c
index d058113..5f2bff5 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -283,7 +283,8 @@ static int virClearCapabilities(void)
capng_clear(CAPNG_SELECT_BOTH);
if ((ret = capng_apply(CAPNG_SELECT_BOTH)) < 0) {
- VIR_ERROR(_("cannot clear process capabilities %d"), ret);
+ virUtilError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot clear process capabilities %d"), ret);
return -1;
}
@@ -559,7 +560,7 @@ __virExec(const char *const*argv,
/* The fork was sucessful, but after that there was an error
* in the child (which was already logged).
*/
- _exit(1);
+ goto fork_error;
}
openmax = sysconf (_SC_OPEN_MAX);
@@ -575,19 +576,19 @@ __virExec(const char *const*argv,
if (dup2(infd >= 0 ? infd : null, STDIN_FILENO) < 0) {
virReportSystemError(errno,
"%s", _("failed to setup stdin file handle"));
- _exit(1);
+ goto fork_error;
}
if (childout > 0 &&
dup2(childout, STDOUT_FILENO) < 0) {
virReportSystemError(errno,
"%s", _("failed to setup stdout file handle"));
- _exit(1);
+ goto fork_error;
}
if (childerr > 0 &&
dup2(childerr, STDERR_FILENO) < 0) {
virReportSystemError(errno,
"%s", _("failed to setup stderr file handle"));
- _exit(1);
+ goto fork_error;
}
if (infd > 0)
@@ -605,20 +606,20 @@ __virExec(const char *const*argv,
if (setsid() < 0) {
virReportSystemError(errno,
"%s", _("cannot become session leader"));
- _exit(1);
+ goto fork_error;
}
if (chdir("/") < 0) {
virReportSystemError(errno,
"%s", _("cannot change to root directory: %s"));
- _exit(1);
+ goto fork_error;
}
pid = fork();
if (pid < 0) {
virReportSystemError(errno,
"%s", _("cannot fork child process"));
- _exit(1);
+ goto fork_error;
}
if (pid > 0) {
@@ -629,7 +630,7 @@ __virExec(const char *const*argv,
virReportSystemError(errno,
_("could not write pidfile %s for %d"),
pidfile, pid);
- _exit(1);
+ goto fork_error;
}
_exit(0);
}
@@ -638,15 +639,14 @@ __virExec(const char *const*argv,
if (hook)
if ((hook)(data) != 0) {
VIR_DEBUG0("Hook function failed.");
- virDispatchError(NULL);
- _exit(1);
+ goto fork_error;
}
/* The steps above may need todo something privileged, so
* we delay clearing capabilities until the last minute */
if ((flags & VIR_EXEC_CLEAR_CAPS) &&
virClearCapabilities() < 0)
- _exit(1);
+ goto fork_error;
if (envp)
execve(argv[0], (char **) argv, (char**)envp);
@@ -657,6 +657,8 @@ __virExec(const char *const*argv,
_("cannot execute binary %s"),
argv[0]);
+ fork_error:
+ virDispatchError(NULL);
_exit(1);
cleanup:
--
1.6.6.1
14 years, 4 months
[libvirt] [PATCH] qemu: Improve some qemu.conf error reporting
by Cole Robinson
Log some info if we can't find a config file. Make parse failures
fatal, and actually raise an error message.
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
src/qemu/qemu_conf.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index ce42bd6..e2f7b31 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -133,16 +133,21 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
/* Just check the file is readable before opening it, otherwise
* libvirt emits an error.
*/
- if (access (filename, R_OK) == -1) return 0;
+ if (access (filename, R_OK) == -1) {
+ VIR_INFO("Could not read qemu config file %s", filename);
+ return 0;
+ }
conf = virConfReadFile (filename, 0);
- if (!conf) return 0;
+ if (!conf) {
+ return -1;
+ }
#define CHECK_TYPE(name,typ) if (p && p->type != (typ)) { \
qemuReportError(VIR_ERR_INTERNAL_ERROR, \
- "remoteReadConfigFile: %s: %s: expected type " #typ, \
- filename, (name)); \
+ "%s: %s: %s: expected type " #typ, \
+ __func__, filename, (name)); \
virConfFree(conf); \
return -1; \
}
--
1.6.6.1
14 years, 4 months
[libvirt] [PATCH] udev: Parse PCI devices even if libpciaccess fails
by Cole Robinson
We only use libpciaccess for resolving device product/vendor. If
initializing the library fails (say if using qemu:///session), don't
warn so loudly, and carry on as usual.
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
src/node_device/node_device_udev.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 73217c5..f872483 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -363,12 +363,15 @@ static int udevTranslatePCIIds(unsigned int vendor,
char **vendor_string,
char **product_string)
{
- int ret = -1;
+ int ret = -1, pciret;
struct pci_id_match m;
const char *vendor_name = NULL, *device_name = NULL;
- if (pci_system_init() != 0) {
- VIR_ERROR0(_("Failed to initialize libpciaccess"));
+ if ((pciret = pci_system_init()) != 0) {
+ char ebuf[1024];
+ VIR_INFO("Failed to initialize libpciaccess: %s",
+ virStrerror(pciret, ebuf, sizeof ebuf));
+ ret = 0;
goto out;
}
--
1.6.6.1
14 years, 4 months
[libvirt] [PATCH v2 REPOST 0/8]: Add arbitrary qemu command-line and monitor commands
by Chris Lalancette
As we discussed previously, here is the patch series to add the ability
to specify arbitrary qemu command-line parameters and environment variables,
and also give arbitrary monitor commands to a guest. Because these
extra arguments have a good shot at confusing libvirt, the use of them
is not supported, but left available for advanced users and developers.
They are also in a separate library and have a separate on-the-wire
protocol.
There is one bug left that I have not yet been able to fix. Because of the
complicated way that virsh parses command-line arguments, it is not possible
to pass through spaces and quotes when using the qemu-monitor-command.
Unfortunately, the qemu monitor commands (and in particular when using QMP)
depend heavily on quoting and spacing, so using virsh to send through
command-lines is difficult. I'll have to think about how to better resolve
this issue, but it should not hold up the rest of the series.
I will point out one particular patch that could use some careful review,
namely PATCH 6/8. In there, I change the remote_message_hdr to use an
unsigned proc instead of a remote_procedure proc. Now, as far as I can tell
the two sizes should be the same, so the wire protocol should be the same.
Indeed, testing seems to show that older virsh can talk just fine to a libvirtd
with this patch applied. However, the regenerated remote_protocol.c file for
parsing remote_message_header has some strange bits in it that I don't quite
understand. I'm hoping someone else can look at it and confirm that it is OK.
Thanks to Dan Berrange and Eric Blake for their reviews already, and to DV
for the Relax NG schema changes.
Changes since v1 are listed in the individual patches.
14 years, 4 months
[libvirt] ANNOUNCE: ruby-libvirt bindings 0.2.0
by Chris Lalancette
Hello all,
I'm pleased to announce the release of 0.2.0 of the ruby-libvirt bindings.
This release has a number of new features:
- Updated Storage class, implementing pool.active?, pool.persistent?,
pool.vol_create_xml_from
- Updated Connect class, implementing conn.node_free_memory,
conn.node_cells_free_memory, conn.node_get_security_model, conn.encrypted?,
conn.libversion, and conn.secure?
- Updated Network class, implementing network.active? and network.persistent?
- Update Domain class, implementing conn.domain_xml_from_native,
conn.domain_xml_to_native, dom.migrate_to_uri, dom.migrate_set_max_downtime,
dom.managed_save, dom.has_managed_save?, dom.managed_save_remove,
dom.security_label, dom.block_stats, dom.memory_stats, dom.blockinfo,
dom.block_peek, dom.memory_peek, dom.active?, dom.persistent?,
dom.snapshot_create_xml, dom.num_of_snapshots, dom.list_snapshots,
dom.lookup_snapshot_by_name, dom.has_current_snapshot?,
dom.revert_to_snapshot, dom.current_snapshot, snapshot.xml_desc,
snapshot.delete, dom.job_info, and dom.abort_job
- Implementation of the NodeDevice class
- Implementation of the Secret class
- Implementation of the NWFilter class
- Implementation of the Interface class
- Conversion of the development tree to git
- New maintainer (me). David Lutterkort has agreed to transfer maintainership
of the bindings over to me, since he is not actively involved in their
development anymore.
With the above list, almost all of the APIs up to and including libvirt 0.8.1
are covered. There are a few that I have not yet had time to implement; you
can look at the list of FIXMEs in the source code to find them.
I've uploaded new tarballs and source RPMs to: http://libvirt.org/ruby/download/
The new git repo is here: http://libvirt.org/git/?p=ruby-libvirt.git;a=summary
The documentation for the new API's are here: http://libvirt.org/ruby/api/index.html
If you have time, and are interested in the bindings, please give these new
ones a whirl and let me know if they work for you. As usual, if you have
any questions, problems, patches, or bug reports, feel free to email the
libvirt development list (and CC me) so that I can take a look at them.
--
Chris Lalancette
14 years, 4 months
Re: [libvirt] Documentation for synchronous hooks
by Jintao Yang
hi DV, I saw the changelog of 0.7.8, which told the hooks scripts are supported. but is it took away in 0.8.0-4?
[root@dhcp-66-70 libvirt]# rpm -ql libvirt | grep etc
/etc/libvirt
/etc/libvirt/libvirtd.conf
/etc/libvirt/lxc.conf
/etc/libvirt/nwfilter
/etc/libvirt/nwfilter/allow-arp.xml
/etc/libvirt/nwfilter/allow-dhcp-server.xml
/etc/libvirt/nwfilter/allow-dhcp.xml
/etc/libvirt/nwfilter/allow-incoming-ipv4.xml
/etc/libvirt/nwfilter/allow-ipv4.xml
/etc/libvirt/nwfilter/clean-traffic.xml
/etc/libvirt/nwfilter/no-arp-spoofing.xml
/etc/libvirt/nwfilter/no-ip-multicast.xml
/etc/libvirt/nwfilter/no-ip-spoofing.xml
/etc/libvirt/nwfilter/no-mac-broadcast.xml
/etc/libvirt/nwfilter/no-mac-spoofing.xml
/etc/libvirt/nwfilter/no-other-l2-traffic.xml
/etc/libvirt/qemu
/etc/libvirt/qemu.conf
/etc/libvirt/qemu/networks
/etc/libvirt/qemu/networks/autostart
/etc/logrotate.d/libvirtd.lxc
/etc/logrotate.d/libvirtd.qemu
/etc/rc.d/init.d/libvirtd
/etc/sysconfig/libvirtd
[root@dhcp-66-70 libvirt]# rpm -q libvirt
libvirt-0.8.0-4.el6.x86_64
Regards
osier
----- Original Message -----
From: "Daniel Veillard" <veillard(a)redhat.com>
To: libvir-list(a)redhat.com
Sent: Monday, April 12, 2010 11:16:27 PM GMT +08:00 Beijing / Chongqing / Hong Kong / Urumqi
Subject: [libvirt] Documentation for synchronous hooks
Was still missing from main commits and would be needed for 0.8.0
Add documentation for synchronous hooks
* docs/sitemap.html.in: add in navigation under
Documentation/Deployment/Hooks
* docs/hooks.html.in: new doc describing current support for 0.8.0
diff --git a/docs/hooks.html.in b/docs/hooks.html.in
new file mode 100644
index 0000000..4ebeec3
--- /dev/null
+++ b/docs/hooks.html.in
@@ -0,0 +1,71 @@
+<?xml version="1.0"?>
+<html>
+ <body>
+ <h1>Hooks for specific system management</h1>
+ <p>Libvirt includes synchronous hooks starting from version 0.8.0,
+ this is a way to tie specific tailored system actions at specific
+ time. This is based on scripts being called on the Host where the
+ hypervisor is running, if the script is present when the libvirtd
+ daemon is doing some significant actions.</p>
+ <p>The scripts are expected to execute quickly, return a zero exit
+ status if all conditions are set for the daemon to continue the
+ action (non zero will be considered a failure which may
+ be ignored but in general will stops the ongoing operation).
+ The script also should not call back into libvirt as the daemon
+ is waiting for the script exit and deadlock is likely to occur
+ otherwise.</p>
+ <p>The scripts are stored in the directory <code>/etc/libvirt/hooks/</code>
+ when using a standard installation path
+ (<code>$SYSCONF_DIR/libvirt/hook/</code> in general).</p>
+ <p>The scripts gets arguments as parameter on their command line:</p>
+ <ul>
+ <li> the first argument is the name of the object involved in the
+ operation or '-' if there is none.
+ <li> the second argument is the name of the operation.
+ <li> the third argument is a suboperation indication like 'start'
+ 'end' or '-' if there is none.
+ <li> the last argument is an extra argument string or '-' if there
+ is none.
+ </ul>
+ <p>There is currently scripts for 3 domains of operation:
+ <ul>
+ <li><p><code>/etc/libvirt/hooks/daemon</code> script if
+ present is called at 3 points in time:</p>
+ <p>at daemon startup, typically started with the following
+ arguments:</p>
+ <pre>/etc/libvirt/hooks/daemon - start - start</pre>
+ <p>at daemon shutdown when it is about to exit, with the following
+ arguments:</p>
+ <pre>/etc/libvirt/hooks/daemon - shutdown - shutdown</pre>
+ <p>When the daemon is asked to reload its driver state when
+ receiving the SIGHUP signal, arguments are:</p>
+ <pre>/etc/libvirt/hooks/daemon - reload begin SIGHUP</pre>
+ </li>
+ <li><p><code>/etc/libvirt/hooks/qemu</code> script and <br/>
+ <code>/etc/libvirt/hooks/lxc</code> to associate hooks for domain
+ operation on the respective QEmu/KVM and LXC drivers.</p>
+ <p> The domain related hooks also receive the full XML description
+ for the concerned domain on their stdin, which allows to get
+ all the informations from the domain, including UUID or storage
+ if that is needed for the script operation.</p>
+ <p> Currently only domain startup and domain end operations
+ involve the hook, the first one just before the domain gets
+ created.
+ For example if starting a QEmu domain named <code>test</code>
+ the following script will get called:</p>
+ <pre>/etc/libvirt/hooks/qemu test start begin -</pre>
+ <p> note that a non-zero return value from the script will abort the
+ domain startup operation, and if an error string is passed on
+ stderr by the hook script, it will be provided back to the user
+ at the libvirt API level.</p>
+ <p> For domain shutdown, the script will be called just after the
+ domain has finished execution, and the script will get:</p>
+ <pre>/etc/libvirt/hooks/qemu test stopped end -</pre>
+ <p> It is expected that other operation will be associated to hooks
+ but at the time of 0.8.0 only those 2 are associated to domains
+ lifecycle</p>
+ </li>
+ </ul>
+ <p></p>
+ </body>
+</html>
diff --git a/docs/sitemap.html.in b/docs/sitemap.html.in
index 0c3f0c3..0117c8d 100644
--- a/docs/sitemap.html.in
+++ b/docs/sitemap.html.in
@@ -50,6 +50,10 @@
<a href="logging.html">Logging</a>
<span>The library and the daemon logging support</span>
</li>
+ <li>
+ <a href="hooks.html">Hooks</a>
+ <span>Hooks for system specific management</span>
+ </li>
</ul>
</li>
<li>
--
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/
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
14 years, 4 months
Re: [libvirt] [libvirt-users] C API example
by Dave Allan
On Thu, Jul 01, 2010 at 01:43:55PM -0700, steven765(a)yahoo.com wrote:
> Hi Dave,
> Thanks for the reply after getting some sleep the question I should have asked is what libraries do I need to link the application against? If I just try gcc -o a.out hellolibvirt.c it can't find any of the libvirt calls.
[cc'ing the list again so the answer gets archived]
Libvirt's no different from any other library, you need to link
against libvirt, and you need to have the libvirt headers installed.
On Fedora, that's:
yum install libvirt-devel
If you want to build hellolibvirt without using make, you'll need to
edit hellolibvirt.c and take out config.h, which is unused. Then you
can do:
gcc -o hellolibvirt -lvirt hellolibvirt.c
Then you just need to learn the API and decide what you want to do
with it. ;-)
The API is documented at:
http://libvirt.org/html/libvirt-libvirt.html
Dave
> Thanks,
> Steve
>
> --- On Thu, 7/1/10, Dave Allan <dallan(a)redhat.com> wrote:
>
> > From: Dave Allan <dallan(a)redhat.com>
> > Subject: Re: [libvirt-users] C API example
> > To: steven765(a)yahoo.com
> > Cc: "Justin Clift" <justin(a)salasaga.org>, libvirt-users(a)redhat.com
> > Date: Thursday, July 1, 2010, 2:06 PM
> > On Wed, Jun 30, 2010 at 07:37:27PM
> > -0700, steven765(a)yahoo.com
> > wrote:
> > > I think so, but I'm locked out at home. I'll have to
> > try at school tomorrow. It gave me a remote error, but
> > with the correct directory so fingers crossed thanks!
> >
> > >
> > > btw might you or anyone know what I have to include to
> > start a clean project of my own? So if I want to just
> > build an application that uses the API with nothing else but
> > what's necessary?
> >
> > If you're talking about a C application, you're pretty much
> > describing
> > hellolibvirt. I tried to put enough in there to
> > demonstrate a couple
> > of different calls, but hopefully not so much that it's
> > overwhelming.
> > If it seems like there's a lot there, cut some of it
> > out. You don't
> > need the showDomains function, for example. Remove
> > it, compile and
> > see what happens.
> >
> > Dave
> >
> >
> > > Thanks,
> > > Steve
> > >
> > > --- On Wed, 6/30/10, Justin Clift <justin(a)salasaga.org>
> > wrote:
> > >
> > > > From: Justin Clift <justin(a)salasaga.org>
> > > > Subject: Re: [libvirt-users] C API example
> > > > To: "Dave Allan" <dallan(a)redhat.com>
> > > > Cc: steven765(a)yahoo.com,
> > libvirt-users(a)redhat.com
> > > > Date: Wednesday, June 30, 2010, 10:09 PM
> > > > On 07/01/2010 11:54 AM, Dave Allan
> > > > wrote:
> > > > <snip>
> > > > > ./hellolibvirt \
> > > > >
> > > >
> > qemu+unix:///system?socket=/var/run/libvirt/libvirt-sock
> > > >
> > > > Thanks Dave. The +unix:// and ?socket=xxx bits
> > are
> > > > what I'd not been picking up on. Should be good
> > now.
> > > >
> > > > Steven, is it working for you?
> > > >
> > > > Regards and best wishes,
> > > >
> > > > Justin Clift
> > > >
> > > > -- Salasaga - Open Source eLearning IDE
> > > > http://www.salasaga.org
> > > >
> > >
> > >
> > >
> >
>
>
>
14 years, 4 months