mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
qemu: lookup node device against nodedev driver before getting XML
Some of the node device APIs are a little odd because they accept a virNodeDevicePtr object but are still implemented by the virt drivers. The first thing the virt drivers need to do is get the XML config associated with the node device, and that means talking to the node device driver. This worked previously because with monolithic libvirtd, both the virt driver and node device driver were in the same daemon and thus a single virConnectPtr can talk to both drivers. With the split daemon world though, the virNodeDevicePtr passed into the APIs is associated with the QEMU driver virConnectPtr, which has no ability to invoke APIs against the node device driver. We must thus get a duplicate virNodeDevicePtr object which is associated with a virConnectPtr for the node device driver. Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
69eee587da
commit
b8a3ed957e
@ -5786,10 +5786,23 @@ libxlNodeDeviceDetachFlags(virNodeDevicePtr dev,
|
||||
char *xml = NULL;
|
||||
libxlDriverPrivatePtr driver = dev->conn->privateData;
|
||||
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
|
||||
virConnectPtr nodeconn = NULL;
|
||||
virNodeDevicePtr nodedev = NULL;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
|
||||
xml = virNodeDeviceGetXMLDesc(dev, 0);
|
||||
if (!(nodeconn = virGetConnectNodeDev()))
|
||||
goto cleanup;
|
||||
|
||||
/* 'dev' is associated with the QEMU virConnectPtr,
|
||||
* so for split daemons, we need to get a copy that
|
||||
* is associated with the virnodedevd daemon.
|
||||
*/
|
||||
if (!(nodedev = virNodeDeviceLookupByName(nodeconn,
|
||||
virNodeDeviceGetName(dev))))
|
||||
goto cleanup;
|
||||
|
||||
xml = virNodeDeviceGetXMLDesc(nodedev, 0);
|
||||
if (!xml)
|
||||
goto cleanup;
|
||||
|
||||
@ -5797,6 +5810,8 @@ libxlNodeDeviceDetachFlags(virNodeDevicePtr dev,
|
||||
if (!def)
|
||||
goto cleanup;
|
||||
|
||||
/* ACL check must happen against original 'dev',
|
||||
* not the new 'nodedev' we acquired */
|
||||
if (virNodeDeviceDetachFlagsEnsureACL(dev->conn, def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -5822,6 +5837,8 @@ libxlNodeDeviceDetachFlags(virNodeDevicePtr dev,
|
||||
cleanup:
|
||||
virPCIDeviceFree(pci);
|
||||
virNodeDeviceDefFree(def);
|
||||
virObjectUnref(nodedev);
|
||||
virObjectUnref(nodeconn);
|
||||
VIR_FREE(xml);
|
||||
return ret;
|
||||
}
|
||||
@ -5842,8 +5859,21 @@ libxlNodeDeviceReAttach(virNodeDevicePtr dev)
|
||||
char *xml = NULL;
|
||||
libxlDriverPrivatePtr driver = dev->conn->privateData;
|
||||
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
|
||||
virConnectPtr nodeconn = NULL;
|
||||
virNodeDevicePtr nodedev = NULL;
|
||||
|
||||
xml = virNodeDeviceGetXMLDesc(dev, 0);
|
||||
if (!(nodeconn = virGetConnectNodeDev()))
|
||||
goto cleanup;
|
||||
|
||||
/* 'dev' is associated with the QEMU virConnectPtr,
|
||||
* so for split daemons, we need to get a copy that
|
||||
* is associated with the virnodedevd daemon.
|
||||
*/
|
||||
if (!(nodedev = virNodeDeviceLookupByName(
|
||||
nodeconn, virNodeDeviceGetName(dev))))
|
||||
goto cleanup;
|
||||
|
||||
xml = virNodeDeviceGetXMLDesc(nodedev, 0);
|
||||
if (!xml)
|
||||
goto cleanup;
|
||||
|
||||
@ -5851,6 +5881,8 @@ libxlNodeDeviceReAttach(virNodeDevicePtr dev)
|
||||
if (!def)
|
||||
goto cleanup;
|
||||
|
||||
/* ACL check must happen against original 'dev',
|
||||
* not the new 'nodedev' we acquired */
|
||||
if (virNodeDeviceReAttachEnsureACL(dev->conn, def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -5869,6 +5901,8 @@ libxlNodeDeviceReAttach(virNodeDevicePtr dev)
|
||||
cleanup:
|
||||
virPCIDeviceFree(pci);
|
||||
virNodeDeviceDefFree(def);
|
||||
virObjectUnref(nodedev);
|
||||
virObjectUnref(nodeconn);
|
||||
VIR_FREE(xml);
|
||||
return ret;
|
||||
}
|
||||
@ -5883,8 +5917,21 @@ libxlNodeDeviceReset(virNodeDevicePtr dev)
|
||||
char *xml = NULL;
|
||||
libxlDriverPrivatePtr driver = dev->conn->privateData;
|
||||
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
|
||||
virConnectPtr nodeconn = NULL;
|
||||
virNodeDevicePtr nodedev = NULL;
|
||||
|
||||
xml = virNodeDeviceGetXMLDesc(dev, 0);
|
||||
if (!(nodeconn = virGetConnectNodeDev()))
|
||||
goto cleanup;
|
||||
|
||||
/* 'dev' is associated with the QEMU virConnectPtr,
|
||||
* so for split daemons, we need to get a copy that
|
||||
* is associated with the virnodedevd daemon.
|
||||
*/
|
||||
if (!(nodedev = virNodeDeviceLookupByName(
|
||||
nodeconn, virNodeDeviceGetName(dev))))
|
||||
goto cleanup;
|
||||
|
||||
xml = virNodeDeviceGetXMLDesc(nodedev, 0);
|
||||
if (!xml)
|
||||
goto cleanup;
|
||||
|
||||
@ -5892,6 +5939,8 @@ libxlNodeDeviceReset(virNodeDevicePtr dev)
|
||||
if (!def)
|
||||
goto cleanup;
|
||||
|
||||
/* ACL check must happen against original 'dev',
|
||||
* not the new 'nodedev' we acquired */
|
||||
if (virNodeDeviceResetEnsureACL(dev->conn, def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -5910,6 +5959,8 @@ libxlNodeDeviceReset(virNodeDevicePtr dev)
|
||||
cleanup:
|
||||
virPCIDeviceFree(pci);
|
||||
virNodeDeviceDefFree(def);
|
||||
virObjectUnref(nodedev);
|
||||
virObjectUnref(nodeconn);
|
||||
VIR_FREE(xml);
|
||||
return ret;
|
||||
}
|
||||
|
@ -12965,10 +12965,23 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev,
|
||||
g_autofree char *xml = NULL;
|
||||
bool vfio = qemuHostdevHostSupportsPassthroughVFIO();
|
||||
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
|
||||
virConnectPtr nodeconn = NULL;
|
||||
virNodeDevicePtr nodedev = NULL;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
|
||||
xml = virNodeDeviceGetXMLDesc(dev, 0);
|
||||
if (!(nodeconn = virGetConnectNodeDev()))
|
||||
goto cleanup;
|
||||
|
||||
/* 'dev' is associated with the QEMU virConnectPtr,
|
||||
* so for split daemons, we need to get a copy that
|
||||
* is associated with the virnodedevd daemon.
|
||||
*/
|
||||
if (!(nodedev = virNodeDeviceLookupByName(nodeconn,
|
||||
virNodeDeviceGetName(dev))))
|
||||
goto cleanup;
|
||||
|
||||
xml = virNodeDeviceGetXMLDesc(nodedev, 0);
|
||||
if (!xml)
|
||||
goto cleanup;
|
||||
|
||||
@ -12976,6 +12989,8 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev,
|
||||
if (!def)
|
||||
goto cleanup;
|
||||
|
||||
/* ACL check must happen against original 'dev',
|
||||
* not the new 'nodedev' we acquired */
|
||||
if (virNodeDeviceDetachFlagsEnsureACL(dev->conn, def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -13012,6 +13027,8 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev,
|
||||
cleanup:
|
||||
virPCIDeviceFree(pci);
|
||||
virNodeDeviceDefFree(def);
|
||||
virObjectUnref(nodedev);
|
||||
virObjectUnref(nodeconn);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -13031,8 +13048,21 @@ qemuNodeDeviceReAttach(virNodeDevicePtr dev)
|
||||
virNodeDeviceDefPtr def = NULL;
|
||||
g_autofree char *xml = NULL;
|
||||
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
|
||||
virConnectPtr nodeconn = NULL;
|
||||
virNodeDevicePtr nodedev = NULL;
|
||||
|
||||
xml = virNodeDeviceGetXMLDesc(dev, 0);
|
||||
if (!(nodeconn = virGetConnectNodeDev()))
|
||||
goto cleanup;
|
||||
|
||||
/* 'dev' is associated with the QEMU virConnectPtr,
|
||||
* so for split daemons, we need to get a copy that
|
||||
* is associated with the virnodedevd daemon.
|
||||
*/
|
||||
if (!(nodedev = virNodeDeviceLookupByName(
|
||||
nodeconn, virNodeDeviceGetName(dev))))
|
||||
goto cleanup;
|
||||
|
||||
xml = virNodeDeviceGetXMLDesc(nodedev, 0);
|
||||
if (!xml)
|
||||
goto cleanup;
|
||||
|
||||
@ -13040,6 +13070,8 @@ qemuNodeDeviceReAttach(virNodeDevicePtr dev)
|
||||
if (!def)
|
||||
goto cleanup;
|
||||
|
||||
/* ACL check must happen against original 'dev',
|
||||
* not the new 'nodedev' we acquired */
|
||||
if (virNodeDeviceReAttachEnsureACL(dev->conn, def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -13055,6 +13087,8 @@ qemuNodeDeviceReAttach(virNodeDevicePtr dev)
|
||||
virPCIDeviceFree(pci);
|
||||
cleanup:
|
||||
virNodeDeviceDefFree(def);
|
||||
virObjectUnref(nodedev);
|
||||
virObjectUnref(nodeconn);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -13068,8 +13102,21 @@ qemuNodeDeviceReset(virNodeDevicePtr dev)
|
||||
virNodeDeviceDefPtr def = NULL;
|
||||
g_autofree char *xml = NULL;
|
||||
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
|
||||
virConnectPtr nodeconn = NULL;
|
||||
virNodeDevicePtr nodedev = NULL;
|
||||
|
||||
xml = virNodeDeviceGetXMLDesc(dev, 0);
|
||||
if (!(nodeconn = virGetConnectNodeDev()))
|
||||
goto cleanup;
|
||||
|
||||
/* 'dev' is associated with the QEMU virConnectPtr,
|
||||
* so for split daemons, we need to get a copy that
|
||||
* is associated with the virnodedevd daemon.
|
||||
*/
|
||||
if (!(nodedev = virNodeDeviceLookupByName(
|
||||
nodeconn, virNodeDeviceGetName(dev))))
|
||||
goto cleanup;
|
||||
|
||||
xml = virNodeDeviceGetXMLDesc(nodedev, 0);
|
||||
if (!xml)
|
||||
goto cleanup;
|
||||
|
||||
@ -13077,6 +13124,8 @@ qemuNodeDeviceReset(virNodeDevicePtr dev)
|
||||
if (!def)
|
||||
goto cleanup;
|
||||
|
||||
/* ACL check must happen against original 'dev',
|
||||
* not the new 'nodedev' we acquired */
|
||||
if (virNodeDeviceResetEnsureACL(dev->conn, def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -13092,6 +13141,8 @@ qemuNodeDeviceReset(virNodeDevicePtr dev)
|
||||
virPCIDeviceFree(pci);
|
||||
cleanup:
|
||||
virNodeDeviceDefFree(def);
|
||||
virObjectUnref(nodedev);
|
||||
virObjectUnref(nodeconn);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user