On 11/06/2013 06:56 PM, Peter Krempa wrote:
To avoid code duplication between snapshot configuration code that
parses the disk source too we need to split out this code that will be
reused later on.
This patch tries to be code movement, some aspects of this function will
be refactored later.
---
src/conf/domain_conf.c | 261 ++++++++++++++++++++++++++++---------------------
1 file changed, 147 insertions(+), 114 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 50ce44d..a6e7047 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
+ if (virDomainDiskSourceDefParse(cur, def->type,
+ &source,
+ &def->protocol,
+ &def->nhosts,
+ &def->hosts,
+ &def->srcpool) < 0)
goto error;
+
+ if (def->protocol ==
VIR_DOMAIN_DISK_PROTOCOL_ISCSI) {
+ expected_secret_usage = VIR_SECRET_USAGE_TYPE_ISCSI;
+ } else if (def->protocol == VIR_DOMAIN_DISK_PROTOCOL_RBD) {
+ expected_secret_usage = VIR_SECRET_USAGE_TYPE_CEPH;
}
def->protocol was only filled if def->type is TYPE_NETWORK
startupPolicy = virXMLPropString(cur, "startupPolicy");
- /* People sometimes pass a bogus '' source path
- when they mean to omit the source element
- completely (e.g. CDROM without media). This is
- just a little compatibility check to help
- those broken apps */
- if (source && STREQ(source, ""))
- VIR_FREE(source);
} else if (!target &&
xmlStrEqual(cur->name, BAD_CAST "target")) {
target = virXMLPropString(cur, "dev");
@@ -5601,11 +5639,6 @@ cleanup:
VIR_FREE(tray);
VIR_FREE(removable);
VIR_FREE(trans);
- while (nhosts > 0) {
- virDomainDiskHostDefFree(&hosts[nhosts - 1]);
- nhosts--;
- }
- VIR_FREE(hosts);
VIR_FREE(protocol);
VIR_FREE(protocol_transport);
You forgot to move these two.
VIR_FREE(device);