From nobody Fri May 3 12:05:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616609015; cv=none; d=zohomail.com; s=zohoarc; b=Kvq04CbHDgZM5KZ3f07ru5Ikv2SQyW36vvW952iU3okgDsGCgMiq86XrFGWxFh85GuQRCAM6Jli4LbfyUNEevlnY55jomlTf4RILfx2hBQzovHS1k3vque0kJLYiHGfIdo7Q/K9rh8ZqeuS33OZnik2LYnY9MWLAQym6UtciPXg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616609015; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=l3cL6XqfBeq8GnTubDm+ZdqKo6CAD5Qtuk+Aeq2emaE=; b=lu7RuxBidL63WGHvLCDj7fnme5ICIg6/jczQ2hPIUYT20niobwoi4g3AKlAOx2MgH4PUs2G1VZ1C4TyvKKrK2zFign0d7N8eNLAqUgK3farFXJNmJlH8uJ34bRs4Gx4PnUQuqs5Ao4OUR3mlMkwnUGNcsuboGKv7FLOaakOMvcc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 161660901506869.22278222041678; Wed, 24 Mar 2021 11:03:35 -0700 (PDT) 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-367-0bBI3Ld8NOGF7lJYCOQyPg-1; Wed, 24 Mar 2021 14:03:27 -0400 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 9B0A484B9A2; Wed, 24 Mar 2021 18:03:20 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 693C462953; Wed, 24 Mar 2021 18:03:20 +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 0B7EA4A7CA; Wed, 24 Mar 2021 18:03:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12OI1saS012425 for ; Wed, 24 Mar 2021 14:01:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id E60B11002EE6; Wed, 24 Mar 2021 18:01:54 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.145]) by smtp.corp.redhat.com (Postfix) with ESMTP id 657DD10023B0 for ; Wed, 24 Mar 2021 18:01:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616609010; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=l3cL6XqfBeq8GnTubDm+ZdqKo6CAD5Qtuk+Aeq2emaE=; b=B6IbdrBnigzeBfqG177aIm4LBKTLo9LSKlgZcw5lXSTXtUqIIOfMg2erG1yWNCwlzUCb9p AeJQIF60/vrJd/Xk81eJkp5l96Pe04Qcr9EkkoeKiWTZtmBB1WO6eVmRULUnBCghX/Xtnb anLTutEaKGV8BnBXwYti2CSdNfUiW+k= X-MC-Unique: 0bBI3Ld8NOGF7lJYCOQyPg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/2] virnetsocket: Revert part of g_steal_pointer() rewrite Date: Wed, 24 Mar 2021 19:01:48 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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" Turns out, the way that glib implements g_steal_pointer() is not compatible with function callbacks. And that's what my recent patch did in virNetSocketEventFree(). Revert that part. Signed-off-by: Michal Privoznik --- src/rpc/virnetsocket.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index 5675c0769d..b1f47636d1 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -2156,9 +2156,10 @@ static void virNetSocketEventFree(void *opaque) void *eopaque; =20 virObjectLock(sock); - ff =3D g_steal_pointer(&sock->ff); + ff =3D sock->ff; eopaque =3D g_steal_pointer(&sock->opaque); sock->func =3D NULL; + sock->ff =3D NULL; virObjectUnlock(sock); =20 if (ff) --=20 2.26.2 From nobody Fri May 3 12:05:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616609017; cv=none; d=zohomail.com; s=zohoarc; b=MO/uwguWZFBbSd38VKzWukv9GcPldmN66aJrpgPLF8IidPLlpl2dFoBcHaaKyFKr7l9I1se3Ofd9GVNCtdCSsP2/1T0wX/A+BeNkJC48d9k2sWhPV0bX42OSEDiQ5zOm9ZkczjGjtwytbw6LRbmIoOoVcE5rECWGVK3JcAFdFkw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616609017; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kAJ8718a8DQRA1hMzDDnxN4mi7Z4IKW8ekS0GpNJQE0=; b=TdX23TJqDRRvwStmu7Q1k4+s4z1OwKaTPWO+iVnJCmiTw9KCRqj0WHnK2Z+B73n9Q7qMC8kCkyJcN8W1XZKnRVXMgGTHu8Fcwd/6PxOOJJT4PH7FTk0zKtY1Lu1JVuUGeLijAdMlKGKVCjTvZne/K3OaXu4U1hzTH2GxbLiTbMU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1616609017719647.427584759103; Wed, 24 Mar 2021 11:03:37 -0700 (PDT) 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-146-X26fJDJaNKSvwoO_0-E54A-1; Wed, 24 Mar 2021 14:03:33 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4DD1A81626; Wed, 24 Mar 2021 18:03:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 24F1C866D4; Wed, 24 Mar 2021 18:03:27 +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 D23FF4BB7C; Wed, 24 Mar 2021 18:03:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12OI1tdL012434 for ; Wed, 24 Mar 2021 14:01:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id EF5D01002EE6; Wed, 24 Mar 2021 18:01:55 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.145]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4590110023B0 for ; Wed, 24 Mar 2021 18:01:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616609016; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=kAJ8718a8DQRA1hMzDDnxN4mi7Z4IKW8ekS0GpNJQE0=; b=ARukHBIFpQAgbolXTXf1uin10UbQzWKk6Br2oOOPR0QIW/J7rkki9a4RdyO2fJDbvQmHh3 667cmNmmebSyR41nvMb+Hbx8clCgjSwmZhcJZXGAwMQe4olmQpW2sdfIiIgYlZ83teswWn xCb8rOEiZFiqyRfvT+sfDD9yRzXziCM= X-MC-Unique: X26fJDJaNKSvwoO_0-E54A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/2] lib: Undo some g_steal_pointer() changes Date: Wed, 24 Mar 2021 19:01:49 +0100 Message-Id: <6e14d3007c3fd6e0278bca712ecbb7746e883ad4.1616608792.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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" Recently, a few commits back I've switched bunch of code to g_steal_pointer() using coccinelle. Problem was that the semantic patch used was slightly off: @@ expression a, b; @@ + b =3D g_steal_pointer(&a); - b =3D a; ... when !=3D a - a =3D NULL; Problem is that, "... when !=3D a" is supposed to jump over those lines, which don't contain expression a. My idea was to replace the following pattern too: ptrX =3D ptrY; if (something(ptrZ) < 0) goto error; ptrY =3D NULL; But what I missed is that the following pattern is also matched and replaced: ptrX =3D ptrY; if (something(ptrX) < 0) goto error; ptrY =3D NULL; This is not necessarily correct - as demonstrated by our hotplug code. The real problem is ambiguous memory ownership transfer (functions which add device to domain def take ownership only on success), but to not tackle the real issue let's revert those parts. Signed-off-by: Michal Privoznik --- src/libxl/libxl_driver.c | 9 ++++++--- src/lxc/lxc_driver.c | 12 ++++++++---- src/qemu/qemu_driver.c | 36 ++++++++++++++++++++++++------------ 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 23ef55cf37..5afae01a92 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -3529,7 +3529,7 @@ libxlDomainAttachDeviceConfig(virDomainDefPtr vmdef, = virDomainDeviceDefPtr dev) =20 switch (dev->type) { case VIR_DOMAIN_DEVICE_DISK: - disk =3D g_steal_pointer(&dev->data.disk); + disk =3D dev->data.disk; if (virDomainDiskIndexByName(vmdef, disk->dst, true) >=3D 0) { virReportError(VIR_ERR_INVALID_ARG, _("target %s already exists."), disk->dst); @@ -3537,10 +3537,11 @@ libxlDomainAttachDeviceConfig(virDomainDefPtr vmdef= , virDomainDeviceDefPtr dev) } virDomainDiskInsert(vmdef, disk); /* vmdef has the pointer. Generic codes for vmdef will do all = jobs */ + dev->data.disk =3D NULL; break; =20 case VIR_DOMAIN_DEVICE_CONTROLLER: - controller =3D g_steal_pointer(&dev->data.controller); + controller =3D dev->data.controller; if (controller->idx !=3D -1 && virDomainControllerFind(vmdef, controller->type, controller->idx) >=3D 0) { @@ -3550,10 +3551,11 @@ libxlDomainAttachDeviceConfig(virDomainDefPtr vmdef= , virDomainDeviceDefPtr dev) } =20 virDomainControllerInsert(vmdef, controller); + dev->data.controller =3D NULL; break; =20 case VIR_DOMAIN_DEVICE_NET: - net =3D g_steal_pointer(&dev->data.net); + net =3D dev->data.net; if (virDomainHasNet(vmdef, net)) { virReportError(VIR_ERR_INVALID_ARG, _("network device with mac %s already exist= s"), @@ -3562,6 +3564,7 @@ libxlDomainAttachDeviceConfig(virDomainDefPtr vmdef, = virDomainDeviceDefPtr dev) } if (virDomainNetInsert(vmdef, net)) return -1; + dev->data.net =3D NULL; break; =20 case VIR_DOMAIN_DEVICE_HOSTDEV: diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 3fc15ff2ec..8e0ec82e0b 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -3041,7 +3041,7 @@ lxcDomainAttachDeviceConfig(virDomainDefPtr vmdef, =20 switch (dev->type) { case VIR_DOMAIN_DEVICE_DISK: - disk =3D g_steal_pointer(&dev->data.disk); + disk =3D dev->data.disk; if (virDomainDiskIndexByName(vmdef, disk->dst, true) >=3D 0) { virReportError(VIR_ERR_INVALID_ARG, _("target %s already exists."), disk->dst); @@ -3049,18 +3049,20 @@ lxcDomainAttachDeviceConfig(virDomainDefPtr vmdef, } virDomainDiskInsert(vmdef, disk); /* vmdef has the pointer. Generic codes for vmdef will do all jobs= */ + dev->data.disk =3D NULL; ret =3D 0; break; =20 case VIR_DOMAIN_DEVICE_NET: - net =3D g_steal_pointer(&dev->data.net); + net =3D dev->data.net; if (virDomainNetInsert(vmdef, net) < 0) return -1; + dev->data.net =3D NULL; ret =3D 0; break; =20 case VIR_DOMAIN_DEVICE_HOSTDEV: - hostdev =3D g_steal_pointer(&dev->data.hostdev); + hostdev =3D dev->data.hostdev; if (virDomainHostdevFind(vmdef, hostdev, NULL) >=3D 0) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("device is already in the domain configuratio= n")); @@ -3068,6 +3070,7 @@ lxcDomainAttachDeviceConfig(virDomainDefPtr vmdef, } if (virDomainHostdevInsert(vmdef, hostdev) < 0) return -1; + dev->data.hostdev =3D NULL; ret =3D 0; break; =20 @@ -3092,7 +3095,7 @@ lxcDomainUpdateDeviceConfig(virDomainDefPtr vmdef, =20 switch (dev->type) { case VIR_DOMAIN_DEVICE_NET: - net =3D g_steal_pointer(&dev->data.net); + net =3D dev->data.net; if ((idx =3D virDomainNetFindIdx(vmdef, net)) < 0) return -1; =20 @@ -3106,6 +3109,7 @@ lxcDomainUpdateDeviceConfig(virDomainDefPtr vmdef, return -1; =20 virDomainNetDefFree(oldDev.data.net); + dev->data.net =3D NULL; ret =3D 0; =20 break; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b31be76f91..f3f8caab44 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7238,7 +7238,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, =20 switch ((virDomainDeviceType)dev->type) { case VIR_DOMAIN_DEVICE_DISK: - disk =3D g_steal_pointer(&dev->data.disk); + disk =3D dev->data.disk; if (virDomainDiskIndexByName(vmdef, disk->dst, true) >=3D 0) { virReportError(VIR_ERR_OPERATION_INVALID, _("target %s already exists"), disk->dst); @@ -7250,22 +7250,25 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, return -1; virDomainDiskInsert(vmdef, disk); /* vmdef has the pointer. Generic codes for vmdef will do all jobs= */ + dev->data.disk =3D NULL; break; =20 case VIR_DOMAIN_DEVICE_NET: - net =3D g_steal_pointer(&dev->data.net); + net =3D dev->data.net; if (virDomainNetInsert(vmdef, net)) return -1; + dev->data.net =3D NULL; break; =20 case VIR_DOMAIN_DEVICE_SOUND: - sound =3D g_steal_pointer(&dev->data.sound); + sound =3D dev->data.sound; if (VIR_APPEND_ELEMENT(vmdef->sounds, vmdef->nsounds, sound) < 0) return -1; + dev->data.sound =3D NULL; break; =20 case VIR_DOMAIN_DEVICE_HOSTDEV: - hostdev =3D g_steal_pointer(&dev->data.hostdev); + hostdev =3D dev->data.hostdev; if (virDomainHostdevFind(vmdef, hostdev, NULL) >=3D 0) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("device is already in the domain configuratio= n")); @@ -7273,10 +7276,11 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, } if (virDomainHostdevInsert(vmdef, hostdev)) return -1; + dev->data.hostdev =3D NULL; break; =20 case VIR_DOMAIN_DEVICE_LEASE: - lease =3D g_steal_pointer(&dev->data.lease); + lease =3D dev->data.lease; if (virDomainLeaseIndex(vmdef, lease) >=3D 0) { virReportError(VIR_ERR_OPERATION_INVALID, _("Lease %s in lockspace %s already exists"), @@ -7286,10 +7290,11 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, virDomainLeaseInsert(vmdef, lease); =20 /* vmdef has the pointer. Generic codes for vmdef will do all jobs= */ + dev->data.lease =3D NULL; break; =20 case VIR_DOMAIN_DEVICE_CONTROLLER: - controller =3D g_steal_pointer(&dev->data.controller); + controller =3D dev->data.controller; if (controller->idx !=3D -1 && virDomainControllerFind(vmdef, controller->type, controller->idx) >=3D 0) { @@ -7300,6 +7305,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, } =20 virDomainControllerInsert(vmdef, controller); + dev->data.controller =3D NULL; =20 break; =20 @@ -7310,7 +7316,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, break; =20 case VIR_DOMAIN_DEVICE_FS: - fs =3D g_steal_pointer(&dev->data.fs); + fs =3D dev->data.fs; if (virDomainFSIndexByName(vmdef, fs->dst) >=3D 0) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Target already exists")); @@ -7319,6 +7325,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, =20 if (virDomainFSInsert(vmdef, fs) < 0) return -1; + dev->data.fs =3D NULL; break; =20 case VIR_DOMAIN_DEVICE_RNG: @@ -7350,14 +7357,15 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, break; =20 case VIR_DOMAIN_DEVICE_REDIRDEV: - redirdev =3D g_steal_pointer(&dev->data.redirdev); + redirdev =3D dev->data.redirdev; =20 if (VIR_APPEND_ELEMENT(vmdef->redirdevs, vmdef->nredirdevs, redird= ev) < 0) return -1; + dev->data.redirdev =3D NULL; break; =20 case VIR_DOMAIN_DEVICE_SHMEM: - shmem =3D g_steal_pointer(&dev->data.shmem); + shmem =3D dev->data.shmem; if (virDomainShmemDefFind(vmdef, shmem) >=3D 0) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("device is already in the domain configuratio= n")); @@ -7365,6 +7373,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, } if (virDomainShmemDefInsert(vmdef, shmem) < 0) return -1; + dev->data.shmem =3D NULL; break; =20 case VIR_DOMAIN_DEVICE_WATCHDOG: @@ -7636,7 +7645,7 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef, =20 switch ((virDomainDeviceType)dev->type) { case VIR_DOMAIN_DEVICE_DISK: - newDisk =3D g_steal_pointer(&dev->data.disk); + newDisk =3D dev->data.disk; if ((pos =3D virDomainDiskIndexByName(vmdef, newDisk->dst, false))= < 0) { virReportError(VIR_ERR_INVALID_ARG, _("target %s doesn't exist."), newDisk->dst); @@ -7651,10 +7660,11 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef, =20 virDomainDiskDefFree(vmdef->disks[pos]); vmdef->disks[pos] =3D newDisk; + dev->data.disk =3D NULL; break; =20 case VIR_DOMAIN_DEVICE_GRAPHICS: - newGraphics =3D g_steal_pointer(&dev->data.graphics); + newGraphics =3D dev->data.graphics; pos =3D qemuDomainFindGraphicsIndex(vmdef, newGraphics); if (pos < 0) { virReportError(VIR_ERR_INVALID_ARG, @@ -7671,10 +7681,11 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef, =20 virDomainGraphicsDefFree(vmdef->graphics[pos]); vmdef->graphics[pos] =3D newGraphics; + dev->data.graphics =3D NULL; break; =20 case VIR_DOMAIN_DEVICE_NET: - net =3D g_steal_pointer(&dev->data.net); + net =3D dev->data.net; if ((pos =3D virDomainNetFindIdx(vmdef, net)) < 0) return -1; =20 @@ -7688,6 +7699,7 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef, return -1; =20 virDomainNetDefFree(oldDev.data.net); + dev->data.net =3D NULL; break; =20 case VIR_DOMAIN_DEVICE_FS: --=20 2.26.2