[PATCH 5/6] Add auditing to the UML driver

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

 



* src/uml/uml_driver.c: Add audit hooks
---
 src/uml/uml_driver.c |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index a71ea21..b2d11b3 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -55,6 +55,7 @@
 #include "memory.h"
 #include "uuid.h"
 #include "domain_conf.h"
+#include "domain_audit.h"
 #include "datatypes.h"
 #include "logging.h"
 #include "domain_nwfilter.h"
@@ -157,8 +158,11 @@ umlAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaqu
     virDomainObjLock(vm);
     if (vm->autostart &&
         !virDomainObjIsActive(vm)) {
+        int ret;
         virResetLastError();
-        if (umlStartVMDaemon(data->conn, data->driver, vm) < 0) {
+        ret = umlStartVMDaemon(data->conn, data->driver, vm);
+        virDomainAuditStart(vm, "booted", ret >= 0);
+        if (ret < 0) {
             virErrorPtr err = virGetLastError();
             VIR_ERROR(_("Failed to autostart VM '%s': %s"),
                       vm->def->name, err ? err->message : _("unknown error"));
@@ -306,6 +310,7 @@ reread:
             }
 
             umlShutdownVMDaemon(NULL, driver, dom, VIR_DOMAIN_SHUTOFF_SHUTDOWN);
+            virDomainAuditStop(dom, "shutdown");
         } else if (e->mask & (IN_CREATE | IN_MODIFY)) {
             VIR_DEBUG("Got inotify domain startup '%s'", name);
             if (virDomainObjIsActive(dom)) {
@@ -326,10 +331,12 @@ reread:
                 VIR_WARN("Could not open monitor for new domain");
                 umlShutdownVMDaemon(NULL, driver, dom,
                                     VIR_DOMAIN_SHUTOFF_FAILED);
+                virDomainAuditStop(dom, "failed");
             } else if (umlIdentifyChrPTY(driver, dom) < 0) {
                 VIR_WARN("Could not identify charater devices for new domain");
                 umlShutdownVMDaemon(NULL, driver, dom,
                                     VIR_DOMAIN_SHUTOFF_FAILED);
+                virDomainAuditStop(dom, "failed");
             }
         }
         virDomainObjUnlock(dom);
@@ -517,8 +524,10 @@ umlShutdownOneVM(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque)
     struct uml_driver *driver = opaque;
 
     virDomainObjLock(dom);
-    if (virDomainObjIsActive(dom))
+    if (virDomainObjIsActive(dom)) {
         umlShutdownVMDaemon(NULL, driver, dom, VIR_DOMAIN_SHUTOFF_SHUTDOWN);
+        virDomainAuditStop(dom, "shutdown");
+    }
     virDomainObjUnlock(dom);
 }
 
@@ -1286,11 +1295,13 @@ static virDomainPtr umlDomainCreate(virConnectPtr conn, const char *xml,
     def = NULL;
 
     if (umlStartVMDaemon(conn, driver, vm) < 0) {
+        virDomainAuditStart(vm, "booted", false);
         virDomainRemoveInactive(&driver->domains,
                                 vm);
         vm = NULL;
         goto cleanup;
     }
+    virDomainAuditStart(vm, "booted", true);
 
     dom = virGetDomain(conn, vm->def->name, vm->def->uuid);
     if (dom) dom->id = vm->def->id;
@@ -1350,6 +1361,7 @@ static int umlDomainDestroy(virDomainPtr dom) {
     }
 
     umlShutdownVMDaemon(dom->conn, driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED);
+    virDomainAuditStop(vm, "destroyed");
     if (!vm->persistent) {
         virDomainRemoveInactive(&driver->domains,
                                 vm);
@@ -1626,6 +1638,7 @@ static int umlDomainStartWithFlags(virDomainPtr dom, unsigned int flags) {
     }
 
     ret = umlStartVMDaemon(dom->conn, driver, vm);
+    virDomainAuditStart(vm, "booted", ret >= 0);
 
 cleanup:
     if (vm)
-- 
1.7.4.4

--
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]