mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 19:41:16 +00:00
virDomainRedirdevDef: Introduce find & remove routines
Basically, there are just two functions introduced here: virDomainRedirdevDefFind which looks up given redirdev in domain definition, and virDomainRedirdevDefRemove which removes the device at given index in the array of devices. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
9f20b3b45e
commit
e30dbb9f98
@ -14615,6 +14615,48 @@ virDomainMemoryRemove(virDomainDefPtr def,
|
||||
}
|
||||
|
||||
|
||||
ssize_t
|
||||
virDomainRedirdevDefFind(virDomainDefPtr def,
|
||||
virDomainRedirdevDefPtr redirdev)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < def->nredirdevs; i++) {
|
||||
virDomainRedirdevDefPtr tmp = def->redirdevs[i];
|
||||
|
||||
if (redirdev->bus != tmp->bus)
|
||||
continue;
|
||||
|
||||
if (!virDomainChrSourceDefIsEqual(&redirdev->source.chr,
|
||||
&tmp->source.chr))
|
||||
continue;
|
||||
|
||||
if (redirdev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
|
||||
!virDomainDeviceInfoAddressIsEqual(&redirdev->info, &tmp->info))
|
||||
continue;
|
||||
|
||||
if (redirdev->info.alias &&
|
||||
STRNEQ_NULLABLE(redirdev->info.alias, tmp->info.alias))
|
||||
continue;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
virDomainRedirdevDefPtr
|
||||
virDomainRedirdevDefRemove(virDomainDefPtr def, size_t idx)
|
||||
{
|
||||
virDomainRedirdevDefPtr ret = def->redirdevs[idx];
|
||||
|
||||
VIR_DELETE_ELEMENT(def->redirdevs, idx, def->nredirdevs);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
virDomainDefGetDefaultEmulator(virDomainDefPtr def,
|
||||
virCapsPtr caps)
|
||||
|
@ -2834,6 +2834,10 @@ virDomainChrRemove(virDomainDefPtr vmdef,
|
||||
ssize_t virDomainRNGFind(virDomainDefPtr def, virDomainRNGDefPtr rng);
|
||||
virDomainRNGDefPtr virDomainRNGRemove(virDomainDefPtr def, size_t idx);
|
||||
|
||||
ssize_t virDomainRedirdevDefFind(virDomainDefPtr def,
|
||||
virDomainRedirdevDefPtr redirdev);
|
||||
virDomainRedirdevDefPtr virDomainRedirdevDefRemove(virDomainDefPtr def, size_t idx);
|
||||
|
||||
int virDomainSaveXML(const char *configDir,
|
||||
virDomainDefPtr def,
|
||||
const char *xml);
|
||||
|
@ -425,7 +425,9 @@ virDomainPMSuspendedReasonTypeFromString;
|
||||
virDomainPMSuspendedReasonTypeToString;
|
||||
virDomainRedirdevBusTypeFromString;
|
||||
virDomainRedirdevBusTypeToString;
|
||||
virDomainRedirdevDefFind;
|
||||
virDomainRedirdevDefFree;
|
||||
virDomainRedirdevDefRemove;
|
||||
virDomainRNGBackendTypeToString;
|
||||
virDomainRNGDefFree;
|
||||
virDomainRNGFind;
|
||||
|
Loading…
Reference in New Issue
Block a user