On 10.06.2016 10:06, Peter Krempa wrote: > On Thu, Jun 09, 2016 at 17:02:39 +0200, Michal Privoznik wrote: >> 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; > > I don't think we currently match the alias across our device finding > functions. The reason for that is that you won't be able to unplug the > device with --live --config specified for virsh or the corresponding > flag values as the inactive device doesn't have an alias. The problem here is that in some cases alias is the only way of differentiating two redirdevs: <redirdev bus='usb' type='spicevmc'> <alias name='redir0'/> </redirdev> <redirdev bus='usb' type='spicevmc'> <alias name='redir1'/> </redirdev> There is no address, nothing. So what do you suggest to do in this case? I came up with comparing aliases. Michal -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list