]> xenbits.xensource.com Git - libvirt.git/commitdiff
vz: add vzCapabilities to connection structure
authorMikhail Feoktistov <mfeoktistov@virtuozzo.com>
Tue, 15 Mar 2016 07:47:47 +0000 (10:47 +0300)
committerMaxim Nestratov <mnestratov@virtuozzo.com>
Wed, 16 Mar 2016 16:34:26 +0000 (19:34 +0300)
As far as Virtuozzo6 and Virtuozzo7 support different disk types for virtual
machines (ploop and qcow2 respectively) and different buses (vz6: IDE, SCSI,
SATA; vz7: IDE SCSI) we add vzCapabilities structure to help undestand which
disk formats and buses are supported in the context of a current connection.

When a new connection opens, we select proper capabilities in accordance to
current Virtuozzo version.

src/vz/vz_utils.c
src/vz/vz_utils.h

index cf37597bc89a63c6c558ad9ee45fd593434b9727..d8a95acfcb53f4b0bb84d539f7242cc755fac873 100644 (file)
 #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:
index fbade2ea402eec368d745a4ff86182c31f8e6e37..e0b010525fc478b234e128b7ca757247ac1e41d9 100644 (file)
 
 # 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;