From nobody Mon Feb 9 01:22:06 2026 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: 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