* output at " type='type'>". */
static int
virDomainChrSourceDefFormat(virBufferPtr buf,
+ virDomainChrDefPtr chr_def,
virDomainChrSourceDefPtr def,
bool tty_compat,
unsigned int flags)
{
const char *type = virDomainChrTypeToString(def->type);
+ size_t nseclabels = 0;
+ virSecurityDeviceLabelDefPtr *seclabels = NULL;
+
+ if (chr_def) {
+ nseclabels = chr_def->nseclabels;
+ seclabels = chr_def->seclabels;
+ }
if (!type) {
virReportError(VIR_ERR_INTERNAL_ERROR,
if (def->type != VIR_DOMAIN_CHR_TYPE_PTY ||
(def->data.file.path &&
!(flags & VIR_DOMAIN_XML_INACTIVE))) {
- virBufferEscapeString(buf, "<source path='%s'/>\n",
+ virBufferEscapeString(buf, "<source path='%s'",
def->data.file.path);
+ virDomainSourceDefFormatSeclabel(buf, nseclabels, seclabels, flags);
}
break;
virBufferAsprintf(buf, "<source mode='%s'",
def->data.nix.listen ? "bind" : "connect");
virBufferEscapeString(buf, " path='%s'", def->data.nix.path);
- virBufferAddLit(buf, "/>\n");
+ virDomainSourceDefFormatSeclabel(buf, nseclabels, seclabels, flags);
break;
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
const char *targetType = virDomainChrTargetTypeToString(def->deviceType,
def->targetType);
bool tty_compat;
- size_t n;
int ret = 0;
def->source.type == VIR_DOMAIN_CHR_TYPE_PTY &&
!(flags & VIR_DOMAIN_XML_INACTIVE) &&
def->source.data.file.path);
- if (virDomainChrSourceDefFormat(buf, &def->source, tty_compat, flags) < 0)
+ if (virDomainChrSourceDefFormat(buf, def, &def->source, tty_compat, flags) < 0)
return -1;
/* Format <target> block */
return -1;
}
- /* Security label overrides, if any. */
- if (def->seclabels && def->nseclabels > 0) {
- virBufferAdjustIndent(buf, 2);
- for (n = 0; n < def->nseclabels; n++)
- virSecurityDeviceLabelDefFormat(buf, def->seclabels[n], flags);
- virBufferAdjustIndent(buf, -2);
- }
-
virBufferAdjustIndent(buf, -2);
virBufferAsprintf(buf, "</%s>\n", elementName);
break;
case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH:
- if (virDomainChrSourceDefFormat(buf, &def->data.passthru, false,
+ if (virDomainChrSourceDefFormat(buf, NULL, &def->data.passthru, false,
flags) < 0)
return -1;
break;
case VIR_DOMAIN_RNG_BACKEND_EGD:
virBufferAdjustIndent(buf, 2);
- if (virDomainChrSourceDefFormat(buf, def->source.chardev,
+ if (virDomainChrSourceDefFormat(buf, NULL, def->source.chardev,
false, flags) < 0)
return -1;
virBufferAdjustIndent(buf, -2);
virBufferAsprintf(buf, "<redirdev bus='%s'", bus);
virBufferAdjustIndent(buf, 2);
- if (virDomainChrSourceDefFormat(buf, &def->source.chr, false, flags) < 0)
+ if (virDomainChrSourceDefFormat(buf, NULL, &def->source.chr, false, flags) < 0)
return -1;
if (virDomainDeviceInfoFormat(buf, &def->info,
flags | VIR_DOMAIN_XML_INTERNAL_ALLOW_BOOT) < 0)
--- /dev/null
+<domain type='qemu'>
+ <name>machine</name>
+ <uuid>2187c512-ff97-47d7-b67c-c02d3bdc219d</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <serial type='file'>
+ <source path='/tmp/serial.file'>
+ <seclabel model='dac' relabel='no'/>
+ </source>
+ <target port='0'/>
+ </serial>
+ <serial type='unix'>
+ <source mode='connect' path='/tmp/serial.sock'>
+ <seclabel model='dac' relabel='no'/>
+ </source>
+ <target port='1'/>
+ </serial>
+ <console type='file'>
+ <source path='/tmp/serial.file'>
+ <seclabel model='dac' relabel='no'/>
+ </source>
+ <target type='serial' port='0'/>
+ </console>
+ <memballoon model='virtio'/>
+ <rng model='virtio'>
+ <backend model='egd' type='pipe'>
+ <source path='/dev/null'/>
+ </backend>
+ </rng>
+ </devices>
+</domain>