From 3269ee657c8f02b00518a8316401a6ea34c77dc3 Mon Sep 17 00:00:00 2001 From: Laine Stump Date: Fri, 30 Mar 2012 03:16:23 -0400 Subject: [PATCH] qemu: set default name for SPICE agent channel when generating command commit b0e2bb33 set a default value for the SPICE agent channel by inserting it during parsing of the channel XML. That method of setting a default is problematic because it makes a format/parse roundtrip unclean, and experience with setting other values as a side effect of parsing has led to headaches (e.g. automatically setting a MAC address in the parser when one isn't specified in the input XML). This patch does not revert commit b0e2bb33 (it will be reverted in a separate patch) but adds the alternate implementation of simply inserting the default value in the appropriate place on the qemu commandline when no value is provided. --- src/qemu/qemu_command.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3d2bb6bd10..a6a7b063d3 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3444,8 +3444,7 @@ qemuBuildVirtioSerialPortDevStr(virDomainChrDefPtr dev, if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL && dev->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC && - dev->target.name && - STRNEQ(dev->target.name, "com.redhat.spice.0")) { + STRNEQ_NULLABLE(dev->target.name, "com.redhat.spice.0")) { qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported spicevmc target name '%s'"), dev->target.name); @@ -3457,9 +3456,9 @@ qemuBuildVirtioSerialPortDevStr(virDomainChrDefPtr dev, qemuCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPICEVMC))) { virBufferAsprintf(&buf, ",chardev=char%s,id=%s", dev->info.alias, dev->info.alias); - if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL && - dev->target.name) { - virBufferAsprintf(&buf, ",name=%s", dev->target.name); + if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL) { + virBufferAsprintf(&buf, ",name=%s", dev->target.name + ? dev->target.name : "com.redhat.spice.0"); } } else { virBufferAsprintf(&buf, ",id=%s", dev->info.alias);