From nobody Mon Apr 29 17:39:11 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 1505994061782969.2326532334015; Thu, 21 Sep 2017 04:41:01 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3F03E81E0A; Thu, 21 Sep 2017 11:41:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6FB3D600C2; Thu, 21 Sep 2017 11:40:59 +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 AE2C01855943; Thu, 21 Sep 2017 11:40:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8LBet6t005307 for ; Thu, 21 Sep 2017 07:40:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id E51606376F; Thu, 21 Sep 2017 11:40:55 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DD5EA18006; Thu, 21 Sep 2017 11:40:53 +0000 (UTC) Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.217.80.70]) (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 BC8684A6F0; Thu, 21 Sep 2017 11:40:51 +0000 (UTC) Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id E2D6556859AB608E5ECA; Thu, 21 Sep 2017 19:40:49 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id v8LBeGGm054560; Thu, 21 Sep 2017 19:40:16 +0800 (GMT-8) (envelope-from lu.zhipeng@zte.com.cn) Received: from ceshi.localdomain ([10.74.120.130]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2017092119402205-3103856 ; Thu, 21 Sep 2017 19:40:22 +0800 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3F03E81E0A Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=zte.com.cn Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3F03E81E0A DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BC8684A6F0 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=zte.com.cn Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lu.zhipeng@zte.com.cn DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BC8684A6F0 From: ZhiPeng Lu To: libvir-list@redhat.com Date: Thu, 21 Sep 2017 19:39:55 +0800 Message-Id: <1505993995-23223-1-git-send-email-lu.zhipeng@zte.com.cn> X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-09-21 19:40:22, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2017-09-21 19:40:04, Serialize complete at 2017-09-21 19:40:04 X-MAIL: mse01.zte.com.cn v8LBeGGm054560 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 205 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 21 Sep 2017 11:40:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 21 Sep 2017 11:40:52 +0000 (UTC) for IP:'63.217.80.70' DOMAIN:'mxhk.zte.com.cn' HELO:'mxhk.zte.com.cn' FROM:'lu.zhipeng@zte.com.cn' RCPT:'' X-RedHat-Spam-Score: -2.302 (RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, SPF_PASS) 63.217.80.70 mxhk.zte.com.cn 63.217.80.70 mxhk.zte.com.cn X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, ZhiPeng Lu , phrdina@redhat.com Subject: [libvirt] [PATCH] vhost-user: add support reconnect for vhost-user ports 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 21 Sep 2017 11:41:00 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" For vhost-user ports, Open vSwitch acts as the server and QEMU the client. When OVS crashed or restart, QEMU shoule be reconnect to OVS. Signed-off-by: ZhiPeng Lu --- v1->v2: - modify xml format --- --- docs/schemas/domaincommon.rng | 12 ++++++++++ src/conf/domain_conf.c | 26 ++++++++++++++++++= ++++ .../qemuxml2argv-net-vhostuser-multiq.args | 4 ++-- .../qemuxml2argv-net-vhostuser-multiq.xml | 8 +++++-- 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 76852ab..bf015ca 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2388,6 +2388,18 @@ client + + + + + + + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index cc5e79b..d121a9e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -83,6 +83,13 @@ struct _virDomainXMLOption { /* Private data for save image stored in snapshot XML */ virSaveCookieCallbacks saveCookie; }; +static int +virDomainChrSourceReconnectDefParseXML(virDomainChrSourceReconnectDefPtr d= ef, + xmlNodePtr node, + xmlXPathContextPtr ctxt); +static void +virDomainChrSourceReconnectDefFormat(virBufferPtr buf, + virDomainChrSourceReconnectDefPtr def= ); =20 #define VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS \ (VIR_DOMAIN_DEF_FORMAT_SECURE | \ @@ -10245,6 +10252,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, virNWFilterHashTablePtr filterparams =3D NULL; virDomainActualNetDefPtr actual =3D NULL; xmlNodePtr oldnode =3D ctxt->node; + virDomainChrSourceReconnectDef reconnect =3D {0}; int rv, val; =20 if (VIR_ALLOC(def) < 0) @@ -10331,6 +10339,8 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, vhostuser_type =3D virXMLPropString(cur, "type"); vhostuser_path =3D virXMLPropString(cur, "path"); vhostuser_mode =3D virXMLPropString(cur, "mode"); + if (virDomainChrSourceReconnectDefParseXML(&reconnect, cur= , ctxt) < 0) + goto error; } else if (!def->virtPortProfile && virXMLNodeNameEqual(cur, "virtualport")) { if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { @@ -10552,8 +10562,17 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlo= pt, =20 if (STREQ(vhostuser_mode, "server")) { def->data.vhostuser->data.nix.listen =3D true; + if (reconnect.enabled !=3D VIR_TRISTATE_BOOL_ABSENT) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'reconnect' attribute unsupported " + "'server' mode for ")); + goto error; + } } else if (STREQ(vhostuser_mode, "client")) { def->data.vhostuser->data.nix.listen =3D false; + def->data.vhostuser->data.nix.reconnect.enabled =3D reconnect.= enabled; + def->data.vhostuser->data.nix.reconnect.timeout =3D reconnect.= timeout; + reconnect.enabled =3D VIR_TRISTATE_BOOL_ABSENT; } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Wrong 'mode' attribute " @@ -22984,6 +23003,13 @@ virDomainNetDefFormat(virBufferPtr buf, def->data.vhostuser->data.nix.listen ? "server" : "client"); sourceLines++; + if (def->data.vhostuser->data.nix.reconnect.enabled !=3D V= IR_TRISTATE_BOOL_ABSENT) { + virBufferAddLit(buf, ">\n"); + sourceLines++; + virBufferAdjustIndent(buf, 2); + virDomainChrSourceReconnectDefFormat(buf, &def->data.v= hostuser->data.nix.reconnect); + virBufferAdjustIndent(buf, -2); + } } break; =20 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args = b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args index b69ebd8..0b08f44 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args @@ -25,14 +25,14 @@ server,nowait \ -netdev vhost-user,chardev=3Dcharnet0,id=3Dhostnet0 \ -device virtio-net-pci,netdev=3Dhostnet0,id=3Dnet0,mac=3D52:54:00:ee:96:6b= ,bus=3Dpci.0,\ addr=3D0x3 \ --chardev socket,id=3Dcharnet1,path=3D/tmp/vhost1.sock \ +-chardev socket,id=3Dcharnet1,path=3D/tmp/vhost1.sock,reconnect=3D10 \ -netdev vhost-user,chardev=3Dcharnet1,id=3Dhostnet1 \ -device virtio-net-pci,netdev=3Dhostnet1,id=3Dnet1,mac=3D52:54:00:ee:96:6c= ,bus=3Dpci.0,\ addr=3D0x4 \ -netdev socket,listen=3D:2015,id=3Dhostnet2 \ -device rtl8139,netdev=3Dhostnet2,id=3Dnet2,mac=3D52:54:00:95:db:c0,bus=3D= pci.0,\ addr=3D0x5 \ --chardev socket,id=3Dcharnet3,path=3D/tmp/vhost2.sock \ +-chardev socket,id=3Dcharnet3,path=3D/tmp/vhost2.sock,reconnect=3D0 \ -netdev vhost-user,chardev=3Dcharnet3,queues=3D4,id=3Dhostnet3 \ -device virtio-net-pci,mq=3Don,vectors=3D10,netdev=3Dhostnet3,id=3Dnet3,\ mac=3D52:54:00:ee:96:6d,bus=3Dpci.0,addr=3D0x6 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.xml b= /tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.xml index d5c42fe..2fadb1c 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.xml @@ -30,7 +30,9 @@ - + + + @@ -40,7 +42,9 @@ - + + + --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list