libvirt/SOURCES/libvirt-cpu_conf-Format-vendor_id-for-host-model-CPUs.patch
2021-09-10 11:57:33 +00:00

81 lines
3.0 KiB
Diff

From 37b27a297ecb87e65f41c212aaabde7311b042d6 Mon Sep 17 00:00:00 2001
Message-Id: <37b27a297ecb87e65f41c212aaabde7311b042d6@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Thu, 20 Feb 2020 09:08:05 +0100
Subject: [PATCH] cpu_conf: Format vendor_id for host-model CPUs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In commit v5.9.0-400-gaf8e39921a I removed printing model's fallback and
vendor_id attributes when no model is specified. However, vendor_id
makes sense even without a specific CPU model (for host-model CPUs).
https://bugzilla.redhat.com/show_bug.cgi?id=1804549
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 0905f222f1bfd9d741e94a8d653e05bb174846d3)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <0b46ae9e26d1c7dbaa7f2dd58fd1156db237a853.1582186015.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/conf/cpu_conf.c | 14 +++++++++-----
tests/qemuxml2xmloutdata/cpu-host-model-vendor.xml | 4 +++-
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 837d77581c..1a2948ce11 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -791,10 +791,10 @@ virCPUDefFormatBuf(virBufferPtr buf,
return -1;
}
- if (formatModel && def->model) {
+ if (formatModel && (def->model || def->vendor_id)) {
virBufferAddLit(buf, "<model");
- if (def->type == VIR_CPU_TYPE_GUEST) {
+ if (def->type == VIR_CPU_TYPE_GUEST && def->model) {
const char *fallback;
fallback = virCPUFallbackTypeToString(def->fallback);
@@ -805,11 +805,15 @@ virCPUDefFormatBuf(virBufferPtr buf,
return -1;
}
virBufferAsprintf(buf, " fallback='%s'", fallback);
- if (def->vendor_id)
- virBufferEscapeString(buf, " vendor_id='%s'", def->vendor_id);
}
- virBufferEscapeString(buf, ">%s</model>\n", def->model);
+ if (def->type == VIR_CPU_TYPE_GUEST)
+ virBufferEscapeString(buf, " vendor_id='%s'", def->vendor_id);
+
+ if (def->model)
+ virBufferEscapeString(buf, ">%s</model>\n", def->model);
+ else
+ virBufferAddLit(buf, "/>\n");
}
if (formatModel && def->vendor)
diff --git a/tests/qemuxml2xmloutdata/cpu-host-model-vendor.xml b/tests/qemuxml2xmloutdata/cpu-host-model-vendor.xml
index d2447ccd10..2a7d0246cc 100644
--- a/tests/qemuxml2xmloutdata/cpu-host-model-vendor.xml
+++ b/tests/qemuxml2xmloutdata/cpu-host-model-vendor.xml
@@ -8,7 +8,9 @@
<type arch='x86_64' machine='pc'>hvm</type>
<boot dev='network'/>
</os>
- <cpu mode='host-model' check='partial'/>
+ <cpu mode='host-model' check='partial'>
+ <model vendor_id='Libvirt QEMU'/>
+ </cpu>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
--
2.25.0