mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
conf: Introduce virDomainChrTargetDefFormat()
Move formatting of the <target/> element for char devices out of virDomainChrDefFormat() and into its own function. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
4fb8ff9987
commit
00b7f81fa8
@ -23945,38 +23945,15 @@ virDomainChrSourceDefFormat(virBufferPtr buf,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virDomainChrDefFormat(virBufferPtr buf,
|
virDomainChrTargetDefFormat(virBufferPtr buf,
|
||||||
virDomainChrDefPtr def,
|
const virDomainChrDef *def,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
const char *elementName = virDomainChrDeviceTypeToString(def->deviceType);
|
|
||||||
const char *targetType = virDomainChrTargetTypeToString(def->deviceType,
|
const char *targetType = virDomainChrTargetTypeToString(def->deviceType,
|
||||||
def->targetType);
|
def->targetType);
|
||||||
bool tty_compat;
|
|
||||||
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
if (!elementName) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("unexpected char device type %d"),
|
|
||||||
def->deviceType);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
virBufferAsprintf(buf, "<%s", elementName);
|
|
||||||
virBufferAdjustIndent(buf, 2);
|
|
||||||
tty_compat = (def->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
|
|
||||||
def->target.port == 0 &&
|
|
||||||
def->source->type == VIR_DOMAIN_CHR_TYPE_PTY &&
|
|
||||||
!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) &&
|
|
||||||
def->source->data.file.path);
|
|
||||||
if (virDomainChrAttrsDefFormat(buf, def->source, tty_compat) < 0)
|
|
||||||
return -1;
|
|
||||||
virBufferAddLit(buf, ">\n");
|
|
||||||
virDomainChrSourceDefFormat(buf, def->source, flags);
|
|
||||||
|
|
||||||
/* Format <target> block */
|
|
||||||
switch (def->deviceType) {
|
switch (def->deviceType) {
|
||||||
case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: {
|
case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: {
|
||||||
if (!targetType) {
|
if (!targetType) {
|
||||||
@ -24048,6 +24025,42 @@ virDomainChrDefFormat(virBufferPtr buf,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
virDomainChrDefFormat(virBufferPtr buf,
|
||||||
|
virDomainChrDefPtr def,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
const char *elementName = virDomainChrDeviceTypeToString(def->deviceType);
|
||||||
|
bool tty_compat;
|
||||||
|
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
if (!elementName) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("unexpected char device type %d"),
|
||||||
|
def->deviceType);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
virBufferAsprintf(buf, "<%s", elementName);
|
||||||
|
virBufferAdjustIndent(buf, 2);
|
||||||
|
tty_compat = (def->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
|
||||||
|
def->target.port == 0 &&
|
||||||
|
def->source->type == VIR_DOMAIN_CHR_TYPE_PTY &&
|
||||||
|
!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) &&
|
||||||
|
def->source->data.file.path);
|
||||||
|
if (virDomainChrAttrsDefFormat(buf, def->source, tty_compat) < 0)
|
||||||
|
return -1;
|
||||||
|
virBufferAddLit(buf, ">\n");
|
||||||
|
virDomainChrSourceDefFormat(buf, def->source, flags);
|
||||||
|
|
||||||
|
if (virDomainChrTargetDefFormat(buf, def, flags) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
virDomainDeviceInfoFormat(buf, &def->info, flags);
|
virDomainDeviceInfoFormat(buf, &def->info, flags);
|
||||||
|
|
||||||
virBufferAdjustIndent(buf, -2);
|
virBufferAdjustIndent(buf, -2);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user