mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 21:34:54 +03:00
QEMUHotplugRemoveFDSet: Prepare for proper FD unplug handling
For now we have only one code path ('vdpa' interface) which actually cleans up the fdset after it's done, but there are more device types using fdsets. In order to unify the handling of fdsets the removal code will now be able to remove fdsets based on a prefix of the 'opaque' field, which we'll always prefix with a device alias or e.g. node name once fdsets are also used for disk backing. To keep compatibility with old QEMUs, retain the possibility for the VDPA interface to use the path. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
a4449fb158
commit
64a69ee242
@ -140,18 +140,21 @@ qemuDomainDeleteDevice(virDomainObj *vm,
|
||||
/**
|
||||
* qemuHotplugRemoveFDSet:
|
||||
* @mon: monitor object
|
||||
* @fdname: the 'opaque' string used as a name for the FD
|
||||
* @prefix: the prefix of FD names ('opaque' field) to delete
|
||||
* @alternate: alternate name for FD, for historical usage (may be NULL)
|
||||
*
|
||||
* Looks up the 'fdset' by looking for a fd inside one of the fdsets which
|
||||
* has the opaque string set to @fdname. Removes the whole fdset which contains
|
||||
* the fd.
|
||||
* has the opaque string starting with @prefix. Removes the whole fdset which
|
||||
* contains the fd. Alternatively if @alternate is specified fdsets having a fd
|
||||
* with that exact 'opaque' string is removed too.
|
||||
*
|
||||
* Errors are logged, but this is a best-effort hot-unplug cleanup helper so it's
|
||||
* pointless to return a value.
|
||||
*/
|
||||
static void
|
||||
qemuHotplugRemoveFDSet(qemuMonitor *mon,
|
||||
const char *fdname)
|
||||
const char *prefix,
|
||||
const char *alternate)
|
||||
{
|
||||
g_autoptr(qemuMonitorFdsets) fdsets = NULL;
|
||||
size_t i;
|
||||
@ -166,9 +169,11 @@ qemuHotplugRemoveFDSet(qemuMonitor *mon,
|
||||
for (j = 0; j < set->nfds; j++) {
|
||||
qemuMonitorFdsetFdInfo *fdinfo = &set->fds[j];
|
||||
|
||||
if (STREQ_NULLABLE(fdinfo->opaque, fdname)) {
|
||||
if (fdinfo->opaque &&
|
||||
(STRPREFIX(fdinfo->opaque, prefix) ||
|
||||
STREQ_NULLABLE(fdinfo->opaque, alternate))) {
|
||||
ignore_value(qemuMonitorRemoveFdset(mon, set->id));
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4799,7 +4804,7 @@ qemuDomainRemoveNetDevice(virQEMUDriver *driver,
|
||||
*/
|
||||
}
|
||||
} else if (actualType == VIR_DOMAIN_NET_TYPE_VDPA) {
|
||||
qemuHotplugRemoveFDSet(priv->mon, net->data.vdpa.devicepath);
|
||||
qemuHotplugRemoveFDSet(priv->mon, net->info.alias, net->data.vdpa.devicepath);
|
||||
}
|
||||
|
||||
qemuDomainObjExitMonitor(driver, vm);
|
||||
|
Loading…
Reference in New Issue
Block a user