From e751617f83b01eab5799049bc080ab893ae213d9 Mon Sep 17 00:00:00 2001
Message-Id: <e751617f83b01eab5799049bc080ab893ae213d9@dist-git>
From: Laine Stump <laine@laine.org>
Date: Thu, 11 Apr 2019 15:14:50 -0400
Subject: [PATCH] qemu_hotplug: audit *all* auditable device types in
qemuDomainRemoveAuditDevice
Although all hotpluggable devices other than lease, controller,
watchdof, and vsock can be audited, and *are* audited when an unplug
is successful, only disk, net, and hostdev were actually being audited
on failure.
This patch corrects that omission.
Signed-off-by: Laine Stump <laine@laine.org>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
(cherry picked from commit 444c5e7c432961c7ecd59b2627dfb69ce787a22a)
Partially-Resolves: https://bugzilla.redhat.com/1658198
Signed-off-by: Laine Stump <laine@redhat.com>
Signed-off-by: Laine Stump <laine@laine.org>
Message-Id: <20190411191453.24055-39-laine@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
---
src/qemu/qemu_hotplug.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 482111c46e..390fc36cf6 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -4665,19 +4665,28 @@ qemuDomainRemoveAuditDevice(virDomainObjPtr vm,
case VIR_DOMAIN_DEVICE_HOSTDEV:
virDomainAuditHostdev(vm, detach->data.hostdev, "detach", success);
break;
-
case VIR_DOMAIN_DEVICE_INPUT:
+ virDomainAuditInput(vm, detach->data.input, "detach", success);
+ break;
case VIR_DOMAIN_DEVICE_CHR:
+ virDomainAuditChardev(vm, detach->data.chr, NULL, "detach", success);
+ break;
case VIR_DOMAIN_DEVICE_RNG:
- case VIR_DOMAIN_DEVICE_MEMORY:
- case VIR_DOMAIN_DEVICE_SHMEM:
- case VIR_DOMAIN_DEVICE_REDIRDEV:
- /*
- * These devices are supposed to be audited, but current code
- * doesn't audit on failure to remove the device.
- */
- break;
+ virDomainAuditRNG(vm, detach->data.rng, NULL, "detach", success);
+ break;
+ case VIR_DOMAIN_DEVICE_MEMORY: {
+ unsigned long long oldmem = virDomainDefGetMemoryTotal(vm->def);
+ unsigned long long newmem = oldmem - detach->data.memory->size;
+ virDomainAuditMemory(vm, oldmem, newmem, "update", success);
+ break;
+ }
+ case VIR_DOMAIN_DEVICE_SHMEM:
+ virDomainAuditShmem(vm, detach->data.shmem, "detach", success);
+ break;
+ case VIR_DOMAIN_DEVICE_REDIRDEV:
+ virDomainAuditRedirdev(vm, detach->data.redirdev, "detach", success);
+ break;
case VIR_DOMAIN_DEVICE_LEASE:
case VIR_DOMAIN_DEVICE_CONTROLLER:
--
2.21.0