Files
virt/libvirt/debian/patches/0004-STX-DPDK-parms-handling.patch
Murillo Arantes c9f3f21e23 Upversion libvirt to v8.0.0-1
The new stx-openstack release will be based on the Openstack 2025.1
Epoxy version, which uses libvirt >= 8.0.0. This change aims to
upversion the current libvirt package from 7.0.0-3 to the 8.0.0-1. To
make this possible, it was necessary to update the libvirt metadata
and review all the patches currently applied to version 7.0.0-3,
analyzing which patches should be kept, which need to be adapted,
which can be removed and which new patches need to be created. The
following list describes the actions taken for each patch included in
this change:

Patches removed because they are no longer needed in version 8.0.0-1:
 CVE-2021-3631.patch
 CVE-2021-3667.patch
 CVE-2021-3975.patch
 CVE-2021-4147_1.patch
 CVE-2021-4147_2.patch
 CVE-2021-4147_3.patch
 CVE-2021-4147_4.patch
 CVE-2021-4147_5.patch
 CVE-2021-4147_6.patch
 0010-qemu-capabilities-Introduce-QEMU_CAPS_OBJECT_QAPIFIE.patch
 0011-qemu-monitor-Make-wrapping-of-props-of-object-add-op.patch
 0012-qemuMonitorCreateObjectPropsWrap-Open-code-in-qemuBu.patch
 0013-qemu-monitor-Don-t-add-props-wrapper-if-qemu-has-QEM.patch
 0014-qemu-remove-support-for-generating-yes-no-boolean-op.patch
 0015-qemu-command-Use-JSON-for-QAPIfied-object-directly.patch
 0016-qemu-capabilities-Enable-detection-of-QEMU_CAPS_OBJE.patch
 libxl-Fix-domain-shutdown.patch

Patches adapted due to changes between versions 7.0.0-3 and 8.0.0-1:
 CVE-2024-1441.patch
 CVE-2024-2494.patch
 CVE-2024-2496.patch
 0001-STX-Customize-Debian-build-files.patch
 0001-STX-CPU-pinning-not-working-over-live-migration.patch
 0002-STX-System-Logging-set-group-read-permission-on-log.patch
 0003-STX-Drop-migration-poll-times-to-10mS.patch
 0004-STX-DPDK-parms-handling.patch
 0007-STX-Stop-processing-memory-stats-if-balloon-info.patch
 0008-STX-Increase-timeout-for-connecting-to-monitor.patch
 0009-STX-pci-sriov-perform-limited-retry-on-netlink.patch

Some examples of changes between libvirt versions that required
updates to the patches can be found in [1], [2], [3], [4], and [5].

New patch required to ensure compatibility with the libc6-dev version
dependency (see the patch description for more details):
 0002-STX-Adjust-libc6-dev-version-compatibility.patch

[1] https://salsa.debian.org/libvirt-team/libvirt/-/commit/53a7a787d3
[2] https://salsa.debian.org/libvirt-team/libvirt/-/blob/debian/7.0.0-3/src/conf/domain_conf.c?ref_type=tags#L2011
[3] https://salsa.debian.org/libvirt-team/libvirt/-/blob/debian/8.0.0-1/src/conf/domain_conf.c?ref_type=tags#L2079
[4] https://salsa.debian.org/libvirt-team/libvirt/-/blob/debian/7.0.0-3/src/qemu/qemu_monitor_json.c?ref_type=tags#L2270
[5] https://salsa.debian.org/libvirt-team/libvirt/-/blob/debian/8.0.0-1/src/qemu/qemu_monitor_json.c?ref_type=tags#L2076

TEST PLAN:

PASS - build-pkgs --all
PASS - build-pkgs -c -p libvirt
PASS - build ISO image
PASS - build wheels and base docker image
PASS - build stx-libvirt docker image
PASS - build stx-openstack
PASS - AIO-SX: fresh install with the ISO
PASS - launch/pause/resume/restart/delete vm on the host
PASS - STD system: apply stx-openstack
PASS - check pods are healthy
PASS - check libvirt version
PASS - launch vm
PASS - pause/resume vm
PASS - restart vm
PASS - delete vm
PASS - cold migrate vm
PASS - live migrate vm
PASS - virsh list vm

Story: 2011516
Task: 52969

Change-Id: I792e8bba8b7288f2d3257ce3e1c5d0fc0780fcf8
Signed-off-by: Murillo Arantes <murillo.arantes@windriver.com>
Co-Authored-By: Daniel Caires <danielmarques.caires@windriver.com>
2025-11-05 09:33:26 -03:00

353 lines
11 KiB
Diff

From 8da897a3cb0c04d163e67a232799fffa636d6996 Mon Sep 17 00:00:00 2001
From: Ludovic Beliveau <ludovic.beliveau@windriver.com>
Date: Tue, 22 Mar 2016 09:58:36 -0400
Subject: [PATCH] STX: DPDK parms handling
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
[ Removed deprecated macros ]
Signed-off-by: Thales Elero Cervi <thaleselero.cervi@windriver.com>
[ Fixed pointers and goto while porting patch to libvirt v8.0.0-1 ]
Signed-off-by: Murillo Arantes <murillo.arantes@windriver.com>
---
src/conf/domain_conf.c | 152 ++++++++++++++++++++++++++++++++++++++++
src/conf/domain_conf.h | 25 +++++++
src/qemu/qemu.conf | 4 +-
src/qemu/qemu_command.c | 34 +++++++++
4 files changed, 213 insertions(+), 2 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5691b8d2d..3a5bdbfec 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1289,6 +1289,14 @@ VIR_ENUM_IMPL(virDomainVsockModel,
"virtio-non-transitional",
);
+/* STX: DPDK Customization */
+VIR_ENUM_IMPL(virDomainDpdkProcess,
+ VIR_DOMAIN_DPDK_PROCTYPE_LAST,
+ "auto",
+ "primary",
+ "secondary",
+);
+
VIR_ENUM_IMPL(virDomainDiskDiscard,
VIR_DOMAIN_DISK_DISCARD_LAST,
"default",
@@ -1691,6 +1699,103 @@ virBlkioDeviceArrayClear(virBlkioDevice *devices,
VIR_FREE(devices[i].path);
}
+/**
+ * STX: virDomainDpdkParamsDefPtr
+ *
+ * this function parses a XML node:
+ *
+ * <dpdk>
+ * <process type='secondary'/>
+ * <file prefix='vs'/>
+ * <memory channels='4'/>
+ * <cpu list='0,2-3'/>
+ * </dpdk>
+ *
+ * and fills a virDpdkParams struct.
+ */
+static int
+virDomainDpdkParamsParseXML(xmlNodePtr ctxt,
+ virDomainDpdkParamsDefPtr dpdk)
+{
+ char *channels = NULL;
+ char *process_type = NULL;
+ char *file_prefix = NULL;
+ char *cpu_list = NULL;
+ xmlNodePtr cur;
+ int ret = -EINVAL;
+
+ cur = ctxt->children;
+ while (cur != NULL) {
+ if (cur->type == XML_ELEMENT_NODE) {
+ if (!process_type && xmlStrEqual(cur->name, BAD_CAST "process")) {
+ process_type = virXMLPropString(cur, "type");
+ }
+ if (!file_prefix && xmlStrEqual(cur->name, BAD_CAST "file")) {
+ file_prefix = virXMLPropString(cur, "prefix");
+ }
+ if (!cpu_list && xmlStrEqual(cur->name, BAD_CAST "cpu")) {
+ cpu_list = virXMLPropString(cur, "list");
+ }
+ if (!channels && xmlStrEqual(cur->name, BAD_CAST "memory")) {
+ channels = virXMLPropString(cur, "channels");
+ }
+ }
+ cur = cur->next;
+ }
+
+ if (!process_type) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("missing DPDK process type"));
+ goto error;
+ }
+ if (!file_prefix) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("missing DPDK file prefix"));
+ goto error;
+ }
+ if (!cpu_list) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("missing DPDK CPU list"));
+ goto error;
+ }
+ if (!channels) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("missing DPDK memory channel count"));
+ goto error;
+ }
+
+ dpdk->process_type = virDomainDpdkProcessTypeFromString(process_type);
+ if (virStrToLong_ui(channels, NULL, 10, &dpdk->nchannels) < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("could not parse DPDK memory channels %s"),
+ channels);
+ goto error;
+ }
+ if (virBitmapParse(cpu_list, &dpdk->cpumask, 128) < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("could not parse DPDK CPU list %s"),
+ cpu_list);
+ goto error;
+ }
+ if (!(dpdk->file_prefix = g_strdup(file_prefix))) {
+ goto error;
+ }
+
+ ret = 0;
+
+cleanup:
+ VIR_FREE(process_type);
+ VIR_FREE(file_prefix);
+ VIR_FREE(cpu_list);
+ VIR_FREE(channels);
+
+ return ret;
+error:
+ virDomainDpdkParamsDefFree(dpdk);
+ ret = -EINVAL;
+ goto cleanup;
+}
+
/**
* virDomainBlkioDeviceParseXML
*
@@ -3398,6 +3503,16 @@ virDomainClockDefClear(virDomainClockDef *def)
VIR_FREE(def->timers);
}
+/* STX: DPDK Customization */
+void
+virDomainDpdkParamsDefFree(virDomainDpdkParamsDefPtr dpdk)
+{
+ if (!dpdk)
+ return;
+
+ virBitmapFree(dpdk->cpumask);
+ VIR_FREE(dpdk->file_prefix);
+}
static bool
virDomainIOThreadIDArrayHasPin(virDomainDef *def)
@@ -3613,6 +3728,10 @@ void virDomainDefFree(virDomainDef *def)
virDomainVcpuDefFree(def->vcpus[i]);
g_free(def->vcpus);
+ /* STX: DPDK Customization */
+ virDomainDpdkParamsDefFree(def->dpdk);
+ VIR_FREE(def->dpdk);
+
/* hostdevs must be freed before nets (or any future "intelligent
* hostdevs") because the pointer to the hostdev is really
* pointing into the middle of the higher level device's object,
@@ -19130,6 +19249,15 @@ virDomainDefParseMemory(virDomainDef *def,
if (virXPathBoolean("boolean(./memoryBacking/discard)", ctxt))
def->mem.discard = VIR_TRISTATE_BOOL_YES;
+ /* STX: Extract dpdk parameters */
+ if ((node = virXPathNode("./dpdk", ctxt))) {
+ def->dpdk = (virDomainDpdkParamsDefPtr)calloc(1, sizeof(*(def->dpdk)));
+ if (def->dpdk == NULL)
+ return -1;
+ if (virDomainDpdkParamsParseXML(node, def->dpdk) < 0)
+ return -1;
+ }
+
return 0;
}
@@ -28130,6 +28258,8 @@ virDomainDefFormatInternalSetRootName(virDomainDef *def,
unsigned char *uuid;
char uuidstr[VIR_UUID_STRING_BUFLEN];
const char *type = NULL;
+ /* STX: DPDK Customization */
+ char *cpu_list = NULL;
int n;
size_t i;
@@ -28175,6 +28305,28 @@ virDomainDefFormatInternalSetRootName(virDomainDef *def,
virBufferEscapeString(buf, "<description>%s</description>\n",
def->description);
+ /* STX: DPDK Customization */
+ if (def->dpdk) {
+ virBufferAsprintf(buf, " <dpdk>\n");
+ if (!(type = virDomainDpdkProcessTypeToString(def->dpdk->process_type))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unexpected DPDK process type %d"),
+ def->dpdk->process_type);
+ return -1;
+ }
+ if (!(cpu_list = virBitmapFormat(def->dpdk->cpumask))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unexpected CPU CPU list"));
+ return -1;
+ }
+ virBufferAsprintf(buf, " <process type='%s'/>\n", type);
+ virBufferAsprintf(buf, " <file prefix='%s'/>\n", def->dpdk->file_prefix);
+ virBufferAsprintf(buf, " <cpu list='%s'/>\n", cpu_list);
+ virBufferAsprintf(buf, " <memory channels='%u'/>\n", def->dpdk->nchannels);
+ virBufferAsprintf(buf, " </dpdk>\n");
+ VIR_FREE(cpu_list);
+ }
+
if (virXMLFormatMetadata(buf, def->metadata) < 0)
return -1;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 144ba4dd1..0dd1f3978 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2342,6 +2342,24 @@ struct _virDomainOSDef {
virDomainBIOSDef bios;
};
+/* STX: DPDK Customization */
+enum virDomainDpdkProcessType {
+ VIR_DOMAIN_DPDK_PROCTYPE_AUTO,
+ VIR_DOMAIN_DPDK_PROCTYPE_PRIMARY,
+ VIR_DOMAIN_DPDK_PROCTYPE_SECONDARY,
+
+ VIR_DOMAIN_DPDK_PROCTYPE_LAST
+};
+
+typedef struct _virDomainDpdkParamsDef virDomainDpdkParamsDef;
+typedef virDomainDpdkParamsDef *virDomainDpdkParamsDefPtr;
+struct _virDomainDpdkParamsDef {
+ enum virDomainDpdkProcessType process_type;
+ char *file_prefix;
+ unsigned nchannels;
+ virBitmap *cpumask;
+};
+
typedef enum {
VIR_DOMAIN_TIMER_NAME_PLATFORM = 0,
VIR_DOMAIN_TIMER_NAME_PIT,
@@ -2795,6 +2813,9 @@ struct _virDomainDef {
char *title;
char *description;
+ /* STX: DPDK Customization */
+ virDomainDpdkParamsDefPtr dpdk;
+
virDomainBlkiotune blkio;
virDomainMemtune mem;
@@ -3297,6 +3318,8 @@ int virDomainObjWaitUntil(virDomainObj *vm,
void virDomainPanicDefFree(virDomainPanicDef *panic);
void virDomainResourceDefFree(virDomainResourceDef *resource);
+/* STX: DPDK Customization */
+void virDomainDpdkParamsDefFree(virDomainDpdkParamsDefPtr dpdk);
void virDomainGraphicsDefFree(virDomainGraphicsDef *def);
const char *virDomainInputDefGetPath(virDomainInputDef *input);
void virDomainInputDefFree(virDomainInputDef *def);
@@ -3977,6 +4000,8 @@ VIR_ENUM_DECL(virDomainTPMModel);
VIR_ENUM_DECL(virDomainTPMBackend);
VIR_ENUM_DECL(virDomainTPMVersion);
VIR_ENUM_DECL(virDomainTPMPcrBank);
+/* STX: DPDK Customization */
+VIR_ENUM_DECL(virDomainDpdkProcess);
VIR_ENUM_DECL(virDomainMemoryModel);
VIR_ENUM_DECL(virDomainMemoryBackingModel);
VIR_ENUM_DECL(virDomainMemorySource);
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index 71fd12569..e2b92f7de 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -516,11 +516,11 @@
# user = "+0" # Super user (uid=0)
# user = "100" # A user named "100" or a user with uid=100
#
-#user = "root"
+user = "root"
# The group for QEMU processes run by the system instance. It can be
# specified in a similar way to user.
-#group = "root"
+group = "root"
# Whether libvirt should dynamically change file ownership
# to match the configured user/group above. Defaults to 1.
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d822533cc..fde38e84a 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2489,6 +2489,34 @@ qemuBuildFloppyCommandLineControllerOptionsExplicit(virCommand *cmd,
return 0;
}
+/* STX: DPDK Customization */
+static int
+qemuBuildDpdkArgStr(virCommand *cmd,
+ const virDomainDpdkParamsDefPtr dpdk)
+{
+ char *cpumask;
+
+ if (!dpdk) {
+ return 0;
+ }
+
+ cpumask = virBitmapToString(dpdk->cpumask);
+ if (!cpumask) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unable to format DPDK cpumask as string"));
+ return -1;
+ }
+
+ virCommandAddArgFormat(cmd, "-c %s", cpumask);
+ virCommandAddArgFormat(cmd, "-n %u", dpdk->nchannels);
+ virCommandAddArgFormat(cmd, "--proc-type=%s", "secondary");
+ virCommandAddArgFormat(cmd, "--file-prefix=%s", dpdk->file_prefix);
+ virCommandAddArg(cmd, "--");
+ virCommandAddArg(cmd, "-enable-dpdk");
+ VIR_FREE(cpumask);
+
+ return 0;
+}
static int
qemuBuildFloppyCommandLineControllerOptions(virCommand *cmd,
@@ -10495,6 +10523,12 @@ qemuBuildCommandLine(virQEMUDriver *driver,
virCommandAddEnvXDG(cmd, priv->libDir);
}
+ /* STX: DPDK Customization */
+ if (def->dpdk) {
+ if (qemuBuildDpdkArgStr(cmd, def->dpdk) < 0)
+ return NULL;
+ }
+
if (qemuBuildNameCommandLine(cmd, cfg, def) < 0)
return NULL;
--
2.34.1