[libvirt] [PATCHv2] Fix disabling of apparmor/selinux security drivers
by Christophe Fergeau
When using --without-$name --without-secdriver-$name with $name being
selinux or apparmor, configure will fail saying that AppArmor/SELinux
development package must be installed.
This is caused by a small bug in --with-secdriver-$name handling in
configure.ac which treats --without-secdriver-$name when $name as if the
user had requested to enable $name when $name couldn't be detected on
the system.
This commit also makes sure the detection checks for disabled
secdrivers do not needlessly get run, especially as this could
cause an error as well in --with-$name --without-secdriver-$name
situations.
---
configure.ac | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/configure.ac b/configure.ac
index 8810efd..5ea3bc2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1493,10 +1493,11 @@ AC_ARG_WITH([secdriver-selinux],
if test "$with_selinux" != "yes" ; then
if test "$with_secdriver_selinux" = "check" ; then
with_secdriver_selinux=no
- elif test "$with_secdriver_selinux" = "yes"; then
+ fi
+ if test "$with_secdriver_selinux" != "no"; then
AC_MSG_ERROR([You must install the libselinux development package and enable SELinux with the --with-selinux=yes in order to compile libvirt --with-secdriver-selinux=yes])
fi
-else
+elif test "$with_secdriver_selinux" != "no"; then
old_cflags="$CFLAGS"
old_libs="$LIBS"
CFLAGS="$CFLAGS $SELINUX_CFLAGS"
@@ -1571,10 +1572,11 @@ AC_ARG_WITH([secdriver-apparmor],
if test "$with_apparmor" != "yes" ; then
if test "$with_secdriver_apparmor" = "check" ; then
with_secdriver_apparmor=no
- else
+ fi
+ if test "$with_secdriver_apparmor" != "no" ; then
AC_MSG_ERROR([You must install the AppArmor development package in order to compile libvirt])
fi
-else
+elif test "with_secdriver_apparmor" != "no" ; then
old_cflags="$CFLAGS"
old_libs="$LIBS"
CFLAGS="$CFLAGS $APPARMOR_CFLAGS"
--
1.7.12.1
12 years, 1 month
[libvirt] [PATCH v4 1/6] add a configure option --with-fuse to prepare introduction of fuse support for libvirt lxc
by Gao feng
add a configure option --with-fuse to prepare introduction
of fuse support for libvirt lxc.
With help from Daniel
Signed-off-by: Gao feng <gaofeng(a)cn.fujitsu.com>
---
configure.ac | 36 ++++++++++++++++++++++++++++++++++++
libvirt.spec.in | 9 +++++++++
2 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/configure.ac b/configure.ac
index 08dc63d..0bd0297 100644
--- a/configure.ac
+++ b/configure.ac
@@ -115,6 +115,7 @@ LIBSSH2_REQUIRED="1.0"
LIBSSH2_TRANSPORT_REQUIRED="1.3"
LIBBLKID_REQUIRED="2.17"
DBUS_REQUIRED="1.0.0"
+FUSE_REQUIRED="2.8.6"
dnl Checks for C compiler.
AC_PROG_CC
@@ -1850,6 +1851,36 @@ AC_SUBST([CAPNG_CFLAGS])
AC_SUBST([CAPNG_LIBS])
+dnl libfuse
+AC_ARG_WITH([fuse],
+ AC_HELP_STRING([--with-fuse], [use libfuse to proivde fuse filesystem support for libvirt lxc]),
+ [],
+ [with_fuse=check])
+dnl
+dnl This check looks for 'fuse'
+dnl
+FUSE_CFLAGS=
+FUSE_LIBS=
+if test "x$with_fuse" != "xno"; then
+ PKG_CHECK_MODULES([FUSE], [fuse >= $FUSE_REQUIRED],
+ [with_fuse=yes], [
+ if test "x$with_fuse" = "xcheck" ; then
+ with_fuse=no
+ else
+ AC_MSG_ERROR(
+ [You must install fuse Library to compile libvirt])
+ fi
+ ])
+ if test "x$with_fuse" = "xyes" ; then
+ FUSE_LIBS="-lfuse"
+ FUSE_CFLAGS="-D_FILE_OFFSET_BITS=64"
+ AC_DEFINE_UNQUOTED([HAVE_FUSE], 1, [whether fuse is available for libvirt lxc])
+ fi
+fi
+AM_CONDITIONAL([HAVE_FUSE], [test "x$with_fuse" = "xyes"])
+AC_SUBST([FUSE_CFLAGS])
+AC_SUBST([FUSE_LIBS])
+
dnl virsh libraries
AC_CHECK_HEADERS([readline/readline.h])
@@ -3154,6 +3185,11 @@ AC_MSG_NOTICE([ capng: $CAPNG_CFLAGS $CAPNG_LIBS])
else
AC_MSG_NOTICE([ capng: no])
fi
+if test "$with_fuse" = "yes" ; then
+AC_MSG_NOTICE([ fuse: $FUSE_CFLAGS $FUSE_LIBS])
+else
+AC_MSG_NOTICE([ fuse: no])
+fi
if test "$with_xen" = "yes" ; then
AC_MSG_NOTICE([ xen: $XEN_CFLAGS $XEN_LIBS])
else
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 75623eb..157825b 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -93,6 +93,7 @@
# A few optional bits off by default, we enable later
%define with_polkit 0%{!?_without_polkit:0}
%define with_capng 0%{!?_without_capng:0}
+%define with_fuse 0%{!?_without_fuse:0}
%define with_netcf 0%{!?_without_netcf:0}
%define with_udev 0%{!?_without_udev:0}
%define with_hal 0%{!?_without_hal:0}
@@ -497,6 +498,9 @@ BuildRequires: numactl-devel
%if %{with_capng}
BuildRequires: libcap-ng-devel >= 0.5.0
%endif
+%if %{with_fuse}
+BuildRequires: fuse-devel >= 2.8.6
+%endif
%if %{with_phyp} || %{with_libssh2_transport}
%if %{with_libssh2_transport}
BuildRequires: libssh2-devel >= 1.3.0
@@ -1172,6 +1176,10 @@ of recent versions of Linux (and other OSes).
%define _without_capng --without-capng
%endif
+%if ! %{with_fuse}
+%define _without_fuse --without-fuse
+%endif
+
%if ! %{with_netcf}
%define _without_netcf --without-netcf
%endif
@@ -1275,6 +1283,7 @@ autoreconf -if
%{?_without_numactl} \
%{?_without_numad} \
%{?_without_capng} \
+ %{?_without_fuse} \
%{?_without_netcf} \
%{?_without_selinux} \
%{?_with_selinux_mount} \
--
1.7.7.6
12 years, 1 month
[libvirt] vbox hypervisor driver not found
by p.venkatasrinivas@tcs.com
Hi,
I installed Virtual box software in linux open suse. Unable to connect to
the
vbox hypervisor driver.
Version-Release number of selected component (if applicable):
libvirt-0.9.0
How reproducible:
when i am giving the following command for virsh:
virsh -connect vbox:///session then the following error is coming.
error: no hypervisor driver available for vbox:///session
error: failed to connect to the hypervisor
Even I installed virtualbox the above error is coming. I am not able to
find vbox hypervisor driver. Can anyone suggest where can i find vbox
dirver.
Awaiting Response
Thanks and Regards,
Srinivas.
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
12 years, 1 month
[libvirt] vbox Hypervisor driver not found
by p.venkatasrinivas@tcs.com
Hi,
I installed Libvirt. We need virtualbox support for libvirt. But we are
unable to see the vbox option in virt-manager. How we can find vbox
hypervisor driver?
And also we already compiled libvirt with vbox option.(--with-vbox). But
that didn't work. And also when we are creating the new virtual machine
through virt-manager we are getting the following error:
internal error cannot parse QEMU version number in ""
Can you please suggest on this what we need to do as soon as possible?
Thanks in advance.
Srinivas
____________________________________________
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
12 years, 1 month
[libvirt] [PATCH] maint: update to latest gnulib
by Eric Blake
* .gnulib: Update to latest, prior to freeze.
---
Gnulib has been relatively quiet since our last update, and I'm not
sure whether any of these patches directly impact us, but it can't
hurt to have the latest going into a freeze for 1.0.0.
* .gnulib 2a9edc6...d245e6d (14):
> euidaccess: speed up 'configure' on GNU hosts
> * lib/regexec.c (re_search_internal): Fix grammar in comment.
> fchmodat, fchownat, fstatat: port to non-inlining compilers
> fchmodat.c, fchownat.c: fix compile-impeding typos
> fcntl-h: support GNU flags like O_IGNORE_CTTY
> faccessat, etc.: support AT_FDCWD-only use
> faccessat: speed up 'configure' on mainstream hosts
> faccessat: port to Solaris 10
> canonicalize: fix C89 compilation
> autoupdate
> group-member: omit unnecessary dependencies
> gethrxtime: port to C++
> ptsname: fix macro-name typo
> inttostr: Relax license.
.gnulib | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.gnulib b/.gnulib
index 2a9edc6..d245e6d 160000
--- a/.gnulib
+++ b/.gnulib
@@ -1 +1 @@
-Subproject commit 2a9edc6f2b02a05553d266117ddee80b3e0a3749
+Subproject commit d245e6ddd6ab2624d0d83acd8f111454f984f50f
--
1.7.11.7
12 years, 1 month
[libvirt] [PATCHv9] snapshot: sanity check when reusing file for snapshot
by Eric Blake
The snapshot code when reusing an existing file had hard-to-read
logic, as well as a missing sanity check: REUSE_EXT should require
the destination to already be present.
* src/qemu/qemu_driver.c (qemuDomainSnapshotDiskPrepare): Require
destination on REUSE_EXT, rename variable for legibility.
---
v9: separate out from larger series, as this one is ready now;
provide diff with more context and a renamed variable.
https://www.redhat.com/archives/libvir-list/2012-October/msg01107.html
src/qemu/qemu_driver.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d1dc2b8..8af316f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10702,18 +10702,18 @@ qemuDomainSnapshotDiskPrepare(virDomainObjPtr vm, virDomainSnapshotDefPtr def,
{
int ret = -1;
int i;
bool found = false;
bool active = virDomainObjIsActive(vm);
struct stat st;
- bool allow_reuse = (*flags & VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT) != 0;
+ bool reuse = (*flags & VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT) != 0;
bool atomic = (*flags & VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC) != 0;
int external = 0;
qemuDomainObjPrivatePtr priv = vm->privateData;
- if (allow_reuse && !qemuCapsGet(priv->caps, QEMU_CAPS_TRANSACTION)) {
+ if (reuse && !qemuCapsGet(priv->caps, QEMU_CAPS_TRANSACTION)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("reuse is not supported with this QEMU binary"));
goto cleanup;
}
for (i = 0; i < def->ndisks; i++) {
@@ -10756,14 +10756,19 @@ qemuDomainSnapshotDiskPrepare(virDomainObjPtr vm, virDomainSnapshotDefPtr def,
if (stat(disk->file, &st) < 0) {
if (errno != ENOENT) {
virReportSystemError(errno,
_("unable to stat for disk %s: %s"),
disk->name, disk->file);
goto cleanup;
+ } else if (reuse) {
+ virReportSystemError(errno,
+ _("missing existing file for disk %s: %s"),
+ disk->name, disk->file);
+ goto cleanup;
}
- } else if (!(S_ISBLK(st.st_mode) || !st.st_size || allow_reuse)) {
+ } else if (!S_ISBLK(st.st_mode) && st.st_size && !reuse) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("external snapshot file for disk %s already "
"exists and is not a block device: %s"),
disk->name, disk->file);
goto cleanup;
}
--
1.7.11.7
12 years, 1 month
[libvirt] [PATCH v1] helper of copy-storage-* features
by liguang
help to create disk images copy-storage-* required,
try to do non-shared migration without bothering to
create disk images at target by hand.
consider this situation:
1. non-shared migration
virsh migrate --copy-storage-all ...
2. migration fails
3. create disk images required
qemu-img create ...
4 migration run smoothly
so, try do remove step 2, 3, 4
this kind of usage had been discussed before,
http://www.redhat.com/archives/libvir-list/2011-December/msg00451.html
maybe there're some flaws:
- It did not handle more about complete situations
suggested by Daniel P. Berrange,
https://www.redhat.com/archives/libvir-list/2012-October/msg00407.html
but may try to take care of them later.
so, now only normal disk image files be handled.
- for creation of disk images, size was setting as 0xffffffff boldly,
hope it can consolidate qemu, haven't constructed a comfortable
idea to solve it.
Signed-off-by: liguang <lig.fnst(a)cn.fujitsu.com>
---
src/qemu/qemu_migration.c | 100 ++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 98 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index db69a0a..6f8cad7 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -49,6 +49,7 @@
#include "storage_file.h"
#include "viruri.h"
#include "hooks.h"
+#include "dirname.h"
#define VIR_FROM_THIS VIR_FROM_QEMU
@@ -70,6 +71,7 @@ enum qemuMigrationCookieFlags {
QEMU_MIGRATION_COOKIE_FLAG_GRAPHICS,
QEMU_MIGRATION_COOKIE_FLAG_LOCKSTATE,
QEMU_MIGRATION_COOKIE_FLAG_PERSISTENT,
+ QEMU_MIGRATION_COOKIE_FLAG_COPYSTORAGE,
QEMU_MIGRATION_COOKIE_FLAG_LAST
};
@@ -77,12 +79,13 @@ enum qemuMigrationCookieFlags {
VIR_ENUM_DECL(qemuMigrationCookieFlag);
VIR_ENUM_IMPL(qemuMigrationCookieFlag,
QEMU_MIGRATION_COOKIE_FLAG_LAST,
- "graphics", "lockstate", "persistent");
+ "graphics", "lockstate", "persistent", "copystorage");
enum qemuMigrationCookieFeatures {
QEMU_MIGRATION_COOKIE_GRAPHICS = (1 << QEMU_MIGRATION_COOKIE_FLAG_GRAPHICS),
QEMU_MIGRATION_COOKIE_LOCKSTATE = (1 << QEMU_MIGRATION_COOKIE_FLAG_LOCKSTATE),
QEMU_MIGRATION_COOKIE_PERSISTENT = (1 << QEMU_MIGRATION_COOKIE_FLAG_PERSISTENT),
+ QEMU_MIGRATION_COOKIE_COPYSTORAGE = (1 << QEMU_MIGRATION_COOKIE_FLAG_COPYSTORAGE),
};
typedef struct _qemuMigrationCookieGraphics qemuMigrationCookieGraphics;
@@ -439,6 +442,9 @@ qemuMigrationCookieXMLFormat(struct qemud_driver *driver,
virBufferAdjustIndent(buf, -2);
}
+ if (mig->flags & QEMU_MIGRATION_COOKIE_COPYSTORAGE)
+ virBufferAsprintf(buf, " <copystorage/>\n");
+
virBufferAddLit(buf, "</qemu-migration>\n");
return 0;
}
@@ -662,6 +668,11 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
VIR_FREE(nodes);
}
+ if ((flags & QEMU_MIGRATION_COOKIE_COPYSTORAGE)) {
+ if (virXPathBoolean("count(./copystorage) > 0", ctxt))
+ mig->flags |= QEMU_MIGRATION_COOKIE_COPYSTORAGE;
+ }
+
return 0;
error:
@@ -721,6 +732,9 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig,
qemuMigrationCookieAddPersistent(mig, dom) < 0)
return -1;
+ if (flags & QEMU_MIGRATION_COOKIE_COPYSTORAGE)
+ mig->flags |= QEMU_MIGRATION_COOKIE_COPYSTORAGE;
+
if (!(*cookieout = qemuMigrationCookieXMLFormatStr(driver, mig)))
return -1;
@@ -1168,6 +1182,14 @@ char *qemuMigrationBegin(struct qemud_driver *driver,
QEMU_MIGRATION_COOKIE_LOCKSTATE) < 0)
goto cleanup;
+ if (flags & (VIR_MIGRATE_NON_SHARED_DISK |
+ VIR_MIGRATE_NON_SHARED_INC)) {
+ if (qemuMigrationBakeCookie(mig, driver, vm,
+ cookieout, cookieoutlen,
+ QEMU_MIGRATION_COOKIE_COPYSTORAGE) < 0)
+ goto cleanup;
+ }
+
if (xmlin) {
if (!(def = virDomainDefParseString(driver->caps, xmlin,
QEMU_EXPECTED_VIRT_TYPES,
@@ -1215,6 +1237,67 @@ qemuMigrationPrepareCleanup(struct qemud_driver *driver,
qemuDomainObjDiscardAsyncJob(driver, vm);
}
+/*
+ if gen_del is 1, find out disk images migration required,
+ so try to generate them at target,
+ if gen_del is 0, delete disk images generated before.
+*/
+static int qemuMigrationHandleDiskFiles(virDomainDefPtr def, int gen_del)
+{
+ char *tmp_dir = NULL, *outbuf = NULL;
+ char *size = _("0xffffffff");
+ virCommandPtr cmd = NULL;
+ int i, ret = -1;
+
+ if (!def->ndisks)
+ return 0;
+ for (i = 0; i < def->ndisks; i++) {
+ if (STRNEQ(def->disks[i]->driverName, "qemu"))
+ continue;
+ if (def->disks[i]->src == NULL)
+ continue;
+ if (def->disks[i]->driverType == NULL)
+ continue;
+ if (virFileExists(def->disks[i]->src) && gen_del)
+ continue;
+ if (!gen_del && !virFileExists(def->disks[i]->src))
+ continue;
+ if ((tmp_dir = mdir_name(def->disks[i]->src)) == NULL)
+ continue;
+ if (!virFileExists(tmp_dir))
+ if (virFileMakePath(tmp_dir) < 0)
+ continue;
+ if (gen_del) {
+ cmd = virCommandNewArgList("qemu-img", "create", "-f",
+ def->disks[i]->driverType, def->disks[i]->src,
+ size, NULL);
+ virCommandSetOutputBuffer(cmd, &outbuf);
+ if (virCommandRun(cmd, NULL) < 0) {
+ virReportSystemError(errno, "%s", outbuf);
+ goto cleanup;
+ }
+ } else {
+ if (unlink(def->disks[i]->src) < 0) {
+ virReportError(errno, "%s", _("fail to unlink disk image file"));
+ goto cleanup;
+ }
+ }
+ virCommandFree(cmd);
+ VIR_FREE(tmp_dir);
+ VIR_FREE(outbuf);
+ }
+
+ ret = 0;
+
+cleanup:
+ if (ret < 0) {
+ virCommandFree(cmd);
+ VIR_FREE(tmp_dir);
+ VIR_FREE(outbuf);
+ }
+ return ret;
+}
+
static int
qemuMigrationPrepareAny(struct qemud_driver *driver,
virConnectPtr dconn,
@@ -1308,6 +1391,15 @@ qemuMigrationPrepareAny(struct qemud_driver *driver,
/* virDomainAssignDef already set the error */
goto cleanup;
}
+
+ if (!(mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen,
+ QEMU_MIGRATION_COOKIE_COPYSTORAGE)))
+ goto cleanup;
+
+ if (mig->flags & QEMU_MIGRATION_COOKIE_COPYSTORAGE)
+ if (qemuMigrationHandleDiskFiles(def, 1) < 0)
+ goto cleanup;
+
def = NULL;
priv = vm->privateData;
priv->origname = origname;
@@ -2929,7 +3021,7 @@ qemuMigrationFinish(struct qemud_driver *driver,
int newVM = 1;
qemuMigrationCookiePtr mig = NULL;
virErrorPtr orig_err = NULL;
- int cookie_flags = 0;
+ int cookie_flags = 0, migration_status = 0;
qemuDomainObjPrivatePtr priv = vm->privateData;
VIR_DEBUG("driver=%p, dconn=%p, vm=%p, cookiein=%s, cookieinlen=%d, "
@@ -3088,7 +3180,11 @@ qemuMigrationFinish(struct qemud_driver *driver,
if (qemuMigrationBakeCookie(mig, driver, vm, cookieout, cookieoutlen, 0) < 0)
VIR_WARN("Unable to encode migration cookie");
+ migration_status = 1;
+
endjob:
+ if (!migration_status)
+ qemuMigrationHandleDiskFiles(vm->def, 0);
if (qemuMigrationJobFinish(driver, vm) == 0) {
vm = NULL;
} else if (!vm->persistent && !virDomainObjIsActive(vm)) {
--
1.7.2.5
12 years, 1 month
[libvirt] [PATCH 0/3] Transport Open vSwitch per-port data during live migration
by Kyle Mestery
This series of commits has the end goal of allowing per-port data stored
in the Open vSwitch DB to be transported during live migration. This is
done by first providing a generic infrastructure for transporting network
data, adding some utility functions specific to Open vSwitch, and hooking
the two together.
The framework provided is generic in that other networking data could be
transferred as well by simply adding in additional hooks as needed.
Kyle Mestery (3):
Add the ability for the Qemu V3 migration protocol to include
transporting network configuration. A generic framework is proposed
with this patch to allow for the transfer of opaque data.
Add utility functions for Open vSwitch to both save per-port data
before a live migration, and restore the per-port data after a
live migration.
Transport Open vSwitch per-port data during live migration by
using the utility functions
virNetDevOpenvswitchGetMigrateData() and
virNetDevOpenvswitchSetMigrateData().
src/libvirt_private.syms | 2 +
src/qemu/qemu_migration.c | 263 +++++++++++++++++++++++++++++++++++++++-
src/util/virnetdevopenvswitch.c | 70 +++++++++++
src/util/virnetdevopenvswitch.h | 6 +
4 files changed, 339 insertions(+), 2 deletions(-)
--
1.7.11.4
12 years, 1 month
[libvirt] [PATCH] storage: Don't do wait loops from VolLookupByPath
by Cole Robinson
virStorageVolLookupByPath is an API call that virt-manager uses
quite a bit when dealing with storage. This call use BackendStablePath
which has several usleep() heuristics that can be tripped up
and hang virt-manager for a while.
Current example: an empty mpath pool pointing to /dev/mapper makes
_any_ calls to virStorageVolLookupByPath take 5 seconds.
The sleep heuristics are actually only needed in certain cases
when we are waiting for new storage to appear, so let's skip the
timeout steps when calling from LookupByPath.
---
src/storage/storage_backend.c | 12 ++++++++----
src/storage/storage_backend.h | 3 ++-
src/storage/storage_backend_disk.c | 2 +-
src/storage/storage_backend_scsi.c | 3 ++-
src/storage/storage_driver.c | 3 ++-
5 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index aea70e2..85b8287 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -1338,10 +1338,14 @@ virStorageBackendDetectBlockVolFormatFD(virStorageVolTargetPtr target,
*
* Typically target.path is one of the /dev/disk/by-XXX dirs
* with stable paths.
+ *
+ * If 'wait' is true, we use a timeout loop to give dynamic paths
+ * a change to appear.
*/
char *
virStorageBackendStablePath(virStoragePoolObjPtr pool,
- const char *devpath)
+ const char *devpath,
+ bool wait)
{
DIR *dh;
struct dirent *dent;
@@ -1372,7 +1376,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool,
reopen:
if ((dh = opendir(pool->def->target.path)) == NULL) {
opentries++;
- if (errno == ENOENT && opentries < 50) {
+ if (wait && errno == ENOENT && opentries < 50) {
usleep(100 * 1000);
goto reopen;
}
@@ -1387,7 +1391,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool,
* the target directory and figure out which one points
* to this device node.
*
- * And it might need some time till the stabe path shows
+ * And it might need some time till the stable path shows
* up, so add timeout to retry here.
*/
retry:
@@ -1411,7 +1415,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool,
VIR_FREE(stablepath);
}
- if (++retry < 100) {
+ if (wait && ++retry < 100) {
usleep(100 * 1000);
goto retry;
}
diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h
index a67eeb7..71935a7 100644
--- a/src/storage/storage_backend.h
+++ b/src/storage/storage_backend.h
@@ -130,7 +130,8 @@ virStorageBackendDetectBlockVolFormatFD(virStorageVolTargetPtr target,
int fd);
char *virStorageBackendStablePath(virStoragePoolObjPtr pool,
- const char *devpath);
+ const char *devpath,
+ bool wait);
typedef int (*virStorageBackendListVolRegexFunc)(virStoragePoolObjPtr pool,
char **const groups,
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index 5d9e72f..3cd4362 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -83,7 +83,7 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr pool,
* dir every time its run. Should figure out a more efficient
* way of doing this...
*/
- vol->target.path = virStorageBackendStablePath(pool, devpath);
+ vol->target.path = virStorageBackendStablePath(pool, devpath, true);
VIR_FREE(devpath);
if (vol->target.path == NULL)
return -1;
diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
index 27dcbb6..4e832eb 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -246,7 +246,8 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
* way of doing this...
*/
if ((vol->target.path = virStorageBackendStablePath(pool,
- devpath)) == NULL) {
+ devpath,
+ true)) == NULL) {
retval = -1;
goto free_vol;
}
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 28829d3..4fbc0c0 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -1318,7 +1318,8 @@ storageVolumeLookupByPath(virConnectPtr conn,
const char *stable_path;
stable_path = virStorageBackendStablePath(driver->pools.objs[i],
- cleanpath);
+ cleanpath,
+ false);
if (stable_path == NULL) {
/* Don't break the whole lookup process if it fails on
* getting the stable path for some of the pools.
--
1.7.11.7
12 years, 1 month