From nobody Sat Feb 7 06:16:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; 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 207.211.31.81 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=1578913131; cv=none; d=zohomail.com; s=zohoarc; b=Dz/gt9F8q2DwFr2Tlnb5sue+SPTxctzyeW1XqtM1KAHvVoyNkFWWCIMKzDVOavG4eG+/ieoRNtEwOEaw+1qrA249yNR3Z+lJG1fRJ31ffpyT3moJw2eNO8OvJNBuEOkBbZH4y6KBdPjdJA0XhIQzOvaB4nLNINSLcwrxRO+J82k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578913131; 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=3ehPqEM25RVzTOwFGdSsVKVXgvg6IuHU6VR9dBKSwyc=; b=anx4Fatq0xT4logRgJ4Qia5J5FaRJhtt2w7OUMfq/bHwkn3Rw8U++6PFNHf6cuzS3IQF/9EaZv54LtzMgyus2svbTOSIoAAPR5omngW1vsUjQDW14MWXYqPnZn2wFxAFuJIiXtB1c+RUaiCz/l7BvUIsemoMxpFMgGXvPTfC0qM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1578913131358425.5085542699459; Mon, 13 Jan 2020 02:58:51 -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-317-0EaWN9NjNlGhqsQLR5x0mg-1; Mon, 13 Jan 2020 05:58:48 -0500 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 918141800D78; Mon, 13 Jan 2020 10:58:43 +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 3BD0260BF4; Mon, 13 Jan 2020 10:58:43 +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 48C8018089CD; Mon, 13 Jan 2020 10:58:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00DAwfC1005252 for ; Mon, 13 Jan 2020 05:58:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id 53B1160BF4; Mon, 13 Jan 2020 10:58:41 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0A3960BE2 for ; Mon, 13 Jan 2020 10:58:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578913130; 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=3ehPqEM25RVzTOwFGdSsVKVXgvg6IuHU6VR9dBKSwyc=; b=c9AQRUhJj2EiVo0Tt5U/eil5aG3EEJ9rAgy2pehsHSBXKFe/nf9CugNGDhdZ5bp0d0beDA krfSZ17F4HXWFMrqM45JYFUTN1k+Ts3P7jWkXx7MSfgh6Xo1227XOJw+E0Osyhvx7qsQNJ PafeXBB3O9C0vCPbR5tHoLK41bQ6ZQ0= From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 13 Jan 2020 11:58:33 +0100 Message-Id: <4e8f54f118077ec86c9087d6cbe0f2512b24700f.1578912437.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/4] qemuDomainSaveImageStartVM: Use VIR_AUTOCLOSE for @intermediatefd 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 X-MC-Unique: 0EaWN9NjNlGhqsQLR5x0mg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_driver.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d6b1e9f00c..9de5bc6a32 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6803,7 +6803,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, int ret =3D -1; bool restored =3D false; virObjectEventPtr event; - int intermediatefd =3D -1; + VIR_AUTOCLOSE intermediatefd =3D -1; virCommandPtr cmd =3D NULL; g_autofree char *errbuf =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); @@ -6829,6 +6829,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, =20 if (virCommandRunAsync(cmd, NULL) < 0) { *fd =3D intermediatefd; + intermediatefd =3D -1; goto cleanup; } } @@ -6872,8 +6873,6 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, =20 virErrorRestore(&orig_err); } - VIR_FORCE_CLOSE(intermediatefd); - if (VIR_CLOSE(*fd) < 0) { virReportSystemError(errno, _("cannot close file: %s"), path); restored =3D false; --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Feb 7 06:16:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1578913133; cv=none; d=zohomail.com; s=zohoarc; b=boq46aQLfmdl7bwhm0b9vh2hZS2UeZoufiEald0szBslQqXoq5Lcx02MxktxEO+dHzYZUbchslRDGDmuFu6yAFQamu13FNUab1aIBPE3/fLQA4+S19/xDujWVL4XZ724pq4jaXJKhCVQ67dPaLq2QRDIqWg03hISLdzaLxgty0g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578913133; 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=InfOsmF/Uvp4kNJKB6DrplEW7JCvVl5JYTiJDyJerVk=; b=RnxR66kTgLhIW9a6brKL1nI+fKfhAJ/JGjZTT9/JGmAosdJtpbEyGhW40xc8EjKpLzI8Wnit6VBPhBL7L/tO2lml3h7R58zT/aGjClHP+N/ECsKPo0gLm8F1j8gXLuGtLpIt0/WKZc3pkIzFhaxg6GWoMdi+9uQcIDvnivq9Ycc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1578913133034184.62977733670743; Mon, 13 Jan 2020 02:58:53 -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-396-OBjhwCe_NtSGea990Uszug-1; Mon, 13 Jan 2020 05:58:50 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C89DE1005512; Mon, 13 Jan 2020 10:58:44 +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 A46006A846; Mon, 13 Jan 2020 10:58:44 +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 5D83F8250B; Mon, 13 Jan 2020 10:58:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00DAwgK8005259 for ; Mon, 13 Jan 2020 05:58:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id 24DE260BF4; Mon, 13 Jan 2020 10:58:42 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id A18DD60BE2 for ; Mon, 13 Jan 2020 10:58:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578913131; 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=InfOsmF/Uvp4kNJKB6DrplEW7JCvVl5JYTiJDyJerVk=; b=JwfyvU5d7RIGEMj7296i45qTFryLAzU0oim0a9CknyV8ehXLJ5P9UwEZIihUQv0pJ87PTy OP7z2boET8Q9pda3fjtP2KCvJiIuRSEKcfVTl2q1UHE4TF5U9tCEK7UoWY5VBy+u7G1PlH rNssOoh+P02ZQL7t+FbdXmzAAmpIVIk= From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 13 Jan 2020 11:58:34 +0100 Message-Id: <4eb04c80532781fd9ba808f668f9e92f7fdbd8ba.1578912437.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/4] qemuDomainSaveImageStartVM: Use g_autoptr() for virCommand 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.11 X-MC-Unique: OBjhwCe_NtSGea990Uszug-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_driver.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9de5bc6a32..e1c0550b9a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6804,7 +6804,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, bool restored =3D false; virObjectEventPtr event; VIR_AUTOCLOSE intermediatefd =3D -1; - virCommandPtr cmd =3D NULL; + g_autoptr(virCommand) cmd =3D NULL; g_autofree char *errbuf =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); virQEMUSaveHeaderPtr header =3D &data->header; @@ -6920,7 +6920,6 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, =20 cleanup: virObjectUnref(cookie); - virCommandFree(cmd); if (qemuSecurityRestoreSavedStateLabel(driver, vm, path) < 0) VIR_WARN("failed to restore save state label on %s", path); return ret; --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Feb 7 06:16:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1578913140; cv=none; d=zohomail.com; s=zohoarc; b=XRGAhQT1XZ5r7960PPkriQqlZjkSNeZ4+hyYk/2G63+uvW/z8QrWg+PiKdIEnx9yNL04Yrt6alBvTEM43JAhLBT2JFV3xrm0C4O5hldX3RXYlsCFFyCwAH4hthbRCytnSv+fMmoUGH2/3KowyYT+Z5dc4SdCdto5D205RvqGl+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578913140; 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=KTYaOinyb5MiB8W3lFdagQEuH9HiS47hi/vMynYFkkw=; b=KNxZ7wRtTUjgNQW1KIzkirpRj4VQVgxYWFix0JCGI6Iai1lcsY26Hv189+MrhP+lYknQy8X7yOCuNLWd1qd/COpU76dxBRyj2wvfV3oAN2jtLSiLs7YK1IXlptJpFaX2PA7ryIzD3zrbgBUwfHOXs52MAtn9HVSoPCWcIkK3LoI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1578913140107480.543188328621; Mon, 13 Jan 2020 02:59:00 -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-42-CLbaWRpdM-aTI58-lKNOoA-1; Mon, 13 Jan 2020 05:58:57 -0500 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 1AD45800D4E; Mon, 13 Jan 2020 10:58:51 +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 E3F2360BF4; Mon, 13 Jan 2020 10:58:50 +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 90ED782511; Mon, 13 Jan 2020 10:58:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00DAwgVP005272 for ; Mon, 13 Jan 2020 05:58:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id EABA560BF4; Mon, 13 Jan 2020 10:58:42 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7336760BE2 for ; Mon, 13 Jan 2020 10:58:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578913138; 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=KTYaOinyb5MiB8W3lFdagQEuH9HiS47hi/vMynYFkkw=; b=Qa0h1mCklNiRtmK13Q8TkpYMe8yzSNgxF3ZdaiUNHaVeLXj7pZnwDp0ykXi+Uw3v+RJBma 4+zfScwKc+eveuSV7mM5s/z8uXRJadFT60snR/LQI7DPr7mxSqRZXw2oIsmN0l7R2K6ygP gUtJd6lB2soRuoDkRBdOxmkr2QUVmt4= From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 13 Jan 2020 11:58:35 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/4] qemu: Use g_autoptr() for qemuDomainSaveCookie 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 X-MC-Unique: CLbaWRpdM-aTI58-lKNOoA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_domain.c | 28 ++++++++++------------------ src/qemu/qemu_domain.h | 1 + src/qemu/qemu_driver.c | 6 ++---- 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 1f358544ab..3620739120 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -15997,27 +15997,23 @@ qemuDomainSaveCookiePtr qemuDomainSaveCookieNew(virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv =3D vm->privateData; - qemuDomainSaveCookiePtr cookie =3D NULL; + g_autoptr(qemuDomainSaveCookie) cookie =3D NULL; =20 if (qemuDomainInitialize() < 0) - goto error; + return NULL; =20 if (!(cookie =3D virObjectNew(qemuDomainSaveCookieClass))) - goto error; + return NULL; =20 if (priv->origCPU && !(cookie->cpu =3D virCPUDefCopy(vm->def->cpu))) - goto error; + return NULL; =20 cookie->slirpHelper =3D qemuDomainGetSlirpHelperOk(vm); =20 VIR_DEBUG("Save cookie %p, cpu=3D%p, slirpHelper=3D%d", cookie, cookie->cpu, cookie->slirpHelper); =20 - return cookie; - - error: - virObjectUnref(cookie); - return NULL; + return g_steal_pointer(&cookie); } =20 =20 @@ -16025,26 +16021,22 @@ static int qemuDomainSaveCookieParse(xmlXPathContextPtr ctxt G_GNUC_UNUSED, virObjectPtr *obj) { - qemuDomainSaveCookiePtr cookie =3D NULL; + g_autoptr(qemuDomainSaveCookie) cookie =3D NULL; =20 if (qemuDomainInitialize() < 0) - goto error; + return -1; =20 if (!(cookie =3D virObjectNew(qemuDomainSaveCookieClass))) - goto error; + return -1; =20 if (virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST, &cookie->cpu) < 0) - goto error; + return -1; =20 cookie->slirpHelper =3D virXPathBoolean("boolean(./slirpHelper)", ctxt= ) > 0; =20 - *obj =3D (virObjectPtr) cookie; + *obj =3D (virObjectPtr) g_steal_pointer(&cookie); return 0; - - error: - virObjectUnref(cookie); - return -1; } =20 =20 diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index c6afc484f6..60b80297fa 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -610,6 +610,7 @@ struct _qemuDomainSaveCookie { bool slirpHelper; }; =20 +G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuDomainSaveCookie, virObjectUnref); =20 typedef struct _qemuDomainXmlNsDef qemuDomainXmlNsDef; typedef qemuDomainXmlNsDef *qemuDomainXmlNsDefPtr; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e1c0550b9a..ce9b1772c1 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3293,7 +3293,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virObjectEventPtr event =3D NULL; qemuDomainObjPrivatePtr priv =3D vm->privateData; virQEMUSaveDataPtr data =3D NULL; - qemuDomainSaveCookiePtr cookie =3D NULL; + g_autoptr(qemuDomainSaveCookie) cookie =3D NULL; =20 if (!qemuMigrationSrcIsAllowed(driver, vm, false, 0)) goto cleanup; @@ -3399,7 +3399,6 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, qemuDomainRemoveInactiveJob(driver, vm); =20 cleanup: - virObjectUnref(cookie); virQEMUSaveDataFree(data); virObjectEventStateQueue(driver->domainEventState, event); return ret; @@ -6808,7 +6807,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, g_autofree char *errbuf =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); virQEMUSaveHeaderPtr header =3D &data->header; - qemuDomainSaveCookiePtr cookie =3D NULL; + g_autoptr(qemuDomainSaveCookie) cookie =3D NULL; =20 if (virSaveCookieParseString(data->cookie, (virObjectPtr *)&cookie, virDomainXMLOptionGetSaveCookie(driver->x= mlopt)) < 0) @@ -6919,7 +6918,6 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, ret =3D 0; =20 cleanup: - virObjectUnref(cookie); if (qemuSecurityRestoreSavedStateLabel(driver, vm, path) < 0) VIR_WARN("failed to restore save state label on %s", path); return ret; --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Feb 7 06:16:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1578913144; cv=none; d=zohomail.com; s=zohoarc; b=nnD0Dsw+f0At8eJSpBdi7nM4brcrTUZVzUmZQFOUX5ThecH9T4kR1jyplv2mf4bUPpd7YT9Cj2GcaSZkEg6nO2rBGAnfXFtNIjmTSLWtPNvNrD7UbY0JxbpAN3RePI23Au20yYPwkbYtj5IYTIOZXEYv6DlelDsgC64rqWZZp0c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578913144; 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=OBk9f6ee8k0bEgSZI9QeTrQDXgUXwL996eHt90EclGE=; b=WTXsFnX/9Wn3Tags/oycXhSAR/ujPun4I+EkT8/bi3AhlfgjsQ24ny6hVBogSBkQ4k1WgdWG2n0WX3+T5ZSBvNBBqHLc9vXNlHxO3h0v7wSq73oe/ni82acXdebchPyppu5cW4b6o8gtOmc2wq9vp59+WBL20VUa8PfwQWJPx2w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1578913144795440.1298126499064; Mon, 13 Jan 2020 02:59:04 -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-57-CVaSzvdzOh-bm-JwhlNPew-1; Mon, 13 Jan 2020 05:59:00 -0500 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 28CA61005516; Mon, 13 Jan 2020 10:58:55 +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 009CA60BF4; Mon, 13 Jan 2020 10:58:54 +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 A0F0518089CF; Mon, 13 Jan 2020 10:58:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00DAwhdn005279 for ; Mon, 13 Jan 2020 05:58:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id BA79060BE2; Mon, 13 Jan 2020 10:58:43 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4360360C05 for ; Mon, 13 Jan 2020 10:58:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578913143; 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=OBk9f6ee8k0bEgSZI9QeTrQDXgUXwL996eHt90EclGE=; b=XbLJAC5mEb2/EDaCkB0Pozew9EufwuVvjE4oAQasvQoTDWi9XyRn7affIS7PtUMBTuBhPU +eC7PME3VRRa3xPH/43dLwSu9dq+JkOpo6OnyFTrZFXI/vOxqqMIietxZFalquOSstuu8o HWwmkhbPekwKK5WllsVo9YRZwoxoT0U= From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 13 Jan 2020 11:58:36 +0100 Message-Id: <6b29bc84b238347a354a5b63e91806b3f3e3e942.1578912437.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/4] qemu: Stop domain on failed restore 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 X-MC-Unique: CVaSzvdzOh-bm-JwhlNPew-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" When resuming a domain from a save file, we read the domain XML from the file, add it onto our internal list of domains, start the qemu process, let it load the incoming migration stream and resume its vCPUs afterwards. If anything goes wrong, the domain object is removed from the list of domains and error is returned to the caller. However, the qemu process might be left behind - if resuming vCPUs fails (e.g. because qemu is unable to acquire write lock on a disk) then due to a bug the qemu process is not killed but the domain object is removed from the list. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D1718707 Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_driver.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ce9b1772c1..217d873671 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6800,7 +6800,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, { qemuDomainObjPrivatePtr priv =3D vm->privateData; int ret =3D -1; - bool restored =3D false; + bool started =3D false; virObjectEventPtr event; VIR_AUTOCLOSE intermediatefd =3D -1; g_autoptr(virCommand) cmd =3D NULL; @@ -6808,6 +6808,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); virQEMUSaveHeaderPtr header =3D &data->header; g_autoptr(qemuDomainSaveCookie) cookie =3D NULL; + int rc =3D 0; =20 if (virSaveCookieParseString(data->cookie, (virObjectPtr *)&cookie, virDomainXMLOptionGetSaveCookie(driver->x= mlopt)) < 0) @@ -6848,12 +6849,12 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, VIR_NETDEV_VPORT_PROFILE_OP_RESTORE, VIR_QEMU_PROCESS_START_PAUSED | VIR_QEMU_PROCESS_START_GEN_VMID) =3D=3D 0) - restored =3D true; + started =3D true; =20 if (intermediatefd !=3D -1) { virErrorPtr orig_err =3D NULL; =20 - if (!restored) { + if (!started) { /* if there was an error setting up qemu, the intermediate * process will wait forever to write to stdout, so we * must manually kill it and ignore any error related to @@ -6864,21 +6865,17 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, VIR_FORCE_CLOSE(*fd); } =20 - if (virCommandWait(cmd, NULL) < 0) { - qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, asyncJo= b, 0); - restored =3D false; - } + rc =3D virCommandWait(cmd, NULL); VIR_DEBUG("Decompression binary stderr: %s", NULLSTR(errbuf)); - virErrorRestore(&orig_err); } if (VIR_CLOSE(*fd) < 0) { virReportSystemError(errno, _("cannot close file: %s"), path); - restored =3D false; + rc =3D -1; } =20 - virDomainAuditStart(vm, "restored", restored); - if (!restored) + virDomainAuditStart(vm, "restored", started); + if (!started || rc < 0) goto cleanup; =20 /* qemuProcessStart doesn't unset the qemu error reporting infrastruct= ure @@ -6918,6 +6915,10 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, ret =3D 0; =20 cleanup: + if (ret < 0 && started) { + qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, + asyncJob, VIR_QEMU_PROCESS_STOP_MIGRATED); + } if (qemuSecurityRestoreSavedStateLabel(driver, vm, path) < 0) VIR_WARN("failed to restore save state label on %s", path); return ret; --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list