mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
qemu_monitor: Decouple switch()-es in qemuMonitorJSONGetMemoryDeviceInfo()
There are two switch() statements over the same variable inside of qemuMonitorJSONGetMemoryDeviceInfo(). Join them together into one switch. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
This commit is contained in:
parent
f173f6a79c
commit
61233dfbee
@ -7233,6 +7233,8 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
meminfo = g_new0(qemuMonitorMemoryDeviceInfo, 1);
|
||||||
|
|
||||||
switch ((virDomainMemoryModel) model) {
|
switch ((virDomainMemoryModel) model) {
|
||||||
case VIR_DOMAIN_MEMORY_MODEL_DIMM:
|
case VIR_DOMAIN_MEMORY_MODEL_DIMM:
|
||||||
case VIR_DOMAIN_MEMORY_MODEL_NVDIMM:
|
case VIR_DOMAIN_MEMORY_MODEL_NVDIMM:
|
||||||
@ -7245,28 +7247,9 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon,
|
|||||||
_("dimm memory info data is missing 'id'"));
|
_("dimm memory info data is missing 'id'"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case VIR_DOMAIN_MEMORY_MODEL_SGX_EPC:
|
if (model == VIR_DOMAIN_MEMORY_MODEL_DIMM ||
|
||||||
if (!(devalias = virJSONValueObjectGetString(dimminfo, "memdev"))) {
|
model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("sgx-epc memory info data is missing 'memdev'"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VIR_DOMAIN_MEMORY_MODEL_VIRTIO_PMEM:
|
|
||||||
case VIR_DOMAIN_MEMORY_MODEL_NONE:
|
|
||||||
case VIR_DOMAIN_MEMORY_MODEL_LAST:
|
|
||||||
/* type not handled yet */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
meminfo = g_new0(qemuMonitorMemoryDeviceInfo, 1);
|
|
||||||
|
|
||||||
switch ((virDomainMemoryModel) model) {
|
|
||||||
case VIR_DOMAIN_MEMORY_MODEL_DIMM:
|
|
||||||
case VIR_DOMAIN_MEMORY_MODEL_NVDIMM:
|
|
||||||
if (virJSONValueObjectGetNumberUlong(dimminfo, "addr",
|
if (virJSONValueObjectGetNumberUlong(dimminfo, "addr",
|
||||||
&meminfo->address) < 0) {
|
&meminfo->address) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
@ -7296,18 +7279,22 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
} else if (model == VIR_DOMAIN_MEMORY_MODEL_VIRTIO_MEM) {
|
||||||
|
|
||||||
case VIR_DOMAIN_MEMORY_MODEL_VIRTIO_MEM:
|
|
||||||
if (virJSONValueObjectGetNumberUlong(dimminfo, "size",
|
if (virJSONValueObjectGetNumberUlong(dimminfo, "size",
|
||||||
&meminfo->size) < 0) {
|
&meminfo->size) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("malformed/missing size in virtio memory info"));
|
_("malformed/missing size in virtio memory info"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_MEMORY_MODEL_SGX_EPC:
|
case VIR_DOMAIN_MEMORY_MODEL_SGX_EPC:
|
||||||
|
if (!(devalias = virJSONValueObjectGetString(dimminfo, "memdev"))) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
_("sgx-epc memory info data is missing 'memdev'"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (virJSONValueObjectGetNumberUlong(dimminfo, "memaddr",
|
if (virJSONValueObjectGetNumberUlong(dimminfo, "memaddr",
|
||||||
&meminfo->address) < 0) {
|
&meminfo->address) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
Loading…
Reference in New Issue
Block a user