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@xxxxxxxxxx> --- src/conf/domain_conf.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 4 ++++ src/libvirt_private.syms | 2 ++ 3 files changed, 50 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8f5935c..7b2ff98 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14597,6 +14597,50 @@ 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 (STRNEQ_NULLABLE(redirdev->info.alias, tmp->info.alias)) + continue; + + break; + } + + if (i < def->nredirdevs) + 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) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 3792562..c1b002a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2827,6 +2827,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); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index fe7a34d..fc401cd 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -424,7 +424,9 @@ virDomainPMSuspendedReasonTypeFromString; virDomainPMSuspendedReasonTypeToString; virDomainRedirdevBusTypeFromString; virDomainRedirdevBusTypeToString; +virDomainRedirdevDefFind; virDomainRedirdevDefFree; +virDomainRedirdevDefRemove; virDomainRNGBackendTypeToString; virDomainRNGDefFree; virDomainRNGFind; -- 2.8.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list