提交 e30dbb9f 编写于 作者: M Michal Privoznik

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: NMichal Privoznik <mprivozn@redhat.com>
上级 9f20b3b4
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册