From nobody Sun May 5 18:12:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1501005748517356.29743045418616; Tue, 25 Jul 2017 11:02:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A6B597EA83; Tue, 25 Jul 2017 18:02:25 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B546E6BF69; Tue, 25 Jul 2017 18:02:24 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7F1964BB79; Tue, 25 Jul 2017 18:02:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6PI2JWJ005131 for ; Tue, 25 Jul 2017 14:02:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id CCAE0619E5; Tue, 25 Jul 2017 18:02:19 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C4CC3619D7 for ; Tue, 25 Jul 2017 18:02:12 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B8AAA13A43 for ; Tue, 25 Jul 2017 18:02:07 +0000 (UTC) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6PEXx4g042456 for ; Tue, 25 Jul 2017 10:34:03 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bx4v9h4r8-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 25 Jul 2017 10:34:03 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 25 Jul 2017 08:34:02 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 25 Jul 2017 08:34:00 -0600 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6PEY0Pt64749734; Tue, 25 Jul 2017 07:34:00 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 580466A041; Tue, 25 Jul 2017 08:34:00 -0600 (MDT) Received: from kofr2.aus.stglabs.ibm.com (unknown [9.40.193.43]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP id 2DF8F6A03B; Tue, 25 Jul 2017 08:34:00 -0600 (MDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A6B597EA83 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=us.ibm.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A6B597EA83 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B8AAA13A43 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=us.ibm.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=seg@us.ibm.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B8AAA13A43 From: "Scott Garfinkle" To: libvir-list@redhat.com Date: Tue, 25 Jul 2017 09:33:50 -0500 X-TM-AS-GCONF: 00 x-cbid: 17072514-0012-0000-0000-000014BA9856 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007423; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00892709; UDB=6.00446223; IPR=6.00672873; BA=6.00005492; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016370; XFM=3.00000015; UTC=2017-07-25 14:34:01 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17072514-0013-0000-0000-00004EC2B8E9 Message-Id: <1500993230-41108-1-git-send-email-seg@us.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-25_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707250230 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 25 Jul 2017 18:02:09 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 25 Jul 2017 18:02:09 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'seg@us.ibm.com' RCPT:'' X-RedHat-Spam-Score: -3.501 (RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_PASS) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Scott Garfinkle Subject: [libvirt] [PATCH v2] Generate unique socket file X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 25 Jul 2017 18:02:27 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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.so= ck for each instance of 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 --- 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 =3D=3D VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRT= IO && - channel->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_UNIX && - !channel->source->data.nix.path) { + if (channel->targetType !=3D VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO= || + channel->source->type !=3D 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 =3D true; } =20 + channel->source->data.nix.listen =3D true; + return 0; } =20 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.args b= /tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.args index 2b72965..8e0452a 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.args @@ -29,7 +29,7 @@ path=3D/tmp/channel/domain--1-QEMUGuest1/org.qemu.guest_a= gent.0,server,nowait \ -device virtserialport,bus=3Dvirtio-serial0.0,nr=3D1,chardev=3Dcharchannel= 0,\ id=3Dchannel0,name=3Dorg.qemu.guest_agent.0 \ -chardev socket,id=3Dcharchannel1,\ -path=3D/tmp/channel/domain--1-QEMUGuest1/unknown.sock,server,nowait \ +path=3D/tmp/channel/domain--1-QEMUGuest1/vioser-00-00-02.sock,server,nowai= t \ -device virtserialport,bus=3Dvirtio-serial0.0,nr=3D2,chardev=3Dcharchannel= 1,\ id=3Dchannel1 \ -chardev socket,id=3Dcharchannel2,path=3D/tmp/channel/domain--1-QEMUGuest1= /ble,\ --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list