mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
hostdevmgr: remove unneeded oldStateDir
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 <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
65ce8a424f
commit
8fb0b08762
@ -484,17 +484,9 @@ virHostdevSetNetConfig(virDomainHostdevDefPtr hostdev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* @oldStateDir:
|
|
||||||
* For upgrade purpose:
|
|
||||||
* To an existing VM on QEMU, the hostdev netconfig file is originally stored
|
|
||||||
* in cfg->stateDir (/var/run/libvirt/qemu). Switch to new version, it uses new
|
|
||||||
* location (mgr->stateDir) but certainly will not find it. In this
|
|
||||||
* case, try to find in the old state dir.
|
|
||||||
*/
|
|
||||||
static int
|
static int
|
||||||
virHostdevRestoreNetConfig(virDomainHostdevDefPtr hostdev,
|
virHostdevRestoreNetConfig(virDomainHostdevDefPtr hostdev,
|
||||||
const char *stateDir,
|
const char *stateDir)
|
||||||
const char *oldStateDir)
|
|
||||||
{
|
{
|
||||||
g_autofree char *linkdev = NULL;
|
g_autofree char *linkdev = NULL;
|
||||||
g_autofree virMacAddrPtr MAC = NULL;
|
g_autofree virMacAddrPtr MAC = NULL;
|
||||||
@ -528,16 +520,11 @@ virHostdevRestoreNetConfig(virDomainHostdevDefPtr hostdev,
|
|||||||
NULL,
|
NULL,
|
||||||
port_profile_associate);
|
port_profile_associate);
|
||||||
} else {
|
} 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}
|
* 1) ${stateDir}/${PF}_vf${vf}
|
||||||
* This is almost always where the saved config is
|
* This is almost always where the saved config is
|
||||||
*
|
*
|
||||||
* 2) ${oldStateDir/${PF}_vf${vf}
|
* 2) ${stateDir}${PF[1]}_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}
|
|
||||||
* PF[1] means "the netdev for port 2 of the PF device", and
|
* 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
|
* is only valid when the PF is a Mellanox dual port NIC with
|
||||||
* a VF that was created in "single port" mode.
|
* a VF that was created in "single port" mode.
|
||||||
@ -556,18 +543,7 @@ virHostdevRestoreNetConfig(virDomainHostdevDefPtr hostdev,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 2) "old" (pre-1.2.3 circa 2014) location - whenever we get
|
/* 2) try using the PF's "port 2" netdev as the name of the
|
||||||
* 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
|
|
||||||
* config file
|
* config file
|
||||||
*/
|
*/
|
||||||
if (!(adminMAC || vlan || MAC)) {
|
if (!(adminMAC || vlan || MAC)) {
|
||||||
@ -918,7 +894,7 @@ virHostdevPreparePCIDevicesImpl(virHostdevManagerPtr mgr,
|
|||||||
resetvfnetconfig:
|
resetvfnetconfig:
|
||||||
if (last_processed_hostdev_vf >= 0) {
|
if (last_processed_hostdev_vf >= 0) {
|
||||||
for (i = 0; i <= last_processed_hostdev_vf; i++)
|
for (i = 0; i <= last_processed_hostdev_vf; i++)
|
||||||
virHostdevRestoreNetConfig(hostdevs[i], mgr->stateDir, NULL);
|
virHostdevRestoreNetConfig(hostdevs[i], mgr->stateDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
reattachdevs:
|
reattachdevs:
|
||||||
@ -960,8 +936,7 @@ virHostdevReAttachPCIDevicesImpl(virHostdevManagerPtr mgr,
|
|||||||
const char *dom_name,
|
const char *dom_name,
|
||||||
virPCIDeviceListPtr pcidevs,
|
virPCIDeviceListPtr pcidevs,
|
||||||
virDomainHostdevDefPtr *hostdevs,
|
virDomainHostdevDefPtr *hostdevs,
|
||||||
int nhostdevs,
|
int nhostdevs)
|
||||||
const char *oldStateDir)
|
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
@ -1043,8 +1018,7 @@ virHostdevReAttachPCIDevicesImpl(virHostdevManagerPtr mgr,
|
|||||||
if (actual) {
|
if (actual) {
|
||||||
VIR_DEBUG("Restoring network configuration of PCI device %s",
|
VIR_DEBUG("Restoring network configuration of PCI device %s",
|
||||||
virPCIDeviceGetName(actual));
|
virPCIDeviceGetName(actual));
|
||||||
virHostdevRestoreNetConfig(hostdev, mgr->stateDir,
|
virHostdevRestoreNetConfig(hostdev, mgr->stateDir);
|
||||||
oldStateDir);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1061,16 +1035,12 @@ virHostdevReAttachPCIDevicesImpl(virHostdevManagerPtr mgr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* @oldStateDir:
|
|
||||||
* For upgrade purpose: see virHostdevRestoreNetConfig
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
virHostdevReAttachPCIDevices(virHostdevManagerPtr mgr,
|
virHostdevReAttachPCIDevices(virHostdevManagerPtr mgr,
|
||||||
const char *drv_name,
|
const char *drv_name,
|
||||||
const char *dom_name,
|
const char *dom_name,
|
||||||
virDomainHostdevDefPtr *hostdevs,
|
virDomainHostdevDefPtr *hostdevs,
|
||||||
int nhostdevs,
|
int nhostdevs)
|
||||||
const char *oldStateDir)
|
|
||||||
{
|
{
|
||||||
g_autoptr(virPCIDeviceList) pcidevs = NULL;
|
g_autoptr(virPCIDeviceList) pcidevs = NULL;
|
||||||
|
|
||||||
@ -1085,7 +1055,7 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr mgr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
virHostdevReAttachPCIDevicesImpl(mgr, drv_name, dom_name, pcidevs,
|
virHostdevReAttachPCIDevicesImpl(mgr, drv_name, dom_name, pcidevs,
|
||||||
hostdevs, nhostdevs, oldStateDir);
|
hostdevs, nhostdevs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2120,23 +2090,18 @@ virHostdevPrepareDomainDevices(virHostdevManagerPtr mgr,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @oldStateDir
|
|
||||||
* For upgrade purpose: see virHostdevReAttachPCIHostdevs
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
virHostdevReAttachDomainDevices(virHostdevManagerPtr mgr,
|
virHostdevReAttachDomainDevices(virHostdevManagerPtr mgr,
|
||||||
const char *driver,
|
const char *driver,
|
||||||
virDomainDefPtr def,
|
virDomainDefPtr def,
|
||||||
unsigned int flags,
|
unsigned int flags)
|
||||||
const char *oldStateDir)
|
|
||||||
{
|
{
|
||||||
if (!def->nhostdevs || !mgr)
|
if (!def->nhostdevs || !mgr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (flags & VIR_HOSTDEV_SP_PCI) {
|
if (flags & VIR_HOSTDEV_SP_PCI) {
|
||||||
virHostdevReAttachPCIDevices(mgr, driver, def->name,
|
virHostdevReAttachPCIDevices(mgr, driver, def->name,
|
||||||
def->hostdevs, def->nhostdevs,
|
def->hostdevs, def->nhostdevs);
|
||||||
oldStateDir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & VIR_HOSTDEV_SP_USB) {
|
if (flags & VIR_HOSTDEV_SP_USB) {
|
||||||
@ -2388,8 +2353,7 @@ virHostdevReAttachOneNVMeDevice(virHostdevManagerPtr hostdev_mgr,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
virHostdevReAttachPCIDevicesImpl(hostdev_mgr,
|
virHostdevReAttachPCIDevicesImpl(hostdev_mgr,
|
||||||
drv_name, dom_name, pciDevices,
|
drv_name, dom_name, pciDevices, NULL, 0);
|
||||||
NULL, 0, NULL);
|
|
||||||
|
|
||||||
for (i = 0; i < virNVMeDeviceListCount(nvmeDevices); i++) {
|
for (i = 0; i < virNVMeDeviceListCount(nvmeDevices); i++) {
|
||||||
virNVMeDevicePtr temp = virNVMeDeviceListGet(nvmeDevices, i);
|
virNVMeDevicePtr temp = virNVMeDeviceListGet(nvmeDevices, i);
|
||||||
|
@ -113,8 +113,7 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr hostdev_mgr,
|
|||||||
const char *drv_name,
|
const char *drv_name,
|
||||||
const char *dom_name,
|
const char *dom_name,
|
||||||
virDomainHostdevDefPtr *hostdevs,
|
virDomainHostdevDefPtr *hostdevs,
|
||||||
int nhostdevs,
|
int nhostdevs)
|
||||||
const char *oldStateDir)
|
|
||||||
ATTRIBUTE_NONNULL(1);
|
ATTRIBUTE_NONNULL(1);
|
||||||
void
|
void
|
||||||
virHostdevReAttachUSBDevices(virHostdevManagerPtr hostdev_mgr,
|
virHostdevReAttachUSBDevices(virHostdevManagerPtr hostdev_mgr,
|
||||||
@ -188,8 +187,7 @@ void
|
|||||||
virHostdevReAttachDomainDevices(virHostdevManagerPtr mgr,
|
virHostdevReAttachDomainDevices(virHostdevManagerPtr mgr,
|
||||||
const char *driver,
|
const char *driver,
|
||||||
virDomainDefPtr def,
|
virDomainDefPtr def,
|
||||||
unsigned int flags,
|
unsigned int flags)
|
||||||
const char *oldStateDir)
|
|
||||||
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
||||||
|
|
||||||
/* functions used by NodeDevDetach/Reattach/Reset */
|
/* functions used by NodeDevDetach/Reattach/Reset */
|
||||||
|
@ -868,7 +868,7 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
virHostdevReAttachDomainDevices(hostdev_mgr, LIBXL_DRIVER_INTERNAL_NAME,
|
virHostdevReAttachDomainDevices(hostdev_mgr, LIBXL_DRIVER_INTERNAL_NAME,
|
||||||
vm->def, hostdev_flags, NULL);
|
vm->def, hostdev_flags);
|
||||||
|
|
||||||
VIR_FREE(priv->lockState);
|
VIR_FREE(priv->lockState);
|
||||||
if (virDomainLockProcessPause(driver->lockManager, vm, &priv->lockState) < 0)
|
if (virDomainLockProcessPause(driver->lockManager, vm, &priv->lockState) < 0)
|
||||||
|
@ -3153,7 +3153,7 @@ libxlDomainAttachHostPCIDevice(libxlDriverPrivatePtr driver,
|
|||||||
|
|
||||||
error:
|
error:
|
||||||
virHostdevReAttachPCIDevices(hostdev_mgr, LIBXL_DRIVER_INTERNAL_NAME,
|
virHostdevReAttachPCIDevices(hostdev_mgr, LIBXL_DRIVER_INTERNAL_NAME,
|
||||||
vm->def->name, &hostdev, 1, NULL);
|
vm->def->name, &hostdev, 1);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
@ -3690,7 +3690,7 @@ libxlDomainDetachHostPCIDevice(libxlDriverPrivatePtr driver,
|
|||||||
virDomainHostdevRemove(vm->def, idx);
|
virDomainHostdevRemove(vm->def, idx);
|
||||||
|
|
||||||
virHostdevReAttachPCIDevices(hostdev_mgr, LIBXL_DRIVER_INTERNAL_NAME,
|
virHostdevReAttachPCIDevices(hostdev_mgr, LIBXL_DRIVER_INTERNAL_NAME,
|
||||||
vm->def->name, &hostdev, 1, NULL);
|
vm->def->name, &hostdev, 1);
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
|
@ -405,12 +405,10 @@ qemuHostdevReAttachPCIDevices(virQEMUDriverPtr driver,
|
|||||||
virDomainHostdevDefPtr *hostdevs,
|
virDomainHostdevDefPtr *hostdevs,
|
||||||
int nhostdevs)
|
int nhostdevs)
|
||||||
{
|
{
|
||||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
|
||||||
const char *oldStateDir = cfg->stateDir;
|
|
||||||
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
|
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
|
||||||
|
|
||||||
virHostdevReAttachPCIDevices(hostdev_mgr, QEMU_DRIVER_NAME, name,
|
virHostdevReAttachPCIDevices(hostdev_mgr, QEMU_DRIVER_NAME, name,
|
||||||
hostdevs, nhostdevs, oldStateDir);
|
hostdevs, nhostdevs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -245,13 +245,13 @@ testVirHostdevReAttachPCIHostdevs_unmanaged(void)
|
|||||||
inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
|
inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
|
||||||
|
|
||||||
VIR_TEST_DEBUG("Test 0 hostdevs");
|
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->activePCIHostdevs, active_count);
|
||||||
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
|
||||||
|
|
||||||
VIR_TEST_DEBUG("Test >=1 unmanaged hostdevs");
|
VIR_TEST_DEBUG("Test >=1 unmanaged hostdevs");
|
||||||
virHostdevReAttachPCIDevices(mgr, drv_name, dom_name,
|
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->activePCIHostdevs, active_count - nhostdevs);
|
||||||
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count + nhostdevs);
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count + nhostdevs);
|
||||||
|
|
||||||
@ -329,13 +329,13 @@ testVirHostdevReAttachPCIHostdevs_managed(bool mixed)
|
|||||||
inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
|
inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
|
||||||
|
|
||||||
VIR_TEST_DEBUG("Test 0 hostdevs");
|
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->activePCIHostdevs, active_count);
|
||||||
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
|
||||||
|
|
||||||
VIR_TEST_DEBUG("Test >=1 hostdevs");
|
VIR_TEST_DEBUG("Test >=1 hostdevs");
|
||||||
virHostdevReAttachPCIDevices(mgr, drv_name, dom_name,
|
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->activePCIHostdevs, active_count - nhostdevs);
|
||||||
/* If testing a mixed roundtrip, devices are added back to the inactive
|
/* If testing a mixed roundtrip, devices are added back to the inactive
|
||||||
* list as soon as we detach from the guest */
|
* 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
|
/* Don't rely on a state that previous test cases might have
|
||||||
* left the manager in. Start with a clean slate. */
|
* left the manager in. Start with a clean slate. */
|
||||||
virHostdevReAttachPCIDevices(mgr, drv_name, dom_name,
|
virHostdevReAttachPCIDevices(mgr, drv_name, dom_name,
|
||||||
hostdevs, nhostdevs, NULL);
|
hostdevs, nhostdevs);
|
||||||
|
|
||||||
CHECK_NVME_LIST_COUNT(mgr->activeNVMeHostdevs, 0);
|
CHECK_NVME_LIST_COUNT(mgr->activeNVMeHostdevs, 0);
|
||||||
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, 0);
|
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user