[libvirt] [PATCH 19/21] qemu_hotplug: new function qemuDomainRemoveAuditDevice()

Peter Krempa pkrempa at redhat.com
Fri Mar 22 12:24:28 UTC 2019


On Thu, Mar 21, 2019 at 18:28:59 -0400, Laine Stump wrote:
> This function can be called with a virDomainDevicePtr and whether or
> not the removal was successful, and it will call the appropriate
> virDomainAudit*() function with the appropriate args for whatever type
> of device it's given (or do nothing, if that's appropriate). This
> permits generalizing some code that currently has a separate copy for
> each type of device.
> 
> Signed-off-by: Laine Stump <laine at laine.org>
> ---
>  src/qemu/qemu_hotplug.c | 72 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 72 insertions(+)
> 
> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> index b0e2c738b9..5e5ffe16d3 100644
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -5208,6 +5208,78 @@ qemuDomainRemoveRedirdevDevice(virQEMUDriverPtr driver,
>  }
>  
>  
> +static inline void

Don't use inline, it's pointless.

> +qemuDomainRemoveAuditDevice(virDomainObjPtr vm,
> +                            virDomainDeviceDefPtr detach,
> +                            bool success)

@success is always false in the one call place the other patches add.
Especially I doubt it will ever be different. All async device deletion
callbacks do their own per-device-type audit call on success.

This function is unused thus breaks build.

> +{
> +    switch ((virDomainDeviceType)detach->type) {
> +    case VIR_DOMAIN_DEVICE_CHR:
> +        virDomainAuditChardev(vm, detach->data.chr, NULL, "detach", success);
> +        break;
> +
> +    case VIR_DOMAIN_DEVICE_DISK:
> +        virDomainAuditDisk(vm, detach->data.disk->src, NULL, "detach", success);
> +        break;
> +
> +    case VIR_DOMAIN_DEVICE_NET:
> +        virDomainAuditNet(vm, detach->data.net, NULL, "detach", success);
> +        break;
> +
> +    case VIR_DOMAIN_DEVICE_HOSTDEV:
> +        virDomainAuditHostdev(vm, detach->data.hostdev, "detach", success);
> +        break;
> +
> +    case VIR_DOMAIN_DEVICE_RNG:
> +        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);

This is currently not audited, I think it should be added separately.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190322/fb7f831c/attachment-0001.sig>


More information about the libvir-list mailing list