From 361ee3d8a6a3ac0d44eba8651d9cee5c609bc6b3 Mon Sep 17 00:00:00 2001
Message-Id: <361ee3d8a6a3ac0d44eba8651d9cee5c609bc6b3@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Wed, 26 Feb 2014 14:55:23 +0100
Subject: [PATCH] conf: Move qemuDiskGetActualType to
virDomainDiskGetActualType
https://bugzilla.redhat.com/show_bug.cgi?id=1032370
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
(cherry picked from commit f8f020da0a72e4262784eff6325b155ffd03ca37)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
src/conf/domain_conf.c | 10 ++++++++++
src/conf/domain_conf.h | 1 +
src/libvirt_private.syms | 1 +
src/qemu/qemu_command.c | 6 +++---
src/qemu/qemu_conf.c | 10 ----------
src/qemu/qemu_conf.h | 2 --
src/qemu/qemu_driver.c | 6 +++---
7 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6e833c8..d1617b8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1288,6 +1288,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)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 4e6d4e7..00e66ae 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2215,6 +2215,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);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 7df7e73..40b997b 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -196,6 +196,7 @@ virDomainDiskErrorPolicyTypeToString;
virDomainDiskFindByBusAndDst;
virDomainDiskGeometryTransTypeFromString;
virDomainDiskGeometryTransTypeToString;
+virDomainDiskGetActualType;
virDomainDiskHostDefClear;
virDomainDiskHostDefCopy;
virDomainDiskHostDefFree;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 749f97b..8923b09 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3774,7 +3774,7 @@ qemuDomainDiskGetSourceString(virConnectPtr conn,
virDomainDiskDefPtr disk,
char **source)
{
- int actualType = qemuDiskGetActualType(disk);
+ int actualType = virDomainDiskGetActualType(disk);
char *secret = NULL;
int ret = -1;
@@ -3804,7 +3804,7 @@ qemuDomainDiskGetSourceString(virConnectPtr conn,
goto cleanup;
}
- ret = qemuGetDriveSourceString(qemuDiskGetActualType(disk),
+ ret = qemuGetDriveSourceString(virDomainDiskGetActualType(disk),
disk->src,
disk->protocol,
disk->nhosts,
@@ -3832,7 +3832,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,
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index af1e3be..9b02886 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1269,16 +1269,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)
{
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index b90c563..e03be95 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -300,8 +300,6 @@ int qemuSetUnprivSGIO(virDomainDeviceDefPtr dev);
int qemuDriverAllocateID(virQEMUDriverPtr driver);
virDomainXMLOptionPtr virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver);
-int qemuDiskGetActualType(virDomainDiskDefPtr def);
-
int qemuTranslateDiskSourcePool(virConnectPtr conn,
virDomainDiskDefPtr def);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 641d118..03d94fc 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12143,7 +12143,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:
@@ -12182,7 +12182,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) {
@@ -12326,7 +12326,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:
--
1.9.0