conf: Move qemuDiskGetActualType to virDomainDiskGetActualType

All the data for getting the actual type is present in the domain
config. There is no need to have this function private to the qemu
driver and it will be re-used later in other parts of libvirt
This commit is contained in:
Peter Krempa 2014-02-13 10:41:01 +01:00
parent dca5ce4c65
commit f8f020da0a
7 changed files with 18 additions and 18 deletions

View File

@ -1345,6 +1345,16 @@ error:
}
int
virDomainDiskGetActualType(virDomainDiskDefPtr def)
{
if (def->type == VIR_DOMAIN_DISK_TYPE_VOLUME && def->srcpool)
return def->srcpool->actualtype;
return def->type;
}
void virDomainControllerDefFree(virDomainControllerDefPtr def)
{
if (!def)

View File

@ -2252,6 +2252,7 @@ void virDomainDiskHostDefClear(virDomainDiskHostDefPtr def);
void virDomainDiskHostDefFree(size_t nhosts, virDomainDiskHostDefPtr hosts);
virDomainDiskHostDefPtr virDomainDiskHostDefCopy(size_t nhosts,
virDomainDiskHostDefPtr hosts);
int virDomainDiskGetActualType(virDomainDiskDefPtr def);
int virDomainDeviceFindControllerModel(virDomainDefPtr def,
virDomainDeviceInfoPtr info,
int controllerType);

View File

@ -198,6 +198,7 @@ virDomainDiskErrorPolicyTypeToString;
virDomainDiskFindByBusAndDst;
virDomainDiskGeometryTransTypeFromString;
virDomainDiskGeometryTransTypeToString;
virDomainDiskGetActualType;
virDomainDiskHostDefClear;
virDomainDiskHostDefCopy;
virDomainDiskHostDefFree;

View File

@ -3869,7 +3869,7 @@ qemuDomainDiskGetSourceString(virConnectPtr conn,
virDomainDiskDefPtr disk,
char **source)
{
int actualType = qemuDiskGetActualType(disk);
int actualType = virDomainDiskGetActualType(disk);
char *secret = NULL;
int ret = -1;
@ -3899,7 +3899,7 @@ qemuDomainDiskGetSourceString(virConnectPtr conn,
goto cleanup;
}
ret = qemuGetDriveSourceString(qemuDiskGetActualType(disk),
ret = qemuGetDriveSourceString(virDomainDiskGetActualType(disk),
disk->src,
disk->protocol,
disk->nhosts,
@ -3927,7 +3927,7 @@ qemuBuildDriveStr(virConnectPtr conn,
int idx = virDiskNameToIndex(disk->dst);
int busid = -1, unitid = -1;
char *source = NULL;
int actualType = qemuDiskGetActualType(disk);
int actualType = virDomainDiskGetActualType(disk);
if (idx < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,

View File

@ -1303,16 +1303,6 @@ cleanup:
}
int
qemuDiskGetActualType(virDomainDiskDefPtr def)
{
if (def->type == VIR_DOMAIN_DISK_TYPE_VOLUME && def->srcpool)
return def->srcpool->actualtype;
return def->type;
}
int
qemuTranslateDiskSourcePool(virConnectPtr conn,
virDomainDiskDefPtr def)

View File

@ -305,8 +305,6 @@ int qemuSetUnprivSGIO(virDomainDeviceDefPtr dev);
int qemuDriverAllocateID(virQEMUDriverPtr driver);
virDomainXMLOptionPtr virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver);
int qemuDiskGetActualType(virDomainDiskDefPtr def);
int qemuTranslateDiskSourcePool(virConnectPtr conn,
virDomainDiskDefPtr def);

View File

@ -12260,7 +12260,7 @@ endjob:
static int
qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
{
int actualType = qemuDiskGetActualType(disk);
int actualType = virDomainDiskGetActualType(disk);
switch ((enum virDomainDiskType) actualType) {
case VIR_DOMAIN_DISK_TYPE_BLOCK:
@ -12304,7 +12304,7 @@ qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
static int
qemuDomainSnapshotPrepareDiskExternalBackingActive(virDomainDiskDefPtr disk)
{
int actualType = qemuDiskGetActualType(disk);
int actualType = virDomainDiskGetActualType(disk);
if (actualType == VIR_DOMAIN_DISK_TYPE_BLOCK &&
disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) {
@ -12448,7 +12448,7 @@ qemuDomainSnapshotPrepareDiskInternal(virConnectPtr conn,
if (qemuTranslateDiskSourcePool(conn, disk) < 0)
return -1;
actualType = qemuDiskGetActualType(disk);
actualType = virDomainDiskGetActualType(disk);
switch ((enum virDomainDiskType) actualType) {
case VIR_DOMAIN_DISK_TYPE_BLOCK: