|
|
43fe83 |
From 823e31ecb90aeb3d3362d9ff22f689e062d0e28e Mon Sep 17 00:00:00 2001
|
|
|
43fe83 |
Message-Id: <823e31ecb90aeb3d3362d9ff22f689e062d0e28e.1382534061.git.jdenemar@redhat.com>
|
|
|
43fe83 |
From: Laine Stump <laine@laine.org>
|
|
|
43fe83 |
Date: Mon, 21 Oct 2013 10:12:58 -0600
|
|
|
43fe83 |
Subject: [PATCH] qemu: simplify calling qemuDomainHostdevNetConfigRestore
|
|
|
43fe83 |
|
|
|
43fe83 |
This is a prerequisite to the fix for
|
|
|
43fe83 |
|
|
|
43fe83 |
https://bugzilla.redhat.com/show_bug.cgi?id=1005682
|
|
|
43fe83 |
|
|
|
43fe83 |
This function was called in three places, and in each the call was
|
|
|
43fe83 |
qualified by a slightly different conditional. In reality, this
|
|
|
43fe83 |
function should only be called for a hostdev if all of the following
|
|
|
43fe83 |
are true:
|
|
|
43fe83 |
|
|
|
43fe83 |
1) mode='subsystem'
|
|
|
43fe83 |
2) type='pci'
|
|
|
43fe83 |
3) there is a parent device definition which is an <interface>
|
|
|
43fe83 |
(VIR_DOMAIN_DEVICE_NET)
|
|
|
43fe83 |
|
|
|
43fe83 |
We can simplify the callers and make them more consistent by checking
|
|
|
43fe83 |
these conditions at the top ov qemuDomainHostdevNetConfigRestore and
|
|
|
43fe83 |
returning 0 if one of them isn't satisfied.
|
|
|
43fe83 |
|
|
|
43fe83 |
The location of the call to qemuDomainHostdevNetConfigRestore() has
|
|
|
43fe83 |
also been changed in the hot-plug case - it is moved into the caller
|
|
|
43fe83 |
of its previous location (i.e. from qemuDomainRemovePCIHostDevice() to
|
|
|
43fe83 |
qemuDomainRemoveHostDevice()). This was done to be more consistent
|
|
|
43fe83 |
about which functions pay attention to whether or not this is one of
|
|
|
43fe83 |
the special <interface> hostdevs or just a normal hostdev -
|
|
|
43fe83 |
qemuDomainRemoveHostDevice() already contained a call to
|
|
|
43fe83 |
networkReleaseActualDevice() and virDomainNetDefFree(), so it makes
|
|
|
43fe83 |
sense for it to also handle the resetting of the device's MAC address
|
|
|
43fe83 |
and vlan tag (which is what's done by
|
|
|
43fe83 |
qemuDomainHostdevNetConfigRestore()).
|
|
|
43fe83 |
|
|
|
43fe83 |
(cherry picked from commit 7a600cf77fb649e3412d4bf4f9eefba046562880)
|
|
|
43fe83 |
|
|
|
43fe83 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
43fe83 |
---
|
|
|
43fe83 |
src/qemu/qemu_hostdev.c | 33 ++++++++++++++-------------------
|
|
|
43fe83 |
src/qemu/qemu_hotplug.c | 13 ++++---------
|
|
|
43fe83 |
2 files changed, 18 insertions(+), 28 deletions(-)
|
|
|
43fe83 |
|
|
|
43fe83 |
diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
|
|
|
43fe83 |
index 43c03cc..ca26dde 100644
|
|
|
43fe83 |
--- a/src/qemu/qemu_hostdev.c
|
|
|
43fe83 |
+++ b/src/qemu/qemu_hostdev.c
|
|
|
43fe83 |
@@ -466,6 +466,15 @@ qemuDomainHostdevNetConfigRestore(virDomainHostdevDefPtr hostdev,
|
|
|
43fe83 |
bool port_profile_associate = false;
|
|
|
43fe83 |
int isvf;
|
|
|
43fe83 |
|
|
|
43fe83 |
+ /* This is only needed for PCI devices that have been defined
|
|
|
43fe83 |
+ * using <interface type='hostdev'>. For all others, it is a NOP.
|
|
|
43fe83 |
+ */
|
|
|
43fe83 |
+ if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
|
|
|
43fe83 |
+ hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI ||
|
|
|
43fe83 |
+ hostdev->parent.type != VIR_DOMAIN_DEVICE_NET ||
|
|
|
43fe83 |
+ !hostdev->parent.data.net)
|
|
|
43fe83 |
+ return 0;
|
|
|
43fe83 |
+
|
|
|
43fe83 |
isvf = qemuDomainHostdevIsVirtualFunction(hostdev);
|
|
|
43fe83 |
if (isvf <= 0) {
|
|
|
43fe83 |
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
43fe83 |
@@ -799,14 +808,9 @@ inactivedevs:
|
|
|
43fe83 |
}
|
|
|
43fe83 |
|
|
|
43fe83 |
resetvfnetconfig:
|
|
|
43fe83 |
- for (i = 0; last_processed_hostdev_vf != -1 &&
|
|
|
43fe83 |
- i < last_processed_hostdev_vf; i++) {
|
|
|
43fe83 |
- virDomainHostdevDefPtr hostdev = hostdevs[i];
|
|
|
43fe83 |
- if (hostdev->parent.type == VIR_DOMAIN_DEVICE_NET &&
|
|
|
43fe83 |
- hostdev->parent.data.net) {
|
|
|
43fe83 |
- qemuDomainHostdevNetConfigRestore(hostdev, cfg->stateDir);
|
|
|
43fe83 |
- }
|
|
|
43fe83 |
- }
|
|
|
43fe83 |
+ for (i = 0;
|
|
|
43fe83 |
+ last_processed_hostdev_vf != -1 && i < last_processed_hostdev_vf; i++)
|
|
|
43fe83 |
+ qemuDomainHostdevNetConfigRestore(hostdevs[i], cfg->stateDir);
|
|
|
43fe83 |
|
|
|
43fe83 |
reattachdevs:
|
|
|
43fe83 |
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
|
|
|
43fe83 |
@@ -1270,17 +1274,8 @@ qemuDomainReAttachHostdevDevices(virQEMUDriverPtr driver,
|
|
|
43fe83 |
* For SRIOV net host devices, unset mac and port profile before
|
|
|
43fe83 |
* reset and reattach device
|
|
|
43fe83 |
*/
|
|
|
43fe83 |
- for (i = 0; i < nhostdevs; i++) {
|
|
|
43fe83 |
- virDomainHostdevDefPtr hostdev = hostdevs[i];
|
|
|
43fe83 |
- if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
|
|
|
43fe83 |
- continue;
|
|
|
43fe83 |
- if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
|
|
|
43fe83 |
- continue;
|
|
|
43fe83 |
- if (hostdev->parent.type == VIR_DOMAIN_DEVICE_NET &&
|
|
|
43fe83 |
- hostdev->parent.data.net) {
|
|
|
43fe83 |
- qemuDomainHostdevNetConfigRestore(hostdev, cfg->stateDir);
|
|
|
43fe83 |
- }
|
|
|
43fe83 |
- }
|
|
|
43fe83 |
+ for (i = 0; i < nhostdevs; i++)
|
|
|
43fe83 |
+ qemuDomainHostdevNetConfigRestore(hostdevs[i], cfg->stateDir);
|
|
|
43fe83 |
|
|
|
43fe83 |
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
|
|
|
43fe83 |
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
|
|
|
43fe83 |
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
|
|
|
43fe83 |
index cdbafa7..dcee86c 100644
|
|
|
43fe83 |
--- a/src/qemu/qemu_hotplug.c
|
|
|
43fe83 |
+++ b/src/qemu/qemu_hotplug.c
|
|
|
43fe83 |
@@ -2397,18 +2397,10 @@ qemuDomainRemovePCIHostDevice(virQEMUDriverPtr driver,
|
|
|
43fe83 |
virDomainObjPtr vm,
|
|
|
43fe83 |
virDomainHostdevDefPtr hostdev)
|
|
|
43fe83 |
{
|
|
|
43fe83 |
- virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
|
|
43fe83 |
virDomainHostdevSubsysPtr subsys = &hostdev->source.subsys;
|
|
|
43fe83 |
virPCIDevicePtr pci;
|
|
|
43fe83 |
virPCIDevicePtr activePci;
|
|
|
43fe83 |
|
|
|
43fe83 |
- /*
|
|
|
43fe83 |
- * For SRIOV net host devices, unset mac and port profile before
|
|
|
43fe83 |
- * reset and reattach device
|
|
|
43fe83 |
- */
|
|
|
43fe83 |
- if (hostdev->parent.data.net)
|
|
|
43fe83 |
- qemuDomainHostdevNetConfigRestore(hostdev, cfg->stateDir);
|
|
|
43fe83 |
-
|
|
|
43fe83 |
virObjectLock(driver->activePciHostdevs);
|
|
|
43fe83 |
virObjectLock(driver->inactivePciHostdevs);
|
|
|
43fe83 |
pci = virPCIDeviceNew(subsys->u.pci.addr.domain, subsys->u.pci.addr.bus,
|
|
|
43fe83 |
@@ -2429,7 +2421,6 @@ qemuDomainRemovePCIHostDevice(virQEMUDriverPtr driver,
|
|
|
43fe83 |
virObjectUnlock(driver->inactivePciHostdevs);
|
|
|
43fe83 |
|
|
|
43fe83 |
qemuDomainReleaseDeviceAddress(vm, hostdev->info, NULL);
|
|
|
43fe83 |
- virObjectUnref(cfg);
|
|
|
43fe83 |
}
|
|
|
43fe83 |
|
|
|
43fe83 |
static void
|
|
|
43fe83 |
@@ -2465,6 +2456,7 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
|
|
|
43fe83 |
virDomainObjPtr vm,
|
|
|
43fe83 |
virDomainHostdevDefPtr hostdev)
|
|
|
43fe83 |
{
|
|
|
43fe83 |
+ virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
|
|
43fe83 |
virDomainNetDefPtr net = NULL;
|
|
|
43fe83 |
virDomainEventPtr event;
|
|
|
43fe83 |
size_t i;
|
|
|
43fe83 |
@@ -2496,6 +2488,8 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
|
|
|
43fe83 |
|
|
|
43fe83 |
virDomainAuditHostdev(vm, hostdev, "detach", true);
|
|
|
43fe83 |
|
|
|
43fe83 |
+ qemuDomainHostdevNetConfigRestore(hostdev, cfg->stateDir);
|
|
|
43fe83 |
+
|
|
|
43fe83 |
switch ((enum virDomainHostdevSubsysType) hostdev->source.subsys.type) {
|
|
|
43fe83 |
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
|
|
|
43fe83 |
qemuDomainRemovePCIHostDevice(driver, vm, hostdev);
|
|
|
43fe83 |
@@ -2524,6 +2518,7 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
|
|
|
43fe83 |
networkReleaseActualDevice(net);
|
|
|
43fe83 |
virDomainNetDefFree(net);
|
|
|
43fe83 |
}
|
|
|
43fe83 |
+ virObjectUnref(cfg);
|
|
|
43fe83 |
}
|
|
|
43fe83 |
|
|
|
43fe83 |
|
|
|
43fe83 |
--
|
|
|
43fe83 |
1.8.4
|
|
|
43fe83 |
|