]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virt-aa-helper: Rework setting virDomainMemoryDef labels
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 26 Jul 2023 10:34:08 +0000 (12:34 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 24 Aug 2023 10:38:56 +0000 (12:38 +0200)
commit109ae46e4ac35d01db33f610c15273f80c6d0be6
treee9d739f5201e3947fd397536e4e1da60bf020c27
parent2aa5c0789c54195a2b7f712a12c4e78548657d15
virt-aa-helper: Rework setting virDomainMemoryDef labels

Currently, inside of virt-aa-helper code the domain definition is
parsed and then all def->mems are iterated over and for NVDIMM
models corresponding nvdimmPath is set label on. Conceptually,
this code works (except the label should be set for VIRTIO_PMEM
model too, but that is addressed in the next commit), but it can
be written in more extensible way. Firstly, there's no need to
check whether def->mems[i] is not NULL because we're inside a
for() loop that's counting through def->nmems. Secondly, we can
have a helper variable ('mem') to make the code more readable
(just like we do in other loops). Then, we can use switch() to
allow compiler warn us on new memory model.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/security/virt-aa-helper.c