mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-28 22:32:19 +00:00
hypervisor: domain: Extract code for checking iothread usage
The code will be also needed for 'virtio-scsi' controller definitions. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
79c68ae313
commit
3313ab3932
@ -537,6 +537,23 @@ virDomainDriverAddIOThreadCheck(virDomainDef *def,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool
|
||||||
|
virDomainIothreadMappingDefHasIothread(GSList *iothreads,
|
||||||
|
unsigned int iothread_id)
|
||||||
|
{
|
||||||
|
GSList *n;
|
||||||
|
|
||||||
|
for (n = iothreads; n; n = n->next) {
|
||||||
|
virDomainIothreadMappingDef *iothread = n->data;
|
||||||
|
|
||||||
|
if (iothread->id == iothread_id)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virDomainDriverDelIOThreadCheck:
|
* virDomainDriverDelIOThreadCheck:
|
||||||
* @def: domain definition
|
* @def: domain definition
|
||||||
@ -558,19 +575,7 @@ virDomainDriverDelIOThreadCheck(virDomainDef *def,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < def->ndisks; i++) {
|
for (i = 0; i < def->ndisks; i++) {
|
||||||
GSList *n;
|
if (virDomainIothreadMappingDefHasIothread(def->disks[i]->iothreads, iothread_id) ||
|
||||||
bool inuse = false;
|
|
||||||
|
|
||||||
for (n = def->disks[i]->iothreads; n; n = n->next) {
|
|
||||||
virDomainIothreadMappingDef *iothread = n->data;
|
|
||||||
|
|
||||||
if (iothread->id == iothread_id) {
|
|
||||||
inuse = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inuse ||
|
|
||||||
def->disks[i]->iothread == iothread_id) {
|
def->disks[i]->iothread == iothread_id) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("cannot remove IOThread %1$u since it is being used by disk '%2$s'"),
|
_("cannot remove IOThread %1$u since it is being used by disk '%2$s'"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user