From: Mikhail Feoktistov <mfeoktistov(a)virtuozzo.com>
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 | 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;
--
2.4.3