]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: set default name for SPICE agent channel when generating command
authorLaine Stump <laine@laine.org>
Fri, 30 Mar 2012 07:16:23 +0000 (03:16 -0400)
committerLaine Stump <laine@laine.org>
Fri, 30 Mar 2012 16:37:52 +0000 (12:37 -0400)
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

index 3d2bb6bd1077de6e2a84f0639ba8aef80265f252..a6a7b063d36c5bcfbb942a5272c20de28597432e 100644 (file)
@@ -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);