From nobody Sun May 5 00:04:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 158048181242784.08420045631817; Fri, 31 Jan 2020 06:43:32 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-30-zy42xyVnMWCUjaj9w_WAHw-1; Fri, 31 Jan 2020 09:43:28 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 03B001882CCC; Fri, 31 Jan 2020 14:43:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6C9217794B; Fri, 31 Jan 2020 14:43:22 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9C73B18034E9; Fri, 31 Jan 2020 14:43:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00VEhKQP020642 for ; Fri, 31 Jan 2020 09:43:20 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3BC965DA8C; Fri, 31 Jan 2020 14:43:20 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.43.2.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id B8C8F5DA81 for ; Fri, 31 Jan 2020 14:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580481811; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=GGBEXMVZs8oFPRUAJYLCwiFUdlbgxwjAkqN8buWVrLk=; b=RHh6tewn8CtRRf8vap2lN9wEY5E8pkcH93lq/U/sXXCHOmJRhRTblDovNEVTROcXQaRC6i CLdPhKJNEdYMAW6AuGXVTG2C3apjbnlQOnx6lbPyR2HqJA+b8tStKOWJGeompZIXvJtSdH cSq6FaEtYj6hq1ge/V95rC7/lgWzOk4= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH] qemu: Fix domain ID allocation Date: Fri, 31 Jan 2020 15:43:14 +0100 Message-Id: <3e52cadaebd1cc6614da09600c19c7cba32d97a2.1580481540.git.jtomko@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: zy42xyVnMWCUjaj9w_WAHw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The rewrite to use GLib's atomic ops functions changed the behavior of virAtomicIntInc - before it returned the pre-increment value. Most of the callers using its value were adjusted, but the one in qemuDriverAllocateID was not. If libvirtd would reconnect to a running domain during startup, the next started domain would get the same ID: $ virsh list Id Name State Reviewed-by: Peter Krempa -------------------------- 1 f28live running 1 f28live1 running Use the g_atomic_add function directly (as recommended in viratomic.h) and add 1 to the result. This also restores the usual numbering from 1 instead of 0. Signed-off-by: J=C3=A1n Tomko Fixes: 7b9645a7d127a374b8d1c83fdf9789706dbab2c9 --- src/qemu/qemu_conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index e5051027fc..0b119cbe78 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1858,7 +1858,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) =20 int qemuDriverAllocateID(virQEMUDriverPtr driver) { - return virAtomicIntInc(&driver->lastvmid); + return g_atomic_int_add(&driver->lastvmid, 1) + 1; } =20 =20 --=20 2.21.0