Support 'cryptoX' alias for a crypto device. Signed-off-by: zhenwei pi <pizhenwei@xxxxxxxxxxxxx> --- src/qemu/qemu_alias.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index ef8e87ab58..de62f57737 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -607,6 +607,26 @@ qemuAssignDeviceIOMMUAlias(virDomainIOMMUDef *iommu) } +static void +qemuAssignDeviceCryptoAlias(virDomainDef *def, + virDomainCryptoDef *crypto) +{ + size_t i; + int maxidx = 0; + int idx; + + if (crypto->info.alias) + return; + + for (i = 0; i < def->ncryptos; i++) { + if ((idx = qemuDomainDeviceAliasIndex(&def->cryptos[i]->info, "crypto")) >= maxidx) + maxidx = idx + 1; + } + + crypto->info.alias = g_strdup_printf("crypto%d", maxidx); +} + + int qemuAssignDeviceAliases(virDomainDef *def) { @@ -693,6 +713,9 @@ qemuAssignDeviceAliases(virDomainDef *def) } if (def->iommu) qemuAssignDeviceIOMMUAlias(def->iommu); + for (i = 0; i < def->ncryptos; i++) { + qemuAssignDeviceCryptoAlias(def, def->cryptos[i]); + } return 0; } -- 2.34.1