Darryl L. Pierce
2009-Mar-24 21:01 UTC
[Ovirt-devel] [PATCH node] Causes ovirt-post to wait for libvirt to finish initializing.
It will give libvirt up to 10 seconds to complete initializing before
giving up. This overcomes a bug where ovirt-post fails to detect
hardware virtualization due to libvirt having not finished initializing.
Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
scripts/ovirt-post | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/scripts/ovirt-post b/scripts/ovirt-post
index 2f0483b..6135119 100755
--- a/scripts/ovirt-post
+++ b/scripts/ovirt-post
@@ -11,6 +11,20 @@
. /etc/init.d/ovirt-functions
start() {
+ # wait for libvirt to finish initializing
+ local count=0
+ while true; do
+ if [ -r /var/run/libvirt/libvirt-sock ]; then
+ break
+ elif [ "$count" == "10" ]; then
+ log "Libvirt did not initialize in time..."
+ exit 1
+ else
+ log "Waiting for libvirt to finish initializing..."
+ count=$(xpr $count + 1)
+ sleep 1
+ fi
+ done
BACKUP=$(mktemp)
ISSUE=/etc/issue
ISSUE_NET=/etc/issue.net
--
1.6.0.6
Perry Myers
2009-Mar-24 22:00 UTC
[Ovirt-devel] [PATCH node] Causes ovirt-post to wait for libvirt to finish initializing.
Darryl L. Pierce wrote:> It will give libvirt up to 10 seconds to complete initializing before > giving up. This overcomes a bug where ovirt-post fails to detect > hardware virtualization due to libvirt having not finished initializing. > > Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> > --- > scripts/ovirt-post | 14 ++++++++++++++ > 1 files changed, 14 insertions(+), 0 deletions(-) > > diff --git a/scripts/ovirt-post b/scripts/ovirt-post > index 2f0483b..6135119 100755 > --- a/scripts/ovirt-post > +++ b/scripts/ovirt-post > @@ -11,6 +11,20 @@ > . /etc/init.d/ovirt-functions > > start() { > + # wait for libvirt to finish initializing > + local count=0 > + while true; do > + if [ -r /var/run/libvirt/libvirt-sock ]; then > + break > + elif [ "$count" == "10" ]; then > + log "Libvirt did not initialize in time..." > + exit 1 > + else > + log "Waiting for libvirt to finish initializing..." > + count=$(xpr $count + 1) > + sleep 1 > + fi > + doneWaiting for 10 seconds seems somewhat arbitrary. What if the machine is really slow and it takes more than 10 seconds for it to come up? Maybe that's unlikely, it's just that relying on sleep always scares me. Perry
Alan Pevec
2009-Mar-25 14:48 UTC
[Ovirt-devel] [PATCH node] Causes ovirt-post to wait for libvirt to finish initializing.
On Tue, Mar 24, 2009 at 10:01 PM, Darryl L. Pierce <dpierce at redhat.com> wrote:> It will give libvirt up to 10 seconds to complete initializing beforemake it more, for 99% it will exit the loop in a second or so, so bumping the max. timeout to 100 or more doesn't affect normal cases ack with that
Darryl L. Pierce
2009-Mar-26 02:44 UTC
[Ovirt-devel] [PATCH node] Causes ovirt-post to wait for libvirt to finish initializing.
It will give libvirt up to 10 seconds to complete initializing before
giving up. This overcomes a bug where ovirt-post fails to detect
hardware virtualization due to libvirt having not finished initializing.
Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
scripts/ovirt-post | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/scripts/ovirt-post b/scripts/ovirt-post
index 2f0483b..855af51 100755
--- a/scripts/ovirt-post
+++ b/scripts/ovirt-post
@@ -11,13 +11,26 @@
. /etc/init.d/ovirt-functions
start() {
+ # wait for libvirt to finish initializing
+ local count=0
+ while true; do
+ if [ -r /var/run/libvirt/libvirt-sock ]; then
+ break
+ elif [ "$count" == "10" ]; then
+ log "Libvirt did not initialize in time..."
+ exit 1
+ else
+ log "Waiting for libvirt to finish initializing..."
+ count=$(xpr $count + 1)
+ sleep 1
+ fi
+ done
BACKUP=$(mktemp)
ISSUE=/etc/issue
ISSUE_NET=/etc/issue.net
egrep -v "[Vv]irtualization hardware" $ISSUE > $BACKUP
cp -f $BACKUP $ISSUE
- hwvirt=$(virsh capabilities)
- if [[ $hwvirt =~ kvm ]]; then
+ if [ -x /usr/bin/qemu-kvm -a -r /dev/kvm ]; then
log "Hardware virtualization detected"
else
log "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
--
1.6.0.6
Darryl L. Pierce
2009-Mar-26 10:13 UTC
[Ovirt-devel] [PATCH node] Causes ovirt-post to wait for libvirt to finish initializing.
NOTE: Forgot to change the original check for hw virt. This patch supercedes the
one sent last night.
It will give libvirt up to 10 seconds to complete initializing before
giving up. This overcomes a bug where ovirt-post fails to detect
hardware virtualization due to libvirt having not finished initializing.
Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
scripts/ovirt-post | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/scripts/ovirt-post b/scripts/ovirt-post
index 2f0483b..d211aa1 100755
--- a/scripts/ovirt-post
+++ b/scripts/ovirt-post
@@ -11,13 +11,23 @@
. /etc/init.d/ovirt-functions
start() {
+ # wait for libvirt to finish initializing
+ local count=0
+ while true; do
+ if [ -r /dev/kvm -o "$count" == "100"]; then
+ break
+ else
+ log "Waiting for hardware virtualization to initializing..."
+ count=$(xpr $count + 1)
+ sleep 1
+ fi
+ done
BACKUP=$(mktemp)
ISSUE=/etc/issue
ISSUE_NET=/etc/issue.net
egrep -v "[Vv]irtualization hardware" $ISSUE > $BACKUP
cp -f $BACKUP $ISSUE
- hwvirt=$(virsh capabilities)
- if [[ $hwvirt =~ kvm ]]; then
+ if [ -x /usr/bin/qemu-kvm -a -r /dev/kvm ]; then
log "Hardware virtualization detected"
else
log "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
--
1.6.0.6