mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 02:04:16 +03:00
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>
This commit is contained in:
parent
2aa5c0789c
commit
109ae46e4a
@ -1147,10 +1147,20 @@ get_files(vahControl * ctl)
|
||||
}
|
||||
|
||||
for (i = 0; i < ctl->def->nmems; i++) {
|
||||
if (ctl->def->mems[i] &&
|
||||
ctl->def->mems[i]->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM) {
|
||||
if (vah_add_file(&buf, ctl->def->mems[i]->nvdimmPath, "rw") != 0)
|
||||
virDomainMemoryDef *mem = ctl->def->mems[i];
|
||||
|
||||
switch (mem->model) {
|
||||
case VIR_DOMAIN_MEMORY_MODEL_NVDIMM:
|
||||
if (vah_add_file(&buf, mem->nvdimmPath, "rw") != 0)
|
||||
goto cleanup;
|
||||
break;
|
||||
case VIR_DOMAIN_MEMORY_MODEL_DIMM:
|
||||
case VIR_DOMAIN_MEMORY_MODEL_VIRTIO_PMEM:
|
||||
case VIR_DOMAIN_MEMORY_MODEL_VIRTIO_MEM:
|
||||
case VIR_DOMAIN_MEMORY_MODEL_SGX_EPC:
|
||||
case VIR_DOMAIN_MEMORY_MODEL_NONE:
|
||||
case VIR_DOMAIN_MEMORY_MODEL_LAST:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user