From nobody Thu May 2 23:03:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1623908227; cv=none; d=zohomail.com; s=zohoarc; b=d8mbobAHZaBqk2/fqtrGiY72ORSK3rg++++ujMwTG8Hfw+Uw4w/f0wrc5ITh3UdJ+X3YdAKZQ9VfPOm6QKFDyfmqCZKjKKE/qca3cZBcEzyLV8GnnWXQcBIOOAdl/DP+I6QF1/vDc2YG83MStQHavwfqwstLnWBbJ3yn8/Vzms0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623908227; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=70c+bNSFJwMerGHnGHwv79B98Sz/W23CxtmjbyBXj5Q=; b=dgPedvGwkTe92yWIdgzTsP3G7lxKXmNg3PncxSv+OvR9S/Uop/cYbeTUmroiN8fuDQE2qdbWWp3jBH741pVvKSzaU1wE5uwvBkK2l3zFqg+K+CEH35fCfZd5olarpu8H18h9mYn9SfUwZA5x+j1FSgVTzlAWsM6lh84sf4ielPU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1623908227105322.3526009834121; Wed, 16 Jun 2021 22:37:07 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-11-fOsdr2rOM4OeMDs-FrsJHw-1; Thu, 17 Jun 2021 01:37:04 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 595AA1084F47; Thu, 17 Jun 2021 05:36:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E46F360C05; Thu, 17 Jun 2021 05:36:56 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 068F61809CAD; Thu, 17 Jun 2021 05:36:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15H5aosO025810 for ; Thu, 17 Jun 2021 01:36:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id CBE215D9E2; Thu, 17 Jun 2021 05:36:50 +0000 (UTC) Received: from vhost2.router.laine.org (ovpn-112-128.phx2.redhat.com [10.3.112.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 89ABF5D9CC for ; Thu, 17 Jun 2021 05:36:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623908226; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=70c+bNSFJwMerGHnGHwv79B98Sz/W23CxtmjbyBXj5Q=; b=Tkg5BgJXjg12lSHgjsQCIs9zGUxq523Jr0zuB5B/m0BUKVNzg6pRI/TrlDWdMoZY/bZbhR 0YB3hF2jfJN6vcCCyZzrmEngORd59HFN2qRJm7VH6ORykongMQw1Etaivz6g7kmzb5YH69 QeZa8OxhDPtQ55aavObHBy9bLlTl3Bg= X-MC-Unique: fOsdr2rOM4OeMDs-FrsJHw-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH] qemu_hotplug: don't forget to add hostdev interfaces to the interface list Date: Thu, 17 Jun 2021 01:36:45 -0400 Message-Id: <20210617053645.667869-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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) Content-Type: text/plain; charset="utf-8" Originally qemuDomainAttachNetDevice() would wait until the cleanup at the very end of the function to add newly hotplugged interfaces to the domain's nets list. commit 7b8bec4560 modified it to add the new interface to the nets list earlier (but not all the way at the beginning of the function either, because there are some operations (PCI address assignment in particular) that need the new device to not yet be visible in the domaindef). But hostdev interfaces short-circuit past most of the body of qemuDomainAttachNetDevice() (since none of it applies to hostdev interfaces). In the past that was okay, but since the line that adds the new interface to the domaindef's nets list is in that "most of the body", after that commit hotplugged hostdev interfaces are no longer being properly added to the domaindef nets list, so they don't show up in the status XML or the virsh domiflist output. It really *is* important to add interfaces to the nets list earlier, so we can't revert commit 7b8bec4560, and we also can't move the insert to common code *earlier* in the function, so instead this patch duplicates the VIR_APPEND_ELEMENT_COPY() just before the code path for hostdev interfaces jumps to cleanup. Resolves: https://bugzilla.redhat.com/1972991 Fixes: 7b8bec45601b6570f6a7413e94d291986d2663f1 (any other tags I should add?) Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- src/qemu/qemu_hotplug.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 0640cdd9f7..e323edc2e8 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1230,10 +1230,21 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, /* This is really a "smart hostdev", so it should be attached * as a hostdev (the hostdev code will reach over into the * netdev-specific code as appropriate), then also added to - * the nets list (see cleanup:) if successful. + * the nets list if successful. */ - ret =3D qemuDomainAttachHostDevice(driver, vm, - virDomainNetGetActualHostdev(net)= ); + if (qemuDomainAttachHostDevice(driver, vm, + virDomainNetGetActualHostdev(net)) = < 0) { + goto cleanup; + } + if (VIR_APPEND_ELEMENT_COPY(vm->def->nets, vm->def->nnets, net) < = 0) + goto cleanup; + + /* the rest of the setup doesn't apply to hostdev interfaces, so + * we can skip straight to the cleanup (nothing there applies to + * hostdev interfaces either, but it might in the future, so we + * may as well be consistent) + */ + ret =3D 0; goto cleanup; } =20 --=20 2.31.1