Re: [PATCH 02/18] vz: make prlsdkGetDisk more generic

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

 



20.04.2016 17:05, Nikolay Shirokovskiy пишет:

Current implementation works with hard disks only. This patch
adds support for any disk device (cdroms and hdds right now).

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>
---
  src/vz/vz_sdk.c | 27 +++++++++++++++++----------
  1 file changed, 17 insertions(+), 10 deletions(-)

ACK with the comment inline.

diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index bff52f9..0f05dfd 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -3304,29 +3304,36 @@ static PRL_HANDLE
  prlsdkGetDisk(PRL_HANDLE sdkdom, virDomainDiskDefPtr disk, bool isCt)
  {
      PRL_RESULT pret;
-    PRL_UINT32 hddCount;
+    PRL_UINT32 num;
      size_t i;
-    PRL_HANDLE hdd = PRL_INVALID_HANDLE;
+    PRL_HANDLE sdkdisk = PRL_INVALID_HANDLE;
      int bus;
      char *dst = NULL;
+    PRL_DEVICE_TYPE devType;
- pret = PrlVmCfg_GetHardDisksCount(sdkdom, &hddCount);
+    /* FIXME safe conversion?? */

Not sure we need this.

+    if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK)
+        devType = PDE_HARD_DISK;
+    else
+        devType = PDE_OPTICAL_DISK;
+
+    pret = PrlVmCfg_GetDevsCountByType(sdkdom, devType, &num);
      prlsdkCheckRetGoto(pret, error);
- for (i = 0; i < hddCount; ++i) {
-        pret = PrlVmCfg_GetHardDisk(sdkdom, i, &hdd);
+    for (i = 0; i < num; ++i) {
+        pret = PrlVmCfg_GetDevByType(sdkdom, devType, i, &sdkdisk);
          prlsdkCheckRetGoto(pret, error);
- if (prlsdkGetDiskId(hdd, isCt, &bus, &dst) < 0)
+        if (prlsdkGetDiskId(sdkdisk, isCt, &bus, &dst) < 0)
              goto error;
if (disk->bus == bus && STREQ(disk->dst, dst)) {
              VIR_FREE(dst);
-            return hdd;
+            return sdkdisk;
          }
- PrlHandle_Free(hdd);
-        hdd = PRL_INVALID_HANDLE;
+        PrlHandle_Free(sdkdisk);
+        sdkdisk = PRL_INVALID_HANDLE;
          VIR_FREE(dst);
      }
@@ -3337,7 +3344,7 @@ prlsdkGetDisk(PRL_HANDLE sdkdom, virDomainDiskDefPtr disk, bool isCt) error:
      VIR_FREE(dst);
-    PrlHandle_Free(hdd);
+    PrlHandle_Free(sdkdisk);
      return PRL_INVALID_HANDLE;
  }

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[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]