From nobody Sun Dec 22 02:02:42 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 1733994811187853.3761660784552; Thu, 12 Dec 2024 01:13:31 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 05B1E123F; Thu, 12 Dec 2024 04:13:29 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A06D511C1; Thu, 12 Dec 2024 04:13:13 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 1E1E411B4; Thu, 12 Dec 2024 04:13:10 -0500 (EST) 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 920CE11AC for ; Thu, 12 Dec 2024 04:13:09 -0500 (EST) Received: from mx-prod-mc-02.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-463-eVQ4BEUmP9a3A9cZ5ydyFw-1; Thu, 12 Dec 2024 04:13:06 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 947AA1956070 for ; Thu, 12 Dec 2024 09:13:05 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.3.236]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EAB5A30044C1 for ; Thu, 12 Dec 2024 09:13:04 +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_H2,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=1733994789; 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=0PzLXHZsxvFL1OSECg+AgqOZ+Sqy8+EnXVcAmbTtI48=; b=IzwXMkLY2vrM4dM5OfGBubn1jrzjwgg8KR3+To/MFl8ghOwpBkL15Aa5lqn8jaLcagySVj re8sH42533f1mGDw5N/mReOMRlmb96aJjanjRvuuhzaH/XZXa0gPMZvjq4j3ooZuAxQ/HA TCXXOJbShFgPvXVxf8Kyg8a+nNgUbi4= X-MC-Unique: eVQ4BEUmP9a3A9cZ5ydyFw-1 X-Mimecast-MFC-AGG-ID: eVQ4BEUmP9a3A9cZ5ydyFw From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH] qemu: Grab a QUERY job when formatting domain XML Date: Thu, 12 Dec 2024 10:13:02 +0100 Message-ID: <74f199df7032f8dd6658921873138cf5844463e9.1733994782.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: tAX2_Qjf_QG5MEpuSzL_mjcvu0TsWYYarFWZTJYHoxc_1733994785 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: F3SZDIHZDKIQ2SD7AT3JI2OMDEJYYEFA X-Message-ID-Hash: F3SZDIHZDKIQ2SD7AT3JI2OMDEJYYEFA X-MailFrom: mprivozn@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: 1733994811862116600 Content-Type: text/plain; charset="utf-8"; x-default="true" It may happen that, for instance after daemon restart, that one thread is still in qemuProcessReconnect(), i.e. filling in runtime information by talking to QEMU on monitor. If another thread then tries to format domain XML (which is currently guarded by plain mutex on virDomainObj) it'll produce incomplete and misleading information (e.g. current size of virtio-mem). This happens because the reconnecting thread talks to QEMU on monitor and thus unlocks the domain object frequently allowing the XML formatting thread to acquire the mutex meanwhile. Resolves: https://issues.redhat.com/browse/RHEL-71042 Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 09f7edda7d..f1a633fdd3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6163,6 +6163,9 @@ static char if (virDomainGetXMLDescEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; =20 + if (virDomainObjBeginJob(vm, VIR_JOB_QUERY) < 0) + goto cleanup; + qemuDomainUpdateCurrentMemorySize(vm); =20 if ((flags & VIR_DOMAIN_XML_MIGRATABLE)) @@ -6177,6 +6180,8 @@ static char =20 ret =3D qemuDomainFormatXML(driver, vm, flags); =20 + virDomainObjEndJob(vm); + cleanup: virDomainObjEndAPI(&vm); return ret; --=20 2.45.2