From nobody Sat Apr 27 15:58:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1678352364; cv=none; d=zohomail.com; s=zohoarc; b=Ww+Pnb7/FZZLXK+AkRKr/EXwrXXXGHCRSxBB8VQD1WAXSZV7fiFpAD0xxJ/Kjy4mhDNrJkElGqcP2x9Iu/5q3zPeQJMVgCWC33hvzTMvW6Gr3PyPois8XtqEp29uhhN568ddGvh7skZ/dfA1fBJSCsjr/sOLaCngs4eQEkFxL3s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678352364; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=su8ESxdC4e8+z1QAlKtx2eX2yZYPRPsMJHGez4YeSkQ=; b=fEN+C75Mk8huRATnWZq5kdACyJp5yeBqWQQV1qepJmyvUdhrHRP6YPHyRqoKjSi8gJo1VRT+dEAe7CiSfK16GunvidryOAZ891oTw/vHk+Pdqa9QZ6YF7FShfLxO9Y2ZV5KTxbc2J0MPvtSYq0T0GGtSRea8yzqr8hWk0QuEAX8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1678352364297532.9544344092723; Thu, 9 Mar 2023 00:59:24 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-647-vrsVJcvIP2mZa87eveaSSw-1; Thu, 09 Mar 2023 03:59:15 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3E2F38027FD; Thu, 9 Mar 2023 08:59:13 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC3F4492C3E; Thu, 9 Mar 2023 08:59:09 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 708371946A44; Thu, 9 Mar 2023 08:59:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9941919465B5 for ; Thu, 9 Mar 2023 08:59:08 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7DCB72026D68; Thu, 9 Mar 2023 08:59:08 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast07.extmail.prod.ext.rdu2.redhat.com [10.11.55.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 755E72026D4B for ; Thu, 9 Mar 2023 08:59:08 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 524AF3C0F19B for ; Thu, 9 Mar 2023 08:59:08 +0000 (UTC) Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-256-4bx1i7_cOtuo4QK5v3pIfA-1; Thu, 09 Mar 2023 03:59:04 -0500 Received: by mail-pl1-f180.google.com with SMTP id p20so1240855plw.13; Thu, 09 Mar 2023 00:59:04 -0800 (PST) Received: from localhost.localdomain (ec2-18-163-41-22.ap-east-1.compute.amazonaws.com. [18.163.41.22]) by smtp.gmail.com with ESMTPSA id y15-20020a17090322cf00b0019abd4ddbf2sm11075234plg.179.2023.03.09.00.59.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Mar 2023 00:59:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678352362; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=su8ESxdC4e8+z1QAlKtx2eX2yZYPRPsMJHGez4YeSkQ=; b=FJQ5O2LKccb/c9AEdGj81SsZKjO9RcQ1c6tWkV3RSAZLcqcaDVNKJeKdOWe3SzHjqHaSPN 82gkttR6cwk4x5YUgfgGwN6u+QipCoO3uCJfgUxCUNY5YicPeYtNz5OEv+tzjlUEawfJ2I FoVE4MY+v9GLM/17vXZ1SP1so8I7z4A= X-MC-Unique: vrsVJcvIP2mZa87eveaSSw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 4bx1i7_cOtuo4QK5v3pIfA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678352343; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=su8ESxdC4e8+z1QAlKtx2eX2yZYPRPsMJHGez4YeSkQ=; b=lkjObRly9mwP1tgxVMaMnhKMDjASAEm24UlJ7FAWsIH1AnVuRIDCw79pz6TqsGMeea oTM8lMHoPDdZk/HBzmRBuhFLJc3833Lie2v5FE5jbl6zgyZM2mzgmuw9MnG28z6uhFU+ KwHnVP+PVd2XmRFh69AmVldB3yeKAewT2IpgbkYa7o/tdL6r2/blFqyXdxYXUC4U3J0V 1dbMdi6KAPHbLNMItCx+n58R+HnxfgQhaifod0RLNhrHIWcdBQsAKWl/VXiraDzfZgh2 PTwL+MftEkGFfBdQsAPqAIMLbfJAXMpaGeYM8f8FlP+Wo0fJ6Mc/EaGYz6bn8TYupNRZ 8cWQ== X-Gm-Message-State: AO0yUKXdUUzbjX14QAa/DtbDXAVTT1VTmU4aii70yEGTly13ITGEeLG2 ARklLyOX1yeP9RxK8AyYu63S8lNqsQ9synhU X-Google-Smtp-Source: AK7set+MziUmlGsNJ3ZdEQBFJ38zejyozY6iRIB+4P4kBhoKjkuwyA1q/oRvV8IVmjtOtSYAj/s5GQ== X-Received: by 2002:a17:902:e84f:b0:19a:8ce1:2c55 with SMTP id t15-20020a170902e84f00b0019a8ce12c55mr24616948plg.8.1678352343172; Thu, 09 Mar 2023 00:59:03 -0800 (PST) From: Zhenguo Yao To: libvir-list@redhat.com, jjongsma@redhat.com Subject: [PATCH] qemu: Add vhost-user-blk unix socket to support server mode Date: Thu, 9 Mar 2023 16:58:07 +0800 Message-Id: <20230309085807.70848-1-yaozhenguo1@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhenguo Yao , yaozhenguo@jd.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678352366321100001 Content-Type: text/plain; charset="utf-8"; x-default="true" qemu support server mode when using vhost-user-blk disk. Let libvirt to support this. Signed-off-by: Zhenguo Yao --- src/conf/domain_conf.c | 14 ++++++++++++++ src/conf/schemas/domaincommon.rng | 8 ++++++++ .../disk-vhostuser-numa.x86_64-4.2.0.args | 6 ++++-- .../disk-vhostuser-numa.x86_64-latest.args | 6 ++++-- tests/qemuxml2argvdata/disk-vhostuser-numa.xml | 9 +++++++-- .../disk-vhostuser.x86_64-latest.args | 6 ++++-- tests/qemuxml2argvdata/disk-vhostuser.xml | 9 +++++++-- .../disk-vhostuser.x86_64-latest.xml | 12 +++++++++--- 8 files changed, 57 insertions(+), 13 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a5578324b9..61addbe222 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7283,6 +7283,7 @@ virDomainDiskSourceVHostUserParse(xmlNodePtr node, { g_autofree char *type =3D virXMLPropString(node, "type"); g_autofree char *path =3D virXMLPropString(node, "path"); + g_autofree char *mode =3D virXMLPropString(node, "mode"); =20 if (!type) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -7313,6 +7314,17 @@ virDomainDiskSourceVHostUserParse(xmlNodePtr node, ctxt) < 0) { return -1; } + if (mode && STREQ(mode, "server")) { + src->vhostuser->data.nix.listen =3D true; + if (src->vhostuser->data.nix.reconnect.enabled =3D=3D VIR_TRISTATE= _BOOL_YES) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'reconnect' attribute unsupported " + "'server' mode for ``")); + return -1; + } + } else if (mode && STREQ(mode, "client")) { + src->vhostuser->data.nix.listen =3D false; + } =20 return 0; } @@ -22121,6 +22133,8 @@ virDomainDiskSourceVhostuserFormat(virBuffer *attrB= uf, virBufferAddLit(attrBuf, " type=3D'unix'"); virBufferAsprintf(attrBuf, " path=3D'%s'", vhostuser->data.nix.path); =20 + if (vhostuser->data.nix.listen) + virBufferAsprintf(attrBuf, " mode=3D'%s'", "server"); virDomainChrSourceReconnectDefFormat(childBuf, &vhostuser->data.nix.re= connect); } =20 diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index a57dd212ab..d926195d69 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -2359,6 +2359,14 @@ + + + + server + client + + + diff --git a/tests/qemuxml2argvdata/disk-vhostuser-numa.x86_64-4.2.0.args b= /tests/qemuxml2argvdata/disk-vhostuser-numa.x86_64-4.2.0.args index 4480266e75..afd0be4ea5 100644 --- a/tests/qemuxml2argvdata/disk-vhostuser-numa.x86_64-4.2.0.args +++ b/tests/qemuxml2argvdata/disk-vhostuser-numa.x86_64-4.2.0.args @@ -31,9 +31,11 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ -device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ -chardev socket,id=3Dchr-vu-virtio-disk0,path=3D/tmp/vhost1.sock \ -device vhost-user-blk-pci,bus=3Dpci.0,addr=3D0x2,chardev=3Dchr-vu-virtio-= disk0,id=3Dvirtio-disk0,bootindex=3D1 \ --chardev socket,id=3Dchr-vu-virtio-disk1,path=3D/tmp/vhost1.sock,reconnect= =3D10 \ +-chardev socket,id=3Dchr-vu-virtio-disk1,path=3D/tmp/vhost1.sock,server=3D= on,wait=3Doff \ -device vhost-user-blk-pci,iommu_platform=3Don,ats=3Don,packed=3Don,bus=3D= pci.0,addr=3D0x3,chardev=3Dchr-vu-virtio-disk1,id=3Dvirtio-disk1 \ +-chardev socket,id=3Dchr-vu-virtio-disk2,path=3D/tmp/vhost1.sock,reconnect= =3D10 \ +-device vhost-user-blk-pci,iommu_platform=3Don,ats=3Don,packed=3Don,bus=3D= pci.0,addr=3D0x4,chardev=3Dchr-vu-virtio-disk2,id=3Dvirtio-disk2 \ -audiodev '{"id":"audio1","driver":"none"}' \ --device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x4 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x5 \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ -msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/disk-vhostuser-numa.x86_64-latest.args = b/tests/qemuxml2argvdata/disk-vhostuser-numa.x86_64-latest.args index 75b3232dad..ea4b227328 100644 --- a/tests/qemuxml2argvdata/disk-vhostuser-numa.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-vhostuser-numa.x86_64-latest.args @@ -31,9 +31,11 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ -chardev socket,id=3Dchr-vu-virtio-disk0,path=3D/tmp/vhost1.sock \ -device '{"driver":"vhost-user-blk-pci","bus":"pci.0","addr":"0x2","charde= v":"chr-vu-virtio-disk0","id":"virtio-disk0","bootindex":1}' \ --chardev socket,id=3Dchr-vu-virtio-disk1,path=3D/tmp/vhost1.sock,reconnect= =3D10 \ +-chardev socket,id=3Dchr-vu-virtio-disk1,path=3D/tmp/vhost1.sock,server=3D= on,wait=3Doff \ -device '{"driver":"vhost-user-blk-pci","iommu_platform":true,"ats":true,"= packed":true,"bus":"pci.0","addr":"0x3","chardev":"chr-vu-virtio-disk1","id= ":"virtio-disk1"}' \ +-chardev socket,id=3Dchr-vu-virtio-disk2,path=3D/tmp/vhost1.sock,reconnect= =3D10 \ +-device '{"driver":"vhost-user-blk-pci","iommu_platform":true,"ats":true,"= packed":true,"bus":"pci.0","addr":"0x4","chardev":"chr-vu-virtio-disk2","id= ":"virtio-disk2"}' \ -audiodev '{"id":"audio1","driver":"none"}' \ --device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x4"}' \ +-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x5"}' \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ -msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/disk-vhostuser-numa.xml b/tests/qemuxml= 2argvdata/disk-vhostuser-numa.xml index 49efbae0a2..1135b51b8a 100644 --- a/tests/qemuxml2argvdata/disk-vhostuser-numa.xml +++ b/tests/qemuxml2argvdata/disk-vhostuser-numa.xml @@ -23,10 +23,15 @@ - + + + + + + - + diff --git a/tests/qemuxml2argvdata/disk-vhostuser.x86_64-latest.args b/tes= ts/qemuxml2argvdata/disk-vhostuser.x86_64-latest.args index 31428fc697..4391776b88 100644 --- a/tests/qemuxml2argvdata/disk-vhostuser.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-vhostuser.x86_64-latest.args @@ -30,9 +30,11 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ -chardev socket,id=3Dchr-vu-virtio-disk0,path=3D/tmp/vhost1.sock \ -device '{"driver":"vhost-user-blk-pci","bus":"pci.0","addr":"0x2","charde= v":"chr-vu-virtio-disk0","id":"virtio-disk0","bootindex":1}' \ --chardev socket,id=3Dchr-vu-virtio-disk1,path=3D/tmp/vhost1.sock,reconnect= =3D10 \ +-chardev socket,id=3Dchr-vu-virtio-disk1,path=3D/tmp/vhost1.sock,server=3D= on,wait=3Doff \ -device '{"driver":"vhost-user-blk-pci","iommu_platform":true,"ats":true,"= packed":true,"bus":"pci.0","addr":"0x3","chardev":"chr-vu-virtio-disk1","id= ":"virtio-disk1"}' \ +-chardev socket,id=3Dchr-vu-virtio-disk2,path=3D/tmp/vhost1.sock,reconnect= =3D10 \ +-device '{"driver":"vhost-user-blk-pci","iommu_platform":true,"ats":true,"= packed":true,"bus":"pci.0","addr":"0x4","chardev":"chr-vu-virtio-disk2","id= ":"virtio-disk2"}' \ -audiodev '{"id":"audio1","driver":"none"}' \ --device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x4"}' \ +-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x5"}' \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ -msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/disk-vhostuser.xml b/tests/qemuxml2argv= data/disk-vhostuser.xml index a0a3df4dd0..33fc0b885e 100644 --- a/tests/qemuxml2argvdata/disk-vhostuser.xml +++ b/tests/qemuxml2argvdata/disk-vhostuser.xml @@ -21,10 +21,15 @@ - + + + + + + - + diff --git a/tests/qemuxml2xmloutdata/disk-vhostuser.x86_64-latest.xml b/te= sts/qemuxml2xmloutdata/disk-vhostuser.x86_64-latest.xml index c64621fe93..cd955570f3 100644 --- a/tests/qemuxml2xmloutdata/disk-vhostuser.x86_64-latest.xml +++ b/tests/qemuxml2xmloutdata/disk-vhostuser.x86_64-latest.xml @@ -27,13 +27,19 @@
+ + + + +
+ - -
+ +
@@ -43,7 +49,7 @@