From nobody Sun May 19 03:12:55 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) 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 1713357471257178.08880043877252; Wed, 17 Apr 2024 05:37:51 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 361B31BD2; Wed, 17 Apr 2024 08:37:50 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id C1C411B54; Wed, 17 Apr 2024 08:36:47 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1376A1AD5; Wed, 17 Apr 2024 08:36:42 -0400 (EDT) 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 097891C08 for ; Wed, 17 Apr 2024 08:36:28 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-306-Y65vjcULOwCbulGvXmrS0g-1; Wed, 17 Apr 2024 08:36:26 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id E488588CE81 for ; Wed, 17 Apr 2024 12:36:25 +0000 (UTC) Received: from orkuz (unknown [10.45.224.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B5D21121306 for ; Wed, 17 Apr 2024 12:36:25 +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.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: Y65vjcULOwCbulGvXmrS0g-1 From: Jiri Denemark To: devel@lists.libvirt.org Subject: [PATCH v2 1/4] qemu: Fix migration with custom XML Date: Wed, 17 Apr 2024 14:36:08 +0200 Message-ID: <05ac016ff3a3cd54fc85748f8f081c2449a23af4.1713357265.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: E5SDQ3IJWCD4HLZS4JQZED55LEMOS32F X-Message-ID-Hash: E5SDQ3IJWCD4HLZS4JQZED55LEMOS32F X-MailFrom: jdenemar@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: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1713357472116100001 Ages ago origCPU in domain private data was introduced to provide backward compatibility when migrating to an old libvirt, which did not support fetching updated CPU definition from QEMU. Thus origCPU will contain the original CPU definition before such update. But only if the update actually changed anything. Let's always fill origCPU with the original definition when starting a domain so that we can rely on it being always set, even if it matches the updated definition. This fixes migration or save operations with custom domain XML after commit v10.1.0-88-g14d3517410, which expected origCPU to be always set to the CPU definition from inactive XML to check features explicitly requested by a user. https://issues.redhat.com/browse/RHEL-30622 Signed-off-by: Jiri Denemark Tested-by: Han Han Reviewed-by: Peter Krempa --- Notes: Version 2: - virCPUDefCopy never returns NULL - do not remove !*origCPU check in qemuDomainFixupCPUs - make sure origCPU is set when reconnecting to running domains src/qemu/qemu_domain.c | 33 ++++++++++++++++++++------------- src/qemu/qemu_process.c | 19 +++++++------------ 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6b869797a8..d91c7d478b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -10995,12 +10995,13 @@ virSaveCookieCallbacks virQEMUDriverDomainSaveCoo= kie =3D { * @vm: domain which is being started * @cpu: CPU updated when the domain was running previously (before migrat= ion, * snapshot, or save) - * @origCPU: where to store the original CPU from vm->def in case @cpu was - * used instead + * @origCPU: where to store the original CPU from vm->def * - * Replace the CPU definition with the updated one when QEMU is new enough= to - * allow us to check extra features it is about to enable or disable when - * starting a domain. The original CPU is stored in @origCPU. + * Save the original CPU definition from inactive XML in @origCPU so that = we + * can safely update it and still be able to check what exactly a user ask= ed + * for. The domain definition will either contain a copy of the original C= PU + * definition or a copy of @cpu in case the domain was already running and + * we're just restoring a saved state or preparing for incoming migration. * * Returns 0 on success, -1 on error. */ @@ -11013,18 +11014,24 @@ qemuDomainUpdateCPU(virDomainObj *vm, =20 *origCPU =3D NULL; =20 - if (!cpu || !vm->def->cpu || - !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSIO= N) || - virCPUDefIsEqual(vm->def->cpu, cpu, false)) + if (!vm->def->cpu) return 0; =20 - if (!(cpu =3D virCPUDefCopy(cpu))) - return -1; + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSIO= N)) + return 0; + + /* nothing to do if only topology part of CPU def is used */ + if (vm->def->cpu->mode =3D=3D VIR_CPU_MODE_CUSTOM && !vm->def->cpu->mo= del) + return 0; + + VIR_DEBUG("Replacing CPU definition"); =20 - VIR_DEBUG("Replacing CPU def with the updated one"); + *origCPU =3D g_steal_pointer(&vm->def->cpu); =20 - *origCPU =3D vm->def->cpu; - vm->def->cpu =3D cpu; + if (cpu) + vm->def->cpu =3D virCPUDefCopy(cpu); + else + vm->def->cpu =3D virCPUDefCopy(*origCPU); =20 return 0; } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index e4bcb628cf..f3e295ccf0 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4437,8 +4437,6 @@ qemuProcessUpdateLiveGuestCPU(virDomainObj *vm, virCPUData *disabled) { virDomainDef *def =3D vm->def; - qemuDomainObjPrivate *priv =3D vm->privateData; - g_autoptr(virCPUDef) orig =3D NULL; int rc; =20 if (!enabled) @@ -4449,19 +4447,11 @@ qemuProcessUpdateLiveGuestCPU(virDomainObj *vm, !def->cpu->model)) return 0; =20 - orig =3D virCPUDefCopy(def->cpu); - - if ((rc =3D virCPUUpdateLive(def->os.arch, def->cpu, enabled, disabled= )) < 0) { + if ((rc =3D virCPUUpdateLive(def->os.arch, def->cpu, enabled, disabled= )) < 0) return -1; - } else if (rc =3D=3D 0) { - /* Store the original CPU in priv if QEMU changed it and we didn't - * get the original CPU via migration, restore, or snapshot revert. - */ - if (!priv->origCPU && !virCPUDefIsEqual(def->cpu, orig, false)) - priv->origCPU =3D g_steal_pointer(&orig); =20 + if (rc =3D=3D 0) def->cpu->check =3D VIR_CPU_CHECK_FULL; - } =20 return 0; } @@ -9147,6 +9137,11 @@ qemuProcessReconnect(void *opaque) =20 qemuDomainVcpuPersistOrder(obj->def); =20 + /* Make sure priv->origCPU is always set. */ + if (!priv->origCPU && + qemuDomainUpdateCPU(obj, NULL, &priv->origCPU) < 0) + goto error; + if (qemuProcessRefreshCPU(driver, obj) < 0) goto error; =20 --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sun May 19 03:12:55 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) 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 1713357523173877.3083543257684; Wed, 17 Apr 2024 05:38:43 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1A4551C90; Wed, 17 Apr 2024 08:38:42 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 24B4C1C05; Wed, 17 Apr 2024 08:36:56 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id EF2F41C35; Wed, 17 Apr 2024 08:36:49 -0400 (EDT) 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 18C3C1C2F for ; Wed, 17 Apr 2024 08:36:34 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-78-DU7X8rgrMNe0RP5IgvfunQ-1; Wed, 17 Apr 2024 08:36:32 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id BD65180021B for ; Wed, 17 Apr 2024 12:36:31 +0000 (UTC) Received: from orkuz (unknown [10.45.224.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 54B7A492BC7 for ; Wed, 17 Apr 2024 12:36:31 +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.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: DU7X8rgrMNe0RP5IgvfunQ-1 From: Jiri Denemark To: devel@lists.libvirt.org Subject: [PATCH v2 2/4] NEWS: Mention migration bug with custom XML Date: Wed, 17 Apr 2024 14:36:09 +0200 Message-ID: <4a7ed2d732c4c4c1674e87795a2cc37aef43099e.1713357265.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: 3SI47C6VX2CI2IKRGB5Q4P5M5IBJLUER X-Message-ID-Hash: 3SI47C6VX2CI2IKRGB5Q4P5M5IBJLUER X-MailFrom: jdenemar@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: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1713357524231100001 Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- NEWS.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index c108e66f46..852dadf532 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -21,6 +21,14 @@ v10.3.0 (unreleased) =20 * **Bug fixes** =20 + * qemu: Fix migration with custom XML + + Libvirt 10.2.0 would sometimes complain about incompatible CPU definit= ion + when trying to migrate or save a domain and passing a custom XML even + though such XML was properly generated as migratable. Hitting this bug + depends on the guest CPU definition and the host on which a particular + domain was running. + =20 v10.2.0 (2024-04-02) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sun May 19 03:12:55 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) 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 1713357561112240.74691805896134; Wed, 17 Apr 2024 05:39:21 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 0F6B01B23; Wed, 17 Apr 2024 08:39:20 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 2E39A1C44; Wed, 17 Apr 2024 08:37:02 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id C18311C4C; Wed, 17 Apr 2024 08:36:55 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 BC5B61B6E for ; Wed, 17 Apr 2024 08:36:39 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-131-igP_ntaXOnqGuuXjX3uvVg-1; Wed, 17 Apr 2024 08:36:37 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id ADDA929AC021 for ; Wed, 17 Apr 2024 12:36:37 +0000 (UTC) Received: from orkuz (unknown [10.45.224.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46687C13FA8 for ; Wed, 17 Apr 2024 12:36:37 +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.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: igP_ntaXOnqGuuXjX3uvVg-1 From: Jiri Denemark To: devel@lists.libvirt.org Subject: [PATCH v2 3/4] qemu: Change return type of qemuDomainUpdateCPU to void Date: Wed, 17 Apr 2024 14:36:10 +0200 Message-ID: <47cb1a38e061c9db9274e40eb6b8c82f176270aa.1713357265.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: PHCCYJAD2L3S6DY33BIS6Z2G2MW67FMI X-Message-ID-Hash: PHCCYJAD2L3S6DY33BIS6Z2G2MW67FMI X-MailFrom: jdenemar@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: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1713357562374100001 The function never fails. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- src/qemu/qemu_domain.c | 12 ++++-------- src/qemu/qemu_domain.h | 2 +- src/qemu/qemu_process.c | 8 +++----- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d91c7d478b..3dfabfda2f 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11002,10 +11002,8 @@ virSaveCookieCallbacks virQEMUDriverDomainSaveCook= ie =3D { * for. The domain definition will either contain a copy of the original C= PU * definition or a copy of @cpu in case the domain was already running and * we're just restoring a saved state or preparing for incoming migration. - * - * Returns 0 on success, -1 on error. */ -int +void qemuDomainUpdateCPU(virDomainObj *vm, virCPUDef *cpu, virCPUDef **origCPU) @@ -11015,14 +11013,14 @@ qemuDomainUpdateCPU(virDomainObj *vm, *origCPU =3D NULL; =20 if (!vm->def->cpu) - return 0; + return; =20 if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSIO= N)) - return 0; + return; =20 /* nothing to do if only topology part of CPU def is used */ if (vm->def->cpu->mode =3D=3D VIR_CPU_MODE_CUSTOM && !vm->def->cpu->mo= del) - return 0; + return; =20 VIR_DEBUG("Replacing CPU definition"); =20 @@ -11032,8 +11030,6 @@ qemuDomainUpdateCPU(virDomainObj *vm, vm->def->cpu =3D virCPUDefCopy(cpu); else vm->def->cpu =3D virCPUDefCopy(*origCPU); - - return 0; } =20 =20 diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index bd37cb245a..264817eef9 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -980,7 +980,7 @@ virStorageSource *qemuDomainGetStorageSourceByDevstr(co= nst char *devstr, virDomainDef *def, virDomainBackupDef = *backupdef); =20 -int +void qemuDomainUpdateCPU(virDomainObj *vm, virCPUDef *cpu, virCPUDef **origCPU); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f3e295ccf0..7fdb9ac23a 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5674,8 +5674,7 @@ qemuProcessInit(virQEMUDriver *driver, if (qemuProcessPrepareQEMUCaps(vm, driver->qemuCapsCache) < 0) return -1; =20 - if (qemuDomainUpdateCPU(vm, updatedCPU, &origCPU) < 0) - return -1; + qemuDomainUpdateCPU(vm, updatedCPU, &origCPU); =20 if (qemuProcessStartValidate(driver, vm, priv->qemuCaps, flags) < 0) return -1; @@ -9138,9 +9137,8 @@ qemuProcessReconnect(void *opaque) qemuDomainVcpuPersistOrder(obj->def); =20 /* Make sure priv->origCPU is always set. */ - if (!priv->origCPU && - qemuDomainUpdateCPU(obj, NULL, &priv->origCPU) < 0) - goto error; + if (!priv->origCPU) + qemuDomainUpdateCPU(obj, NULL, &priv->origCPU); =20 if (qemuProcessRefreshCPU(driver, obj) < 0) goto error; --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sun May 19 03:12:55 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) 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 1713357598941937.2845597732547; Wed, 17 Apr 2024 05:39:58 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id DC1C1179C; Wed, 17 Apr 2024 08:39:57 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 691D11C5C; Wed, 17 Apr 2024 08:37:42 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id DE65A1C27; Wed, 17 Apr 2024 08:37:36 -0400 (EDT) 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 D7D5B1C6B for ; Wed, 17 Apr 2024 08:36:52 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-96-ynv4V_PhPt-7FV858Ne19A-1; Wed, 17 Apr 2024 08:36:50 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 64532806602 for ; Wed, 17 Apr 2024 12:36:50 +0000 (UTC) Received: from orkuz (unknown [10.45.224.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id F074618209F for ; Wed, 17 Apr 2024 12:36: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.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: ynv4V_PhPt-7FV858Ne19A-1 From: Jiri Denemark To: devel@lists.libvirt.org Subject: [PATCH v2 4/4] qemu: Change return type of qemuDomainFixupCPUs to void Date: Wed, 17 Apr 2024 14:36:11 +0200 Message-ID: <2b5c50ec2cc6cb64b62144166053c2fcc82219a4.1713357265.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: PG4T2WPCXDREF5LIVLKZKEHGC422HIK3 X-Message-ID-Hash: PG4T2WPCXDREF5LIVLKZKEHGC422HIK3 X-MailFrom: jdenemar@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: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1713357600457100001 The function never fails. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- Notes: Version 2: - virCPUDefCopy never returns NULL - do not remove !*origCPU check in qemuDomainFixupCPUs - make sure origCPU is set when reconnecting to running domains src/qemu/qemu_domain.c | 12 ++++-------- src/qemu/qemu_domain.h | 2 +- src/qemu/qemu_process.c | 8 +++----- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 3dfabfda2f..3469f0d40c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11050,29 +11050,27 @@ qemuDomainUpdateCPU(virDomainObj *vm, * * This function can only be used on an active domain or when restoring a * domain which was running. - * - * Returns 0 on success, -1 on error. */ -int +void qemuDomainFixupCPUs(virDomainObj *vm, virCPUDef **origCPU) { virArch arch =3D vm->def->os.arch; =20 if (!ARCH_IS_X86(arch)) - return 0; + return; =20 if (!vm->def->cpu || vm->def->cpu->mode !=3D VIR_CPU_MODE_CUSTOM || !vm->def->cpu->model) - return 0; + return; =20 /* Missing origCPU means QEMU created exactly the same virtual CPU whi= ch * we asked for or libvirt was too old to mess up the translation from * host-model. */ if (!*origCPU) - return 0; + return; =20 if (virCPUDefFindFeature(vm->def->cpu, "cmt")) { g_autoptr(virCPUDef) fixedCPU =3D virCPUDefCopyWithoutModel(vm->de= f->cpu); @@ -11093,8 +11091,6 @@ qemuDomainFixupCPUs(virDomainObj *vm, virCPUDefFree(*origCPU); *origCPU =3D g_steal_pointer(&fixedOrig); } - - return 0; } =20 =20 diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 264817eef9..a3089ea449 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -985,7 +985,7 @@ qemuDomainUpdateCPU(virDomainObj *vm, virCPUDef *cpu, virCPUDef **origCPU); =20 -int +void qemuDomainFixupCPUs(virDomainObj *vm, virCPUDef **origCPU); =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 7fdb9ac23a..686f6ed6c1 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8278,9 +8278,8 @@ qemuProcessStartWithMemoryState(virConnectPtr conn, /* No cookie means libvirt which saved the domain was too old to mess = up * the CPU definitions. */ - if (cookie && - qemuDomainFixupCPUs(vm, &cookie->cpu) < 0) - return -1; + if (cookie) + qemuDomainFixupCPUs(vm, &cookie->cpu); =20 if (cookie && !cookie->slirpHelper) priv->disableSlirp =3D true; @@ -8926,8 +8925,7 @@ qemuProcessRefreshCPU(virQEMUDriver *driver, * case the host-model is known to not contain features which QEMU * doesn't know about. */ - if (qemuDomainFixupCPUs(vm, &priv->origCPU) < 0) - return -1; + qemuDomainFixupCPUs(vm, &priv->origCPU); } =20 return 0; --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org