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