virt/qemu/debian/patches/0003-STX-qemu-dpdk-changes-for-openvswitch-dpdk.patch
Thales Elero Cervi c2f773a9d9 Re-order DPDK args parsing in STX Patch
When STX Patches were ported to the top of QEMU 7.2 version, the
auto-merging placed our custom cli args parsing in the wrong place at
softmmu/vl.c file. These extra cli arguments are related to DPDK
configurations and supposed to be passed to rte_eal_init() function,
called only when dpdk is enabled.
This wrong placing was actually causing an error for any instance that
we tried to launch, since in the new base version there is QEMU code
parsing the cli args BEFORE we properly handle and remove the DPDK extra
args.

This change re-orders the code position inside our patch, such that DPDK
arguments are properly parsed, sent to rte_eal_init() and removed from
argc and argv before proceeding with QEMU upstream logic.

TEST PLAN:
PASS - build-pkgs -c -p qemu
PASS - build-image
PASS - bootstrap a virtual AIO-SX
PASS - apply stx-openstack
PASS - 'openstack hypervisor list' shows a QEMU hypervisor UP
PASS - launch a simple VM (no volumes, single network), it is
       properly built and end up in Running state.

Closes-Bug: 2078230

Change-Id: Id14a2328e2fb249a4de8fc8ad6302cee0b1d48ab
Signed-off-by: Thales Elero Cervi <thaleselero.cervi@windriver.com>
2024-08-28 18:20:16 +00:00

196 lines
5.7 KiB
Diff

From 31ae2e35caa16dcf4cc1fa2ff5e3c1aa825b5352 Mon Sep 17 00:00:00 2001
From: Jim Somerville <Jim.Somerville@windriver.com>
Date: Fri, 26 Apr 2019 17:41:04 -0300
Subject: [PATCH] STX: qemu dpdk changes for openvswitch dpdk
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
Signed-off-by: Rafael Falcao <Rafael.VieiraFalcao@windriver.com>
[Rebased original changes to the qemu 7.2 version]
Signed-off-by: david.liu <david.liu@windriver.com>
[Reordered custom DPDK args parsing on QEMU 7.2]
Signed-off-by: Thales Elero Cervi <thaleselero.cervi@windriver.com>
---
configure | 27 +++++++++++++++++++
hw/net/virtio-net.c | 5 ++++
softmmu/vl.c | 66 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 98 insertions(+)
diff --git a/configure b/configure
index 26c7bc51..c5810ea3 100755
--- a/configure
+++ b/configure
@@ -853,6 +853,11 @@ for opt do
;;
--with-coroutine=*) coroutine="$optarg"
;;
+ --disable-dpdk) dpdk="no"
+ ;;
+ --dpdkdir=*) rte_sdk="$optarg"
+ dpdk="yes"
+ ;;
--disable-zlib-test)
;;
--disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
@@ -2401,6 +2406,28 @@ if test -n "$gdb_bin"; then
fi
fi
+if test "$dpdk" = "yes"; then
+ if test "${rte_sdk+set}" != set; then
+ echo "No dpdkdir given"
+ exit 1
+ fi
+ echo "dpdk_dir=`eval echo $rte_sdk`" >> $config_host_mak
+ echo "dpdk_lib_dir=\$(dpdk_dir)/x86_64-default-linuxapp-gcc/lib" >> $config_host_mak_
+ echo "dpdk_inc_dir=\$(dpdk_dir)/x86_64-default-linuxapp-gcc/include" >> $config_host_mak
+ echo "" >> $config_host_mak
+ echo "dpdk_libs=\$(dpdk_lib_dir)/librte_eal.a \\" >> $config_host_mak
+ echo " \$(dpdk_lib_dir)/libethdev.a \\" >> $config_host_mak
+ echo " \$(dpdk_lib_dir)/librte_cmdline.a \\" >> $config_host_mak
+ echo " \$(dpdk_lib_dir)/librte_hash.a \\" >> $config_host_mak
+ echo " \$(dpdk_lib_dir)/librte_lpm.a \\" >> $config_host_mak
+ echo " \$(dpdk_lib_dir)/librte_mbuf.a \\" >> $config_host_mak
+ echo " \$(dpdk_lib_dir)/librte_mempool.a \\" >> $config_host_mak
+ echo " \$(dpdk_lib_dir)/librte_ring.a \\" >> $config_host_mak
+ echo " \$(dpdk_lib_dir)/librte_malloc.a" >> $config_host_mak
+ LIBS="\$(dpdk_libs) $LIBS"
+ QEMU_INCLUDES="-I\$(dpdk_inc_dir) $QEMU_INCLUDES"
+fi
+
if test "$container" != no; then
echo "ENGINE=$container" >> $config_host_mak
fi
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index aba12759..01ca6015 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -2,6 +2,7 @@
* Virtio Network Device
*
* Copyright IBM, Corp. 2007
+ * Copyright 2012-2013 Intel Corporation All Rights Reserved.
*
* Authors:
* Anthony Liguori <aliguori@us.ibm.com>
@@ -1671,6 +1672,7 @@ static void receive_header(VirtIONet *n, const struct iovec *iov, int iov_cnt,
}
}
+#if 0
static int receive_filter(VirtIONet *n, const uint8_t *buf, int size)
{
static const uint8_t bcast[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
@@ -1721,6 +1723,7 @@ static int receive_filter(VirtIONet *n, const uint8_t *buf, int size)
return 0;
}
+#endif
static uint8_t virtio_net_get_hash_type(bool isip4,
bool isip6,
@@ -1852,8 +1855,10 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,
return 0;
}
+ #if 0
if (!receive_filter(n, buf, size))
return size;
+ #endif
offset = i = 0;
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 333c3be2..039df6c4 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -1583,6 +1583,35 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
return popt;
}
+#ifdef CONFIG_ENABLE_DPDK
+static const QEMUOption *quick_scan_opt(int argc, char **argv, int *poptind)
+{
+ const QEMUOption *popt;
+ int optind = *poptind;
+ char *r = argv[optind];
+
+ loc_set_cmdline(argv, optind, 1);
+ optind++;
+ /* Treat --foo the same as -foo. */
+ if (r[1] == '-')
+ r++;
+ popt = qemu_options;
+ for(;;) {
+ /* need to ignore non qemu args, e.g. dpdk args */
+ if (!popt->name) {
+ *poptind = optind;
+ return NULL;
+ }
+ if (!strcmp(popt->name, r + 1))
+ break;
+ popt++;
+ }
+
+ *poptind = optind;
+ return popt;
+}
+#endif
+
static MachineClass *select_machine(QDict *qdict, Error **errp)
{
const char *optarg = qdict_get_try_str(qdict, "type");
@@ -2645,6 +2674,40 @@ void qemu_init(int argc, char **argv)
bool userconfig = true;
FILE *vmstate_dump_file = NULL;
+#ifdef CONFIG_ENABLE_DPDK
+ bool use_dpdk = false;
+ int retval;
+
+ /* need to check for -enable-dpdk before calling rte_eal_init. If
+ * it is not found, don't call rte_eal_init */
+ optind = 1;
+ while (optind < argc) {
+ if (argv[optind][0] != '-') {
+ /* disk image */
+ optind++;
+ continue;
+ } else {
+ const QEMUOption *popt;
+ popt = quick_scan_opt(argc, argv, &optind);
+ if (popt) {
+ switch (popt->index) {
+ case QEMU_OPTION_enable_dpdk:
+ use_dpdk = true;
+ break;
+ }
+ }
+ }
+ }
+
+ if (use_dpdk) {
+ if ((retval = rte_eal_init(argc, argv)) < 0)
+ return -1;
+
+ argc -= retval;
+ argv += retval;
+ }
+#endif
+
qemu_add_opts(&qemu_drive_opts);
qemu_add_drive_opts(&qemu_legacy_drive_opts);
qemu_add_drive_opts(&qemu_common_drive_opts);
@@ -3532,6 +3595,9 @@ void qemu_init(int argc, char **argv)
cpu_timers_init();
user_register_global_props();
+
+ extern int rte_eal_init(int argc, char **argv);
+
replay_configure(icount_opts);
configure_rtc(qemu_find_opts_singleton("rtc"));
--
2.34.1