|
|
c401cc |
From 22bf0d340df32aac9efb1c8a0fbd8843485a13a3 Mon Sep 17 00:00:00 2001
|
|
|
c401cc |
Message-Id: <22bf0d340df32aac9efb1c8a0fbd8843485a13a3@dist-git>
|
|
|
c401cc |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
c401cc |
Date: Wed, 26 Feb 2014 14:54:44 +0100
|
|
|
c401cc |
Subject: [PATCH] conf: Clean up virDomainDiskSourceDefFormatInternal
|
|
|
c401cc |
|
|
|
c401cc |
https://bugzilla.redhat.com/show_bug.cgi?id=1032370
|
|
|
c401cc |
|
|
|
c401cc |
Avoid if statements when used with virBufferEscapeString which
|
|
|
c401cc |
automaticaly omits the whole string. Also add some line breaks to
|
|
|
c401cc |
visualy separate the code.
|
|
|
c401cc |
|
|
|
c401cc |
(cherry picked from commit 03ad83cb5a32d62a71075716139356a4fcc9972b)
|
|
|
c401cc |
|
|
|
c401cc |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c401cc |
---
|
|
|
c401cc |
src/conf/domain_conf.c | 48 ++++++++++++++++++++----------------------------
|
|
|
c401cc |
1 file changed, 20 insertions(+), 28 deletions(-)
|
|
|
c401cc |
|
|
|
c401cc |
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
|
|
c401cc |
index 7032b2b..bba6201 100644
|
|
|
c401cc |
--- a/src/conf/domain_conf.c
|
|
|
c401cc |
+++ b/src/conf/domain_conf.c
|
|
|
c401cc |
@@ -14485,53 +14485,49 @@ virDomainDiskSourceDefFormatInternal(virBufferPtr buf,
|
|
|
c401cc |
switch (type) {
|
|
|
c401cc |
case VIR_DOMAIN_DISK_TYPE_FILE:
|
|
|
c401cc |
virBufferAddLit(buf, "
|
|
|
c401cc |
- if (src)
|
|
|
c401cc |
- virBufferEscapeString(buf, " file='%s'", src);
|
|
|
c401cc |
- if (startupPolicy)
|
|
|
c401cc |
- virBufferEscapeString(buf, " startupPolicy='%s'",
|
|
|
c401cc |
- startupPolicy);
|
|
|
c401cc |
+ virBufferEscapeString(buf, " file='%s'", src);
|
|
|
c401cc |
+ virBufferEscapeString(buf, " startupPolicy='%s'", startupPolicy);
|
|
|
c401cc |
+
|
|
|
c401cc |
if (nseclabels) {
|
|
|
c401cc |
virBufferAddLit(buf, ">\n");
|
|
|
c401cc |
virBufferAdjustIndent(buf, 8);
|
|
|
c401cc |
for (n = 0; n < nseclabels; n++)
|
|
|
c401cc |
- virSecurityDeviceLabelDefFormat(buf, seclabels[n],
|
|
|
c401cc |
- flags);
|
|
|
c401cc |
+ virSecurityDeviceLabelDefFormat(buf, seclabels[n], flags);
|
|
|
c401cc |
virBufferAdjustIndent(buf, -8);
|
|
|
c401cc |
virBufferAddLit(buf, " </source>\n");
|
|
|
c401cc |
} else {
|
|
|
c401cc |
virBufferAddLit(buf, "/>\n");
|
|
|
c401cc |
}
|
|
|
c401cc |
break;
|
|
|
c401cc |
+
|
|
|
c401cc |
case VIR_DOMAIN_DISK_TYPE_BLOCK:
|
|
|
c401cc |
virBufferAddLit(buf, "
|
|
|
c401cc |
virBufferEscapeString(buf, " dev='%s'", src);
|
|
|
c401cc |
- if (startupPolicy)
|
|
|
c401cc |
- virBufferEscapeString(buf, " startupPolicy='%s'",
|
|
|
c401cc |
- startupPolicy);
|
|
|
c401cc |
+ virBufferEscapeString(buf, " startupPolicy='%s'", startupPolicy);
|
|
|
c401cc |
+
|
|
|
c401cc |
if (nseclabels) {
|
|
|
c401cc |
virBufferAddLit(buf, ">\n");
|
|
|
c401cc |
virBufferAdjustIndent(buf, 8);
|
|
|
c401cc |
for (n = 0; n < nseclabels; n++)
|
|
|
c401cc |
- virSecurityDeviceLabelDefFormat(buf, seclabels[n],
|
|
|
c401cc |
- flags);
|
|
|
c401cc |
+ virSecurityDeviceLabelDefFormat(buf, seclabels[n], flags);
|
|
|
c401cc |
virBufferAdjustIndent(buf, -8);
|
|
|
c401cc |
virBufferAddLit(buf, " </source>\n");
|
|
|
c401cc |
} else {
|
|
|
c401cc |
virBufferAddLit(buf, "/>\n");
|
|
|
c401cc |
}
|
|
|
c401cc |
break;
|
|
|
c401cc |
+
|
|
|
c401cc |
case VIR_DOMAIN_DISK_TYPE_DIR:
|
|
|
c401cc |
- virBufferEscapeString(buf, "
|
|
|
c401cc |
- if (startupPolicy)
|
|
|
c401cc |
- virBufferEscapeString(buf, " startupPolicy='%s'",
|
|
|
c401cc |
- startupPolicy);
|
|
|
c401cc |
+ virBufferAddLit(buf, "
|
|
|
c401cc |
+ virBufferEscapeString(buf, " dir='%s'", src);
|
|
|
c401cc |
+ virBufferEscapeString(buf, " startupPolicy='%s'", startupPolicy);
|
|
|
c401cc |
virBufferAddLit(buf, "/>\n");
|
|
|
c401cc |
break;
|
|
|
c401cc |
+
|
|
|
c401cc |
case VIR_DOMAIN_DISK_TYPE_NETWORK:
|
|
|
c401cc |
virBufferAsprintf(buf, "
|
|
|
c401cc |
virDomainDiskProtocolTypeToString(protocol));
|
|
|
c401cc |
- if (src)
|
|
|
c401cc |
- virBufferEscapeString(buf, " name='%s'", src);
|
|
|
c401cc |
+ virBufferEscapeString(buf, " name='%s'", src);
|
|
|
c401cc |
|
|
|
c401cc |
if (nhosts == 0) {
|
|
|
c401cc |
virBufferAddLit(buf, "/>\n");
|
|
|
c401cc |
@@ -14539,25 +14535,21 @@ virDomainDiskSourceDefFormatInternal(virBufferPtr buf,
|
|
|
c401cc |
virBufferAddLit(buf, ">\n");
|
|
|
c401cc |
for (n = 0; n < nhosts; n++) {
|
|
|
c401cc |
virBufferAddLit(buf, "
|
|
|
c401cc |
- if (hosts[n].name)
|
|
|
c401cc |
- virBufferEscapeString(buf, " name='%s'", hosts[n].name);
|
|
|
c401cc |
-
|
|
|
c401cc |
- if (hosts[n].port)
|
|
|
c401cc |
- virBufferEscapeString(buf, " port='%s'",
|
|
|
c401cc |
- hosts[n].port);
|
|
|
c401cc |
+ virBufferEscapeString(buf, " name='%s'", hosts[n].name);
|
|
|
c401cc |
+ virBufferEscapeString(buf, " port='%s'", hosts[n].port);
|
|
|
c401cc |
|
|
|
c401cc |
if (hosts[n].transport)
|
|
|
c401cc |
virBufferAsprintf(buf, " transport='%s'",
|
|
|
c401cc |
virDomainDiskProtocolTransportTypeToString(hosts[n].transport));
|
|
|
c401cc |
|
|
|
c401cc |
- if (hosts[n].socket)
|
|
|
c401cc |
- virBufferEscapeString(buf, " socket='%s'", hosts[n].socket);
|
|
|
c401cc |
+ virBufferEscapeString(buf, " socket='%s'", hosts[n].socket);
|
|
|
c401cc |
|
|
|
c401cc |
virBufferAddLit(buf, "/>\n");
|
|
|
c401cc |
}
|
|
|
c401cc |
virBufferAddLit(buf, " </source>\n");
|
|
|
c401cc |
}
|
|
|
c401cc |
break;
|
|
|
c401cc |
+
|
|
|
c401cc |
case VIR_DOMAIN_DISK_TYPE_VOLUME:
|
|
|
c401cc |
virBufferAddLit(buf, "
|
|
|
c401cc |
|
|
|
c401cc |
@@ -14568,8 +14560,7 @@ virDomainDiskSourceDefFormatInternal(virBufferPtr buf,
|
|
|
c401cc |
virBufferAsprintf(buf, " mode='%s'",
|
|
|
c401cc |
virDomainDiskSourcePoolModeTypeToString(srcpool->mode));
|
|
|
c401cc |
}
|
|
|
c401cc |
- if (startupPolicy)
|
|
|
c401cc |
- virBufferEscapeString(buf, " startupPolicy='%s'", startupPolicy);
|
|
|
c401cc |
+ virBufferEscapeString(buf, " startupPolicy='%s'", startupPolicy);
|
|
|
c401cc |
|
|
|
c401cc |
if (nseclabels) {
|
|
|
c401cc |
virBufferAddLit(buf, ">\n");
|
|
|
c401cc |
@@ -14583,6 +14574,7 @@ virDomainDiskSourceDefFormatInternal(virBufferPtr buf,
|
|
|
c401cc |
virBufferAddLit(buf, "/>\n");
|
|
|
c401cc |
}
|
|
|
c401cc |
break;
|
|
|
c401cc |
+
|
|
|
c401cc |
default:
|
|
|
c401cc |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c401cc |
_("unexpected disk type %s"),
|
|
|
c401cc |
--
|
|
|
c401cc |
1.9.0
|
|
|
c401cc |
|