mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 09:53:10 +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 *
|
char *
|
||||||
virDomainDefGetDefaultEmulator(virDomainDefPtr def,
|
virDomainDefGetDefaultEmulator(virDomainDefPtr def,
|
||||||
virCapsPtr caps)
|
virCapsPtr caps)
|
||||||
|
@ -2834,6 +2834,10 @@ virDomainChrRemove(virDomainDefPtr vmdef,
|
|||||||
ssize_t virDomainRNGFind(virDomainDefPtr def, virDomainRNGDefPtr rng);
|
ssize_t virDomainRNGFind(virDomainDefPtr def, virDomainRNGDefPtr rng);
|
||||||
virDomainRNGDefPtr virDomainRNGRemove(virDomainDefPtr def, size_t idx);
|
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,
|
int virDomainSaveXML(const char *configDir,
|
||||||
virDomainDefPtr def,
|
virDomainDefPtr def,
|
||||||
const char *xml);
|
const char *xml);
|
||||||
|
@ -425,7 +425,9 @@ virDomainPMSuspendedReasonTypeFromString;
|
|||||||
virDomainPMSuspendedReasonTypeToString;
|
virDomainPMSuspendedReasonTypeToString;
|
||||||
virDomainRedirdevBusTypeFromString;
|
virDomainRedirdevBusTypeFromString;
|
||||||
virDomainRedirdevBusTypeToString;
|
virDomainRedirdevBusTypeToString;
|
||||||
|
virDomainRedirdevDefFind;
|
||||||
virDomainRedirdevDefFree;
|
virDomainRedirdevDefFree;
|
||||||
|
virDomainRedirdevDefRemove;
|
||||||
virDomainRNGBackendTypeToString;
|
virDomainRNGBackendTypeToString;
|
||||||
virDomainRNGDefFree;
|
virDomainRNGDefFree;
|
||||||
virDomainRNGFind;
|
virDomainRNGFind;
|
||||||
|
Loading…
Reference in New Issue
Block a user