|
|
c401cc |
From 33fb1d6dc316343067768c9e7d0720c4ebf5733b Mon Sep 17 00:00:00 2001
|
|
|
c401cc |
Message-Id: <33fb1d6dc316343067768c9e7d0720c4ebf5733b@dist-git>
|
|
|
c401cc |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
c401cc |
Date: Wed, 26 Feb 2014 14:54:45 +0100
|
|
|
c401cc |
Subject: [PATCH] conf: Split out seclabel formating code for disk source
|
|
|
c401cc |
|
|
|
c401cc |
https://bugzilla.redhat.com/show_bug.cgi?id=1032370
|
|
|
c401cc |
|
|
|
c401cc |
The code is common for all the various disk types. Split it out to a
|
|
|
c401cc |
common function.
|
|
|
c401cc |
|
|
|
c401cc |
(cherry picked from commit 30f7ca67d96d448411c1a92749bbe9f9bf4c167f)
|
|
|
c401cc |
|
|
|
c401cc |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c401cc |
---
|
|
|
c401cc |
src/conf/domain_conf.c | 62 ++++++++++++++++++++++++--------------------------
|
|
|
c401cc |
1 file changed, 30 insertions(+), 32 deletions(-)
|
|
|
c401cc |
|
|
|
c401cc |
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
|
|
c401cc |
index bba6201..e4e3f6b 100644
|
|
|
c401cc |
--- a/src/conf/domain_conf.c
|
|
|
c401cc |
+++ b/src/conf/domain_conf.c
|
|
|
c401cc |
@@ -14462,6 +14462,32 @@ virDomainDiskBlockIoDefFormat(virBufferPtr buf,
|
|
|
c401cc |
}
|
|
|
c401cc |
}
|
|
|
c401cc |
|
|
|
c401cc |
+
|
|
|
c401cc |
+/* virDomainDiskSourceDefFormatSeclabel:
|
|
|
c401cc |
+ *
|
|
|
c401cc |
+ * This function automaticaly closes the <source> element and formats any
|
|
|
c401cc |
+ * possible seclabels.
|
|
|
c401cc |
+ */
|
|
|
c401cc |
+static void
|
|
|
c401cc |
+virDomainDiskSourceDefFormatSeclabel(virBufferPtr buf,
|
|
|
c401cc |
+ size_t nseclabels,
|
|
|
c401cc |
+ virSecurityDeviceLabelDefPtr *seclabels,
|
|
|
c401cc |
+ unsigned int flags)
|
|
|
c401cc |
+{
|
|
|
c401cc |
+ size_t n;
|
|
|
c401cc |
+
|
|
|
c401cc |
+ if (nseclabels) {
|
|
|
c401cc |
+ virBufferAddLit(buf, ">\n");
|
|
|
c401cc |
+ virBufferAdjustIndent(buf, 8);
|
|
|
c401cc |
+ for (n = 0; n < nseclabels; n++)
|
|
|
c401cc |
+ virSecurityDeviceLabelDefFormat(buf, seclabels[n], flags);
|
|
|
c401cc |
+ virBufferAdjustIndent(buf, -8);
|
|
|
c401cc |
+ virBufferAddLit(buf, " </source>\n");
|
|
|
c401cc |
+ } else {
|
|
|
c401cc |
+ virBufferAddLit(buf, "/>\n");
|
|
|
c401cc |
+ }
|
|
|
c401cc |
+}
|
|
|
c401cc |
+
|
|
|
c401cc |
static int
|
|
|
c401cc |
virDomainDiskSourceDefFormatInternal(virBufferPtr buf,
|
|
|
c401cc |
int type,
|
|
|
c401cc |
@@ -14488,33 +14514,15 @@ virDomainDiskSourceDefFormatInternal(virBufferPtr buf,
|
|
|
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], flags);
|
|
|
c401cc |
- virBufferAdjustIndent(buf, -8);
|
|
|
c401cc |
- virBufferAddLit(buf, " </source>\n");
|
|
|
c401cc |
- } else {
|
|
|
c401cc |
- virBufferAddLit(buf, "/>\n");
|
|
|
c401cc |
- }
|
|
|
c401cc |
- break;
|
|
|
c401cc |
+ virDomainDiskSourceDefFormatSeclabel(buf, nseclabels, seclabels, flags);
|
|
|
c401cc |
+ break;
|
|
|
c401cc |
|
|
|
c401cc |
case VIR_DOMAIN_DISK_TYPE_BLOCK:
|
|
|
c401cc |
virBufferAddLit(buf, "
|
|
|
c401cc |
virBufferEscapeString(buf, " dev='%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], flags);
|
|
|
c401cc |
- virBufferAdjustIndent(buf, -8);
|
|
|
c401cc |
- virBufferAddLit(buf, " </source>\n");
|
|
|
c401cc |
- } else {
|
|
|
c401cc |
- virBufferAddLit(buf, "/>\n");
|
|
|
c401cc |
- }
|
|
|
c401cc |
+ virDomainDiskSourceDefFormatSeclabel(buf, nseclabels, seclabels, flags);
|
|
|
c401cc |
break;
|
|
|
c401cc |
|
|
|
c401cc |
case VIR_DOMAIN_DISK_TYPE_DIR:
|
|
|
c401cc |
@@ -14562,17 +14570,7 @@ virDomainDiskSourceDefFormatInternal(virBufferPtr buf,
|
|
|
c401cc |
}
|
|
|
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 |
- virBufferAdjustIndent(buf, -8);
|
|
|
c401cc |
- virBufferAddLit(buf, " </source>\n");
|
|
|
c401cc |
- } else {
|
|
|
c401cc |
- virBufferAddLit(buf, "/>\n");
|
|
|
c401cc |
- }
|
|
|
c401cc |
+ virDomainDiskSourceDefFormatSeclabel(buf, nseclabels, seclabels, flags);
|
|
|
c401cc |
break;
|
|
|
c401cc |
|
|
|
c401cc |
default:
|
|
|
c401cc |
--
|
|
|
c401cc |
1.9.0
|
|
|
c401cc |
|