[PATCH RFC] virhook: adding virHookCheck() inside virHookCall().

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This commit introduces the virHookCheck() before running the command (hook).
The virHookCheck() before virCommandRun() will avoid errors with changes
(removal and other permissions changes) in the hook file, while the libvirt
daemon is running.

Now, when you remove the hook file while libvirtd is running you get the
following error:

virsh # start WINDOWS_7
error: Failed to start domain WINDOWS_7
error: Hook script execution failed: internal error: Child process (LC_ALL=C
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOME=/home/julio USER=root LOGNAME=root /etc/libvirt/hooks/qemu WINDOWS_7
prepare begin -) unexpected exit status 127: libvirt:  error : cannot execute
binary /etc/libvirt/hooks/qemu: No such file or directory

Cc: Carlos Castilho <ccast@xxxxxxxxxx>
Signed-off-by: Julio Faracco <jcfaracco@xxxxxxxxx>
---
 src/util/virhook.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/util/virhook.c b/src/util/virhook.c
index d37d6da..f741b30 100644
--- a/src/util/virhook.c
+++ b/src/util/virhook.c
@@ -294,7 +294,12 @@ virHookCall(int driver,
     if (output)
         virCommandSetOutputBuffer(cmd, output);
 
-    ret = virCommandRun(cmd, NULL);
+    ret = virHookCheck(driver, virHookDriverTypeToString(driver));
+
+    if (ret > 0) {
+        ret = virCommandRun(cmd, NULL);
+    }
+
     if (ret < 0) {
         /* Convert INTERNAL_ERROR into known error.  */
         virReportError(VIR_ERR_HOOK_SCRIPT_FAILED, "%s",
-- 
1.9.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]