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;
+
+ if (channel->target.name) {
if (virAsprintf(&channel->source->data.nix.path,
"%s/%s", domainChannelTargetDir,
- channel->target.name ? channel->target.name
- : "unknown.sock") < 0)
+ channel->target.name) < 0)
+ return -1;
+ } else { // Generate a unique name
+ if (virAsprintf(&channel->source->data.nix.path,
+ "%s/vioser-%02d-%02d-%02d.sock",
+ domainChannelTargetDir,
+ channel->info.addr.vioserial.controller,
+ channel->info.addr.vioserial.bus,
+ channel->info.addr.vioserial.port) < 0)
return -1;
-
- channel->source->data.nix.listen = true;
}
+ channel->source->data.nix.listen = true;
+
return 0;
}
-device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,\
id=channel0,name=org.qemu.guest_agent.0 \
-chardev socket,id=charchannel1,\
-path=/tmp/channel/domain--1-QEMUGuest1/unknown.sock,server,nowait \
+path=/tmp/channel/domain--1-QEMUGuest1/vioser-00-00-02.sock,server,nowait \
-device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,\
id=channel1 \
-chardev socket,id=charchannel2,path=/tmp/channel/domain--1-QEMUGuest1/ble,\