cpu_conf: Simplify formatting of guest CPU attributes

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Jiri Denemark 2017-06-30 16:05:28 +02:00
parent 4fd179f518
commit 659a92f2e3

View File

@ -604,20 +604,20 @@ virCPUDefFormatBufFull(virBufferPtr buf,
if (!def) if (!def)
return 0; return 0;
/* Format attributes */ /* Format attributes for guest CPUs unless they only specify
if (def->type == VIR_CPU_TYPE_GUEST) { * topology or cache. */
if (def->type == VIR_CPU_TYPE_GUEST &&
(def->mode != VIR_CPU_MODE_CUSTOM || def->model)) {
const char *tmp; const char *tmp;
if (def->mode != VIR_CPU_MODE_CUSTOM || def->model) { if (!(tmp = virCPUModeTypeToString(def->mode))) {
if (!(tmp = virCPUModeTypeToString(def->mode))) { virReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR, _("Unexpected CPU mode %d"), def->mode);
_("Unexpected CPU mode %d"), def->mode); goto cleanup;
goto cleanup;
}
virBufferAsprintf(&attributeBuf, " mode='%s'", tmp);
} }
virBufferAsprintf(&attributeBuf, " mode='%s'", tmp);
if (def->model && def->mode == VIR_CPU_MODE_CUSTOM) { if (def->mode == VIR_CPU_MODE_CUSTOM) {
if (!(tmp = virCPUMatchTypeToString(def->match))) { if (!(tmp = virCPUMatchTypeToString(def->match))) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected CPU match policy %d"), _("Unexpected CPU match policy %d"),