From nobody Mon May 6 07:45:09 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=quarantine dis=quarantine) header.from=exoscale.ch ARC-Seal: i=1; a=rsa-sha256; t=1676652681; cv=none; d=zohomail.com; s=zohoarc; b=L5edg9x5Lq3ZoWsRTRpPV7SaGQneKBCqHjncJiYlBK4vVt3nn/kLYpK9ekAbI7l/pHbXx0Aa+TsFq0zU1S9OTI85t58WO6kW1ChWX5G4wJrlUjCHV//PH5+GPBogJm+SN6gdrln1l4vpdkQYzelIEPbEJpJYR+1yOgpa5ETesnA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676652681; 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=zfHckqTw48DVk1E+PFvKOrK99DZIWZdQ7J74tZcJgz4=; b=GpNvKHhDBaP/6CPU4Hc5ia7FKYCLrXuQakSD/oVVwhiIwCaPHwZV0Svex6ezKmceU+y7uqkVKIXJp2fp109V2EpTCz1BW0Lnh81hPL/TGTLo6yaMQNAWd1GV5z15gwE4uH37I9MYAw3aJHhQF6mYJwb8XKKOgTbHPiwMYfZC3LI= 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=quarantine dis=quarantine) 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 1676652681434886.1381909343887; Fri, 17 Feb 2023 08:51:21 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-439-kcLHWrKjMmeziINGRDDnXg-1; Fri, 17 Feb 2023 11:51:17 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0741029DD9A3; Fri, 17 Feb 2023 16:51:14 +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 717E11121315; Fri, 17 Feb 2023 16:51:13 +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 1E5551946589; Fri, 17 Feb 2023 16:51:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1DD4C1946588 for ; Fri, 17 Feb 2023 16:51:12 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id F239D140EBF6; Fri, 17 Feb 2023 16:51:11 +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 E9F4B140EBF4 for ; Fri, 17 Feb 2023 16:51:11 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 CA5EC85A5A3 for ; Fri, 17 Feb 2023 16:51:11 +0000 (UTC) Received: from smtprelay03.ispgateway.de (smtprelay03.ispgateway.de [80.67.18.15]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-605-v3wm7f6NP2Karolgr0dJYw-1; Fri, 17 Feb 2023 11:51:09 -0500 Received: from [84.148.237.80] (helo=coldplay) by smtprelay03.ispgateway.de with esmtpa (Exim 4.94.2) (envelope-from ) id 1pT3vz-0001FM-NJ for libvir-list@redhat.com; Fri, 17 Feb 2023 17:50:07 +0100 Received: from localhost (localhost [127.0.0.1]) by coldplay (Postfix) with ESMTP id 93F351A0164 for ; Fri, 17 Feb 2023 17:50:07 +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 ozz7Kf7s0LCo for ; Fri, 17 Feb 2023 17:50:07 +0100 (CET) Received: by coldplay (Postfix, from userid 125) id 248E51A00FB; Fri, 17 Feb 2023 17:50:07 +0100 (CET) Received: from beastieboys.. (beastieboys [192.168.178.2]) by coldplay (Postfix) with ESMTP id 2DEF31A00FB; Fri, 17 Feb 2023 17:50:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676652680; 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=zfHckqTw48DVk1E+PFvKOrK99DZIWZdQ7J74tZcJgz4=; b=cQ1Y0Kd/Y6hHBV+/wZSwX+YeDccnGnYnFMRYOLtrmP8y5cmDHWhRKYgR65cvAgZiFoouhc yn0J1xqJfSKc4u6kkqmxgoAzc/GqeYs95vBCBwvmRZHCsHBGYh/qWcPUU+mEntEsC4zHsY qCEQocxOkh/Ww/R0jy5cpoNuAOYv/YI= X-MC-Unique: kcLHWrKjMmeziINGRDDnXg-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: v3wm7f6NP2Karolgr0dJYw-1 From: Christian Nautze To: libvir-list@redhat.com Subject: [libvirt PATCH v2] qemu: implement QEMU NBD source reconnect delay attribute Date: Fri, 17 Feb 2023 17:50:05 +0100 Message-Id: <20230217165005.130148-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.7 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.3 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: 1676652683566100001 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 --- Change: reconnect element: drop mandatory 'enabled' attribute when using 'd= elay' --- docs/formatdomain.rst | 11 +++++++-- src/conf/domain_conf.c | 12 ++++++++++ src/conf/schemas/domaincommon.rng | 3 +++ src/conf/schemas/storagecommon.rng | 13 ++++++++--- 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, 81 insertions(+), 16 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 36c6d87907..ee30c51cea 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -2946,13 +2946,20 @@ 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 reconnec= t delay + can be set via attribute ``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`` + Only for NBD hosts. The amount of seconds during which all reques= ts are + paused and will be rerun after a successful reconnect. After that= time, any + delayed requests and all future requests before a successful reco= nnect + will immediately fail. If not set the default QEMU value is 0. =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 a5578324b9..3f2ba2aab8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7146,6 +7146,15 @@ 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))) { + if (virXMLPropUInt(cur, "delay", 10, VIR_XML_PROP_NONE, + &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 && @@ -22073,6 +22082,9 @@ virDomainDiskSourceFormatNetwork(virBuffer *attrBuf, virBufferAddLit(childBuf, "/>\n"); } =20 + if (src->reconnectDelay) { + virBufferAsprintf(childBuf, "\n", src->re= connectDelay); + } =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 a57dd212ab..dd5fbeac09 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -2199,6 +2199,9 @@ + + + diff --git a/src/conf/schemas/storagecommon.rng b/src/conf/schemas/storagec= ommon.rng index 4d6e646c9a..582375358c 100644 --- a/src/conf/schemas/storagecommon.rng +++ b/src/conf/schemas/storagecommon.rng @@ -55,14 +55,21 @@ =20 - - - + + + + + + + + + + =20 diff --git a/src/conf/storage_source_conf.c b/src/conf/storage_source_conf.c index cecd7e811e..58009fd06e 100644 --- a/src/conf/storage_source_conf.c +++ b/src/conf/storage_source_conf.c @@ -811,6 +811,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 14a6825d54..c6187dda59 100644 --- a/src/conf/storage_source_conf.h +++ b/src/conf/storage_source_conf.h @@ -312,6 +312,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 5e700eff99..8fcebd8992 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -529,6 +529,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 @@ -1848,7 +1849,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 e9bc0f375d..02ae3823fb 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5020,6 +5020,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..4e8b1e5b03 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..38d1f290c8 100644 --- a/tests/qemuxml2xmloutdata/disk-network-nbd.xml +++ b/tests/qemuxml2xmloutdata/disk-network-nbd.xml @@ -54,6 +54,15 @@
+ + + + + + + +
+
--=20 2.34.1