From nobody Thu Nov 21 12:42:01 2024 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1731944779254375.78277383909654; Mon, 18 Nov 2024 07:46:19 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 0FC8A1BE4; Mon, 18 Nov 2024 10:46:18 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id E7D261BEC; Mon, 18 Nov 2024 10:45:55 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 6EF501BD0; Mon, 18 Nov 2024 10:45:53 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id E415313A2 for ; Mon, 18 Nov 2024 10:45:52 -0500 (EST) Received: from mx-prod-mc-04.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-474-6TzHTV0tP5-8wmokVQTazw-1; Mon, 18 Nov 2024 10:45:51 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8E1041955F57 for ; Mon, 18 Nov 2024 15:45:50 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B67511956054 for ; Mon, 18 Nov 2024 15:45:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731944752; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=zZ4R7e1LDWpoFlVngmLE93vVC0dI7PSnKAaIq0t6aPk=; b=aJegRFBpyRxW0bVDlXbMg9sugfuGbRwVf3iS3mG8JK4XdVpaIK52U1cUGzElTebLwCxKz3 5BHfJQaBvzHVtSTdnq3BKM5FLfqGeUigk2kbqVPZn75Xtwiwk4IOGlHrI0jkaAOudBGveL 6WHn28xmViUawRw/tW32+CgfXjrneoo= X-MC-Unique: 6TzHTV0tP5-8wmokVQTazw-1 X-Mimecast-MFC-AGG-ID: 6TzHTV0tP5-8wmokVQTazw From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH v2] qemuDomainDiskChangeSupported: Add missing iothreads check Date: Mon, 18 Nov 2024 16:45:48 +0100 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: QjC1LfNVVykeXmGscx5yHjo61i8244ckgTlRx73wStc_1731944750 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 3IFEHNVRI7NKORWW6QDI35WHDQHGYRVK X-Message-ID-Hash: 3IFEHNVRI7NKORWW6QDI35WHDQHGYRVK X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1731944780458116600 Content-Type: text/plain; charset="utf-8" From: Adam Julis GSList of iothreads is not allowed to be changed while the virtual machine is running. Resolves: https://issues.redhat.com/browse/RHEL-23607 Signed-off-by: Adam Julis Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- Changes to v1: - extrac to separate function - improve readability of loops and handling of error - fix possibility of infinitely looping if first queue of both queue lists matches src/qemu/qemu_domain.c | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 66ab4baa8b..153bd56e86 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6591,6 +6591,49 @@ qemuDomainStorageSourceAccessAllow(virQEMUDriver *dr= iver, } +static bool +qemuDomainDiskChangeSupportedIothreads(virDomainDiskDef *disk, + virDomainDiskDef *orig_disk) +{ + GSList *old =3D orig_disk->iothreads; + GSList *new =3D disk->iothreads; + + while (true) { + virDomainDiskIothreadDef *old_def; + virDomainDiskIothreadDef *new_def; + size_t i; + + /* match - both empty or both at the end */ + if (!old && !new) + return true; + + /* mismatched length of lists */ + if (!old || !new) + goto fail; + + old_def =3D old->data; + new_def =3D new->data; + + if (old_def->id !=3D new_def->id || + old_def->nqueues !=3D new_def->nqueues) + goto fail; + + for (i =3D 0; i < old_def->nqueues; i++) { + if (old_def->queues[i] !=3D new_def->queues[i]) + goto fail; + } + + new =3D new->next; + old =3D old->next; + } + + fail: + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("cannot modify field '' (or it's parts) of= the disk")); + return false; +} + + /* * Makes sure the @disk differs from @orig_disk only by the source * path and nothing else. Fields that are being checked and the @@ -6735,6 +6778,9 @@ qemuDomainDiskChangeSupported(virDomainDiskDef *disk, CHECK_EQ(discard, "discard", true); CHECK_EQ(iothread, "iothread", true); + if (!qemuDomainDiskChangeSupportedIothreads(disk, orig_disk)) + return false; + CHECK_STREQ_NULLABLE(domain_name, "backenddomain"); --=20 2.47.0