[PATCH 2/6] vz: add vzCapabilities to connection structure

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

 



Virtuozzo6 supports only ploop disks for containers and
virtual machines on IDE SCSI and SATA buses.
Virtuozzo7 supports only qcow2 for virtual machines on IDE and SCSI buses.
In this patch we add vzCapabilities structure to connection structure.
It contains disk formats and list of buses that we support for virtual machines and containers.
In openConnection() callback we get virtuozzo version and select proper capabilities.
---
 src/vz/vz_utils.c | 24 ++++++++++++++++++++++++
 src/vz/vz_utils.h | 10 ++++++++++
 2 files changed, 34 insertions(+)

diff --git a/src/vz/vz_utils.c b/src/vz/vz_utils.c
index cf37597..d8a95ac 100644
--- a/src/vz/vz_utils.c
+++ b/src/vz/vz_utils.c
@@ -36,6 +36,15 @@
 #define VIR_FROM_THIS VIR_FROM_PARALLELS
 #define PRLSRVCTL "prlsrvctl"
 
+static virDomainDiskBus vz6DiskBuses[] = {VIR_DOMAIN_DISK_BUS_IDE,
+                                          VIR_DOMAIN_DISK_BUS_SCSI,
+                                          VIR_DOMAIN_DISK_BUS_SATA,
+                                          VIR_DOMAIN_DISK_BUS_LAST};
+
+static virDomainDiskBus vz7DiskBuses[] = {VIR_DOMAIN_DISK_BUS_IDE,
+                                          VIR_DOMAIN_DISK_BUS_SCSI,
+                                          VIR_DOMAIN_DISK_BUS_LAST};
+
 /**
  * vzDomObjFromDomain:
  * @domain: Domain pointer that has to be looked up
@@ -180,6 +189,20 @@ vzNewDomain(vzConnPtr privconn, char *name, const unsigned char *uuid)
     return NULL;
 }
 
+static void
+vzInitCaps(unsigned long vzVersion, vzCapabilities *vzCaps)
+{
+    if (vzVersion < VIRTUOZZO_VER_7) {
+        vzCaps->ctDiskFormat = VIR_STORAGE_FILE_PLOOP;
+        vzCaps->vmDiskFormat = VIR_STORAGE_FILE_PLOOP;
+        vzCaps->diskBuses = vz6DiskBuses;
+    } else {
+        vzCaps->ctDiskFormat = VIR_STORAGE_FILE_PLOOP;
+        vzCaps->vmDiskFormat = VIR_STORAGE_FILE_QCOW2;
+        vzCaps->diskBuses = vz7DiskBuses;
+    }
+}
+
 int
 vzInitVersion(vzConnPtr privconn)
 {
@@ -219,6 +242,7 @@ vzInitVersion(vzConnPtr privconn)
         goto cleanup;
     }
 
+    vzInitCaps(privconn->vzVersion, &privconn->vzCaps);
     ret = 0;
 
  cleanup:
diff --git a/src/vz/vz_utils.h b/src/vz/vz_utils.h
index fbade2e..e0b0105 100644
--- a/src/vz/vz_utils.h
+++ b/src/vz/vz_utils.h
@@ -48,6 +48,15 @@
 
 # define PARALLELS_DOMAIN_ROUTED_NETWORK_NAME   "Routed"
 # define PARALLELS_DOMAIN_BRIDGED_NETWORK_NAME  "Bridged"
+# define VIRTUOZZO_VER_7 ((unsigned long) 7000000)
+
+struct _vzCapabilities {
+    virStorageFileFormat vmDiskFormat;
+    virStorageFileFormat ctDiskFormat;
+    virDomainDiskBus *diskBuses;
+};
+typedef struct _vzCapabilities vzCapabilities;
+typedef struct _vzCapabilities *vzCapabilitiesPtr;
 
 struct _vzConn {
     virMutex lock;
@@ -63,6 +72,7 @@ struct _vzConn {
     /* Immutable pointer, self-locking APIs */
     virConnectCloseCallbackDataPtr closeCallback;
     unsigned long vzVersion;
+    vzCapabilities vzCaps;
 };
 
 typedef struct _vzConn vzConn;
-- 
1.8.3.1

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