From nobody Mon Mar 23 23:24:08 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1774015106; cv=none; d=zohomail.com; s=zohoarc; b=U3CKm0uMpG0e9olBXfv3o7rtmFUqKHGmqa/OsDv51rYFxLTHFiaDODV/dyXzyn7AgTBwbitrq59TpMrhIlCw21AOQB4MqcNlh4/i7hlQ0AbgHVoZlrPp+U3nxP/46dGfksYNJGMFOiHlsWFTQiQWhEIhds9mTAhbTFWuk1SlL/w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774015106; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=Qy5jpsGyjTEWdPfD++K6msE60NK6MybTiPDHRolS1NA=; b=JsOKMfL8XEhaioqyOVM+19/W74Q6XexgFPoX8orWs8E3I/VCCsqvCHHAQzAcrSnUs0kossiZCTEQIZgUS3u40bPjjCD4doezaS/1fxNGyc+y8kPEinF1nCyTXZ6Q0iaFmZ+aOuPJGOlEm8jF7zj5TbwHEjvz/+SLS4ZC1QJgk9U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1774015106414213.97228584520428; Fri, 20 Mar 2026 06:58:26 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 6DF3A41902; Fri, 20 Mar 2026 09:58:25 -0400 (EDT) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 3EF4341B11; Fri, 20 Mar 2026 09:56:59 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 69B784180A; Fri, 20 Mar 2026 09:56:52 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id EB85F3F8AA for ; Fri, 20 Mar 2026 09:56:51 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-609-oCo_v6UMMy-wPrGaOYdjNQ-1; Fri, 20 Mar 2026 09:56:50 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 145011944F2F; Fri, 20 Mar 2026 13:56:49 +0000 (UTC) Received: from speedmetal.openshiftapps.com (unknown [10.45.242.5]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C41A71955D84; Fri, 20 Mar 2026 13:56:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774015011; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=Qy5jpsGyjTEWdPfD++K6msE60NK6MybTiPDHRolS1NA=; b=PuVtdnp4sejga1ZJCq2ERoU7ADc92d2snVNJSEKyFrTeMoqNO6zXe1JtGvztLcfGQuQR0A /2x7pvoSSSn+BDSo8EOP7/twxmPl6onv3wJ9RjkVWCSI5CM6rtacq8IK/qUb7n7RUJbhgJ UUmEZW9F6lwNpPWr2SEOpG2DIFyACaA= X-MC-Unique: oCo_v6UMMy-wPrGaOYdjNQ-1 X-Mimecast-MFC-AGG-ID: oCo_v6UMMy-wPrGaOYdjNQ_1774015009 To: devel@lists.libvirt.org Subject: [PATCH v2 1/3] qemu: conf: add setup for automatic port allocation for pull-mode backup NBD servers Date: Fri, 20 Mar 2026 14:56:42 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: AvT5PMaXd674f4x4cQRDYJedk9qaPr_YlwNYiZ5ErT8_1774015009 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: PMQTLZWGGH3GX4IXTX3CPSWL437BN5MC X-Message-ID-Hash: PMQTLZWGGH3GX4IXTX3CPSWL437BN5MC X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Peter Krempa , Lucas Amaral X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1774015108986158500 Content-Type: text/plain; charset="utf-8" From: Lucas Amaral Add backup_port_min and backup_port_max configuration options to qemu.conf, defaulting to 10809-10872 (10809 is the IANA-assigned NBD port; range of 64 matches the migration port pattern). Signed-off-by: Lucas Amaral Signed-off-by: Peter Krempa Reviewed-by: Peter Krempa --- src/qemu/libvirtd_qemu.aug | 2 ++ src/qemu/qemu.conf.in | 9 +++++++++ src/qemu/qemu_conf.c | 25 +++++++++++++++++++++++++ src/qemu/qemu_conf.h | 3 +++ src/qemu/test_libvirtd_qemu.aug.in | 2 ++ 5 files changed, 41 insertions(+) diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug index 0286582169..eb790d48be 100644 --- a/src/qemu/libvirtd_qemu.aug +++ b/src/qemu/libvirtd_qemu.aug @@ -146,6 +146,8 @@ module Libvirtd_qemu =3D | int_entry "migration_port_min" | int_entry "migration_port_max" | str_entry "migration_host" + | int_entry "backup_port_min" + | int_entry "backup_port_max" let log_entry =3D bool_entry "log_timestamp" diff --git a/src/qemu/qemu.conf.in b/src/qemu/qemu.conf.in index 2d1c67034d..5eacd70022 100644 --- a/src/qemu/qemu.conf.in +++ b/src/qemu/qemu.conf.in @@ -969,6 +969,15 @@ #migration_port_max =3D 49215 +# Port range used for automatic allocation of NBD backup server ports. +# When a pull-mode backup is started without specifying a TCP port, a +# port from this range will be assigned automatically. The NBD standard +# port is 10809. +# +#backup_port_min =3D 10809 +#backup_port_max =3D 10872 + + # Timestamp QEMU's log messages (if QEMU supports it) # # Defaults to 1. diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 3ea42da502..d43e0c2b97 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -74,6 +74,9 @@ VIR_LOG_INIT("qemu.qemu_conf"); #define QEMU_MIGRATION_PORT_MIN 49152 #define QEMU_MIGRATION_PORT_MAX 49215 +#define QEMU_BACKUP_PORT_MIN 10809 +#define QEMU_BACKUP_PORT_MAX 10872 + VIR_ENUM_IMPL(virQEMUSchedCore, QEMU_SCHED_CORE_LAST, "none", @@ -268,6 +271,9 @@ virQEMUDriverConfig *virQEMUDriverConfigNew(bool privil= eged, cfg->migrationPortMin =3D QEMU_MIGRATION_PORT_MIN; cfg->migrationPortMax =3D QEMU_MIGRATION_PORT_MAX; + cfg->backupPortMin =3D QEMU_BACKUP_PORT_MIN; + cfg->backupPortMax =3D QEMU_BACKUP_PORT_MAX; + /* For privileged driver, try and find hugetlbfs mounts automatically. * Non-privileged driver requires admin to create a dir for the * user, chown it, and then let user configure it manually. */ @@ -989,6 +995,25 @@ virQEMUDriverConfigLoadNetworkEntry(virQEMUDriverConfi= g *cfg, return -1; } + if (virConfGetValueUInt(conf, "backup_port_min", &cfg->backupPortMin) = < 0) + return -1; + if (cfg->backupPortMin <=3D 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("%1$s: backup_port_min: port must be greater than= 0"), + filename); + return -1; + } + + if (virConfGetValueUInt(conf, "backup_port_max", &cfg->backupPortMax) = < 0) + return -1; + if (cfg->backupPortMax > 65535 || + cfg->backupPortMax < cfg->backupPortMin) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("%1$s: backup_port_max: port must be between the= minimal port %2$d and 65535"), + filename, cfg->backupPortMin); + return -1; + } + if (virConfGetValueString(conf, "migration_host", &cfg->migrateHost) <= 0) return -1; virStringStripIPv6Brackets(cfg->migrateHost); diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index aa2bac6891..af1e7ee503 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -241,6 +241,9 @@ struct _virQEMUDriverConfig { unsigned int migrationPortMin; unsigned int migrationPortMax; + unsigned int backupPortMin; + unsigned int backupPortMax; + bool logTimestamp; bool stdioLogD; diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qe= mu.aug.in index 82cfec3b4b..2582c6a09c 100644 --- a/src/qemu/test_libvirtd_qemu.aug.in +++ b/src/qemu/test_libvirtd_qemu.aug.in @@ -110,6 +110,8 @@ module Test_libvirtd_qemu =3D { "migration_host" =3D "host.example.com" } { "migration_port_min" =3D "49152" } { "migration_port_max" =3D "49215" } +{ "backup_port_min" =3D "10809" } +{ "backup_port_max" =3D "10872" } { "log_timestamp" =3D "0" } { "nvram" { "1" =3D "/usr/share/OVMF/OVMF_CODE.fd:/usr/share/OVMF/OVMF_VARS.fd" } --=20 2.53.0 From nobody Mon Mar 23 23:24:08 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1774015137; cv=none; d=zohomail.com; s=zohoarc; b=G5V2S9wRPlcdkFrxIlPV3hnmdDFU3MjThZHKSPjxmFm4Im0gaIizRqjdYIecEI1888siHasLDs+GE+Oyus43CmJ4XJ/Samc1oMPV3X3Ikrl1Dp9Sdyujb0/3zq97TmZn0V7pa8+0YdWjHnlxyXlSWzKnfxm45Thhjq9kk5N3G1A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774015137; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=QXPkg1hDaRPc2paCUaQX2+aOiD3xLo4eFEnoOC1Kncc=; b=Crqu57LfUANBqxh8RcDMmZdAE6M8Yw8il8mPa37ljmFOGx5NsEXP7as64eE1nwax0AGBv/j4gfHxyq5gZgY98hMzadwhMJsf45ArARhXtMc8p62li2A2h18QHPJrxTdKzAHPl5rlqedPB3c5kzQkq3H88Y3l/Q7d7Ef3XzMD3xw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1774015137623561.0852377265464; Fri, 20 Mar 2026 06:58:57 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 05404419F9; Fri, 20 Mar 2026 09:58:57 -0400 (EDT) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 7934F41B69; Fri, 20 Mar 2026 09:57:12 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 7CA3541AA1; Fri, 20 Mar 2026 09:57:08 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 7A2AC41917 for ; Fri, 20 Mar 2026 09:56:55 -0400 (EDT) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-649-lJvpOajIMbm9MhCARWJryw-1; Fri, 20 Mar 2026 09:56:51 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 96A2118005B4; Fri, 20 Mar 2026 13:56:50 +0000 (UTC) Received: from speedmetal.openshiftapps.com (unknown [10.45.242.5]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7830C1955D84; Fri, 20 Mar 2026 13:56:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774015015; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=QXPkg1hDaRPc2paCUaQX2+aOiD3xLo4eFEnoOC1Kncc=; b=bnf1HJhmj9UPhkw0EDEcTykVuf0b4rXFyTBOb5XeabCLWu4KQAGU70DB9aSagNQ3Azjjt4 1CzF0jOXaX9XF9Dn9+Os+ympZtvtuvZ47eYpAmgQxgVdm98TR5Zjdz/d2vrCLx8q5VrbwC PPRkdt81S0Kj3ZNk2m+rDIKx1oI0XjA= X-MC-Unique: lJvpOajIMbm9MhCARWJryw-1 X-Mimecast-MFC-AGG-ID: lJvpOajIMbm9MhCARWJryw_1774015010 To: devel@lists.libvirt.org Subject: [PATCH v2 2/3] qemu: driver: Setup 'virPortAllocator' for backup NBD server ports Date: Fri, 20 Mar 2026 14:56:43 +0100 Message-ID: <36cf50f85b9c8f3351332dc5302401e4b06176e1.1774014870.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: FMEAdbvMrdM_uHrwBNcQETGC2SgIlp0ggotBRAEmcEE_1774015010 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: F7BL2EKKD3EQBGY3WGWNAWM6UOEOQBKG X-Message-ID-Hash: F7BL2EKKD3EQBGY3WGWNAWM6UOEOQBKG X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Peter Krempa , Lucas Amaral X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1774015139168154100 Content-Type: text/plain; charset="utf-8" From: Lucas Amaral Signed-off-by: Lucas Amaral Signed-off-by: Peter Krempa Reviewed-by: Peter Krempa --- src/qemu/qemu_conf.h | 3 +++ src/qemu/qemu_driver.c | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index af1e7ee503..511ab77f71 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -342,6 +342,9 @@ struct _virQEMUDriver { /* Immutable pointer, immutable object */ virPortAllocatorRange *migrationPorts; + /* Immutable pointer, immutable object */ + virPortAllocatorRange *backupPorts; + /* Immutable pointer, lockless APIs */ virSysinfoDef *hostsysinfo; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 5ef3ec649f..6fa6170b6f 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -719,6 +719,12 @@ qemuStateInitialize(bool privileged, cfg->migrationPortMax)) =3D=3D NULL) goto error; + if ((qemu_driver->backupPorts =3D + virPortAllocatorRangeNew(_("backup"), + cfg->backupPortMin, + cfg->backupPortMax)) =3D=3D NULL) + goto error; + if (qemuSecurityInit(qemu_driver) < 0) goto error; --=20 2.53.0 From nobody Mon Mar 23 23:24:08 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1774015178; cv=none; d=zohomail.com; s=zohoarc; b=ed7WcVnWyT4tbOqAvhtJhU/1kAJuUtg1bKbug8NsT7/YEfnP0C3K+K/tEHNgw5OEf/YfbiJsCU+RnlsHnVYc3vTIpZRRHLC96OIl8r6O4G+R5DU8ofpJpo37i6Jmjnh0AnrSj6FwKaQI6eWfyJ79F0WISGGqduKuu9oUUzb4c2Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774015178; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=RVhHcPf2/GdfBXRsIRnb7h/sgFW184beBCa26FcWANc=; b=HROGnqdbIVHVCzFAU+HIQvMIgLhoyn941+bYb5HOgG5Mx/UQA+TYg7JtgaS9LO8zTN2TsxTpWX9bjJFUBLfdQMso3Yc4/3xrGwtl1UMlzj+XOJDBZawbIvdlGaGCtHmM2SoUpmmG6M+gSN+E2WUlLjcY+Qybuwr+zhiY5rftgVs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1774015178074732.3971474975851; Fri, 20 Mar 2026 06:59:38 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 53DE04184D; Fri, 20 Mar 2026 09:59:37 -0400 (EDT) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 317F541B73; Fri, 20 Mar 2026 09:57:42 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 6651A4198E; Fri, 20 Mar 2026 09:57:36 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 2C9424188C for ; Fri, 20 Mar 2026 09:56:57 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-146-QoRgDZgrPPqfzx5vhhmOTg-1; Fri, 20 Mar 2026 09:56:53 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A2FDE19560AA; Fri, 20 Mar 2026 13:56:52 +0000 (UTC) Received: from speedmetal.openshiftapps.com (unknown [10.45.242.5]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1565E1955D84; Fri, 20 Mar 2026 13:56:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774015016; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=RVhHcPf2/GdfBXRsIRnb7h/sgFW184beBCa26FcWANc=; b=MjHs+VA0Y8/DMziGbhKjW+IXhxZPZnnRhnTjwILiVncCVS4pGs7JcKaKbLM39e3bgVrZPg M6rCQ0hchpdG3B/MlLkdXsbTH/IaJ4E/AbAl1wk9OFhPTCBabQcYeMmeMOpd+5lAX7GHIn sDgUgnrl36XWVD/PRTimNPLmorCTVIg= X-MC-Unique: QoRgDZgrPPqfzx5vhhmOTg-1 X-Mimecast-MFC-AGG-ID: QoRgDZgrPPqfzx5vhhmOTg_1774015012 To: devel@lists.libvirt.org Subject: [PATCH v2 3/3] qemu: add automatic port allocation for pull-mode backup NBD servers Date: Fri, 20 Mar 2026 14:56:44 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ptCx96OBd6BaS5J8TpOnx2we7BwlcoSRjW4h_L5_agg_1774015012 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: IB5RSANAHTM4E6HXGYS22JSFDNVBGDK3 X-Message-ID-Hash: IB5RSANAHTM4E6HXGYS22JSFDNVBGDK3 X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Peter Krempa , Lucas Amaral X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1774015179121158500 Content-Type: text/plain; charset="utf-8" From: Lucas Amaral Previously, users had to manually specify a TCP port when starting a pull-mode backup with an NBD server. A TODO comment in qemuBackupPrepare() noted this limitation and pointed toward using virPortAllocator, as done for migration, VNC, and SPICE ports. When a pull-mode backup is started without specifying a TCP port, a port is now acquired automatically from the configured range via virPortAllocatorAcquire(). The port is released when the backup ends or if startup fails. Signed-off-by: Lucas Amaral Signed-off-by: Peter Krempa Reviewed-by: Peter Krempa --- docs/formatbackup.rst | 3 ++- src/qemu/qemu_backup.c | 30 ++++++++++++++++++++---------- src/qemu/qemu_domain.h | 1 + 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/docs/formatbackup.rst b/docs/formatbackup.rst index df6392e3bd..24857eaf72 100644 --- a/docs/formatbackup.rst +++ b/docs/formatbackup.rst @@ -42,7 +42,8 @@ were supplied). The following child elements and attribut= es are supported: ```protocol`` element of a disk `__ attached via NBD in the domain (such as transport, socket, name, port, or tls), necessary to set up an NBD server that exposes the content of each disk= at - the time the backup is started. + the time the backup is started. For TCP transport, if ``port`` is omitt= ed, a + port is allocated automatically from the range configured in ``/etc/lib= virt/qemu.conf``. In addition to the above the NBD server used for backups allows using ``transport=3D'fd' fdgroup=3D'NAME'`` where ``NAME`` is the name used w= ith diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index d380dd3a63..ddab4be34b 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -32,6 +32,7 @@ #include "storage_source.h" #include "storage_source_conf.h" #include "virerror.h" +#include "virportallocator.h" #include "virlog.h" #include "virbuffer.h" #include "backup_conf.h" @@ -58,7 +59,8 @@ qemuDomainGetBackup(virDomainObj *vm) static int -qemuBackupPrepare(virDomainBackupDef *def) +qemuBackupPrepare(qemuDomainObjPrivate *priv, + virDomainBackupDef *def) { if (def->type =3D=3D VIR_DOMAIN_BACKUP_TYPE_PULL) { @@ -71,15 +73,12 @@ qemuBackupPrepare(virDomainBackupDef *def) switch (def->server->transport) { case VIR_STORAGE_NET_HOST_TRANS_TCP: - /* TODO: Update qemu.conf to provide a port range, - * probably starting at 10809, for obtaining automatic - * port via virPortAllocatorAcquire, as well as store - * somewhere if we need to call virPortAllocatorRelease - * during BackupEnd. Until then, user must provide port */ if (!def->server->port) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _(" must specify TCP port for= now")); - return -1; + if (virPortAllocatorAcquire(priv->driver->backupPorts, + &priv->backupNBDPort) < 0) + return -1; + + def->server->port =3D priv->backupNBDPort; } break; @@ -838,7 +837,7 @@ qemuBackupBegin(virDomainObj *vm, goto endjob; } - if (qemuBackupPrepare(def) < 0) + if (qemuBackupPrepare(priv, def) < 0) goto endjob; if (qemuBackupBeginPrepareTLS(vm, cfg, def, &tlsProps, &tlsSecretProps= ) < 0) @@ -969,6 +968,11 @@ qemuBackupBegin(virDomainObj *vm, qemuDomainObjExitMonitor(vm); } + if (ret < 0 && priv->backupNBDPort) { + virPortAllocatorRelease(priv->backupNBDPort); + priv->backupNBDPort =3D 0; + } + if (ret < 0 && !job_started && priv->backup) def =3D g_steal_pointer(&priv->backup); @@ -1026,6 +1030,12 @@ qemuBackupNotifyBlockjobEndStopNBD(virDomainObj *vm, qemuDomainObjExitMonitor(vm); backup->nbdStopped =3D true; + + if (priv->backupNBDPort) { + virPortAllocatorRelease(priv->backupNBDPort); + priv->backupNBDPort =3D 0; + backup->server->port =3D 0; + } } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index f797542a87..b321a64e96 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -147,6 +147,7 @@ struct _qemuDomainObjPrivate { char *origname; int nbdPort; /* Port used for migration with NBD */ unsigned short migrationPort; + unsigned short backupNBDPort; int preMigrationState; unsigned long long preMigrationMemlock; /* Original RLIMIT_MEMLOCK in = case it was changed for the curr= ent --=20 2.53.0