Skip to contentSkip to conversation

Instead of trying to remove kvm modules with rmmod, use modprobe -r, as it handles module dependencies better

PATCH In review Lucas Meneghel Rodrigues 3 participants 3 messages May 14, 2009 – May 24, 2009 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Instead of trying to remove kvm modules with rmmod, use modprobe -r, as it handles module dependencies better

In certain situations, trying to do a rmmod on the kvm modules might generate errors, as there is a chain of dependencies involved. Instead, let's use modprobe -r, as it handles dependencies.

client/tests/kvm_runtest_2/kvm_install.py +2 -2
index dbf8401..c27c6c7 100755
@@ -192,9 +192,9 @@ def __load_kvm_modules():
     #utils.system("pkill qemu 1>/dev/null 2>&1", ignore_status=True)
     utils.system("pkill qemu", ignore_status=True)
     #if utils.system("grep kvm_%s /proc/modules 1>/dev/null" % vendor, ignore_s
-    utils.system("/sbin/rmmod kvm_%s" % vendor, ignore_status=True)
+    utils.system("/sbin/modprobe -r kvm_%s" % vendor, ignore_status=True)
     #if utils.system("grep kvm /proc/modules 1>/dev/null", ignore_status=True) 
-    utils.system("/sbin/rmmod kvm", ignore_status=True)
+    utils.system("/sbin/modprobe -r kvm", ignore_status=True)
 
     if utils.system("grep kvm /proc/modules 1>/dev/null", ignore_status=True) =
         message = "Failed to remove old KVM modules"
Signature · 3 lines
Lucas Meneghel Rodrigues
Software Engineer (QE)
Red Hat - Emerging Technologies
#1 lore raw
Quoted 14 lines · Lucas Meneghel Rodrigues

In certain situations, trying to do a rmmod on the kvm modules might generate errors, as there is a chain of dependencies involved. Instead, let's use modprobe -r, as it handles dependencies.

client/tests/kvm_runtest_2/kvm_install.py +0 -0
index dbf8401..c27c6c7 100755
@@ -192,9 +192,9 @@ def __load_kvm_modules():
     #utils.system("pkill qemu 1>/dev/null 2>&1", ignore_status=True)

client/tests/kvm_runtest_2/kvm_install.py def __load_kvm_modules(): · line 200

Quoted 10 lines
client/tests/kvm_runtest_2/kvm_install.py +2 -2
     utils.system("pkill qemu", ignore_status=True)
     #if utils.system("grep kvm_%s /proc/modules 1>/dev/null" % vendor, ignore_s
-    utils.system("/sbin/rmmod kvm_%s" % vendor, ignore_status=True)
+    utils.system("/sbin/modprobe -r kvm_%s" % vendor, ignore_status=True)
     #if utils.system("grep kvm /proc/modules 1>/dev/null", ignore_status=True) 
-    utils.system("/sbin/rmmod kvm", ignore_status=True)
+    utils.system("/sbin/modprobe -r kvm", ignore_status=True)
 
     if utils.system("grep kvm /proc/modules 1>/dev/null", ignore_status=True) =
         message = "Failed to remove old KVM modules"

In normal situations, this works perfectly fine. It also suppresses the output to stderr if a module is not already loaded on the machine. Errors are are still encountered, however, if another module is installed that depends on one of the modules kvm_install is trying to remove. In my environment, I have a module, ksm, which depends on kvm being loaded. If I modprobe -r kvm, them it will fail saying "Module kvm is in use". Overall, this is a minimal impact change that doesn't cause any problems, but it doesn't seem to address the initial problem of having other modules that depend on one of the kvm modules.

Mike

#2 lore raw
Quoted 22 lines · Mike Burns
Quoted 20 lines · Lucas Meneghel Rodrigues

In certain situations, trying to do a rmmod on the kvm modules might generate errors, as there is a chain of dependencies involved. Instead, let's use modprobe -r, as it handles dependencies.

client/tests/kvm_runtest_2/kvm_install.py +2 -2
index dbf8401..c27c6c7 100755
@@ -192,9 +192,9 @@ def __load_kvm_modules():
     #utils.system("pkill qemu 1>/dev/null 2>&1", ignore_status=True)
     utils.system("pkill qemu", ignore_status=True)
     #if utils.system("grep kvm_%s /proc/modules 1>/dev/null" % vendor, ignore_s
-    utils.system("/sbin/rmmod kvm_%s" % vendor, ignore_status=True)
+    utils.system("/sbin/modprobe -r kvm_%s" % vendor, ignore_status=True)
     #if utils.system("grep kvm /proc/modules 1>/dev/null", ignore_status=True) 
-    utils.system("/sbin/rmmod kvm", ignore_status=True)
+    utils.system("/sbin/modprobe -r kvm", ignore_status=True)
 
Quoted 14 lines

client/tests/kvm_runtest_2/kvm_install.py def __load_kvm_modules(): · line 200

Quoted 5 lines
client/tests/kvm_runtest_2/kvm_install.py +0 -0
     if utils.system("grep kvm /proc/modules 1>/dev/null", ignore_status=True) =
         message = "Failed to remove old KVM modules"

In normal situations, this works perfectly fine. It also suppresses the
output to stderr if a module is not already loaded on the machine. Errors are are still encountered, however, if another module is installed that depends on one of the modules kvm_install is trying to
remove. In my environment, I have a module, ksm, which depends on kvm
being loaded. If I modprobe -r kvm, them it will fail saying "Module
kvm is in use". Overall, this is a minimal impact change that doesn't
cause any problems, but it doesn't seem to address the initial problem
of having other modules that depend on one of the kvm modules.

Ignoring status is a recipe for disaster. Instead we should check if the modules are loaded and only unload then (and fail if we can't).

Signature · 1 line
error compiling committee.c: too many arguments to function