[PATCH v2 3/5] qemu: alias: support crypto device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux