]> xenbits.xensource.com Git - libvirt.git/commitdiff
cpu_conf: Simplify formatting of guest CPU attributes
authorJiri Denemark <jdenemar@redhat.com>
Fri, 30 Jun 2017 14:05:28 +0000 (16:05 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 21 Sep 2017 13:23:39 +0000 (15:23 +0200)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
src/conf/cpu_conf.c

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