]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Don't bother user with libvirt-internal paths
authorMartin Kletzander <mkletzan@redhat.com>
Wed, 6 Jan 2016 16:35:04 +0000 (17:35 +0100)
committerMartin Kletzander <mkletzan@redhat.com>
Thu, 7 Jan 2016 10:29:53 +0000 (11:29 +0100)
If user defines a virtio channel with UNIX socket backend and doesn't
care about the path for the socket (e.g. qemu-agent channel), we still
generate it into the persistent XML.  Moreover when then user renames
the domain, due to its persistent socket path saved into the per-domain
directory, it will not start.  So let's forget about old generated paths
and also stop putting them into the persistent definition.

https://bugzilla.redhat.com/show_bug.cgi?id=1278068

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
src/qemu/qemu_command.c
src/qemu/qemu_domain.c
tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.args
tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.xml

index 66ca11152ad8e9fc91f7a56587a43908a3755502..1f0593526b55d792ee237c3a6d3e874cd85f7e21 100644 (file)
@@ -10510,6 +10510,23 @@ qemuBuildCommandLine(virConnectPtr conn,
                 goto error;
             }
 
+            /*
+             * TODO: Refactor so that we generate this (and onther
+             * things) somewhere else then where we are building the
+             * command line.
+             */
+            if (channel->source.type == VIR_DOMAIN_CHR_TYPE_UNIX &&
+                !channel->source.data.nix.path) {
+                if (virAsprintf(&channel->source.data.nix.path,
+                                "%s/domain-%s/%s",
+                                cfg->channelTargetDir, def->name,
+                                channel->target.name ? channel->target.name
+                                : "unknown.sock") < 0)
+                    goto error;
+
+                channel->source.data.nix.listen = true;
+            }
+
             if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPICEVMC) &&
                 channel->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) {
                 /* spicevmc was originally introduced via a -device
index bb8d47f9293dc6e2fe19118b74a0311ac3209653..73fc79dab56b58522510969e83c7d18fbd12dd4b 100644 (file)
@@ -1329,20 +1329,21 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
         ARCH_IS_S390(def->os.arch))
         dev->data.controller->model = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI;
 
-    /* auto generate unix socket path */
+    /* clear auto generated unix socket path */
     if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
         dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL &&
         dev->data.chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO &&
         dev->data.chr->source.type == VIR_DOMAIN_CHR_TYPE_UNIX &&
-        !dev->data.chr->source.data.nix.path) {
-        if (virAsprintf(&dev->data.chr->source.data.nix.path,
-                        "%s/domain-%s/%s",
-                        cfg->channelTargetDir, def->name,
-                        dev->data.chr->target.name ? dev->data.chr->target.name
-                        : "unknown.sock") < 0)
-            goto cleanup;
-
-        dev->data.chr->source.data.nix.listen = true;
+        dev->data.chr->source.data.nix.path &&
+        STRPREFIX(dev->data.chr->source.data.nix.path, cfg->channelTargetDir)) {
+        /*
+         * If the address is generated by us (starts with our
+         * channel dir), we should not keep it in the persistent
+         * XML.  If libvirt is the one who generated it, users
+         * shouldn't care about that.  If they do, they are
+         * supposed to set it themselves.
+         */
+        VIR_FREE(dev->data.chr->source.data.nix.path);
     }
 
     /* forbid capabilities mode hostdev in this kind of hypervisor */
index 94375b85df696da62fdd6d9d342e70a084a252d5..6a0b1f3736032a7a5ab2e1e4f00767c91e41f8f7 100644 (file)
@@ -33,4 +33,7 @@ nowait \
 id=channel1 \
 -chardev socket,id=charchannel2,path=/tmp/domain-QEMUGuest1/ble,server,nowait \
 -device virtserialport,bus=virtio-serial0.0,nr=3,chardev=charchannel2,\
-id=channel2,name=ble
+id=channel2,name=ble \
+-chardev socket,id=charchannel3,path=/tmp/domain-QEMUGuest1/fdsa,server,nowait \
+-device virtserialport,bus=virtio-serial0.0,nr=4,chardev=charchannel3,\
+id=channel3,name=fdsa
index 7fac943389bf7e67fe821ad31b4ad4e83029318e..405dff8389bfc0d2a3b3194a7e1514c8d2c5a326 100644 (file)
     <channel type='unix'>
       <target type='virtio' name='ble'/>
     </channel>
+    <channel type='unix'>
+      <source path='/tmp/domain-oldname/fdsa'/>
+      <target type='virtio' name='fdsa'/>
+    </channel>
     <memballoon model='none'/>
   </devices>
 </domain>