From nobody Fri May 17 10:34:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=exoscale.ch ARC-Seal: i=1; a=rsa-sha256; t=1671812115; cv=none; d=zohomail.com; s=zohoarc; b=ghhX88T4xenw/Pe8viZAgYPvIOHV0EThgBiVXMclSeUnWMMyzo4nJNO8ovovx2iAMr2Ghzu0bnM/0o4pRKBRDCxJj+nFGLOrviR/wmDyPqRJKe4UGESUqPhbs6v2KqD0ac+lKwYopB/E5G8900fWRlyfWGN/IAVJsHk8BglBFkU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671812115; 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=pqvGsIghq5llP4a9kEDjiOjA+TmLsd7G2Ezhdxij63I=; b=HPQbJTLFnBP32ZhQ3ndnXJdVcclEN1iLpYeoHLtM7SKCfwuZMHGofYDloyUjYQyk0136zF9qiAwXDG2c2RQYOhQd/nE7qa7CK1l3EOqj2IkTLbJCFcHNMxJ/sfim7H89d8CjLvuTGWOl075Kq2V2mKdhnJ7KIySuqlYftMsC1Bo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1671812115620546.3074738165536; Fri, 23 Dec 2022 08:15:15 -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-422-dpP89ofeN7udJWcnitxrrA-1; Fri, 23 Dec 2022 11:15:13 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8216818483B5; Fri, 23 Dec 2022 16:15:09 +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 78A8F40C2064; Fri, 23 Dec 2022 16:15:07 +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 40CBA19465B3; Fri, 23 Dec 2022 16:15:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id EC72819465B1 for ; Fri, 23 Dec 2022 16:15:04 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D45A1111F3B6; Fri, 23 Dec 2022 16:15:04 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CB036111F3B0 for ; Fri, 23 Dec 2022 16:15:04 +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 A860685A588 for ; Fri, 23 Dec 2022 16:15:04 +0000 (UTC) Received: from smtprelay05.ispgateway.de (smtprelay05.ispgateway.de [80.67.18.28]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-472-9qS29tt8M8aP26VP6zMcUQ-1; Fri, 23 Dec 2022 11:15:02 -0500 Received: from [84.148.237.80] (helo=coldplay) by smtprelay05.ispgateway.de with esmtpa (Exim 4.94.2) (envelope-from ) id 1p8kgb-0001X1-4q for libvir-list@redhat.com; Fri, 23 Dec 2022 17:14:17 +0100 Received: from localhost (localhost [127.0.0.1]) by coldplay (Postfix) with ESMTP id 8E1ED1A01E1 for ; Fri, 23 Dec 2022 17:13:53 +0100 (CET) Received: from coldplay ([127.0.0.1]) by localhost (coldplay.ffm.homeip.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kwKR9OWT7fPl for ; Fri, 23 Dec 2022 17:13:53 +0100 (CET) Received: by coldplay (Postfix, from userid 125) id 1BF1A1A01EF; Fri, 23 Dec 2022 17:13:53 +0100 (CET) Received: from exoxps.homerouter.cpe (unknown [10.8.0.12]) by coldplay (Postfix) with ESMTP id F1A541A01E1; Fri, 23 Dec 2022 17:13:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671812114; 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=pqvGsIghq5llP4a9kEDjiOjA+TmLsd7G2Ezhdxij63I=; b=MruF5zffSWghVUcVRFb01E/TTQ29oaRN3deM4w01RusQWsfVhjOS5NEOXGbTmtfkkDUHKL lhfc6SsY9uAT1Lw8lKR+dU7pQ+x0Loq9QBhnUKfYUb1lzHcMESeRxmBXZZQJOLK4H/Blu5 3shaw8+MPPLTLShCXquZFu08Zoscasg= X-MC-Unique: dpP89ofeN7udJWcnitxrrA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 9qS29tt8M8aP26VP6zMcUQ-1 From: Christian Nautze To: libvir-list@redhat.com Subject: [PATCH] qemu: implement QEMU NBD source reconnect delay attribute Date: Fri, 23 Dec 2022 17:13:46 +0100 Message-Id: <20221223161346.1827645-1-christian.nautze@exoscale.ch> MIME-Version: 1.0 X-Df-Sender: NDUxODI5 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-Mimecast-Spam-Signature: yes X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: Christian Nautze Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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: 1671812117623100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Currently it's only possible to set this parameter during domain creation via QEMU commandline passthrough feature. With the new delay attribute it's also possible to set this parameter if you want to attach a new NBD disk using "virsh attach-device domain device.xml" e.g.: Signed-off-by: Christian Nautze --- docs/formatdomain.rst | 10 ++++++-- src/conf/domain_conf.c | 19 +++++++++++++++ src/conf/schemas/domaincommon.rng | 3 +++ src/conf/schemas/storagecommon.rng | 5 ++++ src/conf/storage_source_conf.c | 1 + src/conf/storage_source_conf.h | 4 ++++ src/qemu/qemu_block.c | 4 +++- src/qemu/qemu_domain.c | 9 ++++++++ .../disk-network-nbd.x86_64-latest.args | 23 +++++++++++-------- tests/qemuxml2argvdata/disk-network-nbd.xml | 8 +++++++ tests/qemuxml2xmloutdata/disk-network-nbd.xml | 9 ++++++++ 11 files changed, 82 insertions(+), 13 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index d7fffc6e0b..3fbeba644a 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -2938,13 +2938,19 @@ paravirtualized driver is specified via the ``disk`= ` element. are intended to be default, then the entire element may be omitted. ``reconnect`` For disk type ``vhostuser`` configures reconnect timeout if the conn= ection - is lost. It has two mandatory attributes: + is lost. This is set with the two mandatory attributes ``enabled`` a= nd + ``timeout``. For disk type ``network`` and protocol ``nbd`` the QEMU= NBD + reconnect delay can be set via the mandatory attributes ``enabled`` + and ``delay``: =20 ``enabled`` If the reconnect feature is enabled, accepts ``yes`` and ``no`` ``timeout`` The amount of seconds after which hypervisor tries to reconnect. - + ``delay`` + The amount of seconds during which all requests are paused and wi= ll be rerun + after a successful reconnect. After that time, any delayed reques= ts and all + future requests before a successful reconnect will immediately fa= il. =20 For a "file" or "volume" disk type which represents a cdrom or floppy (= the ``device`` attribute), it is possible to define policy what to do with = the diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6c088ff295..909c78ef28 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7024,6 +7024,22 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, src->tlsFromConfig =3D !!value; } =20 + if (src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_NBD) { + xmlNodePtr cur; + if ((cur =3D virXPathNode("./reconnect", ctxt))) { + virTristateBool enabled; + if (virXMLPropTristateBool(cur, "enabled", VIR_XML_PROP_NONE, + &enabled) < 0) + return -1; + + if (enabled =3D=3D VIR_TRISTATE_BOOL_YES) { + if (virXMLPropUInt(cur, "delay", 10, VIR_XML_PROP_REQUIRED, + &src->reconnectDelay) < 0) + return -1; + } + } + } + /* for historical reasons we store the volume and image name in one XML * element although it complicates thing when attempting to access the= m. */ if (src->path && @@ -21729,6 +21745,9 @@ virDomainDiskSourceFormatNetwork(virBuffer *attrBuf, virBufferAddLit(childBuf, "/>\n"); } =20 + if (src->reconnectDelay) { + virBufferAsprintf(childBuf, "\n", src->reconnectDelay); + } =20 virBufferEscapeString(childBuf, "\n", src->snap= shot); virBufferEscapeString(childBuf, "\n", src->config= File); diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index c588a48fd2..72587416fe 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -2184,6 +2184,9 @@ + + + diff --git a/src/conf/schemas/storagecommon.rng b/src/conf/schemas/storagec= ommon.rng index 76714c9aad..2842376e78 100644 --- a/src/conf/schemas/storagecommon.rng +++ b/src/conf/schemas/storagecommon.rng @@ -61,6 +61,11 @@ + + + + + =20 diff --git a/src/conf/storage_source_conf.c b/src/conf/storage_source_conf.c index 2b4cf5e241..edfd17c77c 100644 --- a/src/conf/storage_source_conf.c +++ b/src/conf/storage_source_conf.c @@ -810,6 +810,7 @@ virStorageSourceCopy(const virStorageSource *src, def->sslverify =3D src->sslverify; def->readahead =3D src->readahead; def->timeout =3D src->timeout; + def->reconnectDelay =3D src->reconnectDelay; def->metadataCacheMaxSize =3D src->metadataCacheMaxSize; =20 /* storage driver metadata are not copied */ diff --git a/src/conf/storage_source_conf.h b/src/conf/storage_source_conf.h index f2440cec6a..b60a4b3346 100644 --- a/src/conf/storage_source_conf.h +++ b/src/conf/storage_source_conf.h @@ -290,6 +290,10 @@ struct _virStorageSource { unsigned long long readahead; /* size of the readahead buffer in bytes= */ unsigned long long timeout; /* connection timeout in seconds */ =20 + /* NBD QEMU reconnect-delay option, + * 0 as default value */ + unsigned int reconnectDelay; + virStorageSourceNVMeDef *nvme; /* type =3D=3D VIR_STORAGE_TYPE_NVME */ =20 virDomainChrSourceDef *vhostuser; /* type =3D=3D VIR_STORAGE_TYPE_VHOS= T_USER */ diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 8a6f601b29..6913c380a0 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -530,6 +530,7 @@ qemuBlockStorageSourceGetNBDProps(virStorageSource *src, "S:export", src->path, "S:tls-creds", tlsAlias, "S:tls-hostname", tlsHostname, + "p:reconnect-delay", src->reconnectDelay, NULL) < 0) return NULL; =20 @@ -1817,7 +1818,8 @@ qemuBlockGetBackingStoreString(virStorageSource *src, src->ncookies =3D=3D 0 && src->sslverify =3D=3D VIR_TRISTATE_BOOL_ABSENT && src->timeout =3D=3D 0 && - src->readahead =3D=3D 0) { + src->readahead =3D=3D 0 && + src->reconnectDelay =3D=3D 0) { =20 switch ((virStorageNetProtocol) src->protocol) { case VIR_STORAGE_NET_PROTOCOL_NBD: diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 5c05032ce3..840d857f78 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4927,6 +4927,15 @@ qemuDomainValidateStorageSource(virStorageSource *sr= c, } } =20 + if (src->reconnectDelay > 0) { + if (actualType !=3D VIR_STORAGE_TYPE_NETWORK || + src->protocol !=3D VIR_STORAGE_NET_PROTOCOL_NBD) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("reconnect delay is supported only with NBD p= rotocol")); + return -1; + } + } + if (src->query && (actualType !=3D VIR_STORAGE_TYPE_NETWORK || (src->protocol !=3D VIR_STORAGE_NET_PROTOCOL_HTTPS && diff --git a/tests/qemuxml2argvdata/disk-network-nbd.x86_64-latest.args b/t= ests/qemuxml2argvdata/disk-network-nbd.x86_64-latest.args index 21e619af3e..e8d13b0bd4 100644 --- a/tests/qemuxml2argvdata/disk-network-nbd.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-network-nbd.x86_64-latest.args @@ -28,21 +28,24 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config= \ -no-acpi \ -boot strict=3Don \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ --blockdev '{"driver":"nbd","server":{"type":"inet","host":"example.org","p= ort":"6000"},"node-name":"libvirt-5-storage","auto-read-only":true,"discard= ":"unmap"}' \ +-blockdev '{"driver":"nbd","server":{"type":"inet","host":"example.org","p= ort":"6000"},"node-name":"libvirt-6-storage","auto-read-only":true,"discard= ":"unmap"}' \ +-blockdev '{"node-name":"libvirt-6-format","read-only":false,"driver":"raw= ","file":"libvirt-6-storage"}' \ +-device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x2","drive":"li= bvirt-6-format","id":"virtio-disk0","bootindex":1}' \ +-blockdev '{"driver":"nbd","server":{"type":"inet","host":"example.org","p= ort":"6000"},"export":"bar","node-name":"libvirt-5-storage","auto-read-only= ":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-5-format","read-only":false,"driver":"raw= ","file":"libvirt-5-storage"}' \ --device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x2","drive":"li= bvirt-5-format","id":"virtio-disk0","bootindex":1}' \ --blockdev '{"driver":"nbd","server":{"type":"inet","host":"example.org","p= ort":"6000"},"export":"bar","node-name":"libvirt-4-storage","auto-read-only= ":true,"discard":"unmap"}' \ +-device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x3","drive":"li= bvirt-5-format","id":"virtio-disk1"}' \ +-blockdev '{"driver":"nbd","server":{"type":"inet","host":"::1","port":"60= 00"},"node-name":"libvirt-4-storage","auto-read-only":true,"discard":"unmap= "}' \ -blockdev '{"node-name":"libvirt-4-format","read-only":false,"driver":"raw= ","file":"libvirt-4-storage"}' \ --device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x3","drive":"li= bvirt-4-format","id":"virtio-disk1"}' \ --blockdev '{"driver":"nbd","server":{"type":"inet","host":"::1","port":"60= 00"},"node-name":"libvirt-3-storage","auto-read-only":true,"discard":"unmap= "}' \ +-device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x4","drive":"li= bvirt-4-format","id":"virtio-disk2"}' \ +-blockdev '{"driver":"nbd","server":{"type":"inet","host":"::1","port":"60= 00"},"export":"bar","node-name":"libvirt-3-storage","auto-read-only":true,"= discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-3-format","read-only":false,"driver":"raw= ","file":"libvirt-3-storage"}' \ --device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x4","drive":"li= bvirt-3-format","id":"virtio-disk2"}' \ --blockdev '{"driver":"nbd","server":{"type":"inet","host":"::1","port":"60= 00"},"export":"bar","node-name":"libvirt-2-storage","auto-read-only":true,"= discard":"unmap"}' \ +-device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x5","drive":"li= bvirt-3-format","id":"virtio-disk3"}' \ +-blockdev '{"driver":"nbd","server":{"type":"unix","path":"/var/run/nbdsoc= k"},"export":"bar","node-name":"libvirt-2-storage","auto-read-only":true,"d= iscard":"unmap"}' \ -blockdev '{"node-name":"libvirt-2-format","read-only":false,"driver":"raw= ","file":"libvirt-2-storage"}' \ --device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x5","drive":"li= bvirt-2-format","id":"virtio-disk3"}' \ --blockdev '{"driver":"nbd","server":{"type":"unix","path":"/var/run/nbdsoc= k"},"export":"bar","node-name":"libvirt-1-storage","auto-read-only":true,"d= iscard":"unmap"}' \ +-device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x6","drive":"li= bvirt-2-format","id":"virtio-disk4"}' \ +-blockdev '{"driver":"nbd","server":{"type":"inet","host":"example.org","p= ort":"6000"},"export":"foo","reconnect-delay":10,"node-name":"libvirt-1-sto= rage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw= ","file":"libvirt-1-storage"}' \ --device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x6","drive":"li= bvirt-1-format","id":"virtio-disk4"}' \ +-device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x7","drive":"li= bvirt-1-format","id":"virtio-disk5"}' \ -audiodev '{"id":"audio1","driver":"none"}' \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ -msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/disk-network-nbd.xml b/tests/qemuxml2ar= gvdata/disk-network-nbd.xml index 8ac6cc3b7b..243ffeb1ed 100644 --- a/tests/qemuxml2argvdata/disk-network-nbd.xml +++ b/tests/qemuxml2argvdata/disk-network-nbd.xml @@ -49,6 +49,14 @@ + + + + + + + + diff --git a/tests/qemuxml2xmloutdata/disk-network-nbd.xml b/tests/qemuxml2= xmloutdata/disk-network-nbd.xml index f8dcca4bab..ed0c760d5b 100644 --- a/tests/qemuxml2xmloutdata/disk-network-nbd.xml +++ b/tests/qemuxml2xmloutdata/disk-network-nbd.xml @@ -54,6 +54,15 @@
+ + + + + + + +
+
--=20 2.34.1