From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196036; cv=none; d=zohomail.com; s=zohoarc; b=e4QuEx/mbjII65xK/RPbolbkhPPFXR7Qynhr1hILEn24221DIR4eQEOMHClWEBI0yNN5uo2QLlMoWcB4RbUyFp2J8Vzs/iEo7K98n72smizz0TH2pfEiXhVVZlideLuzu37kjuwLDqLr2QzUdz4mzayvDUD61F2rSBbnMX9Tavg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196036; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tWTSWy0Ua8FRG9E3k4R9s1KJrb42YCP2Eafn/LpjP5w=; b=TRhtcilxEG6nmryS8PDTFt0oyoKIZzxz02i+GnNnLpRb3BHdErInHPk/pgSCBap+b7gTLxtMkGwUq6BoNpohFE5MojWpcEmj8j2/JcdpVhqVIeEsNpYOhxVm9VzzNQ3aN6+k+JLFgNwZ3cdyDFE8erPlaJlvfWnBaxxRK6UtREA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1652196036580910.3803510927362; Tue, 10 May 2022 08:20:36 -0700 (PDT) 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-622-GV_BbmWEPZ6JCLcyW00zMg-1; Tue, 10 May 2022 11:20:24 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4F67929324AD; Tue, 10 May 2022 15:20:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 385D6C07F51; Tue, 10 May 2022 15:20:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2E8DE194706A; Tue, 10 May 2022 15:20:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 581A3194704D for ; Tue, 10 May 2022 15:20:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4B0202024CBB; Tue, 10 May 2022 15:20:16 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C58E200B427 for ; Tue, 10 May 2022 15:20:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196035; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=tWTSWy0Ua8FRG9E3k4R9s1KJrb42YCP2Eafn/LpjP5w=; b=OHQ91c5VoD3fs281VjPqjeYVmypLYRxGRzAD6j5Hm+CaUGzEUYzoLjMCBu3uPrWBBTATxI xiG9Wx3DpFE4rKeaaQiTnklUOd/wcuvhMd0lxSpuq9lgsXvBmOt15NTDK05e6GtZqiRMPa SpztoR49km06WCJLzqdnlsv/jCMa2Hc= X-MC-Unique: GV_BbmWEPZ6JCLcyW00zMg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/37] qemu_fd: Add return value handling for qemuFDPassTransfer* APIs Date: Tue, 10 May 2022 17:19:37 +0200 Message-Id: <1ba9df221453209a543280e590091cdedc1a8ea0.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196038085100009 Content-Type: text/plain; charset="utf-8" Add possibility to delay checks to the point when the FDs are to be passed to qemu. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 16 +++++++++++----- src/qemu/qemu_fd.c | 12 ++++++++---- src/qemu/qemu_fd.h | 4 ++-- tests/qemumonitorjsontest.c | 8 ++++++-- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3746f02ff0..30671df4f2 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1494,7 +1494,8 @@ qemuBuildChardevCommand(virCommand *cmd, case VIR_DOMAIN_CHR_TYPE_FILE: case VIR_DOMAIN_CHR_TYPE_UNIX: - qemuFDPassTransferCommand(chrSourcePriv->sourcefd, cmd); + if (qemuFDPassTransferCommand(chrSourcePriv->sourcefd, cmd) < 0) + return -1; break; case VIR_DOMAIN_CHR_TYPE_NULL: @@ -1517,7 +1518,8 @@ qemuBuildChardevCommand(virCommand *cmd, return -1; } - qemuFDPassTransferCommand(chrSourcePriv->logfd, cmd); + if (qemuFDPassTransferCommand(chrSourcePriv->logfd, cmd) < 0) + return -1; if (!(charstr =3D qemuBuildChardevStr(dev, charAlias))) return -1; @@ -8896,7 +8898,8 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, vhostfd[i] =3D -1; } - qemuFDPassTransferCommand(vdpa, cmd); + if (qemuFDPassTransferCommand(vdpa, cmd) < 0) + return -1; if (!(hostnetprops =3D qemuBuildHostNetProps(net, tapfdName, tapfdSize, @@ -9805,8 +9808,11 @@ qemuBuildTPMCommandLine(virCommand *cmd, return -1; } - qemuFDPassTransferCommand(passtpm, cmd); - qemuFDPassTransferCommand(passcancel, cmd); + if (qemuFDPassTransferCommand(passtpm, cmd) < 0) + return -1; + + if (qemuFDPassTransferCommand(passcancel, cmd) < 0) + return -1; if (!(tpmdevstr =3D qemuBuildTPMBackendStr(tpm, passtpm, passcancel))) return -1; diff --git a/src/qemu/qemu_fd.c b/src/qemu/qemu_fd.c index 29370a4bb6..1af8932bdd 100644 --- a/src/qemu/qemu_fd.c +++ b/src/qemu/qemu_fd.c @@ -177,14 +177,14 @@ qemuFDPassAddFD(qemuFDPass *fdpass, * Pass the fds in @fdpass to a commandline object @cmd. @fdpass may be NU= LL * in which case this is a no-op. */ -void +int qemuFDPassTransferCommand(qemuFDPass *fdpass, virCommand *cmd) { size_t i; if (!fdpass) - return; + return 0; for (i =3D 0; i < fdpass->nfds; i++) { virCommandPassFD(cmd, fdpass->fds[i].fd, VIR_COMMAND_PASS_FD_CLOSE= _PARENT); @@ -206,6 +206,8 @@ qemuFDPassTransferCommand(qemuFDPass *fdpass, fdpass->fds[i].fd =3D -1; } + + return 0; } @@ -265,18 +267,20 @@ qemuFDPassTransferMonitor(qemuFDPass *fdpass, * Simulate as if @fdpass was passed via monitor for callers which don't * actually wish to test that code path. */ -void +int qemuFDPassTransferMonitorFake(qemuFDPass *fdpass) { if (!fdpass) - return; + return 0; if (fdpass->useFDSet) { fdpass->path =3D g_strdup_printf("/dev/fdset/monitor-fake"); } else { fdpass->path =3D g_strdup(fdpass->fds[0].opaque); } + + return 0; } diff --git a/src/qemu/qemu_fd.h b/src/qemu/qemu_fd.h index 6d090392db..db16d77ecc 100644 --- a/src/qemu/qemu_fd.h +++ b/src/qemu/qemu_fd.h @@ -39,7 +39,7 @@ qemuFDPassAddFD(qemuFDPass *fdpass, int *fd, const char *suffix); -void +int qemuFDPassTransferCommand(qemuFDPass *fdpass, virCommand *cmd); @@ -47,7 +47,7 @@ int qemuFDPassTransferMonitor(qemuFDPass *fdpass, qemuMonitor *mon); -void +int qemuFDPassTransferMonitorFake(qemuFDPass *fdpass); void diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 278d7ba765..e15c8533f6 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -743,8 +743,12 @@ qemuMonitorJSONTestAttachChardev(virDomainXMLOption *x= mlopt, chrdev.source =3D chr; ignore_value(testQemuPrepareHostBackendChardevOne(&dev, chr, NULL)= ); - qemuFDPassTransferMonitorFake(charpriv->sourcefd); - qemuFDPassTransferMonitorFake(charpriv->logfd); + if (qemuFDPassTransferMonitorFake(charpriv->sourcefd) < 0) + ret =3D -1; + + if (qemuFDPassTransferMonitorFake(charpriv->logfd) < 0) + ret =3D -1; + CHECK("file", false, "{'id':'alias','backend':{'type':'file','data':{'out':'/dev/= fdset/monitor-fake'," "'append':tru= e," --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196031; cv=none; d=zohomail.com; s=zohoarc; b=HJJGxV+ydf64bjEopdE5lOvB6db+ddOtF7sIsYbVD9VWFjPg/Rt1OyZ3JHdhLzM5c7q8zHNsBMraUCcNmcaHabuasLqsn+AlPP2oBmreXNgT7ohLRbhdnquDKUDrUE4Au9VLBIouu5SHuqmroFM2ru8T21YHLJfPNFCySMEiGEE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196031; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2uv82aPVNpvWt496u+aBX/4V/GJQj3E+eem4lkdrom8=; b=Pb7cfwW/NMluvJsqOyZfN8xnas3epom3bKW6a3HjPuO+9SRfJc61Sg4jcJ8Qo8gIlbSTUFwhO+DKNGg6eHus8UruahJr3L0vXoiTtcqYQxFkZGsLicaLKT2G5Nu+7FH/KOQNsqjyi+iWvCYK1r5sbvJ1e93uWI9RqDrV9WY2Yaw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1652196031603633.5463568826273; Tue, 10 May 2022 08:20:31 -0700 (PDT) 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-283-JOAEObWTP8afHrRom_SLdQ-1; Tue, 10 May 2022 11:20:24 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9D1153C8AD0C; Tue, 10 May 2022 15:20:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC5DDC28107; Tue, 10 May 2022 15:20:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 783801947076; Tue, 10 May 2022 15:20:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4171B194706A for ; Tue, 10 May 2022 15:20:17 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 32AFD202699A; Tue, 10 May 2022 15:20:17 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF5842024CBB for ; Tue, 10 May 2022 15:20:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196030; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=2uv82aPVNpvWt496u+aBX/4V/GJQj3E+eem4lkdrom8=; b=eBZOrdLyTGzGV4Bu97b8RetEfdEgDyCltvHIUB0/ZDhJPQ80+sxbKp7FUcFfvMbndN3GlH O1LtmM25DKkkmExpg2Jld5ohEQiSz05zY7z4gHn+BbUgCHYYj7/LQoDUFX0J2b8Q0rYqgp SpN2RpoIGxF/lgaxrWdJyPH67XWjdGQ= X-MC-Unique: JOAEObWTP8afHrRom_SLdQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/37] qemu_fd: Add validation before transferring file descriptors Date: Tue, 10 May 2022 17:19:38 +0200 Message-Id: <0cffcea59e484877765f836c90e3375243bca32b.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196032066100003 Content-Type: text/plain; charset="utf-8" Add validation to the transfer step to make the adding step more simple for easier cleanup paths. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_fd.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/qemu/qemu_fd.c b/src/qemu/qemu_fd.c index 1af8932bdd..284e77ba2b 100644 --- a/src/qemu/qemu_fd.c +++ b/src/qemu/qemu_fd.c @@ -65,6 +65,30 @@ qemuFDPassFree(qemuFDPass *fdpass) } +static int +qemuFDPassValidate(qemuFDPass *fdpass) +{ + size_t i; + + if (!fdpass->useFDSet && + fdpass->nfds > 1) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("direct FD passing supports only 1 file descripto= r")); + return -1; + } + + for (i =3D 0; i < fdpass->nfds; i++) { + if (fdpass->fds[i].fd < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("invalid file descriptor")); + return -1; + } + } + + return 0; +} + + /** * qemuFDPassNew: * @prefix: prefix used for naming the passed FDs @@ -186,6 +210,9 @@ qemuFDPassTransferCommand(qemuFDPass *fdpass, if (!fdpass) return 0; + if (qemuFDPassValidate(fdpass) < 0) + return -1; + for (i =3D 0; i < fdpass->nfds; i++) { virCommandPassFD(cmd, fdpass->fds[i].fd, VIR_COMMAND_PASS_FD_CLOSE= _PARENT); @@ -229,6 +256,9 @@ qemuFDPassTransferMonitor(qemuFDPass *fdpass, if (!fdpass) return 0; + if (qemuFDPassValidate(fdpass) < 0) + return -1; + for (i =3D 0; i < fdpass->nfds; i++) { if (fdpass->useFDSet) { qemuMonitorAddFdInfo fdsetinfo; @@ -274,6 +304,9 @@ qemuFDPassTransferMonitorFake(qemuFDPass *fdpass) if (!fdpass) return 0; + if (qemuFDPassValidate(fdpass) < 0) + return -1; + if (fdpass->useFDSet) { fdpass->path =3D g_strdup_printf("/dev/fdset/monitor-fake"); } else { --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196029; cv=none; d=zohomail.com; s=zohoarc; b=bFO3VsAkEzFCU4u8rgTeuvnsRtvO7cOtZbJfCiE3Ig0pKsQ/iIqsgtDUJldKMx16LGVrKmO/C3zkZgRK1aaukpcRwBGljRA4uD0c0ThkcjmqnaNLRwgz8UjolJD5YKHt1DkWKsfyeM3afY+PS6I+j9vAQQdZXtRVi3rjkxQxXRU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196029; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6bJFeuMl05BPGwGRR8MruszZEl3jUUFKApkRapAuVTc=; b=mTWOzBRcrpkv1o5/PDyizJDbJ9N5TXaUF+vRHnVaocxNpoRv1mXpn1+tRuUoqa+URrLZAT3R7qjuf7/sFraWQ+SEw7g0wOT7hcNopnBKgIM3TsLp6LxPptLsFvLQlns24EXWyeGI9FRVDJNdx4seIi0GHrCx1gVhjPNCrZFrsMY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1652196029365665.2191949944802; Tue, 10 May 2022 08:20:29 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-483-tTfdmJnlPnylzE82lPwKjA-1; Tue, 10 May 2022 11:20:24 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B013E8087BA; Tue, 10 May 2022 15:20:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A1FF40CFD27; Tue, 10 May 2022 15:20:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BE22A1947055; Tue, 10 May 2022 15:20:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7B0FA1947077 for ; Tue, 10 May 2022 15:20:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 59D402024CC8; Tue, 10 May 2022 15:20:18 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 811CF202699A for ; Tue, 10 May 2022 15:20:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196028; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=6bJFeuMl05BPGwGRR8MruszZEl3jUUFKApkRapAuVTc=; b=H1Iu70wQuPXRq1TDoaRTJjjKPlC19fDorxFrZNnKHGbT+AY+hZA7dnMtjTiUX2cAJKh2N0 YdCJDzfusslD3a9jgJymrxqvlhb4J1wgB7Z6xNufF5xdTH3pAqX85QiRwNsc8Cr/oa/Pti nvLGCiDlOm3JHnuwO/PH76n6ned68X8= X-MC-Unique: tTfdmJnlPnylzE82lPwKjA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/37] qemu_fd: Remove error checking from qemuFDPassAddFD Date: Tue, 10 May 2022 17:19:39 +0200 Message-Id: <8154fcef9e2613566acf61137846bdb3d11d161a.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196030058100001 Content-Type: text/plain; charset="utf-8" It's effectively replaced by checks in qemuFDPassTransfer. This will simplify cleanup paths on constructing the qemuFDPass object when FDs are being handled. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 13 ++++--------- src/qemu/qemu_fd.c | 20 +------------------- src/qemu/qemu_fd.h | 2 +- src/qemu/qemu_process.c | 9 +++------ tests/testutilsqemu.c | 6 ++---- 5 files changed, 11 insertions(+), 39 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 30671df4f2..3032cbc623 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4927,10 +4927,7 @@ qemuBuildVideoCommandLine(virCommand *cmd, chrsrc->type =3D VIR_DOMAIN_CHR_TYPE_UNIX; chrsrcpriv->sourcefd =3D qemuFDPassNewDirect(video->info.alias= , priv); - if (qemuFDPassAddFD(chrsrcpriv->sourcefd, - &videopriv->vhost_user_fd, - "-vhost-user") < 0) - return -1; + qemuFDPassAddFD(chrsrcpriv->sourcefd, &videopriv->vhost_user_f= d, "-vhost-user"); if (qemuBuildChardevCommand(cmd, chrsrc, chrAlias, priv->qemuC= aps) < 0) return -1; @@ -8763,8 +8760,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, vdpa =3D qemuFDPassNew(net->info.alias, priv); - if (qemuFDPassAddFD(vdpa, &vdpafd, "-vdpa") < 0) - return -1; + qemuFDPassAddFD(vdpa, &vdpafd, "-vdpa"); } break; @@ -9792,9 +9788,8 @@ qemuBuildTPMCommandLine(virCommand *cmd, passtpm =3D qemuFDPassNew(tpm->info.alias, priv); passcancel =3D qemuFDPassNew(tpm->info.alias, priv); - if (qemuFDPassAddFD(passtpm, &fdtpm, "-tpm") < 0 || - qemuFDPassAddFD(passcancel, &fdcancel, "-cancel") < 0) - return -1; + qemuFDPassAddFD(passtpm, &fdtpm, "-tpm"); + qemuFDPassAddFD(passcancel, &fdcancel, "-cancel"); } break; diff --git a/src/qemu/qemu_fd.c b/src/qemu/qemu_fd.c index 284e77ba2b..84e9d2bfdf 100644 --- a/src/qemu/qemu_fd.c +++ b/src/qemu/qemu_fd.c @@ -159,37 +159,19 @@ qemuFDPassNewDirect(const char *prefix, * @suffix is used to build the name of the file descriptor by concatenati= ng * it with @prefix passed to qemuFDPassNew. @suffix may be NULL, in which = case * it's considered to be an empty string. - * - * Returns 0 on success, -1 on error (when attempting to pass multiple FDs= ) using - * the 'direct' method. */ -int +void qemuFDPassAddFD(qemuFDPass *fdpass, int *fd, const char *suffix) { struct qemuFDPassFD newfd =3D { .fd =3D *fd }; - if (newfd.fd < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("invalid file descriptor")); - return -1; - } - - if (!fdpass->useFDSet && - fdpass->nfds >=3D 1) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("direct FD passing supports only 1 file descripto= r")); - return -1; - } - *fd =3D -1; newfd.opaque =3D g_strdup_printf("%s%s", fdpass->prefix, NULLSTR_EMPTY= (suffix)); VIR_APPEND_ELEMENT(fdpass->fds, fdpass->nfds, newfd); - - return 0; } diff --git a/src/qemu/qemu_fd.h b/src/qemu/qemu_fd.h index db16d77ecc..ef35daba8c 100644 --- a/src/qemu/qemu_fd.h +++ b/src/qemu/qemu_fd.h @@ -34,7 +34,7 @@ qemuFDPass * qemuFDPassNewDirect(const char *prefix, void *dompriv); -int +void qemuFDPassAddFD(qemuFDPass *fdpass, int *fd, const char *suffix); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b0b00eb0a2..39ed10ee41 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6842,8 +6842,7 @@ qemuProcessPrepareHostBackendChardevOne(virDomainDevi= ceDef *dev, charpriv->sourcefd =3D qemuFDPassNew(devalias, data->priv); - if (qemuFDPassAddFD(charpriv->sourcefd, &sourcefd, "-source") < 0) - return -1; + qemuFDPassAddFD(charpriv->sourcefd, &sourcefd, "-source"); } break; @@ -6862,8 +6861,7 @@ qemuProcessPrepareHostBackendChardevOne(virDomainDevi= ceDef *dev, charpriv->sourcefd =3D qemuFDPassNewDirect(devalias, data->pri= v); - if (qemuFDPassAddFD(charpriv->sourcefd, &sourcefd, "-source") = < 0) - return -1; + qemuFDPassAddFD(charpriv->sourcefd, &sourcefd, "-source"); } break; @@ -6890,8 +6888,7 @@ qemuProcessPrepareHostBackendChardevOne(virDomainDevi= ceDef *dev, charpriv->logfd =3D qemuFDPassNew(devalias, data->priv); - if (qemuFDPassAddFD(charpriv->logfd, &logfd, "-log") < 0) - return -1; + qemuFDPassAddFD(charpriv->logfd, &logfd, "-log"); } return 0; diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index d57f982c37..44443d8585 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -1083,8 +1083,7 @@ testQemuPrepareHostBackendChardevOne(virDomainDeviceD= ef *dev, else charpriv->sourcefd =3D qemuFDPassNewDirect(devalias, priv); - if (qemuFDPassAddFD(charpriv->sourcefd, &fakesourcefd, "-source") = < 0) - return -1; + qemuFDPassAddFD(charpriv->sourcefd, &fakesourcefd, "-source"); } if (chardev->logfile) { @@ -1095,8 +1094,7 @@ testQemuPrepareHostBackendChardevOne(virDomainDeviceD= ef *dev, charpriv->logfd =3D qemuFDPassNew(devalias, priv); - if (qemuFDPassAddFD(charpriv->logfd, &fd, "-log") < 0) - return -1; + qemuFDPassAddFD(charpriv->logfd, &fd, "-log"); } return 0; --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196034; cv=none; d=zohomail.com; s=zohoarc; b=Z1zzFywvxnYfQRLaqu6pMfjpSaZaKVCM3Ky+jmcjK6XM8kluqRFzdZNgzj2+mUuiMdGWYhBtHnswhqDkCx3TOzvi7AeGurBJRU8ljkeGAdqeJsQ7cNg4H3ZV9D379rA08Y6FPl0gFEr/ehDJYYcEuacDvmISZGeR9iDUlV/zUlw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196034; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LgIgk68oSsQgGAqQTjf68FxZQWJXAuEIvL1pOqto2xc=; b=gGwgesmGSwlNY7hG0KCn+oc+i1Ah9QaUmRL4gk/hGkBbs4mz5j1JV60PyBxjhYe6/gaWWM+/qQD+yXqwGZuqIYfs1yoERAEqXkVsXs9g+gt+FwADYQRsuW3bS5Ba5wQY1qB+QW9LSNksh2h5B4ktwhQB/E4EoGbeVPsvgTCCfec= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1652196034494300.7387783917542; Tue, 10 May 2022 08:20:34 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-463-865rO3ijNmilFi5rOkbEtQ-1; Tue, 10 May 2022 11:20:28 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8EFA685A5A8; Tue, 10 May 2022 15:20:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 755CC20296A7; Tue, 10 May 2022 15:20:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0D17D194706D; Tue, 10 May 2022 15:20:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5037D194704D for ; Tue, 10 May 2022 15:20:19 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 42DE9202699A; Tue, 10 May 2022 15:20:19 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB6202024CBB for ; Tue, 10 May 2022 15:20:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196033; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=LgIgk68oSsQgGAqQTjf68FxZQWJXAuEIvL1pOqto2xc=; b=WQEnwastQ3ONwS0NFVweiXxb/cD+0FpGj7D4A7+EXNCEnUp/ZnF63Bp0Dl2fVQ1knmV2vH Eo9x4ToVlBjvh7Nd/kJnc/yfoRdTlWhiThqjd50HrQU95KA7nigl9ROgzkMgJQRTUAg3uQ BR3gsdLGBRADUoOfpX9vfqB44Sxtmx8= X-MC-Unique: 865rO3ijNmilFi5rOkbEtQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/37] qemuDomainAttachNetDevice: Use 'qemuFDPass' for the vdpa file descriptor Date: Tue, 10 May 2022 17:19:40 +0200 Message-Id: <407271f56c1d1deb849645d328c8a36c220dd6b3.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196036087100007 Content-Type: text/plain; charset="utf-8" We use the qemuFDPass infrastructure when building the command line, refactor the monitor too. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 274f47c25d..62cfc29a16 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1184,8 +1184,8 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, virErrorPtr originalError =3D NULL; g_autofree char *slirpfdName =3D NULL; int slirpfd =3D -1; - g_autofree char *vdpafdName =3D NULL; int vdpafd =3D -1; + g_autoptr(qemuFDPass) vdpa =3D NULL; char **tapfdName =3D NULL; int *tapfd =3D NULL; size_t tapfdSize =3D 0; @@ -1394,6 +1394,10 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, if ((vdpafd =3D qemuInterfaceVDPAConnect(net)) < 0) goto cleanup; + + vdpa =3D qemuFDPassNew(net->info.alias, priv); + + qemuFDPassAddFD(vdpa, &vdpafd, "-vdpa"); break; case VIR_DOMAIN_NET_TYPE_SERVER: @@ -1455,24 +1459,15 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); - if (vdpafd > 0) { - /* vhost-vdpa only accepts a filename. We can pass an open fd by - * filename if we add the fd to an fdset and then pass a filename = of - * /dev/fdset/$FDSETID. */ - qemuMonitorAddFdInfo fdinfo; - if (qemuMonitorAddFileHandleToSet(priv->mon, vdpafd, -1, - net->data.vdpa.devicepath, - &fdinfo) < 0) { - qemuDomainObjExitMonitor(vm); - goto cleanup; - } - vdpafdName =3D g_strdup_printf("/dev/fdset/%d", fdinfo.fdset); + if (qemuFDPassTransferMonitor(vdpa, priv->mon) < 0) { + qemuDomainObjExitMonitor(vm); + goto cleanup; } if (!(netprops =3D qemuBuildHostNetProps(net, tapfdName, tapfdSize, vhostfdName, vhostfdSize, - slirpfdName, vdpafdName))) { + slirpfdName, qemuFDPassGetPath(= vdpa)))) { qemuDomainObjExitMonitor(vm); goto cleanup; } --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196063; cv=none; d=zohomail.com; s=zohoarc; b=gDK+6fMpIesOJjFNbmyY6yPI9jQ9c0dlRcVlPcWnQuzFeKiP/4wUg+UDEYcr3iGq7Wakw8H55T82vre74c6IqhyxfjJyA7BPLW3cRh2yUis5RyYLKb1yOgwF2a4Zph/gKlzfkepWGf33nesxAXl2LAxDjCGbRFNLQSnovRAh7Hs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196063; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DX59h3pnFWvTkTBTNlVWPKEJyI1SQPZPPj37xPfcRHM=; b=kMKsYWD3veW5eJIwMVgOFt80jwT2vlYtrevAwBXXD2mkPHCcu+X4Tm9ARVxNJoOgUNfZmTxld+TYxDl3NbBcdcKdbAa6ZzXub9s7hj0DxFhpCfShMIrpfNrb2JL5oi8fI5NG1R8wCla+XZZ5/wsJrsonsxUzuAZVuc/Osgdwfqc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1652196063364419.59890983946127; Tue, 10 May 2022 08:21:03 -0700 (PDT) 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-336-QWh5bIbjNhmFrYc4ee9nZQ-1; Tue, 10 May 2022 11:20:55 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 13362293248B; Tue, 10 May 2022 15:20:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id F277340D0165; Tue, 10 May 2022 15:20:21 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BF62B1947055; Tue, 10 May 2022 15:20:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4217D1947066 for ; Tue, 10 May 2022 15:20:20 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3009920296A7; Tue, 10 May 2022 15:20:20 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DF1A2024CDA for ; Tue, 10 May 2022 15:20:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196062; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=DX59h3pnFWvTkTBTNlVWPKEJyI1SQPZPPj37xPfcRHM=; b=U4Fe0RMXU7PclDJJRcxfjMnmTRaSnCE5wLjWhVkqYDNJRYM3bnGEg22fjxDbdct+NfDMYO Cc8jx6Zp1PiA0kMRIB0k2+ZHwH0ma/h0ELepmqGTdomlB2xHRlB/7nzjI+CJpGLh0CCgiZ y6ncSgoUwKqVABUyFJrZYOXRC74jy3U= X-MC-Unique: QWh5bIbjNhmFrYc4ee9nZQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/37] qemu: monitor: Don't parse actual fd's from query-fdsets/add-fd replies Date: Tue, 10 May 2022 17:19:41 +0200 Message-Id: <7c4c01cfb4d089e17b4b0c69003e3833849ca46a.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196064175100001 Content-Type: text/plain; charset="utf-8" Libvirt doesn't use the returned value and in fact there's nothing we could even do with them. Avoid parsing and storing them. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor.h | 2 -- src/qemu/qemu_monitor_json.c | 12 ------------ 2 files changed, 14 deletions(-) diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 5c2a749282..e6a50e73f7 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -943,7 +943,6 @@ int qemuMonitorGraphicsRelocate(qemuMonitor *mon, typedef struct _qemuMonitorAddFdInfo qemuMonitorAddFdInfo; struct _qemuMonitorAddFdInfo { - int fd; int fdset; }; int @@ -959,7 +958,6 @@ qemuMonitorRemoveFdset(qemuMonitor *mon, typedef struct _qemuMonitorFdsetFdInfo qemuMonitorFdsetFdInfo; struct _qemuMonitorFdsetFdInfo { - int fd; char *opaque; }; typedef struct _qemuMonitorFdsetInfo qemuMonitorFdsetInfo; diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 9e611e93e8..659d957b04 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3606,12 +3606,6 @@ qemuAddfdInfoParse(virJSONValue *msg, return -1; } - if (virJSONValueObjectGetNumberInt(returnObj, "fd", &fdinfo->fd) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing or invalid fd in add-fd response")); - return -1; - } - if (virJSONValueObjectGetNumberInt(returnObj, "fdset-id", &fdinfo->fds= et) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing or invalid fdset-id in add-fd response")= ); @@ -3706,12 +3700,6 @@ qemuMonitorJSONQueryFdsetsParse(virJSONValue *msg, return -1; } - if (virJSONValueObjectGetNumberInt(fdentry, "fd", &fdinfo->fd)= < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("query-fdsets return data missing 'fd'")); - return -1; - } - /* opaque is optional and may be missing */ fdinfo->opaque =3D g_strdup(virJSONValueObjectGetString(fdentr= y, "opaque")); } --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196036; cv=none; d=zohomail.com; s=zohoarc; b=Quaks/iAX2PXhqIye6hcuPGu5EHkEfnEiZvDV8omtjuGcPpM5FoCQCHKsNqmx4/Lf3UrL606LM/FZ3o5x7i0MPmgeJyHaaJcBpQL+jylsOfY3KX407DuN+DTaD/WRPwT7gGDsgb8Gk8LHTcXk+jjrg4q3oleM23UkyWRH9uv+U0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196036; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fV1KH0xVj5a6Rwq1IpOwXuJ1l0SmWYVpkl7CFqDWK5c=; b=cS1nHrhH4UovpTfsh6K846Kt9A8zwdsDHtJePSQ61JY/UX/EDQf9aXCWhZYKiBO0EZcjvESIUQlceDmXgWWJxJI4OexTypYRvxNrOYrgnyV+foMDwrZ8GK2XHx0lWNMl6i0wDNS/xl8hSrP6XYrDcH9LdZHgbWK5KDErf+AxZhE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 16521960363411003.6054878282133; Tue, 10 May 2022 08:20:36 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-662-YMTmmeXrMV-gvnbFxjyLGg-1; Tue, 10 May 2022 11:20:29 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AA7B3185A794; Tue, 10 May 2022 15:20:23 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 97C2314E0435; Tue, 10 May 2022 15:20:23 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 627811947062; Tue, 10 May 2022 15:20:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 58BF01947063 for ; Tue, 10 May 2022 15:20:22 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 20F802024CDA; Tue, 10 May 2022 15:20:22 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BB65202699A for ; Tue, 10 May 2022 15:20:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196034; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=fV1KH0xVj5a6Rwq1IpOwXuJ1l0SmWYVpkl7CFqDWK5c=; b=IUBYYba1wBWn2h9sT3wHFf9CgtAaM0MQaT0xqAXW4G/jeF/gqyVt1jrOAXxWJJziV4Yybm owsoIOMgaHC7uhJTOPJ6092IrngijPrvJR/4e4yPT8QmlbgXtx67fUTf2huCe3Ro0Le66m P5jeNRb1y42ZVziIPn9LtRZ8uB40Nto= X-MC-Unique: YMTmmeXrMV-gvnbFxjyLGg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/37] qemuMonitorJSONQueryFdsets: Ensure that JSON arrays are valid before using them Date: Tue, 10 May 2022 17:19:42 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196038102100010 Content-Type: text/plain; charset="utf-8" The code didn't check that the reply value is an array and that the 'fds' array is present. This could lead to a crash if qemu wouldn't return an array in those places. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor_json.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 659d957b04..6939eaea17 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3685,23 +3685,24 @@ qemuMonitorJSONQueryFdsetsParse(virJSONValue *msg, } - fdarray =3D virJSONValueObjectGetArray(entry, "fds"); - fdsetinfo->nfds =3D virJSONValueArraySize(fdarray); - if (fdsetinfo->nfds > 0) - fdsetinfo->fds =3D g_new0(qemuMonitorFdsetFdInfo, fdsetinfo->n= fds); - - for (j =3D 0; j < fdsetinfo->nfds; j++) { - qemuMonitorFdsetFdInfo *fdinfo =3D &fdsetinfo->fds[j]; - virJSONValue *fdentry; - - if (!(fdentry =3D virJSONValueArrayGet(fdarray, j))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("query-fdsets return data missing fd arra= y element")); - return -1; + if ((fdarray =3D virJSONValueObjectGetArray(entry, "fds"))) { + fdsetinfo->nfds =3D virJSONValueArraySize(fdarray); + if (fdsetinfo->nfds > 0) + fdsetinfo->fds =3D g_new0(qemuMonitorFdsetFdInfo, fdsetinf= o->nfds); + + for (j =3D 0; j < fdsetinfo->nfds; j++) { + qemuMonitorFdsetFdInfo *fdinfo =3D &fdsetinfo->fds[j]; + virJSONValue *fdentry; + + if (!(fdentry =3D virJSONValueArrayGet(fdarray, j))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-fdsets return data missing fd = array element")); + return -1; + } + + /* opaque is optional and may be missing */ + fdinfo->opaque =3D g_strdup(virJSONValueObjectGetString(fd= entry, "opaque")); } - - /* opaque is optional and may be missing */ - fdinfo->opaque =3D g_strdup(virJSONValueObjectGetString(fdentr= y, "opaque")); } } @@ -3723,7 +3724,7 @@ int qemuMonitorJSONQueryFdsets(qemuMonitor *mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) return -1; - if (qemuMonitorJSONCheckError(cmd, reply) < 0) + if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) return -1; if (qemuMonitorJSONQueryFdsetsParse(reply, fdsets) < 0) --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196069; cv=none; d=zohomail.com; s=zohoarc; b=Uu9n9H6bSGVaVhsDsG0B8dmLjs8/qq9zpYcel1dGkDisfm1pYaHHUR4+wUtnzWwsH1dCSPH5aUoOGKeWWwh6Ct5DgNYjyErNB5rI5vy+ov17X7c5TLODwfoVUXIX5MQrRp51nWVoXchwPHRyelYf1V6kXm93RUw3CB01lHkZm3s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196069; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wXBlG8r76r3eNsoI5qeck297jjjrqQ7gDt2FXmbdU/k=; b=PpKwEnHPCoy2aENw+Hug9i38/2rL2WaRYk/gUgb8JJ5ajCwEMyn/OJdYLxCDRAzeFzE7Jxg6bR6FRSEZpovg5xBocNmMuQxP4CL0qTr3yDy4vdKejifhXOOMmTcy4r+H02bBz/x88BCs+xIw2/HmxUpoqX7f6a9up3i1I6bgLHU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1652196069986595.7688525748086; Tue, 10 May 2022 08:21:09 -0700 (PDT) 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-653-vFIvGwNUOsaRR9LGYWuepQ-1; Tue, 10 May 2022 11:20:31 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6E4781C06EDE; Tue, 10 May 2022 15:20:24 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4EB42463E1C; Tue, 10 May 2022 15:20:24 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 20BB41947055; Tue, 10 May 2022 15:20:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 61637194705E for ; Tue, 10 May 2022 15:20:23 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 547732024CDA; Tue, 10 May 2022 15:20:23 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 82EA22024CBD for ; Tue, 10 May 2022 15:20:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196069; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=wXBlG8r76r3eNsoI5qeck297jjjrqQ7gDt2FXmbdU/k=; b=S/S3+avrgpBe9kxZd1xjZut8cPfmKfjJpU44dKJAbXZL58fZjhVd4lMJi2sq2850Iagrpu NUcsBDiC/0ne8k9aUQz7hGbFU0XNdbnhMvfe9FNZapnBOp1yaM+LjIgRlLQVYEblyZ0c+9 cRg2l87llQUpaNMlkoq01lIa0Mr2TLM= X-MC-Unique: vFIvGwNUOsaRR9LGYWuepQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/37] qemu: domain: Store and update 'fdsetindex' across libvirtd restarts Date: Tue, 10 May 2022 17:19:43 +0200 Message-Id: <9c9a13a01fddbaa6a791d178771f06f609bae65b.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196070269100001 Content-Type: text/plain; charset="utf-8" While 'add-fd' qmp command gives the possibility to find an unused fdset ID when hot-adding fdsets, such usage is extremely inconvenient. This patch allows us to track the used fdset id so that we can avoid the need to check results and thus employ simpler code flow when hot-adding devices which use FD passing. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 5 +++ src/qemu/qemu_domain.h | 3 +- src/qemu/qemu_process.c | 31 +++++++++++++++++++ .../qemustatusxml2xmldata/backup-pull-in.xml | 1 + .../blockjob-blockdev-in.xml | 1 + .../blockjob-mirror-in.xml | 1 + .../migration-in-params-in.xml | 1 + .../migration-out-nbd-bitmaps-in.xml | 1 + .../migration-out-nbd-out.xml | 1 + .../migration-out-nbd-tls-out.xml | 1 + .../migration-out-params-in.xml | 1 + tests/qemustatusxml2xmldata/modern-in.xml | 1 + tests/qemustatusxml2xmldata/upgrade-out.xml | 1 + .../qemustatusxml2xmldata/vcpus-multi-in.xml | 1 + 14 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 7974cdb00b..a726e2624a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2372,6 +2372,8 @@ qemuDomainObjPrivateXMLFormat(virBuffer *buf, if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) virBufferAsprintf(buf, "\n", priv->noden= ameindex); + virBufferAsprintf(buf, "\n", priv->fdsetindex); + if (priv->memPrealloc) virBufferAddLit(buf, "\n"); @@ -3100,6 +3102,9 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, goto error; } + if (virXPathUInt("string(./fdset/@index)", ctxt, &priv->fdsetindex) = =3D=3D 0) + priv->fdsetindexParsed =3D true; + priv->memPrealloc =3D virXPathBoolean("boolean(./memPrealloc)", ctxt) = =3D=3D 1; return 0; diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index c7125722e0..358f1c163f 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -204,8 +204,9 @@ struct _qemuDomainObjPrivate { /* counter for generating node names for qemu disks */ unsigned long long nodenameindex; - /* counter for generating IDs of fdsets - only relevant during startup= */ + /* counter for generating IDs of fdsets */ unsigned int fdsetindex; + bool fdsetindexParsed; /* qemuProcessStartCPUs stores the reason for starting vCPUs here for = the * RESUME event handler to use it */ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 39ed10ee41..be10d2f3ac 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2261,6 +2261,34 @@ qemuRefreshPRManagerState(virQEMUDriver *driver, } +static int +qemuProcessRefreshFdsetIndex(virDomainObj *vm) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + g_autoptr(qemuMonitorFdsets) fdsets =3D NULL; + size_t i; + int rc; + + /* if the previous index was in the status XML we don't need to update= it */ + if (priv->fdsetindexParsed) + return 0; + + qemuDomainObjEnterMonitor(priv->driver, vm); + rc =3D qemuMonitorQueryFdsets(priv->mon, &fdsets); + qemuDomainObjExitMonitor(vm); + + if (rc < 0) + return -1; + + for (i =3D 0; i < fdsets->nfdsets; i++) { + if (fdsets->fdsets[i].id >=3D priv->fdsetindex) + priv->fdsetindex =3D fdsets->fdsets[i].id + 1; + } + + return 0; +} + + static void qemuRefreshRTC(virQEMUDriver *driver, virDomainObj *vm) @@ -8923,6 +8951,9 @@ qemuProcessReconnect(void *opaque) if (qemuRefreshPRManagerState(driver, obj) < 0) goto error; + if (qemuProcessRefreshFdsetIndex(obj) < 0) + goto error; + qemuProcessReconnectCheckMemAliasOrderMismatch(obj); if (qemuConnectAgent(driver, obj) < 0) diff --git a/tests/qemustatusxml2xmldata/backup-pull-in.xml b/tests/qemusta= tusxml2xmldata/backup-pull-in.xml index 59c934d4f7..e7fdc6c478 100644 --- a/tests/qemustatusxml2xmldata/backup-pull-in.xml +++ b/tests/qemustatusxml2xmldata/backup-pull-in.xml @@ -234,6 +234,7 @@ + diff --git a/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml b/tests/q= emustatusxml2xmldata/blockjob-blockdev-in.xml index 52024f242c..b62b3149c2 100644 --- a/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml +++ b/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml @@ -233,6 +233,7 @@ + diff --git a/tests/qemustatusxml2xmldata/blockjob-mirror-in.xml b/tests/qem= ustatusxml2xmldata/blockjob-mirror-in.xml index 00c8e69adc..73fe437f87 100644 --- a/tests/qemustatusxml2xmldata/blockjob-mirror-in.xml +++ b/tests/qemustatusxml2xmldata/blockjob-mirror-in.xml @@ -22,6 +22,7 @@ + -2 diff --git a/tests/qemustatusxml2xmldata/migration-in-params-in.xml b/tests= /qemustatusxml2xmldata/migration-in-params-in.xml index f4bc5753c4..8b0878c82e 100644 --- a/tests/qemustatusxml2xmldata/migration-in-params-in.xml +++ b/tests/qemustatusxml2xmldata/migration-in-params-in.xml @@ -256,6 +256,7 @@ + -2 diff --git a/tests/qemustatusxml2xmldata/migration-out-nbd-bitmaps-in.xml b= /tests/qemustatusxml2xmldata/migration-out-nbd-bitmaps-in.xml index c88996f923..7d55db0996 100644 --- a/tests/qemustatusxml2xmldata/migration-out-nbd-bitmaps-in.xml +++ b/tests/qemustatusxml2xmldata/migration-out-nbd-bitmaps-in.xml @@ -343,6 +343,7 @@ + diff --git a/tests/qemustatusxml2xmldata/migration-out-nbd-out.xml b/tests/= qemustatusxml2xmldata/migration-out-nbd-out.xml index 039dcacc58..1a918c0b5a 100644 --- a/tests/qemustatusxml2xmldata/migration-out-nbd-out.xml +++ b/tests/qemustatusxml2xmldata/migration-out-nbd-out.xml @@ -259,6 +259,7 @@ + -2 diff --git a/tests/qemustatusxml2xmldata/migration-out-nbd-tls-out.xml b/te= sts/qemustatusxml2xmldata/migration-out-nbd-tls-out.xml index 3d1ddd5771..87c67f8300 100644 --- a/tests/qemustatusxml2xmldata/migration-out-nbd-tls-out.xml +++ b/tests/qemustatusxml2xmldata/migration-out-nbd-tls-out.xml @@ -288,6 +288,7 @@ + -2 diff --git a/tests/qemustatusxml2xmldata/migration-out-params-in.xml b/test= s/qemustatusxml2xmldata/migration-out-params-in.xml index cd9dbccd3a..73ac09fb92 100644 --- a/tests/qemustatusxml2xmldata/migration-out-params-in.xml +++ b/tests/qemustatusxml2xmldata/migration-out-params-in.xml @@ -270,6 +270,7 @@ + -2 diff --git a/tests/qemustatusxml2xmldata/modern-in.xml b/tests/qemustatusxm= l2xmldata/modern-in.xml index cc5fd1cb74..7759034f7a 100644 --- a/tests/qemustatusxml2xmldata/modern-in.xml +++ b/tests/qemustatusxml2xmldata/modern-in.xml @@ -261,6 +261,7 @@ + -2 diff --git a/tests/qemustatusxml2xmldata/upgrade-out.xml b/tests/qemustatus= xml2xmldata/upgrade-out.xml index 5218092cb9..ac2ffeddc2 100644 --- a/tests/qemustatusxml2xmldata/upgrade-out.xml +++ b/tests/qemustatusxml2xmldata/upgrade-out.xml @@ -258,6 +258,7 @@ + -2 diff --git a/tests/qemustatusxml2xmldata/vcpus-multi-in.xml b/tests/qemusta= tusxml2xmldata/vcpus-multi-in.xml index 7f0208453f..0b8bc37c15 100644 --- a/tests/qemustatusxml2xmldata/vcpus-multi-in.xml +++ b/tests/qemustatusxml2xmldata/vcpus-multi-in.xml @@ -308,6 +308,7 @@ + -2 --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196038; cv=none; d=zohomail.com; s=zohoarc; b=OhHlxTFOgj8gSK9FL81dceZMqCQTJ/lUYwu3xOIrsq4i73HGtdDZO5a71hL1hkZBSxAoqFnV48zEAWcJZbQZf/AKmuJfRCGfJh/Tt4VfN+VpcagWs6eRTshby0WGQNHqgylTKjAlPihOWH9LoOW5avpGwo9IT8h0zz3rkkXvpgM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196038; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=60coCetVw1mUulpFxrkzCi0wZFZmd0j7vrpN+SDbXnk=; b=ST7WTXqLdb3J5oveyTPCjxYlwIsx8aT/+QtHrPvBS8xcK9jhS88/tKFsi9D6ZB9Stou7qbF2W+XSgdiJysmUPkzsxLLfcGXSaPTkscAJFYXIyNpsj+prMZbO7nGnd6iwuTDbSMy1ezSo6XfycmJ8YK9hub7RpLHc5LHStQPTwQc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1652196038533115.27586807363036; Tue, 10 May 2022 08:20:38 -0700 (PDT) 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-625-U4RnqqSPNCewcSfMXZy-0g-1; Tue, 10 May 2022 11:20:35 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9D2722919EA3; Tue, 10 May 2022 15:20:26 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8ADB0C26E9C; Tue, 10 May 2022 15:20:26 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 641961947055; Tue, 10 May 2022 15:20:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9B2501947055 for ; Tue, 10 May 2022 15:20:24 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8A605200C0DD; Tue, 10 May 2022 15:20:24 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id B2AD52024CCA for ; Tue, 10 May 2022 15:20:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196037; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=60coCetVw1mUulpFxrkzCi0wZFZmd0j7vrpN+SDbXnk=; b=Z2z/xohxuAQXO/9+vCmTXmY1jXMhSYegzJ4n5493o1ECkz3Hz///IDBIX3V5QfuIWJpSUU suWVEeikQSgOFrno+CMET4CTsQ4PAGkfQXf3gQJ8Yh+ND4f3iPNhppBGC3VubvlpP5yZ9/ ID17Rnf/7wnfpgfBKv+dvSMvm0yFhc8= X-MC-Unique: U4RnqqSPNCewcSfMXZy-0g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/37] qemu_fd: Don't rely on fdset id allocation by qemu Date: Tue, 10 May 2022 17:19:44 +0200 Message-Id: <59fd8a8591916ac2edee5a7fb168e9a42e5a6fcf.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196040093100013 Content-Type: text/plain; charset="utf-8" If we use our own fdset ID when hot-adding a fdset we can vastly simplify our internals. As a stop-gap when a fdset would be added behind libvirt's back we'll validated that the fdset to be added is not yet used. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_fd.c | 61 +++++++++++++++---------------------- src/qemu/qemu_fd.h | 3 -- tests/qemuhotplugtest.c | 1 + tests/qemumonitorjsontest.c | 7 ----- 4 files changed, 25 insertions(+), 47 deletions(-) diff --git a/src/qemu/qemu_fd.c b/src/qemu/qemu_fd.c index 84e9d2bfdf..fe81cc650f 100644 --- a/src/qemu/qemu_fd.c +++ b/src/qemu/qemu_fd.c @@ -111,8 +111,12 @@ qemuFDPassNew(const char *prefix, fdpass->prefix =3D g_strdup(prefix); fdpass->useFDSet =3D true; - if (priv) + if (priv) { fdpass->fdSetID =3D qemuDomainFDSetIDNew(priv); + fdpass->path =3D g_strdup_printf("/dev/fdset/%u", fdpass->fdSetID); + } else { + fdpass->path =3D g_strdup_printf("/dev/fdset/monitor-fake"); + } return fdpass; } @@ -171,6 +175,9 @@ qemuFDPassAddFD(qemuFDPass *fdpass, newfd.opaque =3D g_strdup_printf("%s%s", fdpass->prefix, NULLSTR_EMPTY= (suffix)); + if (!fdpass->useFDSet) + fdpass->path =3D g_strdup(newfd.opaque); + VIR_APPEND_ELEMENT(fdpass->fds, fdpass->nfds, newfd); } @@ -232,7 +239,6 @@ int qemuFDPassTransferMonitor(qemuFDPass *fdpass, qemuMonitor *mon) { - int fdsetid =3D -1; size_t i; if (!fdpass) @@ -240,6 +246,21 @@ qemuFDPassTransferMonitor(qemuFDPass *fdpass, if (qemuFDPassValidate(fdpass) < 0) return -1; + if (fdpass->useFDSet) { + g_autoptr(qemuMonitorFdsets) fdsets =3D NULL; + + if (qemuMonitorQueryFdsets(mon, &fdsets) < 0) + return -1; + + for (i =3D 0; i < fdsets->nfdsets; i++) { + if (fdsets->fdsets[i].id =3D=3D fdpass->fdSetID) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("fdset '%u' is already in use by qemu"), + fdpass->fdSetID); + return -1; + } + } + } for (i =3D 0; i < fdpass->nfds; i++) { if (fdpass->useFDSet) { @@ -247,22 +268,15 @@ qemuFDPassTransferMonitor(qemuFDPass *fdpass, if (qemuMonitorAddFileHandleToSet(mon, fdpass->fds[i].fd, - fdsetid, + fdpass->fdSetID, fdpass->fds[i].opaque, &fdsetinfo) < 0) return -1; - - if (fdsetid =3D=3D -1) { - fdpass->fdSetID =3D fdsetid =3D fdsetinfo.fdset; - fdpass->path =3D g_strdup_printf("/dev/fdset/%u", fdsetid); - } } else { if (qemuMonitorSendFileHandle(mon, fdpass->fds[i].opaque, fdpass->fds[i].fd) < 0) return -1; - - fdpass->path =3D g_strdup(fdpass->fds[i].opaque); } fdpass->passed =3D true; @@ -272,33 +286,6 @@ qemuFDPassTransferMonitor(qemuFDPass *fdpass, } -/** - * qemuFDPassTransferMonitorFake: - * @fdpass: The fd passing helper struct - * - * Simulate as if @fdpass was passed via monitor for callers which don't - * actually wish to test that code path. - */ -int -qemuFDPassTransferMonitorFake(qemuFDPass *fdpass) -{ - - if (!fdpass) - return 0; - - if (qemuFDPassValidate(fdpass) < 0) - return -1; - - if (fdpass->useFDSet) { - fdpass->path =3D g_strdup_printf("/dev/fdset/monitor-fake"); - } else { - fdpass->path =3D g_strdup(fdpass->fds[0].opaque); - } - - return 0; -} - - /** * qemuFDPassTransferMonitorRollback: * @fdpass: The fd passing helper struct diff --git a/src/qemu/qemu_fd.h b/src/qemu/qemu_fd.h index ef35daba8c..d078d4ce5d 100644 --- a/src/qemu/qemu_fd.h +++ b/src/qemu/qemu_fd.h @@ -47,9 +47,6 @@ int qemuFDPassTransferMonitor(qemuFDPass *fdpass, qemuMonitor *mon); -int -qemuFDPassTransferMonitorFake(qemuFDPass *fdpass); - void qemuFDPassTransferMonitorRollback(qemuFDPass *fdpass, qemuMonitor *mon); diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 21302e0fce..fe8f0b58db 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -834,6 +834,7 @@ mymain(void) "device_del", QMP_DEVICE_DELETED("hostdev0") QMP_OK); DO_TEST_ATTACH("base-live", "interface-vdpa", false, true, + "query-fdsets", "{\"return\":[{\"fdset-id\":99999}]}", "add-fd", "{ \"return\": { \"fdset-id\": 1, \"fd\": 95 = }}", "netdev_add", QMP_OK, "device_add", QMP_OK); DO_TEST_DETACH("base-live", "interface-vdpa", false, false, diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index e15c8533f6..c3ee771cbb 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -725,7 +725,6 @@ qemuMonitorJSONTestAttachChardev(virDomainXMLOption *xm= lopt, { g_autoptr(virDomainChrSourceDef) chr =3D virDomainChrSourceDefNew(= xmlopt); - qemuDomainChrSourcePrivate *charpriv =3D QEMU_DOMAIN_CHR_SOURCE_PR= IVATE(chr); chr->data.file.path =3D g_strdup("/test/path"); @@ -743,12 +742,6 @@ qemuMonitorJSONTestAttachChardev(virDomainXMLOption *x= mlopt, chrdev.source =3D chr; ignore_value(testQemuPrepareHostBackendChardevOne(&dev, chr, NULL)= ); - if (qemuFDPassTransferMonitorFake(charpriv->sourcefd) < 0) - ret =3D -1; - - if (qemuFDPassTransferMonitorFake(charpriv->logfd) < 0) - ret =3D -1; - CHECK("file", false, "{'id':'alias','backend':{'type':'file','data':{'out':'/dev/= fdset/monitor-fake'," "'append':tru= e," --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196045; cv=none; d=zohomail.com; s=zohoarc; b=fm7e/BVbqOulrOK6YnmDDIjAyyukeihurWwe3DYDCPjfQr+Fp6w9ZHzV0aL8PQ/IG6InWC5BNp4emPEJshTnndMzGltsa5rUXZ+c+GmLFvigyikuA9jw2LOFFV5u9KuCRBxbSjNz0MpvcSs9u2IpPJlpSXrL88l9wwIKKMoD+wM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196045; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7kg11xRza6VBcxNpvjUapCJ/ObAjhCpfIrJQGv3kZd8=; b=jkZMes9sdsvZmtZ1K/DGK4r9pIXS5aVmo6KnIiiAB/NrvnbbwE4xEA2pRC8WDXbwAPxZPdeyfi7A53Pom00VYPY8FUmoeIewY1QsLqAB3YhzAZH/P68WWTj5xhHaGQ90mvBKtWUk1/l/SAdcZbNYdK8Y4+wdQfphUOME10VHxE8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1652196045179859.7701134345547; Tue, 10 May 2022 08:20:45 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-626-93fcm4sFNIiUS6epGFeDkQ-1; Tue, 10 May 2022 11:20:37 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E5F9218F0242; Tue, 10 May 2022 15:20:27 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDABB2024CBB; Tue, 10 May 2022 15:20:27 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id ACCEC1947055; Tue, 10 May 2022 15:20:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7C423194704D for ; Tue, 10 May 2022 15:20:25 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6E312202699A; Tue, 10 May 2022 15:20:25 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1AA820296A7 for ; Tue, 10 May 2022 15:20:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196044; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=7kg11xRza6VBcxNpvjUapCJ/ObAjhCpfIrJQGv3kZd8=; b=Wp/460rTvVHiLhTn98W/FJZeAfuYjv/mi46kMBqAGzPijt5fOH/+wy1rHtBzF76cbBQugm ol5PYxO7js6hzdsFxCE8Wn91FaZ4PNNPEfEsFTK6K6XzUqq7Ufg7hTbHGDbfZgOjAvKOht 5E92E2ohuBm9nFyOo0I+i5RGyYHNDK4= X-MC-Unique: 93fcm4sFNIiUS6epGFeDkQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/37] qemuMonitorAddFileHandleToSet: Remove return of 'qemuMonitorAddFdInfo' Date: Tue, 10 May 2022 17:19:45 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196046127100007 Content-Type: text/plain; charset="utf-8" The only caller doesn't use the fdset info any more. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_fd.c | 5 +---- src/qemu/qemu_monitor.c | 6 ++---- src/qemu/qemu_monitor.h | 7 +------ src/qemu/qemu_monitor_json.c | 37 ++++++------------------------------ src/qemu/qemu_monitor_json.h | 3 +-- 5 files changed, 11 insertions(+), 47 deletions(-) diff --git a/src/qemu/qemu_fd.c b/src/qemu/qemu_fd.c index fe81cc650f..cbdf1c938f 100644 --- a/src/qemu/qemu_fd.c +++ b/src/qemu/qemu_fd.c @@ -264,13 +264,10 @@ qemuFDPassTransferMonitor(qemuFDPass *fdpass, for (i =3D 0; i < fdpass->nfds; i++) { if (fdpass->useFDSet) { - qemuMonitorAddFdInfo fdsetinfo; - if (qemuMonitorAddFileHandleToSet(mon, fdpass->fds[i].fd, fdpass->fdSetID, - fdpass->fds[i].opaque, - &fdsetinfo) < 0) + fdpass->fds[i].opaque) < 0) return -1; } else { if (qemuMonitorSendFileHandle(mon, diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 316cff5b9b..39004201c0 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2506,7 +2506,6 @@ qemuMonitorGraphicsRelocate(qemuMonitor *mon, * @fd: file descriptor to pass to qemu * @fdset: the fdset to register this fd with, -1 to create a new fdset * @opaque: opaque data to associated with this fd - * @info: structure that will be updated with the fd and fdset returned by= qemu * * Attempts to register a file descriptor with qemu that can then be refer= enced * via the file path /dev/fdset/$FDSETID @@ -2515,8 +2514,7 @@ int qemuMonitorAddFileHandleToSet(qemuMonitor *mon, int fd, int fdset, - const char *opaque, - qemuMonitorAddFdInfo *info) + const char *opaque) { VIR_DEBUG("fd=3D%d,fdset=3D%i,opaque=3D%s", fd, fdset, opaque); @@ -2528,7 +2526,7 @@ qemuMonitorAddFileHandleToSet(qemuMonitor *mon, return -1; } - return qemuMonitorJSONAddFileHandleToSet(mon, fd, fdset, opaque, info); + return qemuMonitorJSONAddFileHandleToSet(mon, fd, fdset, opaque); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index e6a50e73f7..79d8486d08 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -941,16 +941,11 @@ int qemuMonitorGraphicsRelocate(qemuMonitor *mon, int tlsPort, const char *tlsSubject); -typedef struct _qemuMonitorAddFdInfo qemuMonitorAddFdInfo; -struct _qemuMonitorAddFdInfo { - int fdset; -}; int qemuMonitorAddFileHandleToSet(qemuMonitor *mon, int fd, int fdset, - const char *opaque, - qemuMonitorAddFdInfo *info); + const char *opaque); int qemuMonitorRemoveFdset(qemuMonitor *mon, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 6939eaea17..ddef9c6b53 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3594,34 +3594,11 @@ int qemuMonitorJSONGraphicsRelocate(qemuMonitor *mo= n, } -static int -qemuAddfdInfoParse(virJSONValue *msg, - qemuMonitorAddFdInfo *fdinfo) -{ - virJSONValue *returnObj; - - if (!(returnObj =3D virJSONValueObjectGetObject(msg, "return"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing or invalid return data in add-fd respons= e")); - return -1; - } - - if (virJSONValueObjectGetNumberInt(returnObj, "fdset-id", &fdinfo->fds= et) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing or invalid fdset-id in add-fd response")= ); - return -1; - } - - return 0; -} - - -/* if fdset is negative, qemu will create a new fdset and add the fd to th= at */ -int qemuMonitorJSONAddFileHandleToSet(qemuMonitor *mon, - int fd, - int fdset, - const char *opaque, - qemuMonitorAddFdInfo *fdinfo) +int +qemuMonitorJSONAddFileHandleToSet(qemuMonitor *mon, + int fd, + int fdset, + const char *opaque) { g_autoptr(virJSONValue) args =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; @@ -3644,12 +3621,10 @@ int qemuMonitorJSONAddFileHandleToSet(qemuMonitor *= mon, if (qemuMonitorJSONCheckError(cmd, reply) < 0) return -1; - if (qemuAddfdInfoParse(reply, fdinfo) < 0) - return -1; - return 0; } + static int qemuMonitorJSONQueryFdsetsParse(virJSONValue *msg, qemuMonitorFdsets **fdsets) diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 982fbad44e..3c442d669f 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -253,8 +253,7 @@ int qemuMonitorJSONAddFileHandleToSet(qemuMonitor *mon, int fd, int fdset, - const char *opaque, - qemuMonitorAddFdInfo *info); + const char *opaque); int qemuMonitorJSONRemoveFdset(qemuMonitor *mon, --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196074; cv=none; d=zohomail.com; s=zohoarc; b=QR6RhpQqtn3AWeX3bn7xuqZ1BFSLC3O9lsZ1535QvuhjA+g01GgIizmWTPA/TXKLH5vhUqTDg6z3uchdphlV5j87aT75+pJVcZRIgCnb9K1y8JM8LdY7Il1c0H5IMFii+2VpIXvXrJRY2eMdrPUHnOnfOa5WyFv2Cg7ZFAVIL28= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196074; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2QVRcNtHp8OB6zOXWv8zP4NlXkSVOXTb8V6hKCTgpV8=; b=BEAtggOwBTOjwyHzKBD1UMiaSauiH/AhU0ltMf6Vf0dcZoGzVISgaKTbp8b5xKd0O/h9/qLkRf+TRVv+TtfZDn/89UaK/0y9/td9f00i8tPXKlfZxKTUDCWR9jTO5ofLcPvXwy0mweh3tDwRTyHpDgrX8PyNOKG3W1+ZL9PqRic= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1652196074379524.0125729089552; Tue, 10 May 2022 08:21:14 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-271-57yeRkA-OIWXbq9fXmVGkg-1; Tue, 10 May 2022 11:20:36 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D9E3218F0279; Tue, 10 May 2022 15:20:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C635B403171; Tue, 10 May 2022 15:20:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B93041947055; Tue, 10 May 2022 15:20:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 56051194704D for ; Tue, 10 May 2022 15:20:27 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 436D320296AC; Tue, 10 May 2022 15:20:27 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE25B20296A7 for ; Tue, 10 May 2022 15:20:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196073; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=2QVRcNtHp8OB6zOXWv8zP4NlXkSVOXTb8V6hKCTgpV8=; b=I+Z1joCBPX0Vc5P1PlMTHNRJIT3cSW6PRTWMeYNcAz2i0Je8awyKGM9NONRgn9jP4gorWv WGYbTH0mQMWyaOkNXGwTn4M2JURz+XoJd2UgkgT0IkIZnf2pRIsxEMjrg3SjySU882ADkF yQEf2yk/S8UnLjUjufgNWouAIi0d7g0= X-MC-Unique: 57yeRkA-OIWXbq9fXmVGkg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/37] qemuFDPassTransferMonitor: Close local copy of the FD as soon as it's passed to qemu Date: Tue, 10 May 2022 17:19:46 +0200 Message-Id: <35cf2480bd9fd7fdd5e2f71dbbfa8332955d175b.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196076229100001 Content-Type: text/plain; charset="utf-8" We don't want to keep the FDs open more than we need to. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_fd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qemu/qemu_fd.c b/src/qemu/qemu_fd.c index cbdf1c938f..6e3a7ca491 100644 --- a/src/qemu/qemu_fd.c +++ b/src/qemu/qemu_fd.c @@ -276,6 +276,7 @@ qemuFDPassTransferMonitor(qemuFDPass *fdpass, return -1; } + VIR_FORCE_CLOSE(fdpass->fds[i].fd); fdpass->passed =3D true; } --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196390; cv=none; d=zohomail.com; s=zohoarc; b=EoFx3x+jW22linR4DLqJjIdc5+tNW8SURC17N22EMmBx0xHBLLs3dz/qcmEzG/pjgLulbU8k7DddKRiY0XwTvQnYYdmplgeomDxgKhKynkF9P7sMpaMMqffCGe62NU2CjWrreAOHT04Yx3ogIQTD5ZXGFUra91+Y1FNpgxjrEg0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196390; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8D/bxVFbEviVuAUwDC3fxSkmVReBf+t+eYtlF8lG9mA=; b=hVvZEU0m+niy8DZx+yOgfqANZwPUZxpa9snsYmqP0gmyMYIAtKw6XwbAPTeBmEBgCNqm//1y+1Tpb4chCorDaqfjZSiVfekJjpRCcPZ5z2cpF3cQ+CVZCCXoq+7OEPUFJYLtSnLg9aA5WwFR5QvKSSkovTHvVz/NDH+NmOx9y8g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1652196390269232.29408686331226; Tue, 10 May 2022 08:26:30 -0700 (PDT) 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-407-Zapfvy0uMh2PPwDFrRU9uA-1; Tue, 10 May 2022 11:20:39 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5E5062919EBB; Tue, 10 May 2022 15:20:29 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43CF8C28106; Tue, 10 May 2022 15:20:29 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 28934194706A; Tue, 10 May 2022 15:20:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3F0FA1947055 for ; Tue, 10 May 2022 15:20:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2098B202699A; Tue, 10 May 2022 15:20:28 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FBE9200C0DA for ; Tue, 10 May 2022 15:20:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196389; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=8D/bxVFbEviVuAUwDC3fxSkmVReBf+t+eYtlF8lG9mA=; b=b0uCIgJEqNfeLYMRxTOFK1OY0Yqde2whDL3zieXt+G4CNqmIWyNP9Sp0J6+kj+6SS4pR7T qeuHh/hR6Z5m+QN71WOb+/8ofCbMs1uZO2PUXbso++6wJtVFl/NVHDaEm2yzuYugLWuS9A dHYyB6kZFZcYCWyPzKiuL4O1a7zoCKE= X-MC-Unique: Zapfvy0uMh2PPwDFrRU9uA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/37] qemu: Clear 'qemuFDPass' helpers of char devices when no longer needed Date: Tue, 10 May 2022 17:19:47 +0200 Message-Id: <389d6a5b6c3edaaadfb259ef20d7ce36916a9713.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196390881100001 Content-Type: text/plain; charset="utf-8" While the FDs are closed right after use to prevent leaks, at certain point we don't need the whole helper any more. Clear them for char devices after hotplug and on start. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 2 ++ src/qemu/qemu_domain.c | 14 ++++++++++++-- src/qemu/qemu_domain.h | 3 +++ src/qemu/qemu_hotplug.c | 3 +++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3032cbc623..95632827cb 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1526,6 +1526,8 @@ qemuBuildChardevCommand(virCommand *cmd, virCommandAddArgList(cmd, "-chardev", charstr, NULL); + qemuDomainChrSourcePrivateClearFDPass(chrSourcePriv); + return 0; } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a726e2624a..2df02943bf 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -908,13 +908,23 @@ qemuDomainChrSourcePrivateNew(void) } +void +qemuDomainChrSourcePrivateClearFDPass(qemuDomainChrSourcePrivate *priv) +{ + if (!priv) + return; + + g_clear_pointer(&priv->sourcefd, qemuFDPassFree); + g_clear_pointer(&priv->logfd, qemuFDPassFree); +} + + static void qemuDomainChrSourcePrivateDispose(void *obj) { qemuDomainChrSourcePrivate *priv =3D obj; - qemuFDPassFree(priv->sourcefd); - qemuFDPassFree(priv->logfd); + qemuDomainChrSourcePrivateClearFDPass(priv); g_free(priv->tlsCertPath); diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 358f1c163f..e13c6be399 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -356,6 +356,9 @@ struct _qemuDomainChrSourcePrivate { }; +void +qemuDomainChrSourcePrivateClearFDPass(qemuDomainChrSourcePrivate *priv); + typedef struct _qemuDomainVsockPrivate qemuDomainVsockPrivate; struct _qemuDomainVsockPrivate { virObject parent; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 62cfc29a16..e8e028706b 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2293,6 +2293,9 @@ qemuDomainAttachChrDevice(virQEMUDriver *driver, if (teardowndevice && qemuDomainNamespaceTeardownChardev(vm, chr) = < 0) VIR_WARN("Unable to remove chr device from /dev"); } + + qemuDomainChrSourcePrivateClearFDPass(charpriv); + return ret; exit_monitor: --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196043; cv=none; d=zohomail.com; s=zohoarc; b=eD4W2qnqNvRMWDQDzQVBZVbw3sYC+ffb0jw/ycO/Ta7G/HyvWcog71uKV2Vd3y+co0DE5oSaF43e3BxR7R1uQ5t0UsNtyh7tatUmfCf4H8BZ3vBrrvCfCX9PeRSXdY6P/xCdg/APx4mIz0i3y3z0fV+zdvzHLrTpA37cdgTE3nw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196043; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iByRu3/H4qmS2IRplZRQZOOd5qupMAZWMAQAhiByyIM=; b=T6hW5sTrb8JIP23vnudM/9WmkXcwdhTE9hC9U5WixB+aV8jREhIppVD4MatFoGD96SV/tUkS5ZdACSXW8zblTdjsum50tkR6ma5viIeJIChLNucopTXNcoT7QesydYcV2rT8cNJ5X2Sr2eJFjmGTfkkV3ShpzHsr3582R45NC9Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1652196043268977.732017897279; Tue, 10 May 2022 08:20:43 -0700 (PDT) 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-379-o0wimTUaMSuq2i1MjmIUGg-1; Tue, 10 May 2022 11:20:39 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 47F65395AFF4; Tue, 10 May 2022 15:20:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 334E4C28109; Tue, 10 May 2022 15:20:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 14A6B1947055; Tue, 10 May 2022 15:20:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 151A3194705E for ; Tue, 10 May 2022 15:20:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id ECAEB200BCE9; Tue, 10 May 2022 15:20:28 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B4EF2024CBB for ; Tue, 10 May 2022 15:20:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196042; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=iByRu3/H4qmS2IRplZRQZOOd5qupMAZWMAQAhiByyIM=; b=FViP82DPJp0oTq2AHZWBIqTsulmlu98nj5LJED5YJcmcvpa0rEjhhrqCvQtXsRB6g+8Cgs 8MI1Osm3kgtK5lV0yeUFNGGgC6+C7htzI+UmGHHxh5g/OXSfyazPgDZOQ6gUDZpUs2NEgD btmycRzYYjA5VayKh7LyQj/qp3GwzLk= X-MC-Unique: o0wimTUaMSuq2i1MjmIUGg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/37] qemu: domain: Add qemuFDPass helpers into network private data Date: Tue, 10 May 2022 17:19:48 +0200 Message-Id: <860b6d67c303fc8d7b08b8387bdace863ec81909.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196044129100003 Content-Type: text/plain; charset="utf-8" Prepare for the upcoming refactor to use qemuFDPass for all the network related file descriptors: - tapfds - vhostfds - slirp - vdpa This patch adds the private data variables and a utility function to clear it. Clearing is useful since we don't really need the data once the VM is running so we save some memory. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 3 +++ src/qemu/qemu_domain.c | 15 +++++++++++++++ src/qemu/qemu_domain.h | 8 ++++++++ src/qemu/qemu_hotplug.c | 3 +++ 4 files changed, 29 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 95632827cb..0d1517a5d6 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8682,6 +8682,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, qemuSlirp *slirp; size_t i; g_autoptr(virJSONValue) hostnetprops =3D NULL; + qemuDomainNetworkPrivate *netpriv =3D QEMU_DOMAIN_NETWORK_PRIVATE(net); if (qemuDomainValidateActualNetDef(net, qemuCaps) < 0) return -1; @@ -8938,6 +8939,8 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, ret =3D 0; cleanup: + qemuDomainNetworkPrivateClearFDs(netpriv); + if (ret < 0) { virErrorPtr saved_err; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2df02943bf..96b0fe56ee 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1045,12 +1045,27 @@ qemuDomainNetworkPrivateNew(void) } +void +qemuDomainNetworkPrivateClearFDs(qemuDomainNetworkPrivate *priv) +{ + if (!priv) + return; + + g_clear_pointer(&priv->slirpfd, qemuFDPassFree); + g_clear_pointer(&priv->vdpafd, qemuFDPassFree); + g_slist_free_full(g_steal_pointer(&priv->vhostfds), (GDestroyNotify) q= emuFDPassFree); + g_slist_free_full(g_steal_pointer(&priv->tapfds), (GDestroyNotify) qem= uFDPassFree); +} + + static void qemuDomainNetworkPrivateDispose(void *obj G_GNUC_UNUSED) { qemuDomainNetworkPrivate *priv =3D obj; qemuSlirpFree(priv->slirp); + + qemuDomainNetworkPrivateClearFDs(priv); } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index e13c6be399..85f75ee197 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -398,8 +398,16 @@ struct _qemuDomainNetworkPrivate { virObject parent; qemuSlirp *slirp; + + /* file descriptor transfer helpers */ + qemuFDPass *slirpfd; + GSList *tapfds; + GSList *vhostfds; + qemuFDPass *vdpafd; }; +void +qemuDomainNetworkPrivateClearFDs(qemuDomainNetworkPrivate *priv); typedef enum { QEMU_PROCESS_EVENT_WATCHDOG =3D 0, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index e8e028706b..2923992759 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1181,6 +1181,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, { qemuDomainObjPrivate *priv =3D vm->privateData; virDomainDeviceDef dev =3D { VIR_DOMAIN_DEVICE_NET, { .net =3D net } }; + qemuDomainNetworkPrivate *netpriv =3D QEMU_DOMAIN_NETWORK_PRIVATE(net); virErrorPtr originalError =3D NULL; g_autofree char *slirpfdName =3D NULL; int slirpfd =3D -1; @@ -1541,6 +1542,8 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, ret =3D 0; cleanup: + qemuDomainNetworkPrivateClearFDs(netpriv); + if (ret < 0) { virErrorPreserveLast(&save_err); if (releaseaddr) --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196042; cv=none; d=zohomail.com; s=zohoarc; b=DHTldFRLkYX7r8m5RmLNP7wAIPhGjdQVyb7cBBODh47rjU0Bm6j7cGI3/ZShQmeUzpSkbLq8egFB9wQJE9lOcV/VPU9izs6jdyTYmyzhqOyk09l9zqWP7VmlAk49fisJZoEWpZgzTRq86rojinwU/FO+4AwzHuOO+ALbIixC+co= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196042; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wmTOWzbvIiIWToNEaMH2IpoHyTWf92ATQ2d+IdqGWyg=; b=HA3KjWJqYZ+8rCDzh/Tg4YlyxvZvvP+ex2+o8O0KNyrLRJWCNmXcmAGBvZxfiv6ADCmOY/M2taAtQ2hoksOXaDfmZm4UnBLDYBvgFZSnWbjbj0DvP0mbVREmedM+Fd5x4ZmBKCPDsnRXdtOaK8T0VYAy/LzpwujgQqGwll+n0yA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1652196042958934.7450657260007; Tue, 10 May 2022 08:20:42 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-161-iwLcyhG1OSCV9Y8znov8lw-1; Tue, 10 May 2022 11:20:40 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A2C9D100BAAF; Tue, 10 May 2022 15:20:31 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D8FA40D0161; Tue, 10 May 2022 15:20:31 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 69106194705F; Tue, 10 May 2022 15:20:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id EF62B194704D for ; Tue, 10 May 2022 15:20:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E43A6202699A; Tue, 10 May 2022 15:20:29 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 54D9820296A7 for ; Tue, 10 May 2022 15:20:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196041; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=wmTOWzbvIiIWToNEaMH2IpoHyTWf92ATQ2d+IdqGWyg=; b=OMUAfv3Ktd+7rkQDi4XVaDjLRq3QMJeZd94OYyAct4+jaUctHWd+aG5neAZdJHT0wjYvp9 fZiXd9ds7GVKaD+gEdF/57IXgHK3ZHFVsu2B1vnY+JAJfeUJrI57OWX7pij4C1bwymQwqQ J0E2htHLhxZHMS9/+vUEnV2G16p/UII= X-MC-Unique: iwLcyhG1OSCV9Y8znov8lw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/37] qemu: command: Introduce 'qemuBuildInterfaceConnect' helper Date: Tue, 10 May 2022 17:19:49 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196044112100002 Content-Type: text/plain; charset="utf-8" The helper will aggregate code that is used to connect the network backend to the corresponding host portion. This will be used to refactor the duplicated code between the cold-start and hotplug helper functions. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 43 +++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_command.h | 5 +++++ src/qemu/qemu_hotplug.c | 3 +++ 3 files changed, 51 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 0d1517a5d6..2c4a1a582a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8652,6 +8652,46 @@ qemuInterfaceVhostuserConnect(virCommand *cmd, return 0; } + +int +qemuBuildInterfaceConnect(virDomainObj *vm G_GNUC_UNUSED, + virDomainNetDef *net, + bool standalone G_GNUC_UNUSED) +{ + virDomainNetType actualType =3D virDomainNetGetActualType(net); + + switch (actualType) { + case VIR_DOMAIN_NET_TYPE_NETWORK: + case VIR_DOMAIN_NET_TYPE_BRIDGE: + break; + + case VIR_DOMAIN_NET_TYPE_DIRECT: + break; + + case VIR_DOMAIN_NET_TYPE_ETHERNET: + break; + + case VIR_DOMAIN_NET_TYPE_VHOSTUSER: + break; + + case VIR_DOMAIN_NET_TYPE_VDPA: + break; + + case VIR_DOMAIN_NET_TYPE_HOSTDEV: + case VIR_DOMAIN_NET_TYPE_USER: + case VIR_DOMAIN_NET_TYPE_SERVER: + case VIR_DOMAIN_NET_TYPE_CLIENT: + case VIR_DOMAIN_NET_TYPE_MCAST: + case VIR_DOMAIN_NET_TYPE_INTERNAL: + case VIR_DOMAIN_NET_TYPE_UDP: + case VIR_DOMAIN_NET_TYPE_LAST: + break; + } + + return 0; +} + + static int qemuBuildInterfaceCommandLine(virQEMUDriver *driver, virDomainObj *vm, @@ -8687,6 +8727,9 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, if (qemuDomainValidateActualNetDef(net, qemuCaps) < 0) return -1; + if (qemuBuildInterfaceConnect(vm, net, standalone) < 0) + return -1; + switch (actualType) { case VIR_DOMAIN_NET_TYPE_NETWORK: case VIR_DOMAIN_NET_TYPE_BRIDGE: diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index a653ff7218..4b4e0bb456 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -94,6 +94,11 @@ qemuBuildHostNetProps(virDomainNetDef *net, const char *slirpfd, const char *vdpadev); +int +qemuBuildInterfaceConnect(virDomainObj *vm, + virDomainNetDef *net, + bool standalone); + /* Current, best practice */ virJSONValue * qemuBuildNicDevProps(virDomainDef *def, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 2923992759..221815568b 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1279,6 +1279,9 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, */ VIR_APPEND_ELEMENT_COPY(vm->def->nets, vm->def->nnets, net); + if (qemuBuildInterfaceConnect(vm, net, false) < 0) + return -1; + switch (actualType) { case VIR_DOMAIN_NET_TYPE_BRIDGE: case VIR_DOMAIN_NET_TYPE_NETWORK: --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196042; cv=none; d=zohomail.com; s=zohoarc; b=P+AscLO8I3GcmLX2PL9iMO30JcnlGZHF2uHZz5vS3nkUcpX1KIlaLVG9KzStcWGeBtvKKq+vzgVle1lqtJ2URMfF/l+emkP1BCB7xt4ab6NEowK2TdctOj/TCWNmO9bbDW7i4AqlH5Fc4DlKv9l/9dfwXYErjRRYfXwH9oxZK6I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196042; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=al117wSLa9wAidOlnLvRhaVahmSCPHfkNk+T5LDHQZw=; b=HWa/MP1G2gh31cXLm0vD15OfymC2B2w0Jd9BysyZVE7Gn7b60QEkXxPs5aBVzwCzamzM8JL1pM2UqfqFizqLWUOoUFY3oAdXO9i29uM2D+YSADG6xNy/2ZZ0r1cse45ojcJ6tJsZK8ezsjKezGGIDdfUN0GSC5wCyBx+dl0vrHs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1652196042852848.0102747537046; Tue, 10 May 2022 08:20:42 -0700 (PDT) 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-217-9IAydBtlPtax4_nRKDUung-1; Tue, 10 May 2022 11:20:40 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A576D2919EAF; Tue, 10 May 2022 15:20:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F9AB40D0165; Tue, 10 May 2022 15:20:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 49EB71947055; Tue, 10 May 2022 15:20:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 08B991947055 for ; Tue, 10 May 2022 15:20:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E818E200C0DA; Tue, 10 May 2022 15:20:30 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E3952024CBB for ; Tue, 10 May 2022 15:20:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196041; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=al117wSLa9wAidOlnLvRhaVahmSCPHfkNk+T5LDHQZw=; b=WaRzpEx/wz+tv+1YZegcn1H5jec7aVb9/HDuUxdU5tKx5fd43FOHnmqhGzoDEsCmu0wlar brauaupciNwYYuY33a77n/ppVMcIfcAwvuznNSrokkRWZhg8Snh5TTvQA/vxDK7XhFP9mz NBCjZb7DB6Hcz1AGR2MRdE/BqLmsPpQ= X-MC-Unique: 9IAydBtlPtax4_nRKDUung-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/37] qemuBuildInterfaceConnect: Connect to 'vdpa' netdev Date: Tue, 10 May 2022 17:19:50 +0200 Message-Id: <665d07fdf9888ccafc75f9367e5ddda6a5163ece.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196044106100001 Content-Type: text/plain; charset="utf-8" Move the setup of the 'vdpa' netdev into the new helper shared between commandline and hotplug code. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 40 +++++++++++++++++++--------------------- src/qemu/qemu_command.h | 3 +-- src/qemu/qemu_hotplug.c | 14 ++------------ 3 files changed, 22 insertions(+), 35 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 2c4a1a582a..c86ab3f438 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4192,13 +4192,12 @@ qemuBuildHostNetProps(virDomainNetDef *net, size_t tapfdSize, char **vhostfd, size_t vhostfdSize, - const char *slirpfd, - const char *vdpadev) + const char *slirpfd) { bool is_tap =3D false; virDomainNetType netType =3D virDomainNetGetActualType(net); size_t i; - + qemuDomainNetworkPrivate *netpriv =3D QEMU_DOMAIN_NETWORK_PRIVATE(net); g_autoptr(virJSONValue) netprops =3D NULL; if (net->script && netType !=3D VIR_DOMAIN_NET_TYPE_ETHERNET) { @@ -4333,8 +4332,10 @@ qemuBuildHostNetProps(virDomainNetDef *net, case VIR_DOMAIN_NET_TYPE_VDPA: /* Caller will pass the fd to qemu with add-fd */ - if (virJSONValueObjectAdd(&netprops, "s:type", "vhost-vdpa", NULL)= < 0 || - virJSONValueObjectAppendString(netprops, "vhostdev", vdpadev) = < 0) + if (virJSONValueObjectAdd(&netprops, + "s:type", "vhost-vdpa", + "s:vhostdev", qemuFDPassGetPath(netpriv-= >vdpafd), + NULL) < 0) return NULL; if (net->driver.virtio.queues > 1 && @@ -8654,11 +8655,15 @@ qemuInterfaceVhostuserConnect(virCommand *cmd, int -qemuBuildInterfaceConnect(virDomainObj *vm G_GNUC_UNUSED, +qemuBuildInterfaceConnect(virDomainObj *vm, virDomainNetDef *net, bool standalone G_GNUC_UNUSED) { + + qemuDomainObjPrivate *priv =3D vm->privateData; virDomainNetType actualType =3D virDomainNetGetActualType(net); + qemuDomainNetworkPrivate *netpriv =3D QEMU_DOMAIN_NETWORK_PRIVATE(net); + VIR_AUTOCLOSE vdpafd =3D -1; switch (actualType) { case VIR_DOMAIN_NET_TYPE_NETWORK: @@ -8675,6 +8680,11 @@ qemuBuildInterfaceConnect(virDomainObj *vm G_GNUC_UN= USED, break; case VIR_DOMAIN_NET_TYPE_VDPA: + if ((vdpafd =3D qemuInterfaceVDPAConnect(net)) < 0) + return -1; + + netpriv->vdpafd =3D qemuFDPassNew(net->info.alias, priv); + qemuFDPassAddFD(netpriv->vdpafd, &vdpafd, "-vdpa"); break; case VIR_DOMAIN_NET_TYPE_HOSTDEV: @@ -8703,7 +8713,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, size_t *nnicindexes, int **nicindexes) { - qemuDomainObjPrivate *priv =3D vm->privateData; virDomainDef *def =3D vm->def; int ret =3D -1; g_autoptr(virJSONValue) nicprops =3D NULL; @@ -8715,7 +8724,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, char **tapfdName =3D NULL; char **vhostfdName =3D NULL; g_autofree char *slirpfdName =3D NULL; - g_autoptr(qemuFDPass) vdpa =3D NULL; virDomainNetType actualType =3D virDomainNetGetActualType(net); const virNetDevBandwidth *actualBandwidth; bool requireNicdev =3D false; @@ -8798,16 +8806,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, break; - case VIR_DOMAIN_NET_TYPE_VDPA: { - VIR_AUTOCLOSE vdpafd =3D -1; - - if ((vdpafd =3D qemuInterfaceVDPAConnect(net)) < 0) - goto cleanup; - - vdpa =3D qemuFDPassNew(net->info.alias, priv); - - qemuFDPassAddFD(vdpa, &vdpafd, "-vdpa"); - } + case VIR_DOMAIN_NET_TYPE_VDPA: break; case VIR_DOMAIN_NET_TYPE_USER: @@ -8940,14 +8939,13 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, vhostfd[i] =3D -1; } - if (qemuFDPassTransferCommand(vdpa, cmd) < 0) + if (qemuFDPassTransferCommand(netpriv->vdpafd, cmd) < 0) return -1; if (!(hostnetprops =3D qemuBuildHostNetProps(net, tapfdName, tapfdSize, vhostfdName, vhostfdSize, - slirpfdName, - qemuFDPassGetPath(vdpa)))) + slirpfdName))) goto cleanup; if (qemuBuildNetdevCommandlineFromJSON(cmd, hostnetprops, qemuCaps) < = 0) diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 4b4e0bb456..cae0541445 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -91,8 +91,7 @@ qemuBuildHostNetProps(virDomainNetDef *net, size_t tapfdSize, char **vhostfd, size_t vhostfdSize, - const char *slirpfd, - const char *vdpadev); + const char *slirpfd); int qemuBuildInterfaceConnect(virDomainObj *vm, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 221815568b..d5bdeb83ae 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1185,8 +1185,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, virErrorPtr originalError =3D NULL; g_autofree char *slirpfdName =3D NULL; int slirpfd =3D -1; - int vdpafd =3D -1; - g_autoptr(qemuFDPass) vdpa =3D NULL; char **tapfdName =3D NULL; int *tapfd =3D NULL; size_t tapfdSize =3D 0; @@ -1395,13 +1393,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, if (qemuDomainAdjustMaxMemLock(vm, false) < 0) goto cleanup; adjustmemlock =3D true; - - if ((vdpafd =3D qemuInterfaceVDPAConnect(net)) < 0) - goto cleanup; - - vdpa =3D qemuFDPassNew(net->info.alias, priv); - - qemuFDPassAddFD(vdpa, &vdpafd, "-vdpa"); break; case VIR_DOMAIN_NET_TYPE_SERVER: @@ -1463,7 +1454,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); - if (qemuFDPassTransferMonitor(vdpa, priv->mon) < 0) { + if (qemuFDPassTransferMonitor(netpriv->vdpafd, priv->mon) < 0) { qemuDomainObjExitMonitor(vm); goto cleanup; } @@ -1471,7 +1462,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, if (!(netprops =3D qemuBuildHostNetProps(net, tapfdName, tapfdSize, vhostfdName, vhostfdSize, - slirpfdName, qemuFDPassGetPath(= vdpa)))) { + slirpfdName))) { qemuDomainObjExitMonitor(vm); goto cleanup; } @@ -1611,7 +1602,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, VIR_FREE(vhostfdName); virDomainCCWAddressSetFree(ccwaddrs); VIR_FORCE_CLOSE(slirpfd); - VIR_FORCE_CLOSE(vdpafd); return ret; --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196044; cv=none; d=zohomail.com; s=zohoarc; b=H5NpQG7MJFGSVE4iakrqz+AvXObKpIvcI83RZ2YCX49Y3cIhmb+BA2BsspIvAZMKXQssijET3zLiXQWKH0fzgS6BAFJfFGEjpU69lECPtkEMysEFN6xIMwQdxX6biMoIw6rsDdkMJaosB8VQ7Ak3dUDFQ6Q6JNiK3R8FKY6bdCc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196044; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=L0B5gr7Dr4x7HrSppVU64q4Wspx7fI4EQz7Gs+i0Mz4=; b=b8NIw4zXGWwmUakMcRp1EIY46oMxiHbHil4c+zEdn0cOe+NhooPZxwz6Y520kQWlXl84ojxditWN0hy+uLpXJEe9Ftfb7P/CZQRyX9fCI6XkOq1dhXuXV/KjLl/7F8DpEyTseV3NDDTeN4ALGN1UOZhH7Nj6ZNjCFbL8E4Lz29U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1652196044284483.35537963830893; Tue, 10 May 2022 08:20:44 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-660-BY3yOjDON-2j-8lFbKs8ZQ-1; Tue, 10 May 2022 11:20:41 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 49C3C85D53C; Tue, 10 May 2022 15:20:33 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 11CF0463EC3; Tue, 10 May 2022 15:20:33 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DC07F1947067; Tue, 10 May 2022 15:20:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 040A9194705E for ; Tue, 10 May 2022 15:20:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id DABA120296A7; Tue, 10 May 2022 15:20:31 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47CBA2024CBB for ; Tue, 10 May 2022 15:20:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196042; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=L0B5gr7Dr4x7HrSppVU64q4Wspx7fI4EQz7Gs+i0Mz4=; b=Ktr9N2uTfvpbN2GqsTnU52eQMFhzf9/XgkN3lJ0BtYeWY6pHGpxKPGDfnzq9nXZYPxDe5C XXAoV83lMaU04nq/4x3ss5t+Pl438IU0NW8wVN/qacml3e0D5DhS7voqYpiP8jYQfwMqE1 hcAVpXjtcDjfvnm8PfETfhxCcFUF68c= X-MC-Unique: BY3yOjDON-2j-8lFbKs8ZQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 15/37] qemuBuildHostNetProps: Move all 'tap' code together Date: Tue, 10 May 2022 17:19:51 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196046129100008 Content-Type: text/plain; charset="utf-8" Move the block guarded by 'is_tap' boolean to the only place where 'is_tap' is set to true. This causes few arguments to change places. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 55 +++++++++---------- .../net-eth-unmanaged-tap.args | 2 +- tests/qemuxml2argvdata/user-aliases.args | 2 +- 3 files changed, 27 insertions(+), 32 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c86ab3f438..19afad22a1 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4194,7 +4194,6 @@ qemuBuildHostNetProps(virDomainNetDef *net, size_t vhostfdSize, const char *slirpfd) { - bool is_tap =3D false; virDomainNetType netType =3D virDomainNetGetActualType(net); size_t i; qemuDomainNetworkPrivate *netpriv =3D QEMU_DOMAIN_NETWORK_PRIVATE(net); @@ -4239,7 +4238,31 @@ qemuBuildHostNetProps(virDomainNetDef *net, return NULL; } - is_tap =3D true; + if (vhostfdSize) { + if (virJSONValueObjectAppendBoolean(netprops, "vhost", true) <= 0) + return NULL; + + if (vhostfdSize =3D=3D 1) { + if (virJSONValueObjectAdd(&netprops, "s:vhostfd", vhostfd[= 0], NULL) < 0) + return NULL; + } else { + g_auto(virBuffer) fdsbuf =3D VIR_BUFFER_INITIALIZER; + + for (i =3D 0; i < vhostfdSize; i++) + virBufferAsprintf(&fdsbuf, "%s:", vhostfd[i]); + + virBufferTrim(&fdsbuf, ":"); + + if (virJSONValueObjectAdd(&netprops, + "s:vhostfds", virBufferCurrentCo= ntent(&fdsbuf), + NULL) < 0) + return NULL; + } + } + + if (net->tune.sndbuf_specified && + virJSONValueObjectAppendNumberUlong(netprops, "sndbuf", net->t= une.sndbuf) < 0) + return NULL; break; case VIR_DOMAIN_NET_TYPE_CLIENT: @@ -4352,34 +4375,6 @@ qemuBuildHostNetProps(virDomainNetDef *net, if (virJSONValueObjectAppendStringPrintf(netprops, "id", "host%s", net= ->info.alias) < 0) return NULL; - if (is_tap) { - if (vhostfdSize) { - if (virJSONValueObjectAppendBoolean(netprops, "vhost", true) <= 0) - return NULL; - - if (vhostfdSize =3D=3D 1) { - if (virJSONValueObjectAdd(&netprops, "s:vhostfd", vhostfd[= 0], NULL) < 0) - return NULL; - } else { - g_auto(virBuffer) fdsbuf =3D VIR_BUFFER_INITIALIZER; - - for (i =3D 0; i < vhostfdSize; i++) - virBufferAsprintf(&fdsbuf, "%s:", vhostfd[i]); - - virBufferTrim(&fdsbuf, ":"); - - if (virJSONValueObjectAdd(&netprops, - "s:vhostfds", virBufferCurrentCo= ntent(&fdsbuf), - NULL) < 0) - return NULL; - } - } - - if (net->tune.sndbuf_specified && - virJSONValueObjectAppendNumberUlong(netprops, "sndbuf", net->t= une.sndbuf) < 0) - return NULL; - } - return g_steal_pointer(&netprops); } diff --git a/tests/qemuxml2argvdata/net-eth-unmanaged-tap.args b/tests/qemu= xml2argvdata/net-eth-unmanaged-tap.args index 8722f27207..5909d60490 100644 --- a/tests/qemuxml2argvdata/net-eth-unmanaged-tap.args +++ b/tests/qemuxml2argvdata/net-eth-unmanaged-tap.args @@ -29,6 +29,6 @@ QEMU_AUDIO_DRV=3Dnone \ -usb \ -drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ --netdev tap,fd=3D3,id=3Dhostnet0,vhost=3Don,vhostfd=3D44 \ +-netdev tap,fd=3D3,vhost=3Don,vhostfd=3D44,id=3Dhostnet0 \ -device virtio-net-pci,netdev=3Dhostnet0,id=3Dnet0,mac=3Dfe:11:22:33:44:55= ,bus=3Dpci.0,addr=3D0x2 \ -msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/user-aliases.args b/tests/qemuxml2argvd= ata/user-aliases.args index f88ebbf11d..c80be4b439 100644 --- a/tests/qemuxml2argvdata/user-aliases.args +++ b/tests/qemuxml2argvdata/user-aliases.args @@ -47,7 +47,7 @@ QEMU_AUDIO_DRV=3Dnone \ -drive file=3D/home/zippy/tmp/install-amd64-minimal-20140619.iso,format=3D= raw,if=3Dnone,id=3Ddrive-ua-WhatAnAwesomeCDROM,readonly=3Don,cache=3Dnone \ -device ide-cd,bus=3Dide.1,unit=3D0,drive=3Ddrive-ua-WhatAnAwesomeCDROM,id= =3Dua-WhatAnAwesomeCDROM,bootindex=3D2 \ -global isa-fdc.driveA=3Ddrive-ua-myDisk1 \ --netdev tap,fd=3D3,id=3Dhostua-CheckoutThisNIC,vhost=3Don,vhostfd=3D44 \ +-netdev tap,fd=3D3,vhost=3Don,vhostfd=3D44,id=3Dhostua-CheckoutThisNIC \ -device virtio-net-pci,netdev=3Dhostua-CheckoutThisNIC,id=3Dua-CheckoutThi= sNIC,mac=3D52:54:00:d6:c0:0b,bus=3Dpci.0,addr=3D0x3 \ -netdev socket,listen=3D127.0.0.1:1234,id=3Dhostua-WeCanAlsoDoServerMode \ -device rtl8139,netdev=3Dhostua-WeCanAlsoDoServerMode,id=3Dua-WeCanAlsoDoS= erverMode,mac=3D52:54:00:22:c9:42,bus=3Dpci.0,addr=3D0x9 \ --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196078; cv=none; d=zohomail.com; s=zohoarc; b=myWT6sCOlWk57aS0QmXn6J2cZIudGj+bIIx/XefJJp3KgCPM2MN5K9RLW56QzSos2Z4e2CA7EdFcasOS/JtRTWqLHHsjOYt51HtqB3+2Z7jLTDPQXqGKajc+mS2tJIc6L53Pwrdqxz6Dpr7dCGOYjL4BasgFBLKJ8tHZTwaVHG8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196078; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AEGmG42HS1+n2WAIgQh/aB1cNfjrl8U3er4CRruMCI0=; b=BzTnyH33QY4mxYhQgW3mg43elbm5iP8wnU9V+CJXQDDqFtg1GxgJ9q2udb0+tXMryVVrxQzGYzzGCNpvfxmRQi73zDAVi0JyP92ybAqRlvSnaZfESfGGDrOpJc/4BXuuDwQqfU6vPXRmKwoBpFnN95O1PW/OFnZpN0JlD82J374= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1652196078686101.74267078972002; Tue, 10 May 2022 08:21:18 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-73-ip1ZskPaMgaD96seY7Qzng-1; Tue, 10 May 2022 11:21:12 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AC46D85A5BC; Tue, 10 May 2022 15:21:09 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9861640CFD06; Tue, 10 May 2022 15:21:09 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 633091947055; Tue, 10 May 2022 15:21:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F23F2194704D for ; Tue, 10 May 2022 15:21:07 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C635A200B427; Tue, 10 May 2022 15:21:07 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 569B72024CCA for ; Tue, 10 May 2022 15:20:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196077; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=AEGmG42HS1+n2WAIgQh/aB1cNfjrl8U3er4CRruMCI0=; b=Que02MTWaICO+mQ9jt6U+PMDOa+04/xseKeHjJERnMAwsNSHMYKqzzmbBbGhtPdwsakS2y KBlJa820Evj8X1i12NjvEAWI57vJwwP0GCim/GO3ewvKhMT05Guk6ADegynMdORzeUtOuc NJGwuh0ONM3QqB/tBcGg5dD93IlYuFA= X-MC-Unique: ip1ZskPaMgaD96seY7Qzng-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 16/37] qemuBuildHostNetProps: Refactor construction of tapfd/vhostfd arguments Date: Tue, 10 May 2022 17:19:52 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196080287100001 Content-Type: text/plain; charset="utf-8" Pre-construct the array the same way for the case when there's only one FD and when there are multiple. We just change the argument name depending on the count. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 66 +++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 19afad22a1..c412bc50e0 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4215,54 +4215,50 @@ qemuBuildHostNetProps(virDomainNetDef *net, case VIR_DOMAIN_NET_TYPE_BRIDGE: case VIR_DOMAIN_NET_TYPE_NETWORK: case VIR_DOMAIN_NET_TYPE_DIRECT: - case VIR_DOMAIN_NET_TYPE_ETHERNET: - if (virJSONValueObjectAdd(&netprops, "s:type", "tap", NULL) < 0) - return NULL; + case VIR_DOMAIN_NET_TYPE_ETHERNET: { + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + /* for one tapfd/vhostfd 'fd=3D' shall be used, for more than use = 'fds=3D' */ + const char *tapfd_field =3D "s:fd"; + g_autofree char *tapfd_arg =3D NULL; + const char *vhostfd_field =3D "S:vhostfd"; + g_autofree char *vhostfd_arg =3D NULL; + bool vhost =3D false; - /* for one tapfd 'fd=3D' shall be used, - * for more than one 'fds=3D' is the right choice */ - if (tapfdSize =3D=3D 1) { - if (virJSONValueObjectAdd(&netprops, "s:fd", tapfd[0], NULL) <= 0) - return NULL; - } else { - g_auto(virBuffer) fdsbuf =3D VIR_BUFFER_INITIALIZER; + for (i =3D 0; i < tapfdSize; i++) + virBufferAsprintf(&buf, "%s:", tapfd[i]); - for (i =3D 0; i < tapfdSize; i++) - virBufferAsprintf(&fdsbuf, "%s:", tapfd[i]); + if (tapfdSize > 1) + tapfd_field =3D "s:fds"; - virBufferTrim(&fdsbuf, ":"); + virBufferTrim(&buf, ":"); + tapfd_arg =3D virBufferContentAndReset(&buf); - if (virJSONValueObjectAdd(&netprops, - "s:fds", virBufferCurrentContent(&fd= sbuf), - NULL) < 0) - return NULL; - } + if (vhostfdSize > 0) { + vhost =3D true; - if (vhostfdSize) { - if (virJSONValueObjectAppendBoolean(netprops, "vhost", true) <= 0) - return NULL; + for (i =3D 0; i < vhostfdSize; i++) + virBufferAsprintf(&buf, "%s:", vhostfd[i]); - if (vhostfdSize =3D=3D 1) { - if (virJSONValueObjectAdd(&netprops, "s:vhostfd", vhostfd[= 0], NULL) < 0) - return NULL; - } else { - g_auto(virBuffer) fdsbuf =3D VIR_BUFFER_INITIALIZER; + if (vhostfdSize > 1) + vhostfd_field =3D "s:vhostfds"; + } - for (i =3D 0; i < vhostfdSize; i++) - virBufferAsprintf(&fdsbuf, "%s:", vhostfd[i]); + virBufferTrim(&buf, ":"); + vhostfd_arg =3D virBufferContentAndReset(&buf); - virBufferTrim(&fdsbuf, ":"); + if (virJSONValueObjectAdd(&netprops, + "s:type", "tap", + tapfd_field, tapfd_arg, + "B:vhost", vhost, + vhostfd_field, vhostfd_arg, + NULL) < 0) + return NULL; - if (virJSONValueObjectAdd(&netprops, - "s:vhostfds", virBufferCurrentCo= ntent(&fdsbuf), - NULL) < 0) - return NULL; - } - } if (net->tune.sndbuf_specified && virJSONValueObjectAppendNumberUlong(netprops, "sndbuf", net->t= une.sndbuf) < 0) return NULL; + } break; case VIR_DOMAIN_NET_TYPE_CLIENT: --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196087; cv=none; d=zohomail.com; s=zohoarc; b=ZNjU7BHMrhdEC6HUL/A7qngkmF2mlLo+czImi/ss8DuLNJA0SArwCMoTuCyYnIFkwhCRb/OWe6udQ9vh0Pd7U1yzdwsdxSkFoE3iKYurr7Kw4oD02R0OMrb3AGzUuENeibJT7xV5sky0877ZN56gSc4up00z2aJQyw7ooR6ONeI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196087; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hYVom7ACsgqRvE8JWa6BPC+1fklsOkRP8gqkF7gyf9I=; b=QLbm1ZISbcPgq/vPWm9MLwVw9socUah19etezt4+AB6QZp3SQfI7ejkrhj499gP7V3Fq++fCabl6qY+0kiYJFILPnZVjwPBWmcpIUHuQ6KxykX8INpKpRobjcQFYh2PLOFn9NjmeWRWh5Pxt6JA/imXAE8226FFxiQFNglLzG98= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 165219608733478.24803233934722; Tue, 10 May 2022 08:21:27 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-441-K5qqRBn1OVeNRuj04wXpbQ-1; Tue, 10 May 2022 11:21:22 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E7C9285A5A8; Tue, 10 May 2022 15:21:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D50F040D0161; Tue, 10 May 2022 15:21:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AC63C1947055; Tue, 10 May 2022 15:21:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id EBC2C194704D for ; Tue, 10 May 2022 15:21:17 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id DD7232024CBD; Tue, 10 May 2022 15:21:17 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 529502024CBB for ; Tue, 10 May 2022 15:21:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196086; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=hYVom7ACsgqRvE8JWa6BPC+1fklsOkRP8gqkF7gyf9I=; b=KUBT/25FDJyhKekZtTIFs2qRyCbzisBb2aoud0Nx7nyCT/vQgTceHGwtcuPGupxzYseV18 AIG4bWuEaHWsFqwsFpsBR9K6QyOMWXlkse0WBz/a2PbHG03gkY5ubhAJblF39PUMrQGNQB i4bo5D6OYI0Y3baClZerOburYO/ThHA= X-MC-Unique: K5qqRBn1OVeNRuj04wXpbQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 17/37] qemuDomainAttachNetDevice: Don't construct network device properties under monitor lock Date: Tue, 10 May 2022 17:19:53 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196088296100001 Content-Type: text/plain; charset="utf-8" After the 'qemuFDPass' code was refactored we no longer need to hand off the FD to qemu before we know the path for it. Thus the call to qemuBuildHostNetProps can be moved outside of the monitor critical section. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index d5bdeb83ae..525c55baf2 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1452,17 +1452,15 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, for (i =3D 0; i < vhostfdSize; i++) vhostfdName[i] =3D g_strdup_printf("vhostfd-%s%zu", net->info.alia= s, i); - qemuDomainObjEnterMonitor(driver, vm); - - if (qemuFDPassTransferMonitor(netpriv->vdpafd, priv->mon) < 0) { - qemuDomainObjExitMonitor(vm); - goto cleanup; - } - if (!(netprops =3D qemuBuildHostNetProps(net, tapfdName, tapfdSize, vhostfdName, vhostfdSize, - slirpfdName))) { + slirpfdName))) + goto cleanup; + + qemuDomainObjEnterMonitor(driver, vm); + + if (qemuFDPassTransferMonitor(netpriv->vdpafd, priv->mon) < 0) { qemuDomainObjExitMonitor(vm); goto cleanup; } --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196110; cv=none; d=zohomail.com; s=zohoarc; b=WHTGe/sM3jZSCmjQTSoQ4mdcUZ/WliyQMjh/nkgTj32cZ5fnBzboKSL80awPn8dfx7tM2E9dDgNhd7y1SlczQC80Xex7vNXhVBykoXD5lZMA+K1lVzdXF+ALA2UvG5xJ6NWDMQuZHp9wSMetEbjs++P9atEfUfxDKMcBXP/GOaA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196110; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pEKeZGdc0swyXSxLETMJwTlWAyf3GDYaHcDZKHpZsyQ=; b=d+LQWeW0Yl7MVr45bYOE5TT+WI2JmZ2LH07wnKz7+uOqqYuNJW3yYgybsCVh/exu1eHCux+xyFODIVqQ+QygQ3W8NZtmM15CMvxxAvdAU22YZt/9bRfzTjFiSzKWbGuZMi6uoTgI0bXjlYklpiKWnnx9gqr5S4m9BH0LxyAFSK0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 165219611087074.99133793658348; Tue, 10 May 2022 08:21:50 -0700 (PDT) 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-257-OC3Cv5u_MgG4ltm1icyC_A-1; Tue, 10 May 2022 11:21:47 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5ECF81D33860; Tue, 10 May 2022 15:21:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4753854B087; Tue, 10 May 2022 15:21:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0A40A1947055; Tue, 10 May 2022 15:21:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C541A194704D for ; Tue, 10 May 2022 15:21:37 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 999CA2024CBB; Tue, 10 May 2022 15:21:37 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B3AA20296AC for ; Tue, 10 May 2022 15:21:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196109; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=pEKeZGdc0swyXSxLETMJwTlWAyf3GDYaHcDZKHpZsyQ=; b=I68m2fo1OZgooghVQsh1tFOKIZ69olfCeQXml+gvJWBtWDTe1imJmntrOpd7O/yEiebMzE DcI/SaLAnF8Y7uN1YrAiAiwgZ4wvDOYit2r8QrwLcvVBRuOz2JOrhJB/+hoL8sdyNpRyzR 4pDbhAnTumnjuHsbb+s/zODFjgisWCw= X-MC-Unique: OC3Cv5u_MgG4ltm1icyC_A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 18/37] qemu: Prepare netdev code for use of qemuFDPass for tapfd/vhostfd passing Date: Tue, 10 May 2022 17:19:54 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196112377100001 Content-Type: text/plain; charset="utf-8" Add alternative code paths for passing of the FDs using the new infrastructure. This way we'll be able to refactor the code incrementally. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 45 ++++++++++++++++++++++++++++++++++++----- src/qemu/qemu_hotplug.c | 22 ++++++++++++++++++++ 2 files changed, 62 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c412bc50e0..fc8e209976 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4223,17 +4223,41 @@ qemuBuildHostNetProps(virDomainNetDef *net, const char *vhostfd_field =3D "S:vhostfd"; g_autofree char *vhostfd_arg =3D NULL; bool vhost =3D false; + size_t nfds; + GSList *n; + + if (netpriv->tapfds) { + nfds =3D 0; + for (n =3D netpriv->tapfds; n; n =3D n->next) { + virBufferAsprintf(&buf, "%s:", qemuFDPassGetPath(n->data)); + nfds++; + } - for (i =3D 0; i < tapfdSize; i++) - virBufferAsprintf(&buf, "%s:", tapfd[i]); + if (nfds > 1) + tapfd_field =3D "s:fds"; + } else { + for (i =3D 0; i < tapfdSize; i++) + virBufferAsprintf(&buf, "%s:", tapfd[i]); - if (tapfdSize > 1) - tapfd_field =3D "s:fds"; + if (tapfdSize > 1) + tapfd_field =3D "s:fds"; + } virBufferTrim(&buf, ":"); tapfd_arg =3D virBufferContentAndReset(&buf); - if (vhostfdSize > 0) { + if (netpriv->vhostfds) { + vhost =3D true; + + nfds =3D 0; + for (n =3D netpriv->vhostfds; n; n =3D n->next) { + virBufferAsprintf(&buf, "%s:", qemuFDPassGetPath(n->data)); + nfds++; + } + + if (nfds > 1) + vhostfd_field =3D "s:vhostfds"; + } else if (vhostfdSize > 0) { vhost =3D true; for (i =3D 0; i < vhostfdSize; i++) @@ -8722,6 +8746,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, size_t i; g_autoptr(virJSONValue) hostnetprops =3D NULL; qemuDomainNetworkPrivate *netpriv =3D QEMU_DOMAIN_NETWORK_PRIVATE(net); + GSList *n; if (qemuDomainValidateActualNetDef(net, qemuCaps) < 0) return -1; @@ -8930,6 +8955,16 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, vhostfd[i] =3D -1; } + for (n =3D netpriv->tapfds; n; n =3D n->next) { + if (qemuFDPassTransferCommand(n->data, cmd) < 0) + return -1; + } + + for (n =3D netpriv->vhostfds; n; n =3D n->next) { + if (qemuFDPassTransferCommand(n->data, cmd) < 0) + return -1; + } + if (qemuFDPassTransferCommand(netpriv->vdpafd, cmd) < 0) return -1; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 525c55baf2..28868cf3d0 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1210,6 +1210,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, g_autoptr(virConnect) conn =3D NULL; virErrorPtr save_err =3D NULL; bool teardownlabel =3D false; + GSList *n; /* If appropriate, grab a physical device from the configured * network's pool of devices, or resolve bridge device name @@ -1460,6 +1461,20 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); + for (n =3D netpriv->tapfds; n; n =3D n->next) { + if (qemuFDPassTransferMonitor(n->data, priv->mon) < 0) { + qemuDomainObjExitMonitor(vm); + goto cleanup; + } + } + + for (n =3D netpriv->vhostfds; n; n =3D n->next) { + if (qemuFDPassTransferMonitor(n->data, priv->mon) < 0) { + qemuDomainObjExitMonitor(vm); + goto cleanup; + } + } + if (qemuFDPassTransferMonitor(netpriv->vdpafd, priv->mon) < 0) { qemuDomainObjExitMonitor(vm); goto cleanup; @@ -1619,6 +1634,13 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, qemuMonitorRemoveNetdev(priv->mon, netdev_name) < 0) VIR_WARN("Failed to remove network backend for netdev %s", netdev_name); + + for (n =3D netpriv->tapfds; n; n =3D n->next) + qemuFDPassTransferMonitorRollback(n->data, priv->mon); + + for (n =3D netpriv->vhostfds; n; n =3D n->next) + qemuFDPassTransferMonitorRollback(n->data, priv->mon); + qemuDomainObjExitMonitor(vm); virErrorRestore(&originalError); goto cleanup; --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196318; cv=none; d=zohomail.com; s=zohoarc; b=IIIiECj+rrRMeZA5oqdCKzR8x3SUncuSQy3ON8hR/H8S8FRP7ugE3rRrpaUHvLyV5k61uJ29ZMeOXE2sVa0jsFHkeZ4IuiHQdnp7D39WC/VLjZuxbdZIeflTkH9X/k0rMPGfObC3oh+wHk6T11WT7K6jmZB/g1Q/VieBW3P3DVA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196318; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Z1fgetM+ceW7WnZ6RZc0XYIT/Zc60gTgxHOCcrjbzsY=; b=F4r8K5CwVqghStoFdCwbVwAfgw2AqD+fusOEEi1pAjWKRT1d65jO3MiCclcEdtUqAyWbc/I1CkP6kTrwDY/N5diBoKs6Pqa6H9ImfzwlMAGALGd8+3Tiy8l/gS8/sFbj+Uh4WxAhHODa162tAr/ypJybBptlulv7I6JdLTf5XZI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1652196318165686.259872002036; Tue, 10 May 2022 08:25:18 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-613-BJOqpCLRPju4Tf7Kkm0WVg-1; Tue, 10 May 2022 11:23:25 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9A84C824077; Tue, 10 May 2022 15:22:24 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 843954010E46; Tue, 10 May 2022 15:22:24 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 64D9C1947055; Tue, 10 May 2022 15:22:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F01641947055 for ; Tue, 10 May 2022 15:22:22 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id CC7A6202699A; Tue, 10 May 2022 15:22:22 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E80A2024CBD for ; Tue, 10 May 2022 15:21:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196313; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Z1fgetM+ceW7WnZ6RZc0XYIT/Zc60gTgxHOCcrjbzsY=; b=S66QtfdQSC+oT+7iKVNO4zwKTIuSTUpd72nDC5JZY17mNl7Mi4+X7LGs6pYkGxP1P7ZFHb yKi302WzRCjMWHIWAm3MDGCADC3ENlChI3f5lP3GJexmNjwlihRAucf8mDxEJB8gtKL4dB cGohleTvH9uoCJrNDQw8rBSEycgBpLQ= X-MC-Unique: BJOqpCLRPju4Tf7Kkm0WVg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 19/37] qemuBuildNicDevProps: Don't pass 'vhostfdSize' Date: Tue, 10 May 2022 17:19:55 +0200 Message-Id: <70ef0c9fa710a4e53e98ef2795504de7a99422df.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196320565100001 Content-Type: text/plain; charset="utf-8" All callers effectively pass 'net->driver.virtio.queues'. In case of the code in 'qemu_hotplug.c' this value was set to '1' if it was 0 before. Since 'qemuBuildNicDevProps' only uses it if it's greater than 1 we can remove all the extra complexity. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 7 +++---- src/qemu/qemu_command.h | 1 - src/qemu/qemu_hotplug.c | 12 +----------- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index fc8e209976..78ea638c26 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4075,7 +4075,6 @@ qemuBuildLegacyNicStr(virDomainNetDef *net) virJSONValue * qemuBuildNicDevProps(virDomainDef *def, virDomainNetDef *net, - size_t vhostfdSize, virQEMUCaps *qemuCaps) { g_autoptr(virJSONValue) props =3D NULL; @@ -4112,7 +4111,7 @@ qemuBuildNicDevProps(virDomainDef *def, } } - if (vhostfdSize > 1) { + if (net->driver.virtio.queues > 1) { if (net->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { /* ccw provides a one to one relation of fds to queues and * does not support the vectors option @@ -4123,7 +4122,7 @@ qemuBuildNicDevProps(virDomainDef *def, * we should add vectors=3D2*N+2 where N is the vhostfdSize */ mq =3D VIR_TRISTATE_SWITCH_ON; - vectors =3D 2 * vhostfdSize + 2; + vectors =3D 2 * net->driver.virtio.queues + 2; } } @@ -8987,7 +8986,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, if (qemuCommandAddExtDevice(cmd, &net->info, def, qemuCaps) < 0) goto cleanup; - if (!(nicprops =3D qemuBuildNicDevProps(def, net, net->driver.virt= io.queues, qemuCaps))) + if (!(nicprops =3D qemuBuildNicDevProps(def, net, qemuCaps))) goto cleanup; if (qemuBuildDeviceCommandlineFromJSON(cmd, nicprops, def, qemuCap= s) < 0) goto cleanup; diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index cae0541445..3b487a647c 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -102,7 +102,6 @@ qemuBuildInterfaceConnect(virDomainObj *vm, virJSONValue * qemuBuildNicDevProps(virDomainDef *def, virDomainNetDef *net, - size_t vhostfdSize, virQEMUCaps *qemuCaps); char *qemuDeviceDriveHostAlias(virDomainDiskDef *disk); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 28868cf3d0..90ca35bccf 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1191,7 +1191,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, char **vhostfdName =3D NULL; int *vhostfd =3D NULL; size_t vhostfdSize =3D 0; - size_t queueSize =3D 0; g_autoptr(virJSONValue) nicprops =3D NULL; g_autoptr(virJSONValue) netprops =3D NULL; int ret =3D -1; @@ -1287,7 +1286,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, tapfdSize =3D vhostfdSize =3D net->driver.virtio.queues; if (!tapfdSize) tapfdSize =3D vhostfdSize =3D 1; - queueSize =3D tapfdSize; tapfd =3D g_new0(int, tapfdSize); memset(tapfd, -1, sizeof(*tapfd) * tapfdSize); vhostfd =3D g_new0(int, vhostfdSize); @@ -1304,7 +1302,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, tapfdSize =3D vhostfdSize =3D net->driver.virtio.queues; if (!tapfdSize) tapfdSize =3D vhostfdSize =3D 1; - queueSize =3D tapfdSize; tapfd =3D g_new0(int, tapfdSize); memset(tapfd, -1, sizeof(*tapfd) * tapfdSize); vhostfd =3D g_new0(int, vhostfdSize); @@ -1322,7 +1319,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, tapfdSize =3D vhostfdSize =3D net->driver.virtio.queues; if (!tapfdSize) tapfdSize =3D vhostfdSize =3D 1; - queueSize =3D tapfdSize; tapfd =3D g_new0(int, tapfdSize); memset(tapfd, -1, sizeof(*tapfd) * tapfdSize); vhostfd =3D g_new0(int, vhostfdSize); @@ -1336,9 +1332,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, break; case VIR_DOMAIN_NET_TYPE_VHOSTUSER: - queueSize =3D net->driver.virtio.queues; - if (!queueSize) - queueSize =3D 1; if (!qemuDomainSupportsNicdev(vm->def, net)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Nicdev support unavailable")); @@ -1388,9 +1381,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, break; case VIR_DOMAIN_NET_TYPE_VDPA: - queueSize =3D net->driver.virtio.queues; - if (!queueSize) - queueSize =3D 1; if (qemuDomainAdjustMaxMemLock(vm, false) < 0) goto cleanup; adjustmemlock =3D true; @@ -1506,7 +1496,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, for (i =3D 0; i < vhostfdSize; i++) VIR_FORCE_CLOSE(vhostfd[i]); - if (!(nicprops =3D qemuBuildNicDevProps(vm->def, net, queueSize, priv-= >qemuCaps))) + if (!(nicprops =3D qemuBuildNicDevProps(vm->def, net, priv->qemuCaps))) goto try_remove; qemuDomainObjEnterMonitor(driver, vm); --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196345; cv=none; d=zohomail.com; s=zohoarc; b=DpaROosLl/IwBlvUz72dqFvgaER/7usr0Qg0tn3qVtFpikV9Md7bCoxv4ZYAYlt261BUGlki1OX3Bf3XpC+5CoEVC1byJrjLsxqR9s434NlWBIYX+AfbHfYK4UI0oqtma7aZnwLuJaUKqT0uDP3M7f06BJRvcw0k2twKavRyCYA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196345; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=K4t212YDrKjkJMDItlqPFZW+ZD4wJCGHn6Dmhk9CTkM=; b=MCDSFsPULWp259obLIjCcMTE9Kh/QY22guWp7XTkJbY6oButD5sT4//+gznIQwJMvRKvIQWkZdsZ1GEAoLt7TUMVjc1dWTiBwnSkZ+L12Avn2eqDNH7kJLow0dXAHP631Es0jX+Fct0VKHKo6XnqXXUM/BcswKeq1Pob9PnxPJM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1652196345136802.3223560655695; Tue, 10 May 2022 08:25:45 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-30-Y7Y3UlSNNqihwBf_XAmqkA-1; Tue, 10 May 2022 11:23:21 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2BF98100BACC; Tue, 10 May 2022 15:22:43 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D662F15101E6; Tue, 10 May 2022 15:22:42 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A752B1947059; Tue, 10 May 2022 15:22:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C8E34194704D for ; Tue, 10 May 2022 15:22:41 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A7280200C0DD; Tue, 10 May 2022 15:22:41 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D89B2024CBD for ; Tue, 10 May 2022 15:22:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196343; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=K4t212YDrKjkJMDItlqPFZW+ZD4wJCGHn6Dmhk9CTkM=; b=IW7R8xiLcAUojmRwZJqSaK8SGQ+0fJRe+C8HSH8MbWfE7qethOay3omsHNCrG+UtWlyVUJ LnFVabSVJFD7BaNISLcWqzNAcgjtktECVB878O4z51cETQEwAFlg+2EXxRIi1dAzPIGAzy +ZPkmxe4x/EjUj5uI+wQD17zMnDBycI= X-MC-Unique: Y7Y3UlSNNqihwBf_XAmqkA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 20/37] qemuInterfaceOpenVhostNet: Reformat error messages per new guidelines Date: Tue, 10 May 2022 17:19:56 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196346717100001 Content-Type: text/plain; charset="utf-8" Remove the linebreaks inside of error messages. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_interface.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c index e5f4710988..e6a26e377f 100644 --- a/src/qemu/qemu_interface.c +++ b/src/qemu/qemu_interface.c @@ -726,9 +726,8 @@ qemuInterfaceOpenVhostNet(virDomainDef *def, */ if (!qemuDomainSupportsNicdev(def, net)) { if (net->driver.virtio.name =3D=3D VIR_DOMAIN_NET_BACKEND_TYPE_VHO= ST) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("vhost-net is not supported with " - "this QEMU binary")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("vhost-net is not supported with this QEMU bi= nary")); return -1; } *vhostfdSize =3D 0; @@ -738,9 +737,8 @@ qemuInterfaceOpenVhostNet(virDomainDef *def, /* If the nic model isn't virtio, don't try to open. */ if (!virDomainNetIsVirtioModel(net)) { if (net->driver.virtio.name =3D=3D VIR_DOMAIN_NET_BACKEND_TYPE_VHO= ST) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("vhost-net is only supported for " - "virtio network interfaces")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("vhost-net is only supported for virtio netwo= rk interfaces")); return -1; } *vhostfdSize =3D 0; @@ -756,9 +754,8 @@ qemuInterfaceOpenVhostNet(virDomainDef *def, if (vhostfd[i] < 0) { virDomainAuditNetDevice(def, net, vhostnet_path, false); if (net->driver.virtio.name =3D=3D VIR_DOMAIN_NET_BACKEND_TYPE= _VHOST) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("vhost-net was requested for an int= erface, " - "but is unavailable")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("vhost-net was requested for an interface= , but is unavailable")); goto error; } VIR_WARN("Unable to open vhost-net. Opened so far %zu, request= ed %zu", --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196315; cv=none; d=zohomail.com; s=zohoarc; b=PtYZawnD6L523/TR8rVAUki9+8c+4rdCDdorhh0j7vabgPhCjOZ66w28uM/E7gKn9e+vK2qC+VxErA27PxC2I1nY9+iACwHWPKAKdmXAbOdxxWd/1RmXRXv96uSHLfRE1QYiVq5RTtj5qIZqIJH+JKm8iaVbv66zqCyhSVccROY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196315; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UR4QpeKrhJTMXzkzJP69j/69sAQp4OZxERo1dduOvFk=; b=Rbh2gGHfBRAarmH3GtDIpwZWbbTEtIgcGhsGOXwzcWq65zMz0CJCtd2HMF7Voln/bjWh6tlcPHfaua+9Pw0WEucsl5FQ8ZMjIdlM4JRiW/AkriqfRp31NpADGclmXa4RTilKYlYSI9UhPH0rfxGI1je27AAGg+Ftr499I7AfnWk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1652196315104555.6158975189877; Tue, 10 May 2022 08:25:15 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-219-lpka3dedPg2BEI4UXGoW2Q-1; Tue, 10 May 2022 11:23:34 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 166C6884646; Tue, 10 May 2022 15:23:11 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id F3D8E2166B4D; Tue, 10 May 2022 15:23:10 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 980DD194705E; Tue, 10 May 2022 15:23:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 61AF51947060 for ; Tue, 10 May 2022 15:23:09 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 47294200BCE9; Tue, 10 May 2022 15:23:09 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6B132024CD7 for ; Tue, 10 May 2022 15:22:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196313; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=UR4QpeKrhJTMXzkzJP69j/69sAQp4OZxERo1dduOvFk=; b=SCWLFZ6J08vSk262tBVet+vcAs1PnNesT/pJCbq3Ka/gii1DBC0cYN5ycdlg0/HVyir1CV PMACZpUSfc5U3kxAhO4Osepr6MgRs2R/t7SVkRt0AngBm/S7wsM6EyZP2ME6ubU6eJgGQk jQAoKWssXVnookmv4m3nAfUfo2TNTUM= X-MC-Unique: lpka3dedPg2BEI4UXGoW2Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 21/37] qemu: Move opening of vhost file descriptors for net devices into qemuBuildInterfaceConnect Date: Tue, 10 May 2022 17:19:57 +0200 Message-Id: <85de03e1028aaae4274aef11df14b494b84e9dec.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196316496100003 Content-Type: text/plain; charset="utf-8" Use the new infrastructure which stores the fds inside 'qemuFDPass' objects in the private data. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 31 +++++++-------------- src/qemu/qemu_hotplug.c | 28 ++++++------------- src/qemu/qemu_interface.c | 58 ++++++++++++++++++--------------------- src/qemu/qemu_interface.h | 6 ++-- tests/qemuxml2argvmock.c | 28 +++++++++++++------ 5 files changed, 67 insertions(+), 84 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 78ea638c26..0b527784c5 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8671,23 +8671,27 @@ qemuInterfaceVhostuserConnect(virCommand *cmd, int qemuBuildInterfaceConnect(virDomainObj *vm, virDomainNetDef *net, - bool standalone G_GNUC_UNUSED) + bool standalone) { qemuDomainObjPrivate *priv =3D vm->privateData; virDomainNetType actualType =3D virDomainNetGetActualType(net); qemuDomainNetworkPrivate *netpriv =3D QEMU_DOMAIN_NETWORK_PRIVATE(net); VIR_AUTOCLOSE vdpafd =3D -1; + bool vhostfd =3D false; switch (actualType) { case VIR_DOMAIN_NET_TYPE_NETWORK: case VIR_DOMAIN_NET_TYPE_BRIDGE: + vhostfd =3D true; break; case VIR_DOMAIN_NET_TYPE_DIRECT: + vhostfd =3D true; break; case VIR_DOMAIN_NET_TYPE_ETHERNET: + vhostfd =3D true; break; case VIR_DOMAIN_NET_TYPE_VHOSTUSER: @@ -8712,6 +8716,11 @@ qemuBuildInterfaceConnect(virDomainObj *vm, break; } + if (vhostfd && !standalone) { + if (qemuInterfaceOpenVhostNet(vm, net) < 0) + return -1; + } + return 0; } @@ -8908,26 +8917,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, virNetDevSetMTU(net->ifname, net->mtu) < 0) goto cleanup; - if ((actualType =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK || - actualType =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE || - actualType =3D=3D VIR_DOMAIN_NET_TYPE_ETHERNET || - actualType =3D=3D VIR_DOMAIN_NET_TYPE_DIRECT) && - !standalone) { - /* Attempt to use vhost-net mode for these types of - network device */ - vhostfdSize =3D net->driver.virtio.queues; - if (!vhostfdSize) - vhostfdSize =3D 1; - - vhostfd =3D g_new0(int, vhostfdSize); - vhostfdName =3D g_new0(char *, vhostfdSize); - - memset(vhostfd, -1, vhostfdSize * sizeof(vhostfd[0])); - - if (qemuInterfaceOpenVhostNet(def, net, vhostfd, &vhostfdSize) < 0) - goto cleanup; - } - slirp =3D QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp; if (slirp && !standalone) { int slirpfd =3D qemuSlirpGetFD(slirp); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 90ca35bccf..2bede03e35 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1283,52 +1283,40 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, switch (actualType) { case VIR_DOMAIN_NET_TYPE_BRIDGE: case VIR_DOMAIN_NET_TYPE_NETWORK: - tapfdSize =3D vhostfdSize =3D net->driver.virtio.queues; + tapfdSize =3D net->driver.virtio.queues; if (!tapfdSize) - tapfdSize =3D vhostfdSize =3D 1; + tapfdSize =3D 1; tapfd =3D g_new0(int, tapfdSize); memset(tapfd, -1, sizeof(*tapfd) * tapfdSize); - vhostfd =3D g_new0(int, vhostfdSize); - memset(vhostfd, -1, sizeof(*vhostfd) * vhostfdSize); if (qemuInterfaceBridgeConnect(vm->def, driver, net, tapfd, &tapfdSize) < 0) goto cleanup; iface_connected =3D true; - if (qemuInterfaceOpenVhostNet(vm->def, net, vhostfd, &vhostfdSize)= < 0) - goto cleanup; break; case VIR_DOMAIN_NET_TYPE_DIRECT: - tapfdSize =3D vhostfdSize =3D net->driver.virtio.queues; + tapfdSize =3D net->driver.virtio.queues; if (!tapfdSize) - tapfdSize =3D vhostfdSize =3D 1; + tapfdSize =3D 1; tapfd =3D g_new0(int, tapfdSize); memset(tapfd, -1, sizeof(*tapfd) * tapfdSize); - vhostfd =3D g_new0(int, vhostfdSize); - memset(vhostfd, -1, sizeof(*vhostfd) * vhostfdSize); if (qemuInterfaceDirectConnect(vm->def, driver, net, tapfd, tapfdSize, VIR_NETDEV_VPORT_PROFILE_OP_CREATE)= < 0) goto cleanup; iface_connected =3D true; - if (qemuInterfaceOpenVhostNet(vm->def, net, vhostfd, &vhostfdSize)= < 0) - goto cleanup; break; case VIR_DOMAIN_NET_TYPE_ETHERNET: - tapfdSize =3D vhostfdSize =3D net->driver.virtio.queues; + tapfdSize =3D net->driver.virtio.queues; if (!tapfdSize) - tapfdSize =3D vhostfdSize =3D 1; + tapfdSize =3D 1; tapfd =3D g_new0(int, tapfdSize); memset(tapfd, -1, sizeof(*tapfd) * tapfdSize); - vhostfd =3D g_new0(int, vhostfdSize); - memset(vhostfd, -1, sizeof(*vhostfd) * vhostfdSize); if (qemuInterfaceEthernetConnect(vm->def, driver, net, tapfd, tapfdSize) < 0) goto cleanup; iface_connected =3D true; - if (qemuInterfaceOpenVhostNet(vm->def, net, vhostfd, &vhostfdSize)= < 0) - goto cleanup; break; case VIR_DOMAIN_NET_TYPE_VHOSTUSER: @@ -1445,7 +1433,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, if (!(netprops =3D qemuBuildHostNetProps(net, tapfdName, tapfdSize, - vhostfdName, vhostfdSize, + NULL, 0, slirpfdName))) goto cleanup; @@ -1481,7 +1469,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, if (qemuMonitorAddNetdev(priv->mon, &netprops, tapfd, tapfdName, tapfdSize, - vhostfd, vhostfdName, vhostfdSize, + NULL, NULL, 0, slirpfd, slirpfdName) < 0) { qemuDomainObjExitMonitor(vm); virDomainAuditNet(vm, NULL, net, "attach", false); diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c index e6a26e377f..c807be0745 100644 --- a/src/qemu/qemu_interface.c +++ b/src/qemu/qemu_interface.c @@ -688,49 +688,46 @@ qemuInterfacePrepareSlirp(virQEMUDriver *driver, /** * qemuInterfaceOpenVhostNet: - * @def: domain definition + * @vm: domain object * @net: network definition - * @qemuCaps: qemu binary capabilities - * @vhostfd: array of opened vhost-net device - * @vhostfdSize: number of file descriptors in @vhostfd array * * Open vhost-net, multiple times - if requested. - * In case, no vhost-net is needed, @vhostfdSize is set to 0 - * and 0 is returned. * * Returns: 0 on success * -1 on failure */ int -qemuInterfaceOpenVhostNet(virDomainDef *def, - virDomainNetDef *net, - int *vhostfd, - size_t *vhostfdSize) +qemuInterfaceOpenVhostNet(virDomainObj *vm, + virDomainNetDef *net) { + qemuDomainObjPrivate *priv =3D vm->privateData; + qemuDomainNetworkPrivate *netpriv =3D QEMU_DOMAIN_NETWORK_PRIVATE(net); size_t i; const char *vhostnet_path =3D net->backend.vhost; + size_t vhostfdSize =3D net->driver.virtio.queues; + g_autofree char *prefix =3D g_strdup_printf("vhostfd-%s", net->info.al= ias); + + if (!vhostfdSize) + vhostfdSize =3D 1; if (!vhostnet_path) vhostnet_path =3D "/dev/vhost-net"; /* If running a plain QEMU guest, or * if the config says explicitly to not use vhost, return now */ - if (def->virtType !=3D VIR_DOMAIN_VIRT_KVM || - net->driver.virtio.name =3D=3D VIR_DOMAIN_NET_BACKEND_TYPE_QEMU) { - *vhostfdSize =3D 0; + if (vm->def->virtType !=3D VIR_DOMAIN_VIRT_KVM || + net->driver.virtio.name =3D=3D VIR_DOMAIN_NET_BACKEND_TYPE_QEMU) return 0; - } /* If qemu doesn't support vhost-net mode (including the -netdev and * -device command options), don't try to open the device. */ - if (!qemuDomainSupportsNicdev(def, net)) { + if (!qemuDomainSupportsNicdev(vm->def, net)) { if (net->driver.virtio.name =3D=3D VIR_DOMAIN_NET_BACKEND_TYPE_VHO= ST) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("vhost-net is not supported with this QEMU bi= nary")); return -1; } - *vhostfdSize =3D 0; return 0; } @@ -741,35 +738,34 @@ qemuInterfaceOpenVhostNet(virDomainDef *def, _("vhost-net is only supported for virtio netwo= rk interfaces")); return -1; } - *vhostfdSize =3D 0; return 0; } - for (i =3D 0; i < *vhostfdSize; i++) { - vhostfd[i] =3D open(vhostnet_path, O_RDWR); + for (i =3D 0; i < vhostfdSize; i++) { + VIR_AUTOCLOSE fd =3D open(vhostnet_path, O_RDWR); + g_autoptr(qemuFDPass) pass =3D qemuFDPassNewDirect(prefix, priv); + g_autofree char *suffix =3D g_strdup_printf("%zu", i); /* If the config says explicitly to use vhost and we couldn't open= it, * report an error. */ - if (vhostfd[i] < 0) { - virDomainAuditNetDevice(def, net, vhostnet_path, false); + if (fd < 0) { + virDomainAuditNetDevice(vm->def, net, vhostnet_path, false); if (net->driver.virtio.name =3D=3D VIR_DOMAIN_NET_BACKEND_TYPE= _VHOST) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("vhost-net was requested for an interface= , but is unavailable")); - goto error; + return -1; } VIR_WARN("Unable to open vhost-net. Opened so far %zu, request= ed %zu", - i, *vhostfdSize); - *vhostfdSize =3D i; + i, vhostfdSize); break; } - } - virDomainAuditNetDevice(def, net, vhostnet_path, *vhostfdSize); - return 0; - error: - while (i--) - VIR_FORCE_CLOSE(vhostfd[i]); + qemuFDPassAddFD(pass, &fd, suffix); + netpriv->vhostfds =3D g_slist_prepend(netpriv->vhostfds, g_steal_p= ointer(&pass)); + } - return -1; + netpriv->vhostfds =3D g_slist_reverse(netpriv->vhostfds); + virDomainAuditNetDevice(vm->def, net, vhostnet_path, vhostfdSize); + return 0; } diff --git a/src/qemu/qemu_interface.h b/src/qemu/qemu_interface.h index 438d548065..a566d877b0 100644 --- a/src/qemu/qemu_interface.h +++ b/src/qemu/qemu_interface.h @@ -51,10 +51,8 @@ int qemuInterfaceBridgeConnect(virDomainDef *def, size_t *tapfdSize) ATTRIBUTE_NONNULL(2); -int qemuInterfaceOpenVhostNet(virDomainDef *def, - virDomainNetDef *net, - int *vhostfd, - size_t *vhostfdSize) G_GNUC_NO_INLINE; +int qemuInterfaceOpenVhostNet(virDomainObj *def, + virDomainNetDef *net) G_GNUC_NO_INLINE; int qemuInterfacePrepareSlirp(virQEMUDriver *driver, virDomainNetDef *net, diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index 08f176667d..aa82ffa2d6 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -226,20 +226,32 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *pa= th G_GNUC_UNUSED, } int -qemuInterfaceOpenVhostNet(virDomainDef *def G_GNUC_UNUSED, - virDomainNetDef *net, - int *vhostfd, - size_t *vhostfdSize) +qemuInterfaceOpenVhostNet(virDomainObj *vm, + virDomainNetDef *net) { + qemuDomainObjPrivate *priv =3D vm->privateData; + qemuDomainNetworkPrivate *netpriv =3D QEMU_DOMAIN_NETWORK_PRIVATE(net); + g_autofree char *prefix =3D g_strdup_printf("vhostfd-%s", net->info.al= ias); + size_t vhostfdSize =3D net->driver.virtio.queues; size_t i; - if (!virDomainNetIsVirtioModel(net)) { - *vhostfdSize =3D 0; + if (!vhostfdSize) + vhostfdSize =3D 1; + + if (!virDomainNetIsVirtioModel(net)) return 0; + + for (i =3D 0; i < vhostfdSize; i++) { + g_autoptr(qemuFDPass) pass =3D qemuFDPassNewDirect(prefix, priv); + g_autofree char *suffix =3D g_strdup_printf("%zu", i); + int fd =3D STDERR_FILENO + 42 + i; + + qemuFDPassAddFD(pass, &fd, suffix); + netpriv->vhostfds =3D g_slist_prepend(netpriv->vhostfds, g_steal_p= ointer(&pass)); } - for (i =3D 0; i < *vhostfdSize; i++) - vhostfd[i] =3D STDERR_FILENO + 42 + i; + netpriv->vhostfds =3D g_slist_reverse(netpriv->vhostfds); + return 0; } --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196249; cv=none; d=zohomail.com; s=zohoarc; b=UYKO9ql9EG8rtCHwpO5ZdVWhrhckDOMsnG3g8WUXh5r8E8EvZE4Sl3KgcCo8WiZeFTFouCOjuyhiDcKmQ5TJffLK23jrLJ4jhyQNmuboYX/DQtxJhp1PVFtN9hELMVRfaYRAZ/go/U+XDcdHz/aeRNBNZauwEXh6Nxh9mdsyOfU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196249; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ona7MmQ81ttmaM/nruhdCvOiHm/mw+NPY8T8DpMu6jQ=; b=Sn8j3WV/j/zEZnfAkY4fTnzrgrD2+RCKMBMTpjh6eXcgIp11VS7XjdwCiaZd4QtpRnILH2CKcGKDpNHecUqlXYUTj8Rnji+euUWlZRhWLO4LGoS8/wfc251aZX04ZNTzr4SNW75yb7GT+WYNz/bNvCJQVwH2BbKcvTItpXv5vAc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1652196249106447.20908312686504; Tue, 10 May 2022 08:24:09 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-17-uZbhpXlFPNqI8dona4cliA-1; Tue, 10 May 2022 11:23:32 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 52364101AA46; Tue, 10 May 2022 15:23:13 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0EDB814DFBA2; Tue, 10 May 2022 15:23:13 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7736B194705E; Tue, 10 May 2022 15:23:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 49DB31947060 for ; Tue, 10 May 2022 15:23:10 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2B46C200BCE9; Tue, 10 May 2022 15:23:10 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C9F4200C0DD for ; Tue, 10 May 2022 15:23:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196248; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Ona7MmQ81ttmaM/nruhdCvOiHm/mw+NPY8T8DpMu6jQ=; b=e9y2Dh2krJA9u/nAp8BcKOM0nyt5astD6Z8eYrO4L89UD8qd5n8t0Ytk3qACTr8mKYmbn8 pFLT2IhWFQZiTCY6EI4F5rVXr+AAS7hSysMp/TYyWcEUtx1tcsG5aNSRWUSVSo4aY8g3jb EOFtUabDb9IakpQgZ3g8pQKWLg12XTs= X-MC-Unique: uZbhpXlFPNqI8dona4cliA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 22/37] qemuDomainAttachNetDevice: Remove 'vhostfd' machinery Date: Tue, 10 May 2022 17:19:58 +0200 Message-Id: <66c798f4bbde963c28735827d2c6d150223ac2f7.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196251083100001 Content-Type: text/plain; charset="utf-8" Now all the helper variables and code are not needed. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 2bede03e35..68e8030929 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1188,9 +1188,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, char **tapfdName =3D NULL; int *tapfd =3D NULL; size_t tapfdSize =3D 0; - char **vhostfdName =3D NULL; - int *vhostfd =3D NULL; - size_t vhostfdSize =3D 0; g_autoptr(virJSONValue) nicprops =3D NULL; g_autoptr(virJSONValue) netprops =3D NULL; int ret =3D -1; @@ -1423,14 +1420,10 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, } tapfdName =3D g_new0(char *, tapfdSize); - vhostfdName =3D g_new0(char *, vhostfdSize); for (i =3D 0; i < tapfdSize; i++) tapfdName[i] =3D g_strdup_printf("fd-%s%zu", net->info.alias, i); - for (i =3D 0; i < vhostfdSize; i++) - vhostfdName[i] =3D g_strdup_printf("vhostfd-%s%zu", net->info.alia= s, i); - if (!(netprops =3D qemuBuildHostNetProps(net, tapfdName, tapfdSize, NULL, 0, @@ -1481,8 +1474,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, for (i =3D 0; i < tapfdSize; i++) VIR_FORCE_CLOSE(tapfd[i]); - for (i =3D 0; i < vhostfdSize; i++) - VIR_FORCE_CLOSE(vhostfd[i]); if (!(nicprops =3D qemuBuildNicDevProps(vm->def, net, priv->qemuCaps))) goto try_remove; @@ -1584,13 +1575,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, } VIR_FREE(tapfd); VIR_FREE(tapfdName); - for (i =3D 0; vhostfd && i < vhostfdSize; i++) { - VIR_FORCE_CLOSE(vhostfd[i]); - if (vhostfdName) - VIR_FREE(vhostfdName[i]); - } - VIR_FREE(vhostfd); - VIR_FREE(vhostfdName); virDomainCCWAddressSetFree(ccwaddrs); VIR_FORCE_CLOSE(slirpfd); --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196307; cv=none; d=zohomail.com; s=zohoarc; b=bO3poAl3Y3YqAA690nhtwFmEeQ9BuduVaLgS98pQm2rmxJ0EmuiKI16vsVUCSUMOakxax7seivdhUP/CbDIxFplboE5eTo/Dn6rUb376cM31d45JD6KROcyc9MlRrHXdq4HVlQZ00faZelocogeHW6hleoAPI0eW0/DNA1POoQw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196307; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=z4MDEEXMVtRqOR+wGEREK6H0ynnZcLkSoiolxwYal4s=; b=c6hloFpM5JEpOw2gI/EsNz7YYFUPoFeIdz93MLKpl6fbNn7WMNlzU872vY4AYmO0LN/JYHqr5ZU0yTubE39kM+Wt4otEBEv2TEalQbIG+YrJeFpPA320qpHZTkAfXPkIoEgzlFYrk6sgls19lWy5EP42B0CB/cIPBqM/j9VJyn4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1652196307128372.6422191474571; Tue, 10 May 2022 08:25:07 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-591-enV7Xrk4NXKQblnN8jHonQ-1; Tue, 10 May 2022 11:23:35 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 27317100DDF5; Tue, 10 May 2022 15:23:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FEDC54B074; Tue, 10 May 2022 15:23:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C174E1947062; Tue, 10 May 2022 15:23:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 71971194706B for ; Tue, 10 May 2022 15:23:11 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 62C702024CC8; Tue, 10 May 2022 15:23:11 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD6662024CBD for ; Tue, 10 May 2022 15:23:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196306; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=z4MDEEXMVtRqOR+wGEREK6H0ynnZcLkSoiolxwYal4s=; b=I48VSHHo6xhI8vODopi2/7yb1N5n7ZbKuPc6S9dg7VikRaZJjiCMHil4yAQBXXLBpCPUdA LbhfNYpu1vUPZIV9lreL++PSKltHcO1WaGMEU0p4FHR3tEdrTn0sNQ9U1UK1F2Tkq3b7qQ 2cnn1ag3N1dHIgt36mr/ExzB9W7fRAw= X-MC-Unique: enV7Xrk4NXKQblnN8jHonQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 23/37] qemuBuildInterfaceCommandLine: Remove 'vhostfd' machinery Date: Tue, 10 May 2022 17:19:59 +0200 Message-Id: <1faf5b6e37d6c918788aa719501c96b858aaafd2.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196308392100009 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 0b527784c5..d30c0de748 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8742,10 +8742,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, g_autofree char *nic =3D NULL; int *tapfd =3D NULL; size_t tapfdSize =3D 0; - int *vhostfd =3D NULL; - size_t vhostfdSize =3D 0; char **tapfdName =3D NULL; - char **vhostfdName =3D NULL; g_autofree char *slirpfdName =3D NULL; virDomainNetType actualType =3D virDomainNetGetActualType(net); const virNetDevBandwidth *actualBandwidth; @@ -8936,13 +8933,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, tapfd[i] =3D -1; } - for (i =3D 0; i < vhostfdSize; i++) { - vhostfdName[i] =3D g_strdup_printf("%d", vhostfd[i]); - virCommandPassFD(cmd, vhostfd[i], - VIR_COMMAND_PASS_FD_CLOSE_PARENT); - vhostfd[i] =3D -1; - } - for (n =3D netpriv->tapfds; n; n =3D n->next) { if (qemuFDPassTransferCommand(n->data, cmd) < 0) return -1; @@ -8958,7 +8948,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, if (!(hostnetprops =3D qemuBuildHostNetProps(net, tapfdName, tapfdSize, - vhostfdName, vhostfdSize, + NULL, 0, slirpfdName))) goto cleanup; @@ -9003,13 +8993,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, virDomainConfNWFilterTeardown(net); virErrorRestore(&saved_err); } - for (i =3D 0; vhostfd && i < vhostfdSize; i++) { - if (ret < 0) - VIR_FORCE_CLOSE(vhostfd[i]); - if (vhostfdName) - VIR_FREE(vhostfdName[i]); - } - VIR_FREE(vhostfdName); for (i =3D 0; tapfd && i < tapfdSize; i++) { if (ret < 0) VIR_FORCE_CLOSE(tapfd[i]); @@ -9017,7 +9000,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, VIR_FREE(tapfdName[i]); } VIR_FREE(tapfdName); - VIR_FREE(vhostfd); VIR_FREE(tapfd); return ret; } --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196303; cv=none; d=zohomail.com; s=zohoarc; b=EMprQiZyxok3qTC/EG6AckzzuX8BE9RHiz7JwAeFM/pAjKctFaF2RlyEkyDUGI1FQ8Rw/ifNMn5NPZn6mD55ze9hARRbTXoViVKIjDAVUKqqbufaPw+XvzkdqCcVYXFjtodZFcQdNxshDYBitJvuLi5fHG8hklSNaSG13N7RToc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196303; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=osYNAbU+R2DjffonVfEDeKnfmgIyQH9zHwB71Nesigc=; b=HE1Kwxez4VQxaucNoE/xSgTASe52Wglde03rkhPQLPrSpipH+wNZwnPGOPzK2lJkluFDk5whz0xW2TAGGSevEq+w1Z2+8QDEhw3EOeel12A6UciujMTyaiUtz6BLi0i/SpyHF4XTRvfyH5IJ0S3CBwmdeiMi1djpT4rsERiXPSQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1652196303751503.9538781183718; Tue, 10 May 2022 08:25:03 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-447-1KFio4fVN1GKyMjyRBKQMg-1; Tue, 10 May 2022 11:23:31 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 19667A18EF8; Tue, 10 May 2022 15:23:16 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 019D3C28106; Tue, 10 May 2022 15:23:16 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B8A621947079; Tue, 10 May 2022 15:23:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7BE73194705F for ; Tue, 10 May 2022 15:23:12 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 59ABB202699A; Tue, 10 May 2022 15:23:12 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id C46A4200C0DD for ; Tue, 10 May 2022 15:23:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196302; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=osYNAbU+R2DjffonVfEDeKnfmgIyQH9zHwB71Nesigc=; b=SZ4cLpivD7t2u+oz3q3HFHfw8tt+TTQeI2nLHpopbIUfTvsEWvH7Btul4E3Axsiy2KsgBw fMjj4/vQwdUJ7dzZf1yntkIrg6078Y2F0r2chS46z/6evJGdUAj+fb3VSM9uyeXKKrfH/h Pz9ZAkkEBcn09xY6KqhKnZgXaClLyNc= X-MC-Unique: 1KFio4fVN1GKyMjyRBKQMg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 24/37] qemuBuildHostNetProps: Remove 'vhostfd' machinery Date: Tue, 10 May 2022 17:20:00 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196304335100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 11 ----------- src/qemu/qemu_command.h | 2 -- src/qemu/qemu_hotplug.c | 1 - 3 files changed, 14 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d30c0de748..d23baa54a2 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4189,8 +4189,6 @@ virJSONValue * qemuBuildHostNetProps(virDomainNetDef *net, char **tapfd, size_t tapfdSize, - char **vhostfd, - size_t vhostfdSize, const char *slirpfd) { virDomainNetType netType =3D virDomainNetGetActualType(net); @@ -4256,14 +4254,6 @@ qemuBuildHostNetProps(virDomainNetDef *net, if (nfds > 1) vhostfd_field =3D "s:vhostfds"; - } else if (vhostfdSize > 0) { - vhost =3D true; - - for (i =3D 0; i < vhostfdSize; i++) - virBufferAsprintf(&buf, "%s:", vhostfd[i]); - - if (vhostfdSize > 1) - vhostfd_field =3D "s:vhostfds"; } virBufferTrim(&buf, ":"); @@ -8948,7 +8938,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, if (!(hostnetprops =3D qemuBuildHostNetProps(net, tapfdName, tapfdSize, - NULL, 0, slirpfdName))) goto cleanup; diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 3b487a647c..c26305927e 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -89,8 +89,6 @@ virJSONValue * qemuBuildHostNetProps(virDomainNetDef *net, char **tapfd, size_t tapfdSize, - char **vhostfd, - size_t vhostfdSize, const char *slirpfd); int diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 68e8030929..17fe072e02 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1426,7 +1426,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, if (!(netprops =3D qemuBuildHostNetProps(net, tapfdName, tapfdSize, - NULL, 0, slirpfdName))) goto cleanup; --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196305; cv=none; d=zohomail.com; s=zohoarc; b=AszNDyGyFirwHuhQNig746eE7uqYlC4BktvXKvdKZHZ2zmw+4qe3wEpTJs/FMMkIlRJw7K9Hi+lKxw3Z7gfP9nu0GSSG3DhEGVdJ0Eq6a7dkWppL5qlA3XvM+NOkBac4zY1kjSQe8Oe392+ci1WBXGrJyooK48X0NGzH3YZpsic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196305; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=J+YMOpGGqm10NTpuNDM+Qbk+ZLtAtcXQfLPyaa6cZso=; b=VbuLVstJCMkSqIKgMLEDvk/vmt2HQmh+fhod7YaYQCxy24I9isJALnEeqpUV/3FLMFs3YcjaHd9E48aBjC+VU/RVN9VtCefuvPBpleCXOQp7j52Hxw413CLyg+eZLdz8gQywKLxmYHkDQ9qvgADBrzGQw2lX4wxaYwe9odEx3X0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1652196305555953.2792580189715; Tue, 10 May 2022 08:25:05 -0700 (PDT) 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-245-naApR2MANOmJXtVOzYQiCA-1; Tue, 10 May 2022 11:23:36 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E05DE1C161C3; Tue, 10 May 2022 15:23:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF5D414DFBB4; Tue, 10 May 2022 15:23:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9020F1947062; Tue, 10 May 2022 15:23:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 58C3B194705D for ; Tue, 10 May 2022 15:23:13 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4839A200BCE9; Tue, 10 May 2022 15:23:13 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id B725E202699A for ; Tue, 10 May 2022 15:23:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196304; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=J+YMOpGGqm10NTpuNDM+Qbk+ZLtAtcXQfLPyaa6cZso=; b=Tx0LR8yu8E2gyS++yNvjYBeA98luVVrRe7Pf56+zjMH1Tn9FDI4KYcHtmrFPJ05MKswjYe tQQcGREu5rEfMi60G/Ab0bVTAGgw/TpBRb5wywjTTNqEMPBFtc2txTvtKwrXoeng6w04an /p4grFdFelsAHGffW9hRJzLae9w4Suw= X-MC-Unique: naApR2MANOmJXtVOzYQiCA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 25/37] qemuMonitorAddNetdev: Remove 'vhostfd' machinery Date: Tue, 10 May 2022 17:20:01 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196306350100005 Content-Type: text/plain; charset="utf-8" All callers now pass NULL/0 as arguments for vhostfd passing so we can remove all the associated code. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 3 +-- src/qemu/qemu_monitor.c | 14 ++------------ src/qemu/qemu_monitor.h | 1 - 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 17fe072e02..f7d3b38a6a 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1461,7 +1461,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, if (qemuMonitorAddNetdev(priv->mon, &netprops, tapfd, tapfdName, tapfdSize, - NULL, NULL, 0, slirpfd, slirpfdName) < 0) { qemuDomainObjExitMonitor(vm); virDomainAuditNet(vm, NULL, net, "attach", false); @@ -2242,7 +2241,7 @@ qemuDomainAttachChrDevice(virQEMUDriver *driver, if (netdevprops) { if (qemuMonitorAddNetdev(priv->mon, &netdevprops, - NULL, NULL, 0, NULL, NULL, 0, -1, NULL) <= 0) + NULL, NULL, 0, -1, NULL) < 0) goto exit_monitor; } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 39004201c0..57a9e9af62 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2631,17 +2631,15 @@ int qemuMonitorAddNetdev(qemuMonitor *mon, virJSONValue **props, int *tapfd, char **tapfdName, int tapfdSize, - int *vhostfd, char **vhostfdName, int vhostfdSize, int slirpfd, char *slirpfdName) { int ret =3D -1; - size_t i =3D 0, j =3D 0; + size_t i =3D 0; VIR_DEBUG("props=3D%p tapfd=3D%p tapfdName=3D%p tapfdSize=3D%d" - "vhostfd=3D%p vhostfdName=3D%p vhostfdSize=3D%d" "slirpfd=3D%d slirpfdName=3D%s", props, tapfd, tapfdName, tapfdSize, - vhostfd, vhostfdName, vhostfdSize, slirpfd, slirpfdName); + slirpfd, slirpfdName); QEMU_CHECK_MONITOR(mon); @@ -2649,10 +2647,6 @@ qemuMonitorAddNetdev(qemuMonitor *mon, if (qemuMonitorSendFileHandle(mon, tapfdName[i], tapfd[i]) < 0) goto cleanup; } - for (j =3D 0; j < vhostfdSize; j++) { - if (qemuMonitorSendFileHandle(mon, vhostfdName[j], vhostfd[j]) < 0) - goto cleanup; - } if (slirpfd > 0 && qemuMonitorSendFileHandle(mon, slirpfdName, slirpfd) < 0) @@ -2666,10 +2660,6 @@ qemuMonitorAddNetdev(qemuMonitor *mon, if (qemuMonitorCloseFileHandle(mon, tapfdName[i]) < 0) VIR_WARN("failed to close device handle '%s'", tapfdName[i= ]); } - while (j--) { - if (qemuMonitorCloseFileHandle(mon, vhostfdName[j]) < 0) - VIR_WARN("failed to close device handle '%s'", vhostfdName= [j]); - } if (qemuMonitorCloseFileHandle(mon, slirpfdName) < 0) VIR_WARN("failed to close device handle '%s'", slirpfdName); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 79d8486d08..1008b33671 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -984,7 +984,6 @@ int qemuMonitorCloseFileHandle(qemuMonitor *mon, int qemuMonitorAddNetdev(qemuMonitor *mon, virJSONValue **props, int *tapfd, char **tapfdName, int tapfdSize, - int *vhostfd, char **vhostfdName, int vhostfdSize, int slirpfd, char *slirpfdName); int qemuMonitorRemoveNetdev(qemuMonitor *mon, --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196392; cv=none; d=zohomail.com; s=zohoarc; b=e0sqtBg/AL0dEUNHuknrBQ8J1r6KvF/YSbB+hHtDSZ0jgJorHvUZL+oL6+oXXwpKmcXd04EjvQQMWs/RSuXmBpsBpnju/ryjbce9nQ/gDunZwwBc76LqhtdJvvqafm1lemk4EGbJhFgH8qRZBo+EZtVl7CzD7wBJ0FbW91IN94M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196392; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PL7TEpCW/gV2p9FmdnzRObt8hh35ahCfIhVaS4DE+rI=; b=b6ed6JFBJt/LpG3ZlURAoiE7Ov+sFu93hnX6VfURdTGHIH9AaCsnLDjxpwuVYQ7c+qTZ9az5Rht0Jail2BDeKqo1+GCgLe7Lzz2qbrf9fSZj1rgdXiWG6W3VMNFWux0xwAgOIlINa/YTl/HC5GkeeSFVKQA5E5IjchjN02JszBs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1652196392866844.9884457692169; Tue, 10 May 2022 08:26:32 -0700 (PDT) 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-610-hf1xdgVlOL2mH_qknycS9A-1; Tue, 10 May 2022 11:23:33 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C93523831C74; Tue, 10 May 2022 15:23:17 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B35941460E5C; Tue, 10 May 2022 15:23:17 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 744EE1947064; Tue, 10 May 2022 15:23:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5AA84194706D for ; Tue, 10 May 2022 15:23:14 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3943B202699A; Tue, 10 May 2022 15:23:14 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id A80F22024CBD for ; Tue, 10 May 2022 15:23:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196391; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=PL7TEpCW/gV2p9FmdnzRObt8hh35ahCfIhVaS4DE+rI=; b=eKqMNwmB+OXEpBRM/2haW+69IpWDGNaZCsng/oM+7rtAbPz7kKX1QAGgnf+h1HZKHhUNX3 z6sOZ6zZWZrGUVKg+cvA7zjQM7v+tClxmCEYB4GUlRBKwCFlzCYsvFH2fh5ux56zivVGYN 8KpVrBAn8/B5sga5MJKo6TZnFgmXbws= X-MC-Unique: hf1xdgVlOL2mH_qknycS9A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 26/37] qemu: Move opening of tap file descriptors for net devices into qemuBuildInterfaceConnect Date: Tue, 10 May 2022 17:20:02 +0200 Message-Id: <503934a4404dbcbee9e3a47b22169e6f71d953cc.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196394885100005 Content-Type: text/plain; charset="utf-8" Use the new infrastructure which stores the fds inside 'qemuFDPass' objects in the private data. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 82 ++++++++++++++++++++--------------------- src/qemu/qemu_command.h | 1 + src/qemu/qemu_hotplug.c | 36 ++---------------- 3 files changed, 44 insertions(+), 75 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d23baa54a2..78baa840a8 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8661,6 +8661,7 @@ qemuInterfaceVhostuserConnect(virCommand *cmd, int qemuBuildInterfaceConnect(virDomainObj *vm, virDomainNetDef *net, + virNetDevVPortProfileOp vmop, bool standalone) { @@ -8668,19 +8669,33 @@ qemuBuildInterfaceConnect(virDomainObj *vm, virDomainNetType actualType =3D virDomainNetGetActualType(net); qemuDomainNetworkPrivate *netpriv =3D QEMU_DOMAIN_NETWORK_PRIVATE(net); VIR_AUTOCLOSE vdpafd =3D -1; - bool vhostfd =3D false; + bool vhostfd =3D false; /* also used to signal processing of tapfds */ + size_t tapfdSize =3D net->driver.virtio.queues; + g_autofree int *tapfd =3D g_new0(int, tapfdSize + 1); + + if (tapfdSize =3D=3D 0) + tapfdSize =3D 1; switch (actualType) { case VIR_DOMAIN_NET_TYPE_NETWORK: case VIR_DOMAIN_NET_TYPE_BRIDGE: vhostfd =3D true; + if (qemuInterfaceBridgeConnect(vm->def, priv->driver, net, + tapfd, &tapfdSize) < 0) + return -1; break; case VIR_DOMAIN_NET_TYPE_DIRECT: vhostfd =3D true; + if (qemuInterfaceDirectConnect(vm->def, priv->driver, net, + tapfd, tapfdSize, vmop) < 0) + return -1; break; case VIR_DOMAIN_NET_TYPE_ETHERNET: + if (qemuInterfaceEthernetConnect(vm->def, priv->driver, net, + tapfd, tapfdSize) < 0) + return -1; vhostfd =3D true; break; @@ -8706,6 +8721,29 @@ qemuBuildInterfaceConnect(virDomainObj *vm, break; } + /* 'vhostfd' is set to true in all cases when we need to process tapfd= s */ + if (vhostfd) { + g_autofree char *prefix =3D g_strdup_printf("tapfd-%s", net->info.= alias); + size_t i; + + for (i =3D 0; i < tapfdSize; i++) { + g_autoptr(qemuFDPass) pass =3D qemuFDPassNewDirect(prefix, pri= v); + g_autofree char *suffix =3D g_strdup_printf("%zu", i); + int fd =3D tapfd[i]; /* we want to keep the array intact for s= ecurity labeling*/ + + qemuFDPassAddFD(pass, &fd, suffix); + netpriv->tapfds =3D g_slist_prepend(netpriv->tapfds, g_steal_p= ointer(&pass)); + } + + netpriv->tapfds =3D g_slist_reverse(netpriv->tapfds); + + for (i =3D 0; i < tapfdSize; i++) { + if (qemuSecuritySetTapFDLabel(priv->driver->securityManager, + vm->def, tapfd[i]) < 0) + return -1; + } + } + if (vhostfd && !standalone) { if (qemuInterfaceOpenVhostNet(vm, net) < 0) return -1; @@ -8746,54 +8784,14 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, if (qemuDomainValidateActualNetDef(net, qemuCaps) < 0) return -1; - if (qemuBuildInterfaceConnect(vm, net, standalone) < 0) + if (qemuBuildInterfaceConnect(vm, net, vmop, standalone) < 0) return -1; switch (actualType) { case VIR_DOMAIN_NET_TYPE_NETWORK: case VIR_DOMAIN_NET_TYPE_BRIDGE: - tapfdSize =3D net->driver.virtio.queues; - if (!tapfdSize) - tapfdSize =3D 1; - - tapfd =3D g_new0(int, tapfdSize); - tapfdName =3D g_new0(char *, tapfdSize); - - memset(tapfd, -1, tapfdSize * sizeof(tapfd[0])); - - if (qemuInterfaceBridgeConnect(def, driver, net, - tapfd, &tapfdSize) < 0) - goto cleanup; - break; - case VIR_DOMAIN_NET_TYPE_DIRECT: - tapfdSize =3D net->driver.virtio.queues; - if (!tapfdSize) - tapfdSize =3D 1; - - tapfd =3D g_new0(int, tapfdSize); - tapfdName =3D g_new0(char *, tapfdSize); - - memset(tapfd, -1, tapfdSize * sizeof(tapfd[0])); - - if (qemuInterfaceDirectConnect(def, driver, net, - tapfd, tapfdSize, vmop) < 0) - goto cleanup; - break; - case VIR_DOMAIN_NET_TYPE_ETHERNET: - tapfdSize =3D net->driver.virtio.queues; - if (!tapfdSize) - tapfdSize =3D 1; - - tapfd =3D g_new0(int, tapfdSize); - tapfdName =3D g_new0(char *, tapfdSize); - - memset(tapfd, -1, tapfdSize * sizeof(tapfd[0])); - - if (qemuInterfaceEthernetConnect(def, driver, net, - tapfd, tapfdSize) < 0) - goto cleanup; break; case VIR_DOMAIN_NET_TYPE_HOSTDEV: diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index c26305927e..5a65d94d6f 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -94,6 +94,7 @@ qemuBuildHostNetProps(virDomainNetDef *net, int qemuBuildInterfaceConnect(virDomainObj *vm, virDomainNetDef *net, + virNetDevVPortProfileOp vmop, bool standalone); /* Current, best practice */ diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index f7d3b38a6a..9c6f9e673c 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1274,46 +1274,16 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, */ VIR_APPEND_ELEMENT_COPY(vm->def->nets, vm->def->nnets, net); - if (qemuBuildInterfaceConnect(vm, net, false) < 0) + if (qemuBuildInterfaceConnect(vm, net, VIR_NETDEV_VPORT_PROFILE_OP_CRE= ATE, false) < 0) return -1; + iface_connected =3D true; + switch (actualType) { case VIR_DOMAIN_NET_TYPE_BRIDGE: case VIR_DOMAIN_NET_TYPE_NETWORK: - tapfdSize =3D net->driver.virtio.queues; - if (!tapfdSize) - tapfdSize =3D 1; - tapfd =3D g_new0(int, tapfdSize); - memset(tapfd, -1, sizeof(*tapfd) * tapfdSize); - if (qemuInterfaceBridgeConnect(vm->def, driver, net, - tapfd, &tapfdSize) < 0) - goto cleanup; - iface_connected =3D true; - break; - case VIR_DOMAIN_NET_TYPE_DIRECT: - tapfdSize =3D net->driver.virtio.queues; - if (!tapfdSize) - tapfdSize =3D 1; - tapfd =3D g_new0(int, tapfdSize); - memset(tapfd, -1, sizeof(*tapfd) * tapfdSize); - if (qemuInterfaceDirectConnect(vm->def, driver, net, - tapfd, tapfdSize, - VIR_NETDEV_VPORT_PROFILE_OP_CREATE)= < 0) - goto cleanup; - iface_connected =3D true; - break; - case VIR_DOMAIN_NET_TYPE_ETHERNET: - tapfdSize =3D net->driver.virtio.queues; - if (!tapfdSize) - tapfdSize =3D 1; - tapfd =3D g_new0(int, tapfdSize); - memset(tapfd, -1, sizeof(*tapfd) * tapfdSize); - if (qemuInterfaceEthernetConnect(vm->def, driver, net, - tapfd, tapfdSize) < 0) - goto cleanup; - iface_connected =3D true; break; case VIR_DOMAIN_NET_TYPE_VHOSTUSER: --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196392; cv=none; d=zohomail.com; s=zohoarc; b=AmSaVrKR3x4i7ojLu5EQd0Sbsfvbi2Yf5oldMH/4Ragf/lLKawkoQ51jKNxeXg+2TIiDI9oeiFcFvoaTiMShvg1EJX64tHXJM3nxMMw3kKAeWBGy4hKQj9l33jaW2LoMe2so4iC0vSN4+6edeZKwppEXJH9qt6zUnR80fnfXemo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196392; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YURCQUIxueNFOvFP5HCUmyzaJjSBrxayFnxti8DXQdk=; b=L/ljZgNk0CuzPETdyRoIblDqVGhgt3KpknSYpk11/vweQaXwOU4b8rksUqd6gqO24JPA1+hxL1TWE4WPxnIACwnqDxU5uBisUpL721HoFcKIOaj8HxmsAo3UTEy+yT5r6oKUSdAGzoi600NbTKsQY3CCgvg1QwiPuFZZVvcUeUA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1652196392270332.1728860746989; Tue, 10 May 2022 08:26:32 -0700 (PDT) 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-558-jO5Qaz6YOy6T4gX4tTvfyA-1; Tue, 10 May 2022 11:23:35 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 397472919EAE; Tue, 10 May 2022 15:23:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24B77C27E94; Tue, 10 May 2022 15:23:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5074B1947BA7; Tue, 10 May 2022 15:23:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3B20D1947072 for ; Tue, 10 May 2022 15:23:15 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0F205200BCE9; Tue, 10 May 2022 15:23:15 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 918DC202699A for ; Tue, 10 May 2022 15:23:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196391; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=YURCQUIxueNFOvFP5HCUmyzaJjSBrxayFnxti8DXQdk=; b=dotp7plgZcQnQJEUAUwxRnOcob7oHNpNzk2pbbxXPTk8fjjzxza8DDrbhO/5ehfrZswzLy b4oeXpa+zK/zZiKcdewJatH/vb1r2VsGtDalnmiyx+fKkbCRyAaZijHppos/cOiv2Y2ROT oHkRrrAk/u2CV2gJGn/bSkAT7Ekx72s= X-MC-Unique: jO5Qaz6YOy6T4gX4tTvfyA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 27/37] qemuBuildInterfaceCommandLine: Remove 'tapfd' infrastructure Date: Tue, 10 May 2022 17:20:03 +0200 Message-Id: <4e08dd7135f97ee557e6ed4fbef3334514a45fa8.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196392884100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 78baa840a8..a3b4b8c412 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8768,15 +8768,11 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, int ret =3D -1; g_autoptr(virJSONValue) nicprops =3D NULL; g_autofree char *nic =3D NULL; - int *tapfd =3D NULL; - size_t tapfdSize =3D 0; - char **tapfdName =3D NULL; g_autofree char *slirpfdName =3D NULL; virDomainNetType actualType =3D virDomainNetGetActualType(net); const virNetDevBandwidth *actualBandwidth; bool requireNicdev =3D false; qemuSlirp *slirp; - size_t i; g_autoptr(virJSONValue) hostnetprops =3D NULL; qemuDomainNetworkPrivate *netpriv =3D QEMU_DOMAIN_NETWORK_PRIVATE(net); GSList *n; @@ -8910,17 +8906,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, slirpfdName =3D g_strdup_printf("%d", slirpfd); } - - for (i =3D 0; i < tapfdSize; i++) { - if (qemuSecuritySetTapFDLabel(driver->securityManager, - def, tapfd[i]) < 0) - goto cleanup; - tapfdName[i] =3D g_strdup_printf("%d", tapfd[i]); - virCommandPassFD(cmd, tapfd[i], - VIR_COMMAND_PASS_FD_CLOSE_PARENT); - tapfd[i] =3D -1; - } - for (n =3D netpriv->tapfds; n; n =3D n->next) { if (qemuFDPassTransferCommand(n->data, cmd) < 0) return -1; @@ -8935,7 +8920,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, return -1; if (!(hostnetprops =3D qemuBuildHostNetProps(net, - tapfdName, tapfdSize, + NULL, 0, slirpfdName))) goto cleanup; @@ -8980,14 +8965,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, virDomainConfNWFilterTeardown(net); virErrorRestore(&saved_err); } - for (i =3D 0; tapfd && i < tapfdSize; i++) { - if (ret < 0) - VIR_FORCE_CLOSE(tapfd[i]); - if (tapfdName) - VIR_FREE(tapfdName[i]); - } - VIR_FREE(tapfdName); - VIR_FREE(tapfd); return ret; } --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196263; cv=none; d=zohomail.com; s=zohoarc; b=CvWN6B0m/I70zIxBKod44v1rKbd6vupkg0NYm1SUQZff2akUsHHahPzV3W+QHQ0w9sTm5+Sp3CfD12cZ60eNo6kdunUfqJO3rJBXITtKTJD23uH9Qwox4VrFwM1dYbBiy7zpA58782nSlmOK8mFXhYOLB87WBmyPJJeIhcWUS2o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196263; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jAoZPKNnCFE9lj+8UWQu1zeUst87uT1aRJDTBshnMVA=; b=nDDB8XGLi8eD4LX0/lz3aHZE2QUMAq0S6q+U4z8oaCzqZg9SV0w9dn7f4F1veCht4zIZb8JX4iiTXgBBPhcN+6hegxsgqwL/nxD0rGnr44WOWFtn8g2bQGG8lQxw3JECQkolXNFa2bSLMpS2aOyB/vH2hqB5LNC0wQqt0NeYzn8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1652196263493333.8890394828437; Tue, 10 May 2022 08:24:23 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-107-AV3_ZNWGMReB_vlqq8BctQ-1; Tue, 10 May 2022 11:24:00 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D6DDC805F0A; Tue, 10 May 2022 15:23:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C278F54B070; Tue, 10 May 2022 15:23:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 710A1194705F; Tue, 10 May 2022 15:23:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CD3F21947061 for ; Tue, 10 May 2022 15:23:32 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A80F1200C0DA; Tue, 10 May 2022 15:23:32 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 222BB2024CC8 for ; Tue, 10 May 2022 15:23:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196262; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=jAoZPKNnCFE9lj+8UWQu1zeUst87uT1aRJDTBshnMVA=; b=HDL8YNzt2Fiiiqqq4GE/82BhM0S8UMaskFWkbzyBb6dmA1DFNc/qbeqfo0lK3RNsMx+/wm dr9qRQOkFN953i4tZVqHHJJFw8sTJ1lnoSuI7vJaeqGL6PQxFn+XesPgfHnVll1BQTXXfm +K/F7cWHnWdP0gVm5M7qfSsTBtn4p0M= X-MC-Unique: AV3_ZNWGMReB_vlqq8BctQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 28/37] qemuDomainAttachNetDevice: Remove unused 'tapfd' infrastructure Date: Tue, 10 May 2022 17:20:04 +0200 Message-Id: <5cdb9ecd7557858a9ec71bba0eaf1e840ba770d0.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196265388100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 9c6f9e673c..c3891ddca7 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1185,9 +1185,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, virErrorPtr originalError =3D NULL; g_autofree char *slirpfdName =3D NULL; int slirpfd =3D -1; - char **tapfdName =3D NULL; - int *tapfd =3D NULL; - size_t tapfdSize =3D 0; g_autoptr(virJSONValue) nicprops =3D NULL; g_autoptr(virJSONValue) netprops =3D NULL; int ret =3D -1; @@ -1198,7 +1195,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, const virNetDevBandwidth *actualBandwidth; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); virDomainCCWAddressSet *ccwaddrs =3D NULL; - size_t i; g_autofree char *charDevAlias =3D NULL; bool charDevPlugged =3D false; bool netdevPlugged =3D false; @@ -1383,19 +1379,8 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, virNetDevSetMTU(net->ifname, net->mtu) < 0) goto cleanup; - for (i =3D 0; i < tapfdSize; i++) { - if (qemuSecuritySetTapFDLabel(driver->securityManager, - vm->def, tapfd[i]) < 0) - goto cleanup; - } - - tapfdName =3D g_new0(char *, tapfdSize); - - for (i =3D 0; i < tapfdSize; i++) - tapfdName[i] =3D g_strdup_printf("fd-%s%zu", net->info.alias, i); - if (!(netprops =3D qemuBuildHostNetProps(net, - tapfdName, tapfdSize, + NULL, 0, slirpfdName))) goto cleanup; @@ -1430,7 +1415,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, } if (qemuMonitorAddNetdev(priv->mon, &netprops, - tapfd, tapfdName, tapfdSize, + NULL, NULL, 0, slirpfd, slirpfdName) < 0) { qemuDomainObjExitMonitor(vm); virDomainAuditNet(vm, NULL, net, "attach", false); @@ -1440,9 +1425,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, qemuDomainObjExitMonitor(vm); - for (i =3D 0; i < tapfdSize; i++) - VIR_FORCE_CLOSE(tapfd[i]); - if (!(nicprops =3D qemuBuildNicDevProps(vm->def, net, priv->qemuCaps))) goto try_remove; @@ -1536,13 +1518,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, virErrorRestore(&save_err); } - for (i =3D 0; tapfd && i < tapfdSize; i++) { - VIR_FORCE_CLOSE(tapfd[i]); - if (tapfdName) - VIR_FREE(tapfdName[i]); - } - VIR_FREE(tapfd); - VIR_FREE(tapfdName); virDomainCCWAddressSetFree(ccwaddrs); VIR_FORCE_CLOSE(slirpfd); --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196329; cv=none; d=zohomail.com; s=zohoarc; b=CfzFpQIDfzfJVkUZmm6jJ9DoPGqx191l3uSzrvlEeYmqNJJkTP5hDIbyR5CCoJeohWJJuHhmXo3Zw7opeePbEb0zJMVASWnBByEarMvVsHYNHLcV44YVOHYGXcuc1scD1oUiD0bxQhGmfdeitnigycjseoTMW3LQhgYx5hN2l44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196329; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CV0uvw5bLvIQs5VxsylLwgMtl6ooGLVKbQNk1LEokGY=; b=XiPy9Py9+Vi5GPGnToA8mEkX12Q1D6djS1dLXT7cuQDGyoLVFW2PGDV6Ag4Yp0HKDavJa/4bF2oW5JznDee/LqPHY5DrMzSpkRCccCtY9d8rR6lcWTeqSbEardf7MVSo1h0XZmvipeTBkYa294qL+bREq+ASu9XBCzonR3msYAE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1652196329459727.1306918955586; Tue, 10 May 2022 08:25:29 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-475-rsnmWxWpPUueT1gp6_HTKQ-1; Tue, 10 May 2022 11:23:40 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1CDFA106655A; Tue, 10 May 2022 15:23:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0554140CFD06; Tue, 10 May 2022 15:23:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BA6BE1947B85; Tue, 10 May 2022 15:23:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 98BF4194705F for ; Tue, 10 May 2022 15:23:33 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 802D6200C0DB; Tue, 10 May 2022 15:23:33 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E966200C0DA for ; Tue, 10 May 2022 15:23:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196328; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=CV0uvw5bLvIQs5VxsylLwgMtl6ooGLVKbQNk1LEokGY=; b=HhKWfpbkBT1kJeaY2c4bK8QE859t+tZTuc1HlWbU5xWZ7ICGIDrdCaywyz76mt1iHseV+B wbF6YCn0tE/PnghOtSQCJEVmhC3n1cvz5eoyuwas4fAZSVysqy6nZzEwxolsIsMfDymIAz s1lYFTTbcLMpU+VCwHsOkKgjRiSiczE= X-MC-Unique: rsnmWxWpPUueT1gp6_HTKQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 29/37] qemuBuildNicDevProps: Remove unused 'tapfd' infrastructure Date: Tue, 10 May 2022 17:20:05 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196330526100001 Content-Type: text/plain; charset="utf-8" All callers pass NULL/0. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 9 --------- src/qemu/qemu_command.h | 2 -- src/qemu/qemu_hotplug.c | 1 - 3 files changed, 12 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a3b4b8c412..92b91b0a52 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4187,8 +4187,6 @@ qemuBuildNicDevProps(virDomainDef *def, virJSONValue * qemuBuildHostNetProps(virDomainNetDef *net, - char **tapfd, - size_t tapfdSize, const char *slirpfd) { virDomainNetType netType =3D virDomainNetGetActualType(net); @@ -4232,12 +4230,6 @@ qemuBuildHostNetProps(virDomainNetDef *net, if (nfds > 1) tapfd_field =3D "s:fds"; - } else { - for (i =3D 0; i < tapfdSize; i++) - virBufferAsprintf(&buf, "%s:", tapfd[i]); - - if (tapfdSize > 1) - tapfd_field =3D "s:fds"; } virBufferTrim(&buf, ":"); @@ -8920,7 +8912,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, return -1; if (!(hostnetprops =3D qemuBuildHostNetProps(net, - NULL, 0, slirpfdName))) goto cleanup; diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 5a65d94d6f..9bb63d9598 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -87,8 +87,6 @@ qemuBuildChannelGuestfwdNetdevProps(virDomainChrDef *chr); virJSONValue * qemuBuildHostNetProps(virDomainNetDef *net, - char **tapfd, - size_t tapfdSize, const char *slirpfd); int diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index c3891ddca7..9f71977a4d 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1380,7 +1380,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, goto cleanup; if (!(netprops =3D qemuBuildHostNetProps(net, - NULL, 0, slirpfdName))) goto cleanup; --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196230; cv=none; d=zohomail.com; s=zohoarc; b=CnRUo187zCvkEnK+Gbs6/uCOi3nbCIyYmbxCP7GfiYQGXhaev1cMldTVdhnju4CgCrbEPb7QppTPqxDaDKBTSRa9Ry/suF1AHo4NSsSeiU0lyALyuiF5Z7d7qZQ15PEiQFq8w6Yt3ziKjrVwKgVdvMQ1qLOBDUduXDMVJC4kgbw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196230; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=un7DlggJdqsbOy/PNxt0BdDF06LB7p9ByMRR6czXQDw=; b=l0H0e7+Eabq2CrIGyUDOQ1CHJa/PgQEfUAujjI4Flr1dVm5jfRSGhEocEnfjMyToJvSoXZgHzBg9Gt41Zf2uMmvHJmPpo/oSZ01XWJGfz12SUnKzgdi/HzZtDZ7+3jpxMpQWOg/1umBYzKooTIDcTBkn0vA7zCLrL1MXJPkb9tk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 165219623086892.00146108807485; Tue, 10 May 2022 08:23:50 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-443-RRsh-LWTNw-6rZSAAcN2bg-1; Tue, 10 May 2022 11:23:46 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E9D72A18EE9; Tue, 10 May 2022 15:23:42 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5F684087D63; Tue, 10 May 2022 15:23:42 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 891AF194704D; Tue, 10 May 2022 15:23:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 788F61947072 for ; Tue, 10 May 2022 15:23:34 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 56C8C2024CBD; Tue, 10 May 2022 15:23:34 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id D03BF200C0DA for ; Tue, 10 May 2022 15:23:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196229; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=un7DlggJdqsbOy/PNxt0BdDF06LB7p9ByMRR6czXQDw=; b=Cxmjrd3MmRLwtHUiIIDMDLXB9YHJB5RqQbdQDXnSdewU6P9vmBcs/+p2o4TpZoz3iX4TIG eEmI3scxeH7BfxWoplynYY3M8JTxsVifAn5CdlaFxZ6vO61rHaY5UwVYvbYszM8MAXfV7C IH2k8mPX4Zp/4XF3As2FCxtBY/yx2l8= X-MC-Unique: RRsh-LWTNw-6rZSAAcN2bg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 30/37] qemuMonitorAddNetdev: Remove unused 'tapfd' infrastructure Date: Tue, 10 May 2022 17:20:06 +0200 Message-Id: <740de48601da548a538a4b44642a78f4922ceebf.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196232973100001 Content-Type: text/plain; charset="utf-8" All callers pass NULL/0. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 3 +-- src/qemu/qemu_monitor.c | 15 ++------------- src/qemu/qemu_monitor.h | 1 - 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 9f71977a4d..e126632507 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1414,7 +1414,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, } if (qemuMonitorAddNetdev(priv->mon, &netprops, - NULL, NULL, 0, slirpfd, slirpfdName) < 0) { qemuDomainObjExitMonitor(vm); virDomainAuditNet(vm, NULL, net, "attach", false); @@ -2185,7 +2184,7 @@ qemuDomainAttachChrDevice(virQEMUDriver *driver, if (netdevprops) { if (qemuMonitorAddNetdev(priv->mon, &netdevprops, - NULL, NULL, 0, -1, NULL) < 0) + -1, NULL) < 0) goto exit_monitor; } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 57a9e9af62..a71311d0c4 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2630,24 +2630,17 @@ qemuMonitorCloseFileHandle(qemuMonitor *mon, int qemuMonitorAddNetdev(qemuMonitor *mon, virJSONValue **props, - int *tapfd, char **tapfdName, int tapfdSize, int slirpfd, char *slirpfdName) { int ret =3D -1; - size_t i =3D 0; - VIR_DEBUG("props=3D%p tapfd=3D%p tapfdName=3D%p tapfdSize=3D%d" + VIR_DEBUG("props=3D%p " "slirpfd=3D%d slirpfdName=3D%s", - props, tapfd, tapfdName, tapfdSize, + props, slirpfd, slirpfdName); QEMU_CHECK_MONITOR(mon); - for (i =3D 0; i < tapfdSize; i++) { - if (qemuMonitorSendFileHandle(mon, tapfdName[i], tapfd[i]) < 0) - goto cleanup; - } - if (slirpfd > 0 && qemuMonitorSendFileHandle(mon, slirpfdName, slirpfd) < 0) goto cleanup; @@ -2656,10 +2649,6 @@ qemuMonitorAddNetdev(qemuMonitor *mon, cleanup: if (ret < 0) { - while (i--) { - if (qemuMonitorCloseFileHandle(mon, tapfdName[i]) < 0) - VIR_WARN("failed to close device handle '%s'", tapfdName[i= ]); - } if (qemuMonitorCloseFileHandle(mon, slirpfdName) < 0) VIR_WARN("failed to close device handle '%s'", slirpfdName); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 1008b33671..a49ef180c1 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -983,7 +983,6 @@ int qemuMonitorCloseFileHandle(qemuMonitor *mon, int qemuMonitorAddNetdev(qemuMonitor *mon, virJSONValue **props, - int *tapfd, char **tapfdName, int tapfdSize, int slirpfd, char *slirpfdName); int qemuMonitorRemoveNetdev(qemuMonitor *mon, --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196227; cv=none; d=zohomail.com; s=zohoarc; b=VED//qfF2SXc0Sh4JAoYOOnzr9/IMORi0be1Xzw4iD3tXaEA+4nJfsVnEKJOk308DpDvGD6caltxyhdEjQntXU3RgorCE2/ruHPC1NyzN1FebXiu38nLlUkwkCFIq/P7GL6NnnpLV/sdtk7LH4OviBlB6R3e+AJbi1waURlItq4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196227; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OTRAV/So/BzY5KAm56CACbyhcF1oZUionb5CLaHGniY=; b=LQ2wZErd8MTV/fBL650LTxmvekOabbuGVUQLZ7dZBrb/xCqZM1tbyU310Nm0phiDgIU2/arMwDOXyM2bz4o/FKTkCLAibnM0ecgnpO73H0dPeIMsU67VkV0nQA8xkPWaZYZioeHuWs/dI/9yOJcfaN0+ym+WfdmL6TnjXip0fRw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1652196227581530.0695224307697; Tue, 10 May 2022 08:23:47 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-659-ZHPCj6q0NiyYoOGUgVnb1w-1; Tue, 10 May 2022 11:23:43 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B970C851788; Tue, 10 May 2022 15:23:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A3A7114DFB9D; Tue, 10 May 2022 15:23:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 28EC41947062; Tue, 10 May 2022 15:23:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 51F8F1947060 for ; Tue, 10 May 2022 15:23:35 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 33DB0200C0DA; Tue, 10 May 2022 15:23:35 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id B211C2024CBD for ; Tue, 10 May 2022 15:23:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196226; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=OTRAV/So/BzY5KAm56CACbyhcF1oZUionb5CLaHGniY=; b=GYc2qHlxbSxXGq7FyN9cbmrsj6dgU8nrUtLhKfYnpkAtDz4mbOTsOUu1TnPSR3Udz2W6q4 elarUsJmgYggrdyfw7maYO929tX2pAwqd43hAs9lInVwAmMmfhzilPeAg51RT2/n56eXTe mzW9ea8+AGMDsoLjF2ec707JwOJ54E4= X-MC-Unique: ZHPCj6q0NiyYoOGUgVnb1w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 31/37] qemuInterfacePrepareSlirp: Directly populate the 'slirp' variable in network private data Date: Tue, 10 May 2022 17:20:07 +0200 Message-Id: <7b13aee6a12a656861d58e4aa1d424e00e4d1aad.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196228964100001 Content-Type: text/plain; charset="utf-8" Both callers populate the variable when qemuInterfacePrepareSlirp returned 1. We can save the hassle in the callers by just doing it right away. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 8 +++----- src/qemu/qemu_interface.c | 10 +++++----- src/qemu/qemu_interface.h | 3 +-- src/qemu/qemu_process.c | 7 +------ 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index e126632507..8314d0e546 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1306,14 +1306,12 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, if (!priv->disableSlirp && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DBUS_VMSTATE)) { qemuSlirp *slirp =3D NULL; - int rv =3D qemuInterfacePrepareSlirp(driver, net, &slirp); - if (rv =3D=3D -1) + if (qemuInterfacePrepareSlirp(driver, net) < 0) goto cleanup; - if (rv =3D=3D 0) - break; - QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp =3D slirp; + if (!(slirp =3D QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp)) + break; if (qemuSlirpOpen(slirp, driver, vm->def) < 0 || qemuSlirpStart(slirp, vm, driver, net, NULL) < 0) { diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c index c807be0745..bda96808eb 100644 --- a/src/qemu/qemu_interface.c +++ b/src/qemu/qemu_interface.c @@ -651,12 +651,12 @@ qemuInterfaceVDPAConnect(virDomainNetDef *net) /* - * Returns: -1 on error, 0 if slirp isn't available, 1 on success + * Returns: -1 on error, 0 on success. Populates net->privateData->slirp if + * the slirp helper is needed. */ int qemuInterfacePrepareSlirp(virQEMUDriver *driver, - virDomainNetDef *net, - qemuSlirp **slirpret) + virDomainNetDef *net) { g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); g_autoptr(qemuSlirp) slirp =3D NULL; @@ -681,8 +681,8 @@ qemuInterfacePrepareSlirp(virQEMUDriver *driver, return 0; } - *slirpret =3D g_steal_pointer(&slirp); - return 1; + QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp =3D g_steal_pointer(&slirp); + return 0; } diff --git a/src/qemu/qemu_interface.h b/src/qemu/qemu_interface.h index a566d877b0..e359d4f520 100644 --- a/src/qemu/qemu_interface.h +++ b/src/qemu/qemu_interface.h @@ -55,7 +55,6 @@ int qemuInterfaceOpenVhostNet(virDomainObj *def, virDomainNetDef *net) G_GNUC_NO_INLINE; int qemuInterfacePrepareSlirp(virQEMUDriver *driver, - virDomainNetDef *net, - qemuSlirp **slirp); + virDomainNetDef *net); int qemuInterfaceVDPAConnect(virDomainNetDef *net) G_GNUC_NO_INLINE; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index be10d2f3ac..392a99a769 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5724,13 +5724,8 @@ qemuProcessNetworkPrepareDevices(virQEMUDriver *driv= er, } else if (actualType =3D=3D VIR_DOMAIN_NET_TYPE_USER && !priv->disableSlirp && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DBUS_VMSTATE))= { - qemuSlirp *slirp =3D NULL; - int rv =3D qemuInterfacePrepareSlirp(driver, net, &slirp); - - if (rv =3D=3D -1) + if (qemuInterfacePrepareSlirp(driver, net) < 0) return -1; - if (rv =3D=3D 1) - QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp =3D slirp; } } --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196369; cv=none; d=zohomail.com; s=zohoarc; b=FnUlFNWcRnjAepLPxBz8dAWp2883RnNh9UuCRlEL/FvhujS2deYzDzDkBdDda+TBw9lsnpQkaX14Ulzm1qqocYddOpLlI7RcHU5BuZOj3HZ7D+r9Pu9jjrK93H7I53J187Bb74Q4tSP8c3zkbEe9LRlRuqS7EUww+gBHI36rQN4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196369; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=16CtnXush08OAEgqKlwsriURc1Lk+YSTIyD/ckaHXKg=; b=WAPTMCseZuuPWYjfUPUMlQ/T8659A27874INmdLCmubTTXxdYNWvRiVh6JjweYyR9e75E5SzUUTf1L3ECCIY3UrJCNgyYbt6dQVcg97X7sMIAA1f7nOpkJzXpcWGQa1KSeMqCNXYNUrDykZtDinjCr+iGEe92+pj9MEbs/71VOk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1652196369925936.277734543198; Tue, 10 May 2022 08:26:09 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-607-NY7Yl6VmNwyLnaM7E7WHqA-1; Tue, 10 May 2022 11:24:14 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E3D3AA18EF8; Tue, 10 May 2022 15:24:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCEFB14DFB9D; Tue, 10 May 2022 15:24:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 63360194705D; Tue, 10 May 2022 15:24:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1B2C6194705D for ; Tue, 10 May 2022 15:23:36 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0F0432024CC8; Tue, 10 May 2022 15:23:36 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 81A852024CBD for ; Tue, 10 May 2022 15:23:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196368; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=16CtnXush08OAEgqKlwsriURc1Lk+YSTIyD/ckaHXKg=; b=W5EOI5juojGVlEuGk8A7qW6vfKnX0bFqQh+oReKZuOK9ZimOwDF5ctZcDIRSq++Xwz+tWr JCrJiB2Ogdpa126wB3wdnfqQ03pZS2bl15A5HG5Fq86gVq8mzKUtxmpkQIU5U6vZRzIy4I +OQmTJEqQQU43lExfjEQY2aAt+ZvT44= X-MC-Unique: NY7Yl6VmNwyLnaM7E7WHqA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 32/37] qemuSlirpStart: Simplify parameters Date: Tue, 10 May 2022 17:20:08 +0200 Message-Id: <30c236b601a87679dfc96c84aaedbd3b26bb74cd.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196370736100002 Content-Type: text/plain; charset="utf-8" The 'driver' can be taken from the private data of 'vm' and 'slirp' can be taken from private data of 'net', both of which we need anyways. Additionally by checking whether slirp needs to be started inside the function we don't need to do this logic in the callers. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_extdevice.c | 4 +--- src/qemu/qemu_hotplug.c | 2 +- src/qemu/qemu_slirp.c | 10 +++++++--- src/qemu/qemu_slirp.h | 4 +--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c index 537b130394..1e54d4ef2c 100644 --- a/src/qemu/qemu_extdevice.c +++ b/src/qemu/qemu_extdevice.c @@ -185,10 +185,8 @@ qemuExtDevicesStart(virQEMUDriver *driver, for (i =3D 0; i < def->nnets; i++) { virDomainNetDef *net =3D def->nets[i]; - qemuSlirp *slirp =3D QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp; - if (slirp && - qemuSlirpStart(slirp, vm, driver, net, incomingMigration) < 0) + if (qemuSlirpStart(vm, net, incomingMigration) < 0) return -1; } diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 8314d0e546..9eeba0210f 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1314,7 +1314,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, break; if (qemuSlirpOpen(slirp, driver, vm->def) < 0 || - qemuSlirpStart(slirp, vm, driver, net, NULL) < 0) { + qemuSlirpStart(vm, net, NULL) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to start slirp")); goto cleanup; diff --git a/src/qemu/qemu_slirp.c b/src/qemu/qemu_slirp.c index c832cfc20b..e1f06573e3 100644 --- a/src/qemu/qemu_slirp.c +++ b/src/qemu/qemu_slirp.c @@ -245,12 +245,13 @@ qemuSlirpSetupCgroup(qemuSlirp *slirp, int -qemuSlirpStart(qemuSlirp *slirp, - virDomainObj *vm, - virQEMUDriver *driver, +qemuSlirpStart(virDomainObj *vm, virDomainNetDef *net, bool incoming) { + qemuDomainObjPrivate *priv =3D vm->privateData; + virQEMUDriver *driver =3D priv->driver; + qemuSlirp *slirp =3D QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); g_autoptr(virCommand) cmd =3D NULL; g_autofree char *pidfile =3D NULL; @@ -262,6 +263,9 @@ qemuSlirpStart(qemuSlirp *slirp, VIR_AUTOCLOSE errfd =3D -1; bool killDBusDaemon =3D false; + if (!slirp) + return 0; + if (incoming && !qemuSlirpHasFeature(slirp, QEMU_SLIRP_FEATURE_MIGRATE)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/src/qemu/qemu_slirp.h b/src/qemu/qemu_slirp.h index a9a09cd5f8..507ea720fa 100644 --- a/src/qemu/qemu_slirp.h +++ b/src/qemu/qemu_slirp.h @@ -61,9 +61,7 @@ int qemuSlirpOpen(qemuSlirp *slirp, virQEMUDriver *driver, virDomainDef *def); -int qemuSlirpStart(qemuSlirp *slirp, - virDomainObj *vm, - virQEMUDriver *driver, +int qemuSlirpStart(virDomainObj *vm, virDomainNetDef *net, bool incoming); --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196429; cv=none; d=zohomail.com; s=zohoarc; b=PygWZtfL740fiY+cajrE/Iy+rQvCnefVoX5pofG0IdoO5YVET6I/g/D+WgNpWnDeALlS2MRcgxXaetrb9UBHpw5FKqywDh7HXFlRFgZ1knzDn6IX6V1nrWGWhiOuCROK/QAZHQmc1P7Uf3VA7mRtlSZkhTxPlf+D8lzOaDumo/Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196429; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ddl9mMRevz4o8pwoFZMGpr98rbhvBORLzQcUWghvGV4=; b=FjrA4GK2qAq1u8ibKwPlLJZhyf4jpSV4FA3MnJd79sZFrm6gzm/dRTwYG0x53z0d0V6hw/Kcy2IrdGI2vki3HDeQHCdLg9ugknp9B2SzgUEERfDel7FEACR7uPzU8MotSWULhCZARMAv+d4dVPFfqxt8ua6YIGFOh7VJNgI8Ons= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1652196429707761.4137761828937; Tue, 10 May 2022 08:27:09 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-593-YgeaEEeMPAyeq0q_viWxOw-1; Tue, 10 May 2022 11:23:44 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 68FAD804181; Tue, 10 May 2022 15:23:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53940401E77; Tue, 10 May 2022 15:23:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id EE5D81947063; Tue, 10 May 2022 15:23:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1BC17194705F for ; Tue, 10 May 2022 15:23:37 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 016E6200B427; Tue, 10 May 2022 15:23:37 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 751E32024CC8 for ; Tue, 10 May 2022 15:23:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196428; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ddl9mMRevz4o8pwoFZMGpr98rbhvBORLzQcUWghvGV4=; b=M2mQVuaC7vgQVoVEbnD6cY+60LH/tViB/tiqDLTpYe7dDqMYkMmscXG6woFwiuCl3hZ6T7 O8qnvRHD/Byr20X4aCGE6ihXVB4uLEEvgbxu4aHOoBLUUECWMB7x5jxmJOytxswDLr1dkx JFDMMZbwO8AhUUaZSzXpPCRNjRqWg5A= X-MC-Unique: YgeaEEeMPAyeq0q_viWxOw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 33/37] qemu: slirp: Call qemuSlirpOpen directly from qemuSlirpStart Date: Tue, 10 May 2022 17:20:09 +0200 Message-Id: <9fbd265c3e17744ec7586358c9c33bc93f5c4c07.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196431358100001 Content-Type: text/plain; charset="utf-8" No need to ask the callers to call this extra function. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_extdevice.c | 9 --------- src/qemu/qemu_hotplug.c | 3 +-- src/qemu/qemu_slirp.c | 5 ++++- src/qemu/qemu_slirp.h | 4 ---- 4 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c index 1e54d4ef2c..9ef2a984f5 100644 --- a/src/qemu/qemu_extdevice.c +++ b/src/qemu/qemu_extdevice.c @@ -130,7 +130,6 @@ qemuExtDevicesPrepareHost(virQEMUDriver *driver, virDomainObj *vm) { virDomainDef *def =3D vm->def; - size_t i; if (qemuExtDevicesInitPaths(driver, def) < 0) return -1; @@ -139,14 +138,6 @@ qemuExtDevicesPrepareHost(virQEMUDriver *driver, qemuExtTPMPrepareHost(driver, def) < 0) return -1; - for (i =3D 0; i < def->nnets; i++) { - virDomainNetDef *net =3D def->nets[i]; - qemuSlirp *slirp =3D QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp; - - if (slirp && qemuSlirpOpen(slirp, driver, def) < 0) - return -1; - } - return 0; } diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 9eeba0210f..8f5e971570 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1313,8 +1313,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, if (!(slirp =3D QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp)) break; - if (qemuSlirpOpen(slirp, driver, vm->def) < 0 || - qemuSlirpStart(vm, net, NULL) < 0) { + if (qemuSlirpStart(vm, net, NULL) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to start slirp")); goto cleanup; diff --git a/src/qemu/qemu_slirp.c b/src/qemu/qemu_slirp.c index e1f06573e3..136e4b29d2 100644 --- a/src/qemu/qemu_slirp.c +++ b/src/qemu/qemu_slirp.c @@ -156,7 +156,7 @@ qemuSlirpCreatePidFilename(virQEMUDriverConfig *cfg, } -int +static int qemuSlirpOpen(qemuSlirp *slirp, virQEMUDriver *driver, virDomainDef *def) @@ -272,6 +272,9 @@ qemuSlirpStart(virDomainObj *vm, _("The slirp-helper doesn't support migration")); } + if (qemuSlirpOpen(slirp, driver, vm->def) < 0) + return -1; + if (!(pidfile =3D qemuSlirpCreatePidFilename(cfg, vm->def, net->info.a= lias))) return -1; diff --git a/src/qemu/qemu_slirp.h b/src/qemu/qemu_slirp.h index 507ea720fa..5a6a24b178 100644 --- a/src/qemu/qemu_slirp.h +++ b/src/qemu/qemu_slirp.h @@ -57,10 +57,6 @@ void qemuSlirpSetFeature(qemuSlirp *slirp, bool qemuSlirpHasFeature(const qemuSlirp *slirp, qemuSlirpFeature feature); -int qemuSlirpOpen(qemuSlirp *slirp, - virQEMUDriver *driver, - virDomainDef *def); - int qemuSlirpStart(virDomainObj *vm, virDomainNetDef *net, bool incoming); --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196307; cv=none; d=zohomail.com; s=zohoarc; b=h/Ctw4uVXlB8vTdQKV/UahEXgbDlGEW8Ulg2DYlZzoj9eEgK2BQzTb9osRCzheglZeciFX072DUEvn23V0GRPzZWVIWUC/0kAt/cLhLcS+1TU3VW4aXr1psJmHrxF5C5cXg787/UL998jEsbh/u9CKypgorsTMSIGOchllry/74= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196307; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6Z5hjaIFqwab1mwyUv6xUAU6y+uHUH4IqmxOeZWpQC0=; b=X5RCssM8o1BJ+EccqYN59hoVFIhFt46cAosysmi4mlwqrWv9K5JYM92IUaJ+zAEpT2mzFjGjabtiv+oE1DIBojfY8yRTcxF8fTOofhfgt5fu4vDU14ognLuyR6FMoIJKZp9aSPDKxkA8fRlZu9p90hW+4HhG7btP4ea4bAS+QhU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1652196307670120.41193638150605; Tue, 10 May 2022 08:25:07 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-163-9lGNV-C_PcKN3RyD6SsLoQ-1; Tue, 10 May 2022 11:23:45 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4033D80D190; Tue, 10 May 2022 15:23:40 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14F4114E1D91; Tue, 10 May 2022 15:23:40 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B8C771947060; Tue, 10 May 2022 15:23:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 19D681947061 for ; Tue, 10 May 2022 15:23:38 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 01F3B2024CBD; Tue, 10 May 2022 15:23:38 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5CD41200BCE9 for ; Tue, 10 May 2022 15:23:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196306; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=6Z5hjaIFqwab1mwyUv6xUAU6y+uHUH4IqmxOeZWpQC0=; b=XTgQtwzVUHDI5AdCOQDymSR2wNvgzFoYo8XZMC3LpUOs34UuCCwMkMd+7mV3u0JNJ6/cng o1yAsRn+0zoEHRj+XMqIUrzvGwwUIZYYB0epxTxkUW9pY0jqMDzuYuW+zEgXisOmw8s5W+ WMYrYM+kdOEOcD31Aw3+A4PXb68pHXo= X-MC-Unique: 9lGNV-C_PcKN3RyD6SsLoQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 34/37] qemu: slirp: Pass FDs to qemu via qemuFDPass in the network private data Date: Tue, 10 May 2022 17:20:10 +0200 Message-Id: <858bfd0d988ffeafe8b4201d1ccde48ea106468b.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196308379100008 Content-Type: text/plain; charset="utf-8" Populate the 'slirpfd' qemuFDPass structure inside the private data for passing the fd to qemu rather than using out-of-band variables. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 27 +++++++++------------------ src/qemu/qemu_command.h | 3 +-- src/qemu/qemu_hotplug.c | 9 +++------ src/qemu/qemu_slirp.c | 8 +++++++- 4 files changed, 20 insertions(+), 27 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 92b91b0a52..e48b59abbb 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4186,8 +4186,7 @@ qemuBuildNicDevProps(virDomainDef *def, virJSONValue * -qemuBuildHostNetProps(virDomainNetDef *net, - const char *slirpfd) +qemuBuildHostNetProps(virDomainNetDef *net) { virDomainNetType netType =3D virDomainNetGetActualType(net); size_t i; @@ -4302,9 +4301,11 @@ qemuBuildHostNetProps(virDomainNetDef *net, break; case VIR_DOMAIN_NET_TYPE_USER: - if (slirpfd) { - if (virJSONValueObjectAdd(&netprops, "s:type", "socket", NULL)= < 0 || - virJSONValueObjectAppendString(netprops, "fd", slirpfd) < = 0) + if (netpriv->slirpfd) { + if (virJSONValueObjectAdd(&netprops, + "s:type", "socket", + "s:fd", qemuFDPassGetPath(netpriv->s= lirpfd), + NULL) < 0) return NULL; } else { if (virJSONValueObjectAdd(&netprops, "s:type", "user", NULL) <= 0) @@ -8760,11 +8761,9 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, int ret =3D -1; g_autoptr(virJSONValue) nicprops =3D NULL; g_autofree char *nic =3D NULL; - g_autofree char *slirpfdName =3D NULL; virDomainNetType actualType =3D virDomainNetGetActualType(net); const virNetDevBandwidth *actualBandwidth; bool requireNicdev =3D false; - qemuSlirp *slirp; g_autoptr(virJSONValue) hostnetprops =3D NULL; qemuDomainNetworkPrivate *netpriv =3D QEMU_DOMAIN_NETWORK_PRIVATE(net); GSList *n; @@ -8890,14 +8889,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, virNetDevSetMTU(net->ifname, net->mtu) < 0) goto cleanup; - slirp =3D QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp; - if (slirp && !standalone) { - int slirpfd =3D qemuSlirpGetFD(slirp); - virCommandPassFD(cmd, slirpfd, - VIR_COMMAND_PASS_FD_CLOSE_PARENT); - slirpfdName =3D g_strdup_printf("%d", slirpfd); - } - for (n =3D netpriv->tapfds; n; n =3D n->next) { if (qemuFDPassTransferCommand(n->data, cmd) < 0) return -1; @@ -8908,11 +8899,11 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, return -1; } - if (qemuFDPassTransferCommand(netpriv->vdpafd, cmd) < 0) + if (qemuFDPassTransferCommand(netpriv->slirpfd, cmd) < 0 || + qemuFDPassTransferCommand(netpriv->vdpafd, cmd) < 0) return -1; - if (!(hostnetprops =3D qemuBuildHostNetProps(net, - slirpfdName))) + if (!(hostnetprops =3D qemuBuildHostNetProps(net))) goto cleanup; if (qemuBuildNetdevCommandlineFromJSON(cmd, hostnetprops, qemuCaps) < = 0) diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 9bb63d9598..84877b3d90 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -86,8 +86,7 @@ virJSONValue * qemuBuildChannelGuestfwdNetdevProps(virDomainChrDef *chr); virJSONValue * -qemuBuildHostNetProps(virDomainNetDef *net, - const char *slirpfd); +qemuBuildHostNetProps(virDomainNetDef *net); int qemuBuildInterfaceConnect(virDomainObj *vm, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 8f5e971570..3f368551e3 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1318,9 +1318,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, "%s", _("Failed to start slirp")); goto cleanup; } - - slirpfd =3D qemuSlirpGetFD(slirp); - slirpfdName =3D g_strdup_printf("slirpfd-%s", net->info.alias); } break; @@ -1376,8 +1373,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, virNetDevSetMTU(net->ifname, net->mtu) < 0) goto cleanup; - if (!(netprops =3D qemuBuildHostNetProps(net, - slirpfdName))) + if (!(netprops =3D qemuBuildHostNetProps(net))) goto cleanup; qemuDomainObjEnterMonitor(driver, vm); @@ -1396,7 +1392,8 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, } } - if (qemuFDPassTransferMonitor(netpriv->vdpafd, priv->mon) < 0) { + if (qemuFDPassTransferMonitor(netpriv->slirpfd, priv->mon) < 0 || + qemuFDPassTransferMonitor(netpriv->vdpafd, priv->mon) < 0) { qemuDomainObjExitMonitor(vm); goto cleanup; } diff --git a/src/qemu/qemu_slirp.c b/src/qemu/qemu_slirp.c index 136e4b29d2..b62934f292 100644 --- a/src/qemu/qemu_slirp.c +++ b/src/qemu/qemu_slirp.c @@ -251,7 +251,8 @@ qemuSlirpStart(virDomainObj *vm, { qemuDomainObjPrivate *priv =3D vm->privateData; virQEMUDriver *driver =3D priv->driver; - qemuSlirp *slirp =3D QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp; + qemuDomainNetworkPrivate *netpriv =3D QEMU_DOMAIN_NETWORK_PRIVATE(net); + qemuSlirp *slirp =3D netpriv->slirp; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); g_autoptr(virCommand) cmd =3D NULL; g_autofree char *pidfile =3D NULL; @@ -262,6 +263,7 @@ qemuSlirpStart(virDomainObj *vm, int cmdret =3D 0; VIR_AUTOCLOSE errfd =3D -1; bool killDBusDaemon =3D false; + g_autofree char *fdname =3D g_strdup_printf("slirpfd-%s", net->info.al= ias); if (!slirp) return 0; @@ -359,6 +361,10 @@ qemuSlirpStart(virDomainObj *vm, slirp->pid =3D pid; + netpriv->slirpfd =3D qemuFDPassNewDirect(fdname, priv); + + qemuFDPassAddFD(netpriv->slirpfd, &slirp->fd[0], NULL); + return 0; error: --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196232; cv=none; d=zohomail.com; s=zohoarc; b=UPol+9eBMggby+yMAmBiKQEgxKRQmKOV3KI5P71vaAUUsQXjD0JnbXyg4rxrWjDJVaJK5awwu4TGdObGTGK8pn7AwHVZY7ApXTGFBMx5hXOfGfcyvGr+8KLf+ciCHtH/WT1mqjfpTH3tHpuCezkTzOq5cwnpDH0vewiZf99WDx4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196232; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xI5Sh2Q0dZlUpls7LwzP5L76oOzJa79LrzxqGtBRRWk=; b=EABAOHm5lax22rmID3j9LvUa96HQQAinnVC7m7gbaadJ+7rvW/RME+UeHL69GmfHq65KRXkhKn+4lbUYo06fVDmW2UdiCQ5df8UENxlwRWWlq5V6aWgz3bXb0JUHL3RzsdOGgvlI/G+Ofq+7ZVPoLal1fgXJyxSB7ZRJKytkHoY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1652196232030358.0297985203954; Tue, 10 May 2022 08:23:52 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-208-qRaF6VRBOq69XZmqslLUSQ-1; Tue, 10 May 2022 11:23:45 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 572F086B8AB; Tue, 10 May 2022 15:23:42 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 40FD24087D63; Tue, 10 May 2022 15:23:42 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0FC28194705D; Tue, 10 May 2022 15:23:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 136B5194706E for ; Tue, 10 May 2022 15:23:39 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D652E2024CC8; Tue, 10 May 2022 15:23:38 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 63CB82024CBD for ; Tue, 10 May 2022 15:23:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196230; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=xI5Sh2Q0dZlUpls7LwzP5L76oOzJa79LrzxqGtBRRWk=; b=NPtOVI/KCA54wzT+Nna6n8fght4f7K7B952akGIuEEphCMQFS4X42nVCw5ve92rB0XBU8K KjrjeXhuhxkhP2tHSAfCGzUUWhdlYztAe220dgB64qZCtt7mWdOMpnCtIFlfkR4PI5KYv5 6mTgQfgzD1JCuSxv2HYKeLc0eSVG+nc= X-MC-Unique: qRaF6VRBOq69XZmqslLUSQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 35/37] qemuDomainAttachNetDevice: Clean up unneeded 'slirp' helper variables Date: Tue, 10 May 2022 17:20:11 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196232982100002 Content-Type: text/plain; charset="utf-8" We don't need 'slirpfdName' and 'slirpfd'. The 'slirp' local can be removed too as qemuSlirpStart is safe to be called if there's nothing to do. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 3f368551e3..0f3b1f4bc4 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1183,8 +1183,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, virDomainDeviceDef dev =3D { VIR_DOMAIN_DEVICE_NET, { .net =3D net } }; qemuDomainNetworkPrivate *netpriv =3D QEMU_DOMAIN_NETWORK_PRIVATE(net); virErrorPtr originalError =3D NULL; - g_autofree char *slirpfdName =3D NULL; - int slirpfd =3D -1; g_autoptr(virJSONValue) nicprops =3D NULL; g_autoptr(virJSONValue) netprops =3D NULL; int ret =3D -1; @@ -1305,14 +1303,10 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, case VIR_DOMAIN_NET_TYPE_USER: if (!priv->disableSlirp && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DBUS_VMSTATE)) { - qemuSlirp *slirp =3D NULL; if (qemuInterfacePrepareSlirp(driver, net) < 0) goto cleanup; - if (!(slirp =3D QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp)) - break; - if (qemuSlirpStart(vm, net, NULL) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to start slirp")); @@ -1408,7 +1402,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, } if (qemuMonitorAddNetdev(priv->mon, &netprops, - slirpfd, slirpfdName) < 0) { + -1, NULL) < 0) { qemuDomainObjExitMonitor(vm); virDomainAuditNet(vm, NULL, net, "attach", false); goto try_remove; @@ -1511,7 +1505,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, } virDomainCCWAddressSetFree(ccwaddrs); - VIR_FORCE_CLOSE(slirpfd); return ret; --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196426; cv=none; d=zohomail.com; s=zohoarc; b=mXBPxS9pzysq2reE3rSO9aLVnbSEf0hFmtCvxcjmwMduXU4WOJ7YuGi0hV8vI8iIGkouX5FDBOipA5T/G5PBzFhrh4/U7dTEh2QHB0hJwhxXYDhvNVvrmTH+wm9fSVyg+5vEt12s1JggErnqCjXsCP5X2pxzUJK3ns2T24cLaQ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196426; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=H6BdxIgiLsuyeuI15Bp7ZIynu9wY3sv7yXRsDrENLXU=; b=N8uAe2+EanyHZVyqAYho4MeFuwdwdS+VYQ9YREcaveVpz8AzyvCIWGOQA7tadROdYQsKtnh7/Xp2RL7nwteBpuM9XoYBFtxYSSBUlo0lR0fwl5k3k5JDq2Yytnjyf0xMCUMJFa/Il4YAK4pkZcr8XyzA/BW1UpCTp1FZq6g4z7A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1652196426297135.70091563241908; Tue, 10 May 2022 08:27:06 -0700 (PDT) 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-248-cuWRmDcuNnawV7GzfzG98A-1; Tue, 10 May 2022 11:23:50 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 93EBB1D96CA5; Tue, 10 May 2022 15:23:47 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D51B1460E5C; Tue, 10 May 2022 15:23:47 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3B39D194705D; Tue, 10 May 2022 15:23:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CA0A0194705F for ; Tue, 10 May 2022 15:23:39 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B04302024CC8; Tue, 10 May 2022 15:23:39 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E4422024CBD for ; Tue, 10 May 2022 15:23:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196424; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=H6BdxIgiLsuyeuI15Bp7ZIynu9wY3sv7yXRsDrENLXU=; b=iWYkI76ws5Zi/QcpktgpeT5Zrsw3OLZ9XqhhkuUCB/SWdxI+1BSBybGv70IG1B+uHYSD+S ifse+p4ZTGfMgmTrSLgndkXi7LAiXwT4yKOYqZO+vMfilVXToNX8uZSbczdW0XTNSxVaU/ SFSGlsag8r6bd/qNOADetrtAkDTDHVc= X-MC-Unique: cuWRmDcuNnawV7GzfzG98A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 36/37] qemuMonitorAddNetdev: Remove unneeded 'slirp' variables and useless debug Date: Tue, 10 May 2022 17:20:12 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196427375100001 Content-Type: text/plain; charset="utf-8" None of the callers now uses the slirp fd passing feature, so it can be removed. At this point even the VIR_DEBUG doesn't make sense as it would only log the pointer of 'props'. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 6 ++---- src/qemu/qemu_monitor.c | 23 ++--------------------- src/qemu/qemu_monitor.h | 3 +-- 3 files changed, 5 insertions(+), 27 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 0f3b1f4bc4..cae7b0dd3b 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1401,8 +1401,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, charDevPlugged =3D true; } - if (qemuMonitorAddNetdev(priv->mon, &netprops, - -1, NULL) < 0) { + if (qemuMonitorAddNetdev(priv->mon, &netprops) < 0) { qemuDomainObjExitMonitor(vm); virDomainAuditNet(vm, NULL, net, "attach", false); goto try_remove; @@ -2170,8 +2169,7 @@ qemuDomainAttachChrDevice(virQEMUDriver *driver, chardevAttached =3D true; if (netdevprops) { - if (qemuMonitorAddNetdev(priv->mon, &netdevprops, - -1, NULL) < 0) + if (qemuMonitorAddNetdev(priv->mon, &netdevprops) < 0) goto exit_monitor; } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index a71311d0c4..d44c7f0c60 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2629,31 +2629,12 @@ qemuMonitorCloseFileHandle(qemuMonitor *mon, int qemuMonitorAddNetdev(qemuMonitor *mon, - virJSONValue **props, - int slirpfd, char *slirpfdName) + virJSONValue **props) { - int ret =3D -1; - - VIR_DEBUG("props=3D%p " - "slirpfd=3D%d slirpfdName=3D%s", - props, - slirpfd, slirpfdName); QEMU_CHECK_MONITOR(mon); - if (slirpfd > 0 && - qemuMonitorSendFileHandle(mon, slirpfdName, slirpfd) < 0) - goto cleanup; - - ret =3D qemuMonitorJSONAddNetdev(mon, props); - - cleanup: - if (ret < 0) { - if (qemuMonitorCloseFileHandle(mon, slirpfdName) < 0) - VIR_WARN("failed to close device handle '%s'", slirpfdName); - } - - return ret; + return qemuMonitorJSONAddNetdev(mon, props); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index a49ef180c1..b1484fdff8 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -982,8 +982,7 @@ int qemuMonitorCloseFileHandle(qemuMonitor *mon, const char *fdname); int qemuMonitorAddNetdev(qemuMonitor *mon, - virJSONValue **props, - int slirpfd, char *slirpfdName); + virJSONValue **props); int qemuMonitorRemoveNetdev(qemuMonitor *mon, const char *alias); --=20 2.35.1 From nobody Fri May 17 06:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196316; cv=none; d=zohomail.com; s=zohoarc; b=gIIWUZrWgFAaQaGF8OKrnWGPtjm7s+49KyB6WJU0pqRUrEV2KFEJK+YG6hHzHlBI2q3QeHGpNdfw1qb213oLRQDdHx+AeWZYQPVw2tCjoDskahYfVpY3UdCLMDtGdpRLn8f5tlNHjc7Fj2L2isdi0qUjxygZ4xAdigCBEcu5yTA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196316; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mwF5ySTtpaEXHfzOsT2T0tCrJKqeFF4zNr0zPEWoxrA=; b=G3+BoDiqYUMlHIjetlHxJ9KodEkeUAZNB6rCI65cEZ55P6qh+22yCySXEidGJOswQZxFPlXOnmnR7PJKZUHn0HqvrlAysGaVFB25V1UxnDZJKf0VR7+0/pZ4M3Ym9EQOdUs5IHCN07ofAPCmiiWZvSCPo5qrI50Pqch8vAT1DUA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1652196316206526.3297323834995; Tue, 10 May 2022 08:25:16 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-314-icB6uIylOiqABCOY3SZwGA-1; Tue, 10 May 2022 11:24:12 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6FFEB805B25; Tue, 10 May 2022 15:24:01 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A64640E7F0C; Tue, 10 May 2022 15:24:01 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2BFCF194705F; Tue, 10 May 2022 15:24:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3D842194704D for ; Tue, 10 May 2022 15:23:45 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 300B72024CC8; Tue, 10 May 2022 15:23:45 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3A062024CBD for ; Tue, 10 May 2022 15:23:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196310; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=mwF5ySTtpaEXHfzOsT2T0tCrJKqeFF4zNr0zPEWoxrA=; b=e7HLAruzWcYTcZvwVftiWBZXzMNy9BgpspLr9UPpysIO4gjeF/7MZCPizxSv17q1EE1X6L rmsa2KoJItuwfcxANc6+ztmg7pKJKsag54/5Wt3KSyxm+fzWt5lVMIhi2F+Q4OmPHm8Suu 4PDIt5Lrdgh1sNNx1k8YaFKiV77hSDY= X-MC-Unique: icB6uIylOiqABCOY3SZwGA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 37/37] qemu: slirp: Remove unused 'qemuSlirpGetFD' Date: Tue, 10 May 2022 17:20:13 +0200 Message-Id: <4ffa2fdf74f97389c6465f0414d4711326f5608c.1652195735.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196318464100005 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_slirp.c | 9 --------- src/qemu/qemu_slirp.h | 2 -- 2 files changed, 11 deletions(-) diff --git a/src/qemu/qemu_slirp.c b/src/qemu/qemu_slirp.c index b62934f292..618947b6c1 100644 --- a/src/qemu/qemu_slirp.c +++ b/src/qemu/qemu_slirp.c @@ -188,15 +188,6 @@ qemuSlirpOpen(qemuSlirp *slirp, } -int -qemuSlirpGetFD(qemuSlirp *slirp) -{ - int fd =3D slirp->fd[0]; - slirp->fd[0] =3D -1; - return fd; -} - - static char * qemuSlirpGetDBusVMStateId(virDomainNetDef *net) { diff --git a/src/qemu/qemu_slirp.h b/src/qemu/qemu_slirp.h index 5a6a24b178..03f032555d 100644 --- a/src/qemu/qemu_slirp.h +++ b/src/qemu/qemu_slirp.h @@ -66,8 +66,6 @@ void qemuSlirpStop(qemuSlirp *slirp, virQEMUDriver *driver, virDomainNetDef *net); -int qemuSlirpGetFD(qemuSlirp *slirp); - int qemuSlirpSetupCgroup(qemuSlirp *slirp, virCgroup *cgroup); --=20 2.35.1