|
|
404507 |
From 10d833e6bb2798e23beb01ac50d6588bec15b8ad Mon Sep 17 00:00:00 2001
|
|
|
404507 |
Message-Id: <10d833e6bb2798e23beb01ac50d6588bec15b8ad@dist-git>
|
|
|
404507 |
From: Andrea Bolognani <abologna@redhat.com>
|
|
|
404507 |
Date: Wed, 29 Nov 2017 16:23:00 +0100
|
|
|
404507 |
Subject: [PATCH] conf: Introduce virDomainChrTargetDefFormat()
|
|
|
404507 |
|
|
|
404507 |
Move formatting of the <target/> element for char devices out of
|
|
|
404507 |
virDomainChrDefFormat() and into its own function.
|
|
|
404507 |
|
|
|
404507 |
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
|
|
|
404507 |
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
404507 |
(cherry picked from commit 00b7f81fa8f4e32a722ee2ccbb1862f03be062c0)
|
|
|
404507 |
|
|
|
404507 |
https://bugzilla.redhat.com/show_bug.cgi?id=1449265
|
|
|
404507 |
https://bugzilla.redhat.com/show_bug.cgi?id=1511421
|
|
|
404507 |
https://bugzilla.redhat.com/show_bug.cgi?id=1512929
|
|
|
404507 |
https://bugzilla.redhat.com/show_bug.cgi?id=1512934
|
|
|
404507 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
404507 |
---
|
|
|
404507 |
src/conf/domain_conf.c | 67 ++++++++++++++++++++++++++++++--------------------
|
|
|
404507 |
1 file changed, 40 insertions(+), 27 deletions(-)
|
|
|
404507 |
|
|
|
404507 |
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
|
|
404507 |
index 586a840672..d68a5f415c 100644
|
|
|
404507 |
--- a/src/conf/domain_conf.c
|
|
|
404507 |
+++ b/src/conf/domain_conf.c
|
|
|
404507 |
@@ -23936,38 +23936,15 @@ virDomainChrSourceDefFormat(virBufferPtr buf,
|
|
|
404507 |
return -1;
|
|
|
404507 |
}
|
|
|
404507 |
|
|
|
404507 |
+
|
|
|
404507 |
static int
|
|
|
404507 |
-virDomainChrDefFormat(virBufferPtr buf,
|
|
|
404507 |
- virDomainChrDefPtr def,
|
|
|
404507 |
- unsigned int flags)
|
|
|
404507 |
+virDomainChrTargetDefFormat(virBufferPtr buf,
|
|
|
404507 |
+ const virDomainChrDef *def,
|
|
|
404507 |
+ unsigned int flags)
|
|
|
404507 |
{
|
|
|
404507 |
- const char *elementName = virDomainChrDeviceTypeToString(def->deviceType);
|
|
|
404507 |
const char *targetType = virDomainChrTargetTypeToString(def->deviceType,
|
|
|
404507 |
def->targetType);
|
|
|
404507 |
- bool tty_compat;
|
|
|
404507 |
|
|
|
404507 |
- int ret = 0;
|
|
|
404507 |
-
|
|
|
404507 |
- if (!elementName) {
|
|
|
404507 |
- virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
404507 |
- _("unexpected char device type %d"),
|
|
|
404507 |
- def->deviceType);
|
|
|
404507 |
- return -1;
|
|
|
404507 |
- }
|
|
|
404507 |
-
|
|
|
404507 |
- virBufferAsprintf(buf, "<%s", elementName);
|
|
|
404507 |
- virBufferAdjustIndent(buf, 2);
|
|
|
404507 |
- tty_compat = (def->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
|
|
|
404507 |
- def->target.port == 0 &&
|
|
|
404507 |
- def->source->type == VIR_DOMAIN_CHR_TYPE_PTY &&
|
|
|
404507 |
- !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) &&
|
|
|
404507 |
- def->source->data.file.path);
|
|
|
404507 |
- if (virDomainChrAttrsDefFormat(buf, def->source, tty_compat) < 0)
|
|
|
404507 |
- return -1;
|
|
|
404507 |
- virBufferAddLit(buf, ">\n");
|
|
|
404507 |
- virDomainChrSourceDefFormat(buf, def->source, flags);
|
|
|
404507 |
-
|
|
|
404507 |
- /* Format <target> block */
|
|
|
404507 |
switch (def->deviceType) {
|
|
|
404507 |
case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: {
|
|
|
404507 |
if (!targetType) {
|
|
|
404507 |
@@ -24039,6 +24016,42 @@ virDomainChrDefFormat(virBufferPtr buf,
|
|
|
404507 |
break;
|
|
|
404507 |
}
|
|
|
404507 |
|
|
|
404507 |
+ return 0;
|
|
|
404507 |
+}
|
|
|
404507 |
+
|
|
|
404507 |
+
|
|
|
404507 |
+static int
|
|
|
404507 |
+virDomainChrDefFormat(virBufferPtr buf,
|
|
|
404507 |
+ virDomainChrDefPtr def,
|
|
|
404507 |
+ unsigned int flags)
|
|
|
404507 |
+{
|
|
|
404507 |
+ const char *elementName = virDomainChrDeviceTypeToString(def->deviceType);
|
|
|
404507 |
+ bool tty_compat;
|
|
|
404507 |
+
|
|
|
404507 |
+ int ret = 0;
|
|
|
404507 |
+
|
|
|
404507 |
+ if (!elementName) {
|
|
|
404507 |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
404507 |
+ _("unexpected char device type %d"),
|
|
|
404507 |
+ def->deviceType);
|
|
|
404507 |
+ return -1;
|
|
|
404507 |
+ }
|
|
|
404507 |
+
|
|
|
404507 |
+ virBufferAsprintf(buf, "<%s", elementName);
|
|
|
404507 |
+ virBufferAdjustIndent(buf, 2);
|
|
|
404507 |
+ tty_compat = (def->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
|
|
|
404507 |
+ def->target.port == 0 &&
|
|
|
404507 |
+ def->source->type == VIR_DOMAIN_CHR_TYPE_PTY &&
|
|
|
404507 |
+ !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) &&
|
|
|
404507 |
+ def->source->data.file.path);
|
|
|
404507 |
+ if (virDomainChrAttrsDefFormat(buf, def->source, tty_compat) < 0)
|
|
|
404507 |
+ return -1;
|
|
|
404507 |
+ virBufferAddLit(buf, ">\n");
|
|
|
404507 |
+ virDomainChrSourceDefFormat(buf, def->source, flags);
|
|
|
404507 |
+
|
|
|
404507 |
+ if (virDomainChrTargetDefFormat(buf, def, flags) < 0)
|
|
|
404507 |
+ return -1;
|
|
|
404507 |
+
|
|
|
404507 |
virDomainDeviceInfoFormat(buf, &def->info, flags);
|
|
|
404507 |
|
|
|
404507 |
virBufferAdjustIndent(buf, -2);
|
|
|
404507 |
--
|
|
|
404507 |
2.15.1
|
|
|
404507 |
|