106 lines
4.0 KiB
Diff
106 lines
4.0 KiB
Diff
From d0c72934e0922d19eca8ed0cd812fb56f9222ec6 Mon Sep 17 00:00:00 2001
|
|
Message-ID: <d0c72934e0922d19eca8ed0cd812fb56f9222ec6.1763133105.git.jdenemar@redhat.com>
|
|
From: Michal Privoznik <mprivozn@redhat.com>
|
|
Date: Mon, 29 Sep 2025 16:05:31 +0200
|
|
Subject: [PATCH] domain_conf: Use virXMLFormatElement() to format hyperv
|
|
features
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Not only is it more modern that old virBufferAsprintf() of
|
|
opening and closing tag, it's also aware of child elements buffer
|
|
and thus formats a singleton properly.
|
|
|
|
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
(cherry picked from commit c9716c0e0904c86d7e1c9258bc6e808ba7bc8262)
|
|
|
|
Additionally, hyperv-passthrough.x86_64-6.1.0.xml was modified
|
|
too, since the file doesn't exist upstream anymore (see
|
|
v11.2.0-rc1~225), but downstream it does.
|
|
|
|
Resolves: https://issues.redhat.com/browse/RHEL-122930
|
|
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
---
|
|
src/conf/domain_conf.c | 13 +++++++------
|
|
.../hyperv-passthrough.x86_64-6.1.0.xml | 3 +--
|
|
.../hyperv-passthrough.x86_64-latest.xml | 3 +--
|
|
3 files changed, 9 insertions(+), 10 deletions(-)
|
|
|
|
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
|
index 0b42c283bb..f02efaca4e 100644
|
|
--- a/src/conf/domain_conf.c
|
|
+++ b/src/conf/domain_conf.c
|
|
@@ -28026,18 +28026,19 @@ static void
|
|
virDomainFeaturesHyperVDefFormat(virBuffer *buf,
|
|
const virDomainDef *def)
|
|
{
|
|
- virBuffer tmpChildBuf = VIR_BUFFER_INIT_CHILD(buf);
|
|
+ virBuffer childBuf = VIR_BUFFER_INIT_CHILD(buf);
|
|
+ virBuffer attrBuf = VIR_BUFFER_INITIALIZER;
|
|
size_t j;
|
|
|
|
if (def->features[VIR_DOMAIN_FEATURE_HYPERV] == VIR_DOMAIN_HYPERV_MODE_NONE)
|
|
return;
|
|
|
|
- virBufferAsprintf(buf, "<hyperv mode='%s'>\n",
|
|
+ virBufferAsprintf(&attrBuf, " mode='%s'",
|
|
virDomainHyperVModeTypeToString(def->features[VIR_DOMAIN_FEATURE_HYPERV]));
|
|
|
|
for (j = 0; j < VIR_DOMAIN_HYPERV_LAST; j++) {
|
|
g_auto(virBuffer) hypervAttrBuf = VIR_BUFFER_INITIALIZER;
|
|
- g_auto(virBuffer) hypervChildBuf = VIR_BUFFER_INIT_CHILD(&tmpChildBuf);
|
|
+ g_auto(virBuffer) hypervChildBuf = VIR_BUFFER_INIT_CHILD(&childBuf);
|
|
|
|
if (def->hyperv_features[j] == VIR_TRISTATE_SWITCH_ABSENT)
|
|
continue;
|
|
@@ -28097,14 +28098,14 @@ virDomainFeaturesHyperVDefFormat(virBuffer *buf,
|
|
break;
|
|
}
|
|
|
|
- virXMLFormatElement(&tmpChildBuf, virDomainHypervTypeToString(j),
|
|
+ virXMLFormatElement(&childBuf, virDomainHypervTypeToString(j),
|
|
&hypervAttrBuf, &hypervChildBuf);
|
|
}
|
|
|
|
- virBufferAddBuffer(buf, &tmpChildBuf);
|
|
- virBufferAddLit(buf, "</hyperv>\n");
|
|
+ virXMLFormatElement(buf, "hyperv", &attrBuf, &childBuf);
|
|
}
|
|
|
|
+
|
|
static int
|
|
virDomainDefFormatFeatures(virBuffer *buf,
|
|
virDomainDef *def)
|
|
diff --git a/tests/qemuxmlconfdata/hyperv-passthrough.x86_64-6.1.0.xml b/tests/qemuxmlconfdata/hyperv-passthrough.x86_64-6.1.0.xml
|
|
index 02410a403e..d2130dc5c0 100644
|
|
--- a/tests/qemuxmlconfdata/hyperv-passthrough.x86_64-6.1.0.xml
|
|
+++ b/tests/qemuxmlconfdata/hyperv-passthrough.x86_64-6.1.0.xml
|
|
@@ -10,8 +10,7 @@
|
|
</os>
|
|
<features>
|
|
<acpi/>
|
|
- <hyperv mode='passthrough'>
|
|
- </hyperv>
|
|
+ <hyperv mode='passthrough'/>
|
|
</features>
|
|
<cpu mode='custom' match='exact' check='none'>
|
|
<model fallback='forbid'>qemu64</model>
|
|
diff --git a/tests/qemuxmlconfdata/hyperv-passthrough.x86_64-latest.xml b/tests/qemuxmlconfdata/hyperv-passthrough.x86_64-latest.xml
|
|
index 2cfae8fa4c..0ce5bab605 100644
|
|
--- a/tests/qemuxmlconfdata/hyperv-passthrough.x86_64-latest.xml
|
|
+++ b/tests/qemuxmlconfdata/hyperv-passthrough.x86_64-latest.xml
|
|
@@ -10,8 +10,7 @@
|
|
</os>
|
|
<features>
|
|
<acpi/>
|
|
- <hyperv mode='passthrough'>
|
|
- </hyperv>
|
|
+ <hyperv mode='passthrough'/>
|
|
</features>
|
|
<cpu mode='custom' match='exact' check='none'>
|
|
<model fallback='forbid'>qemu64</model>
|
|
--
|
|
2.51.1
|