[libvirt] [PATCH v2] Generate unique socket file

Martin Kletzander mkletzan at redhat.com
Tue Jul 25 20:28:28 UTC 2017


On Tue, Jul 25, 2017 at 09:33:50AM -0500, Scott Garfinkle wrote:
>It's possible to have more than one unnamed virtio-serial unix channel.
>We need to generate a unique name for each channel. Currently, we use
>".../unknown.sock" for all of them. Better practice would be to specify
>an explicit target path name; however, in the absence of that, we need
>uniqueness in the names we generate internally.
>
>Before the changes we'd get /var/lib/libvirt/qemu/channel/target/unknown.sock
>for each instance of
>    <channel type='unix'>
>        <source mode='bind'/>
>        <target type='virtio'/>
>    </channel>
>
>Now, we get vioser-00-00-01.sock, vioser-00-00-02.sock, etc.
>
>Changes from v1: new socket name
>
>Signed-off-by: Scott Garfinkle <seg at us.ibm.com>
>
>---
> src/qemu/qemu_domain.c                             | 24 +++++++++++++++-------
> .../qemuxml2argv-channel-virtio-unix.args          |  2 +-
> 2 files changed, 18 insertions(+), 8 deletions(-)
>
>diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
>index 78e75f1..7a9958d 100644
>--- a/src/qemu/qemu_domain.c
>+++ b/src/qemu/qemu_domain.c
>@@ -7178,18 +7178,28 @@ int
> qemuDomainPrepareChannel(virDomainChrDefPtr channel,
>                          const char *domainChannelTargetDir)
> {
>-    if (channel->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO &&
>-        channel->source->type == VIR_DOMAIN_CHR_TYPE_UNIX &&
>-        !channel->source->data.nix.path) {
>+    if (channel->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO ||
>+        channel->source->type != VIR_DOMAIN_CHR_TYPE_UNIX ||
>+        channel->source->data.nix.path)
>+            return 0;
>+

Apart from the indentation right here, it looks fine.  I'll fix this up
and push it in a while.

Reviewed-by: Martin Kletzander <mkletzan at redhat.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170725/dc2fd500/attachment-0001.sig>


More information about the libvir-list mailing list