From nobody Tue Feb 10 19:47:54 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1612160880; cv=none; d=zohomail.com; s=zohoarc; b=cOJwLeWWzktcnTLKF+Qqi6QszA4H6Fv01MMROpMv7apzLBquwADhnqweDTYcwb6JR/J2GVahCldJsMouFB13jAaIKl1U6YN4Jl8cU1mqXHDVRpUJPIC/3UrHeLwtSmAWvw6b7GS1ZnI1IAPiK6xPDjagb2eOwmOHH+hpRZUPZzw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612160880; 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=AJnbZI2Zh8Vkm+v7HCZYfrKwWP8Ha0deH2WvEC302WQ=; b=F6vaeJKu0Bc4mKIMPjJWdkHim1WovXaBnfVZjsotsYcMPdi5YM231Cv1M+NDXt4vAVvwcdjiIwRQlmSTizKeHcaHGqPb69wZMbpnYiv0t7zkNOtmFMscI5mTAWAAmvsioOwmDXs29wl/yxyR+osOBCW5xT4oqTz30D6WiwI3SIE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1612160880583621.7385082293432; Sun, 31 Jan 2021 22:28:00 -0800 (PST) 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-378-VOkQm4iuNia-V02UK4Wj4w-1; Mon, 01 Feb 2021 01:27:57 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 047CAC7403; Mon, 1 Feb 2021 06:27:52 +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 D808F10016F5; Mon, 1 Feb 2021 06:27:51 +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 A0FBE1809CA2; Mon, 1 Feb 2021 06:27:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1116RR2d025974 for ; Mon, 1 Feb 2021 01:27:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id F3C4770497; Mon, 1 Feb 2021 06:27:26 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-159.phx2.redhat.com [10.3.112.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD4F670476 for ; Mon, 1 Feb 2021 06:27:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612160879; 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=AJnbZI2Zh8Vkm+v7HCZYfrKwWP8Ha0deH2WvEC302WQ=; b=CYvmD62rUxy6xckzu53/qFiyjLYZnu+Yq8r8B6qYE24r8lXAq7HPkWen7KrDlCWQih19kk JCZlLFL8FPHm8VmMX45hMOtCH2u/FxLebw3kjyu6nJ6+MwjxPtMBybmOtfx5HkwPC17VJy WKr9RQkqJxMcKK1UFjKlzG+sJKW6hQM= X-MC-Unique: VOkQm4iuNia-V02UK4Wj4w-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 2/8] hostdevmgr: remove unneeded oldStateDir Date: Mon, 1 Feb 2021 01:27:14 -0500 Message-Id: <20210201062720.425041-3-laine@redhat.com> In-Reply-To: <20210201062720.425041-1-laine@redhat.com> References: <20210201062720.425041-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.84 on 10.5.11.22 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" Back in commit 2c71d3826, which appeared in libvirt-1.2.3 in April 2014, the location used to store saved MAC addresses and vlan tags of SRIOV VFs was changed from /var/run/libvirt/qemu to /var/run/libvirt/hostdevmgr. For backward compatibility the code was made to continue looking in the old location for the files when it didn't find them in the new location. It's now been 6 years, and even if there was somebody still running libvirt-1.2.3 on their system, that system would now be out of support for libvirt, so there would be no way for them to upgrade to a new libvirt that no longer looks in "oldStateDir" for the files. So let's no longer look in "oldStateDir" for the files! Signed-off-by: Laine Stump --- src/hypervisor/virhostdev.c | 60 ++++++++----------------------------- src/hypervisor/virhostdev.h | 6 ++-- src/libxl/libxl_domain.c | 2 +- src/libxl/libxl_driver.c | 4 +-- src/qemu/qemu_hostdev.c | 3 +- tests/virhostdevtest.c | 10 +++---- 6 files changed, 23 insertions(+), 62 deletions(-) diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c index bd35397f2c..09995a52ed 100644 --- a/src/hypervisor/virhostdev.c +++ b/src/hypervisor/virhostdev.c @@ -484,17 +484,9 @@ virHostdevSetNetConfig(virDomainHostdevDefPtr hostdev, } =20 =20 -/* @oldStateDir: - * For upgrade purpose: - * To an existing VM on QEMU, the hostdev netconfig file is originally sto= red - * in cfg->stateDir (/var/run/libvirt/qemu). Switch to new version, it use= s new - * location (mgr->stateDir) but certainly will not find it. In this - * case, try to find in the old state dir. - */ static int virHostdevRestoreNetConfig(virDomainHostdevDefPtr hostdev, - const char *stateDir, - const char *oldStateDir) + const char *stateDir) { g_autofree char *linkdev =3D NULL; g_autofree virMacAddrPtr MAC =3D NULL; @@ -528,16 +520,11 @@ virHostdevRestoreNetConfig(virDomainHostdevDefPtr hos= tdev, NULL, port_profile_associate); } else { - /* we need to try 3 different places for the config file: + /* we need to try 2 different places for the config file: * 1) ${stateDir}/${PF}_vf${vf} * This is almost always where the saved config is * - * 2) ${oldStateDir/${PF}_vf${vf} - * saved config is only here if this machine was running a - * (by now *very*) old version of libvirt that saved the - * file in a different directory - * - * 3) ${stateDir}${PF[1]}_vf${VF} + * 2) ${stateDir}${PF[1]}_vf${VF} * PF[1] means "the netdev for port 2 of the PF device", and * is only valid when the PF is a Mellanox dual port NIC with * a VF that was created in "single port" mode. @@ -556,18 +543,7 @@ virHostdevRestoreNetConfig(virDomainHostdevDefPtr host= dev, return -1; } =20 - /* 2) "old" (pre-1.2.3 circa 2014) location - whenever we get - * to the point that nobody will ever upgrade directly from - * 1.2.3 (or older) directly to current libvirt, we can - * eliminate this clause - **/ - if (!(adminMAC || vlan || MAC) && oldStateDir && - virNetDevReadNetConfig(linkdev, vf, oldStateDir, - &adminMAC, &vlan, &MAC) < 0) { - return -1; - } - - /* 3) try using the PF's "port 2" netdev as the name of the + /* 2) try using the PF's "port 2" netdev as the name of the * config file */ if (!(adminMAC || vlan || MAC)) { @@ -918,7 +894,7 @@ virHostdevPreparePCIDevicesImpl(virHostdevManagerPtr mg= r, resetvfnetconfig: if (last_processed_hostdev_vf >=3D 0) { for (i =3D 0; i <=3D last_processed_hostdev_vf; i++) - virHostdevRestoreNetConfig(hostdevs[i], mgr->stateDir, NULL); + virHostdevRestoreNetConfig(hostdevs[i], mgr->stateDir); } =20 reattachdevs: @@ -960,8 +936,7 @@ virHostdevReAttachPCIDevicesImpl(virHostdevManagerPtr m= gr, const char *dom_name, virPCIDeviceListPtr pcidevs, virDomainHostdevDefPtr *hostdevs, - int nhostdevs, - const char *oldStateDir) + int nhostdevs) { size_t i; =20 @@ -1043,8 +1018,7 @@ virHostdevReAttachPCIDevicesImpl(virHostdevManagerPtr= mgr, if (actual) { VIR_DEBUG("Restoring network configuration of PCI device %= s", virPCIDeviceGetName(actual)); - virHostdevRestoreNetConfig(hostdev, mgr->stateDir, - oldStateDir); + virHostdevRestoreNetConfig(hostdev, mgr->stateDir); } } } @@ -1061,16 +1035,12 @@ virHostdevReAttachPCIDevicesImpl(virHostdevManagerP= tr mgr, } =20 =20 -/* @oldStateDir: - * For upgrade purpose: see virHostdevRestoreNetConfig - */ void virHostdevReAttachPCIDevices(virHostdevManagerPtr mgr, const char *drv_name, const char *dom_name, virDomainHostdevDefPtr *hostdevs, - int nhostdevs, - const char *oldStateDir) + int nhostdevs) { g_autoptr(virPCIDeviceList) pcidevs =3D NULL; =20 @@ -1085,7 +1055,7 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr mgr, } =20 virHostdevReAttachPCIDevicesImpl(mgr, drv_name, dom_name, pcidevs, - hostdevs, nhostdevs, oldStateDir); + hostdevs, nhostdevs); } =20 =20 @@ -2120,23 +2090,18 @@ virHostdevPrepareDomainDevices(virHostdevManagerPtr= mgr, return 0; } =20 -/* @oldStateDir - * For upgrade purpose: see virHostdevReAttachPCIHostdevs - */ void virHostdevReAttachDomainDevices(virHostdevManagerPtr mgr, const char *driver, virDomainDefPtr def, - unsigned int flags, - const char *oldStateDir) + unsigned int flags) { if (!def->nhostdevs || !mgr) return; =20 if (flags & VIR_HOSTDEV_SP_PCI) { virHostdevReAttachPCIDevices(mgr, driver, def->name, - def->hostdevs, def->nhostdevs, - oldStateDir); + def->hostdevs, def->nhostdevs); } =20 if (flags & VIR_HOSTDEV_SP_USB) { @@ -2388,8 +2353,7 @@ virHostdevReAttachOneNVMeDevice(virHostdevManagerPtr = hostdev_mgr, goto cleanup; =20 virHostdevReAttachPCIDevicesImpl(hostdev_mgr, - drv_name, dom_name, pciDevices, - NULL, 0, NULL); + drv_name, dom_name, pciDevices, NULL,= 0); =20 for (i =3D 0; i < virNVMeDeviceListCount(nvmeDevices); i++) { virNVMeDevicePtr temp =3D virNVMeDeviceListGet(nvmeDevices, i); diff --git a/src/hypervisor/virhostdev.h b/src/hypervisor/virhostdev.h index 811bda40ed..19e1938d9e 100644 --- a/src/hypervisor/virhostdev.h +++ b/src/hypervisor/virhostdev.h @@ -113,8 +113,7 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr hostd= ev_mgr, const char *drv_name, const char *dom_name, virDomainHostdevDefPtr *hostdevs, - int nhostdevs, - const char *oldStateDir) + int nhostdevs) ATTRIBUTE_NONNULL(1); void virHostdevReAttachUSBDevices(virHostdevManagerPtr hostdev_mgr, @@ -188,8 +187,7 @@ void virHostdevReAttachDomainDevices(virHostdevManagerPtr mgr, const char *driver, virDomainDefPtr def, - unsigned int flags, - const char *oldStateDir) + unsigned int flags) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); =20 /* functions used by NodeDevDetach/Reattach/Reset */ diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index afa21bf02e..380f7e0b56 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -868,7 +868,7 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver, } =20 virHostdevReAttachDomainDevices(hostdev_mgr, LIBXL_DRIVER_INTERNAL_NAM= E, - vm->def, hostdev_flags, NULL); + vm->def, hostdev_flags); =20 VIR_FREE(priv->lockState); if (virDomainLockProcessPause(driver->lockManager, vm, &priv->lockStat= e) < 0) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 3eaf106006..f480f8067e 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -3153,7 +3153,7 @@ libxlDomainAttachHostPCIDevice(libxlDriverPrivatePtr = driver, =20 error: virHostdevReAttachPCIDevices(hostdev_mgr, LIBXL_DRIVER_INTERNAL_NAME, - vm->def->name, &hostdev, 1, NULL); + vm->def->name, &hostdev, 1); =20 cleanup: virObjectUnref(cfg); @@ -3690,7 +3690,7 @@ libxlDomainDetachHostPCIDevice(libxlDriverPrivatePtr = driver, virDomainHostdevRemove(vm->def, idx); =20 virHostdevReAttachPCIDevices(hostdev_mgr, LIBXL_DRIVER_INTERNAL_NAME, - vm->def->name, &hostdev, 1, NULL); + vm->def->name, &hostdev, 1); =20 ret =3D 0; =20 diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index 721fe5da82..57971214b7 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -406,11 +406,10 @@ qemuHostdevReAttachPCIDevices(virQEMUDriverPtr driver, int nhostdevs) { g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - const char *oldStateDir =3D cfg->stateDir; virHostdevManagerPtr hostdev_mgr =3D driver->hostdevMgr; =20 virHostdevReAttachPCIDevices(hostdev_mgr, QEMU_DRIVER_NAME, name, - hostdevs, nhostdevs, oldStateDir); + hostdevs, nhostdevs); } =20 void diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c index 40c14a5281..91f9112e8b 100644 --- a/tests/virhostdevtest.c +++ b/tests/virhostdevtest.c @@ -245,13 +245,13 @@ testVirHostdevReAttachPCIHostdevs_unmanaged(void) inactive_count =3D virPCIDeviceListCount(mgr->inactivePCIHostdevs); =20 VIR_TEST_DEBUG("Test 0 hostdevs"); - virHostdevReAttachPCIDevices(mgr, drv_name, dom_name, NULL, 0, NULL); + virHostdevReAttachPCIDevices(mgr, drv_name, dom_name, NULL, 0); CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count); CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count); =20 VIR_TEST_DEBUG("Test >=3D1 unmanaged hostdevs"); virHostdevReAttachPCIDevices(mgr, drv_name, dom_name, - hostdevs, nhostdevs, NULL); + hostdevs, nhostdevs); CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count - nhostdevs); CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count + nhostd= evs); =20 @@ -329,13 +329,13 @@ testVirHostdevReAttachPCIHostdevs_managed(bool mixed) inactive_count =3D virPCIDeviceListCount(mgr->inactivePCIHostdevs); =20 VIR_TEST_DEBUG("Test 0 hostdevs"); - virHostdevReAttachPCIDevices(mgr, drv_name, dom_name, NULL, 0, NULL); + virHostdevReAttachPCIDevices(mgr, drv_name, dom_name, NULL, 0); CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count); CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count); =20 VIR_TEST_DEBUG("Test >=3D1 hostdevs"); virHostdevReAttachPCIDevices(mgr, drv_name, dom_name, - hostdevs, nhostdevs, NULL); + hostdevs, nhostdevs); CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count - nhostdevs); /* If testing a mixed roundtrip, devices are added back to the inactive * list as soon as we detach from the guest */ @@ -542,7 +542,7 @@ testNVMeDiskRoundtrip(const void *opaque G_GNUC_UNUSED) /* Don't rely on a state that previous test cases might have * left the manager in. Start with a clean slate. */ virHostdevReAttachPCIDevices(mgr, drv_name, dom_name, - hostdevs, nhostdevs, NULL); + hostdevs, nhostdevs); =20 CHECK_NVME_LIST_COUNT(mgr->activeNVMeHostdevs, 0); CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, 0); --=20 2.29.2