From: "Ján Tomko" <jtomko@redhat.com>
To: Laine Stump <laine@redhat.com>
Cc: libvir-list@redhat.com, sbrivio@redhat.com, passt-dev@passt.top
Subject: Re: [libvirt PATCH 8/9] qemu: hook up passt config to qemu domains
Date: Mon, 09 Jan 2023 07:31:52 [thread overview]
Message-ID: <Y7vC+VMsebQMjV+7@fedora> (raw)
In-Reply-To: <20230109041112.368790-9-laine@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 5070 bytes --]
On a Sunday in 2023, Laine Stump wrote:
>This consists of (1) adding the necessary args to the qemu commandline
>netdev option, and (2) starting a passt process prior to starting
>qemu, and making sure that it is terminated when it's no longer
>needed. Under normal circumstances, passt will terminate itself as
>soon as qemu closes its socket, but in case of some error where qemu
>is never started, or fails to startup completely, we need to terminate
>passt manually.
>
>Signed-off-by: Laine Stump <laine@redhat.com>
>---
> meson.build | 1 +
> po/POTFILES | 1 +
> src/qemu/meson.build | 2 +
> src/qemu/qemu_command.c | 11 +-
> src/qemu/qemu_command.h | 3 +-
> src/qemu/qemu_domain.c | 5 +-
> src/qemu/qemu_domain.h | 3 +-
> src/qemu/qemu_extdevice.c | 25 +-
> src/qemu/qemu_hotplug.c | 26 +-
> src/qemu/qemu_passt.c | 284 ++++++++++++++++++
> src/qemu/qemu_passt.h | 38 +++
> src/qemu/qemu_process.c | 1 +
> src/qemu/qemu_validate.c | 9 +-
> tests/qemuxml2argvdata/net-user-passt.args | 34 +++
> .../net-user-passt.x86_64-latest.args | 37 +++
> tests/qemuxml2argvtest.c | 2 +
> 16 files changed, 470 insertions(+), 12 deletions(-)
> create mode 100644 src/qemu/qemu_passt.c
> create mode 100644 src/qemu/qemu_passt.h
> create mode 100644 tests/qemuxml2argvdata/net-user-passt.args
> create mode 100644 tests/qemuxml2argvdata/net-user-passt.x86_64-latest.args
>
>diff --git a/src/qemu/qemu_passt.c b/src/qemu/qemu_passt.c
>new file mode 100644
>index 0000000000..5941594811
>--- /dev/null
>+++ b/src/qemu/qemu_passt.c
>@@ -0,0 +1,284 @@
>+/*
>+ * qemu_passt.c: QEMU passt support
>+ *
>+ * Copyright (C) 2022 Red Hat, Inc.
>+ *
>+ * This library is free software; you can redistribute it and/or
>+ * modify it under the terms of the GNU Lesser General Public
>+ * License as published by the Free Software Foundation; either
>+ * version 2.1 of the License, or (at your option) any later version.
>+ *
>+ * This library is distributed in the hope that it will be useful,
>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>+ * Lesser General Public License for more details.
>+ *
>+ * You should have received a copy of the GNU Lesser General Public
>+ * License along with this library. If not, see
>+ * <http://www.gnu.org/licenses/>.
>+ */
>+
>+#include <config.h>
>+
>+#include "qemu_dbus.h"
>+#include "qemu_extdevice.h"
>+#include "qemu_security.h"
>+#include "qemu_passt.h"
>+#include "virenum.h"
>+#include "virerror.h"
>+#include "virjson.h"
>+#include "virlog.h"
>+#include "virpidfile.h"
>+
>+#define VIR_FROM_THIS VIR_FROM_NONE
>+
>+VIR_LOG_INIT("qemu.passt");
>+
>+
>+static char *
>+qemuPasstCreatePidFilename(virDomainObj *vm,
>+ virDomainNetDef *net)
>+{
>+ qemuDomainObjPrivate *priv = vm->privateData;
>+ virQEMUDriver *driver = priv->driver;
>+ g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
>+ g_autofree char *name = NULL;
>+
>+ name = g_strdup_printf("%s-%s-passt", vm->def->name, net->info.alias);
Please use virDomainDefGetShortName for filename purposes.
>+
>+ return virPidFileBuildPath(cfg->passtStateDir, name);
>+}
>+
>+
[...]
>+int
>+qemuPasstAddNetProps(virDomainObj *vm,
>+ virDomainNetDef *net,
>+ virJSONValue **netprops)
>+{
>+ g_autofree char *passtSocketName = qemuPasstCreateSocketPath(vm, net);
>+ g_autoptr(virJSONValue) addrprops = NULL;
>+
>+ if (virJSONValueObjectAdd(&addrprops,
>+ "s:type", "unix",
>+ "s:path", passtSocketName,
>+ NULL) < 0) {
>+ return -1;
>+ }
>+
>+ if (virJSONValueObjectAdd(netprops,
>+ "s:type", "stream",
>+ "a:addr", &addrprops,
>+ "b:server", false,
>+ /* "u:reconnect", 5, */
Debugging leftover?
>+ NULL) < 0) {
>+ return -1;
>+ }
>+ return 0;
>+}
>+
>+
>+void
>+qemuPasstStop(virDomainObj *vm,
>+ virDomainNetDef *net)
>+{
>+ g_autofree char *pidfile = qemuPasstCreatePidFilename(vm, net);
>+ virErrorPtr orig_err;
>+
>+ virErrorPreserveLast(&orig_err);
>+
>+
Extra whitespace
>+ if (virPidFileForceCleanupPath(pidfile) < 0)
>+ VIR_WARN("Unable to kill passt process");
>+
>+ virErrorRestore(&orig_err);
>+}
>+
>+
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Jano
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2023-01-09 7:31 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-09 4:11 [libvirt PATCH 0/9] Support libvirt-managed QEMU domain <interface> backed by a passt process Laine Stump
2023-01-09 4:11 ` [libvirt PATCH 1/9] conf: rename virDomainNetBackend* to virDomainNetDriver* Laine Stump
2023-01-09 5:40 ` Ján Tomko
2023-01-09 4:11 ` [libvirt PATCH 2/9] conf: move anonymous backend struct from virDomainNetDef into its own struct Laine Stump
2023-01-09 5:41 ` Ján Tomko
2023-01-09 4:11 ` [libvirt PATCH 3/9] conf: put interface <backend> parsing/formatting separate functions Laine Stump
2023-01-09 5:47 ` Ján Tomko
2023-01-09 7:04 ` Laine Stump
2023-01-09 4:11 ` [libvirt PATCH 4/9] conf: add passt XML additions to schema Laine Stump
2023-01-09 5:48 ` Ján Tomko
2023-01-11 18:33 ` Daniel P. Berrangé
2023-01-12 14:45 ` Laine Stump
2023-01-12 17:28 ` Stefano Brivio
2023-01-12 18:12 ` Jiri Denemark
2023-01-09 4:11 ` [libvirt PATCH 5/9] conf: parse/format passt-related XML additions Laine Stump
2023-01-09 6:18 ` Ján Tomko
2023-01-09 4:11 ` [libvirt PATCH 6/9] qemu: new capability QEMU_CAPS_NETDEV_STREAM Laine Stump
2023-01-09 6:20 ` Ján Tomko
2023-01-09 4:11 ` [libvirt PATCH 7/9] qemu: add passtStateDir to qemu driver config Laine Stump
2023-01-09 6:23 ` Ján Tomko
2023-01-09 14:02 ` Laine Stump
2023-01-09 4:11 ` [libvirt PATCH 8/9] qemu: hook up passt config to qemu domains Laine Stump
2023-01-09 6:31 ` Ján Tomko [this message]
2023-01-09 14:14 ` Laine Stump
2023-01-09 14:51 ` Ján Tomko
2023-01-09 16:05 ` Laine Stump
2023-01-09 4:11 ` [libvirt PATCH 9/9] specfile: require passt for the build if fedora >= 36 or rhel >= 9 Laine Stump
2023-01-09 6:32 ` Ján Tomko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y7vC+VMsebQMjV+7@fedora \
--to=jtomko@redhat.com \
--cc=laine@redhat.com \
--cc=libvir-list@redhat.com \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).