From nobody Sun Feb 8 22:08:22 2026 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 --- 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