From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id E84635A0082 for ; Mon, 9 Jan 2023 08:31:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673249510; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=4M6/bniTvdpMOZJPY2Bc1ZRQbSfNp5Sl6X7KndlgHBU=; b=cnlACv3rxcSyVBN/22Uyz4FrFfRrsvmdKmv3blvvs4+iEJT+9xa2qhn/aMCHnAyEpM52BN KBXD1Lkkb8/w+Br6pp0oANcCsLVCJ1Ay1LZswg6s9OW5lAcOKgJPmv++XFW2t4oQkJqD53 ydx92sMK3iGDXxQSdnOHR2ugo+774bg= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-258-77BzMoBWO6OGwnxyJ-SFXw-1; Mon, 09 Jan 2023 02:31:49 -0500 X-MC-Unique: 77BzMoBWO6OGwnxyJ-SFXw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 48C563C14861 for ; Mon, 9 Jan 2023 07:31:49 +0000 (UTC) Received: from fedora (ovpn-192-19.brq.redhat.com [10.40.192.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1543A1121314; Mon, 9 Jan 2023 07:31:47 +0000 (UTC) From: =?iso-8859-1?B?SuFu?= Tomko To: Laine Stump Subject: Re: [libvirt PATCH 8/9] qemu: hook up passt config to qemu domains Message-ID: References: <20230109041112.368790-1-laine@redhat.com> <20230109041112.368790-9-laine@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="2ONeBmACijCgJSUs" Content-Disposition: inline In-Reply-To: <20230109041112.368790-9-laine@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-MailFrom: jtomko@redhat.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation Message-ID-Hash: ZD274JV3MXVPS5JITUUMUZWP4GBPLYT3 X-Message-ID-Hash: ZD274JV3MXVPS5JITUUMUZWP4GBPLYT3 X-Mailman-Approved-At: Tue, 10 Jan 2023 16:08:41 +0100 CC: libvir-list@redhat.com, sbrivio@redhat.com, passt-dev@passt.top X-Mailman-Version: 3.3.3 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Date: Mon, 09 Jan 2023 07:31:52 X-Original-Date: Mon, 9 Jan 2023 08:32:09 +0100 --2ONeBmACijCgJSUs Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 >--- > 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.ar= gs > >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 >+ * . >+ */ >+ >+#include >+ >+#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 =3D vm->privateData; >+ virQEMUDriver *driver =3D priv->driver; >+ g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); >+ g_autofree char *name =3D NULL; >+ >+ name =3D g_strdup_printf("%s-%s-passt", vm->def->name, net->info.alia= s); Please use virDomainDefGetShortName for filename purposes. >+ >+ return virPidFileBuildPath(cfg->passtStateDir, name); >+} >+ >+ [...] >+int >+qemuPasstAddNetProps(virDomainObj *vm, >+ virDomainNetDef *net, >+ virJSONValue **netprops) >+{ >+ g_autofree char *passtSocketName =3D qemuPasstCreateSocketPath(vm, ne= t); >+ g_autoptr(virJSONValue) addrprops =3D 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 =3D 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=E1n Tomko Jano --2ONeBmACijCgJSUs Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQT+Rn5j0qdK2hQgnuAU0rOr/y4PvAUCY7vC9QAKCRAU0rOr/y4P vFTYAP9IsF+ZXdK8PSGMafZMeCVipEZUqvC+Z5QY7ORicKX7fQD/UNvl9sMDY4wI AJQugiM3ivVQNOq8162jssktP+FeQgE= =h2fI -----END PGP SIGNATURE----- --2ONeBmACijCgJSUs--