mirror of https://gitee.com/openkylin/libvirt.git
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:
parent
dca5ce4c65
commit
f8f020da0a
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -198,6 +198,7 @@ virDomainDiskErrorPolicyTypeToString;
|
|||
virDomainDiskFindByBusAndDst;
|
||||
virDomainDiskGeometryTransTypeFromString;
|
||||
virDomainDiskGeometryTransTypeToString;
|
||||
virDomainDiskGetActualType;
|
||||
virDomainDiskHostDefClear;
|
||||
virDomainDiskHostDefCopy;
|
||||
virDomainDiskHostDefFree;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue