From nobody Fri May 17 06:07:34 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=1693493722; cv=none; d=zohomail.com; s=zohoarc; b=Gy/PGX/oymewT5m21VLtBc3EyKwZuo8+9L/kr5kWYcgxXVEwehGTUWKWfNCd8y8unZzmlTnM8096OiljtWSn5uudAiFIiSTzubzBdwmKfkFgFxslm0YksFN+1djHc2dbscHyFH3YgBR6xdIHEWny7sqfyxXooVhO3xJbp23KpW0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693493722; 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=QkloTEl6OXSetX44pGPmMarM9rgfZ9wUQAo/iERYur4=; b=cuwRW3hLaUDpt4W4A+vTLGYVfxJ4JmuRvfuPr19M5nHbxhYHG5VmNOglrQMIXVzGp044pVpVvWJv+elvzLzt1pECu/uacj87Sfelkk0m9spMCij7t0te8Ot51dADalNafXpR9/ir4ALtyYw8TU9Vf3GXXO8ayvW7rAJ7eilKpRM= 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) 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 16934937221101004.41446028314; Thu, 31 Aug 2023 07:55:22 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-374-8pu0I8kCPIyKeE9YRb1Cgg-1; Thu, 31 Aug 2023 10:55:18 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0ABAB1C06EF9; Thu, 31 Aug 2023 14:55:16 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA4CE4021C9; Thu, 31 Aug 2023 14:55:15 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 422531946A49; Thu, 31 Aug 2023 14:55:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 395171946587 for ; Thu, 31 Aug 2023 14:55:13 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1A5E040C2070; Thu, 31 Aug 2023 14:55:13 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.224.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91D7E40C2063 for ; Thu, 31 Aug 2023 14:55:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693493721; 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=QkloTEl6OXSetX44pGPmMarM9rgfZ9wUQAo/iERYur4=; b=aBt6dIJeqtH7og9dReZ/6NPKudCXNnN/HQ240Yvifq/C29i+QI915RsPG+SGTJWz7qiwr6 lbZy04OYszBnAGmVPrnZ3+3HT81o0EnjNKMrMN+zqPMcthmJ9coI83m4rarfNVciJnjkUl lXZcqRm26wRU+dd1td+VtnvDxpMUDmc= X-MC-Unique: 8pu0I8kCPIyKeE9YRb1Cgg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 1/7] qemu_saveimage: extract starting process to qemuSaveImageStartProcess Date: Thu, 31 Aug 2023 16:55:00 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1693493724339100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Part of qemuSaveImageStartVM() function will be used when reverting external snapshots. To avoid duplicating code and logic extract the shared bits into separate function. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_saveimage.c | 103 ++++++++++++++++++++++++++------------ src/qemu/qemu_saveimage.h | 12 +++++ 2 files changed, 83 insertions(+), 32 deletions(-) diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index 41310d6a9a..86f31d1820 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -565,42 +565,46 @@ qemuSaveImageOpen(virQEMUDriver *driver, return ret; } =20 +/** + * qemuSaveImageStartProcess: + * @conn: connection object + * @driver: qemu driver object + * @vm: domain object + * @fd: FD pointer of memory state file + * @path: path to memory state file + * @header: header from memory state file + * @cookie: cookie from memory state file + * @asyncJob: type of asynchronous job + * @start_flags: flags to start QEMU process with + * @started: boolean to store if QEMU process was started + * + * Start VM with existing memory state. Make sure that the stored memory s= tate + * is correctly decompressed so it can be loaded by QEMU process. + * + * Returns 0 on success, -1 on error. + */ int -qemuSaveImageStartVM(virConnectPtr conn, - virQEMUDriver *driver, - virDomainObj *vm, - int *fd, - virQEMUSaveData *data, - const char *path, - bool start_paused, - bool reset_nvram, - virDomainAsyncJob asyncJob) +qemuSaveImageStartProcess(virConnectPtr conn, + virQEMUDriver *driver, + virDomainObj *vm, + int *fd, + const char *path, + virQEMUSaveHeader *header, + qemuDomainSaveCookie *cookie, + virDomainAsyncJob asyncJob, + unsigned int start_flags, + bool *started) { qemuDomainObjPrivate *priv =3D vm->privateData; - int ret =3D -1; - bool started =3D false; - virObjectEvent *event; VIR_AUTOCLOSE intermediatefd =3D -1; g_autoptr(virCommand) cmd =3D NULL; g_autofree char *errbuf =3D NULL; - g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - virQEMUSaveHeader *header =3D &data->header; - g_autoptr(qemuDomainSaveCookie) cookie =3D NULL; int rc =3D 0; - unsigned int start_flags =3D VIR_QEMU_PROCESS_START_PAUSED | - VIR_QEMU_PROCESS_START_GEN_VMID; - - if (reset_nvram) - start_flags |=3D VIR_QEMU_PROCESS_START_RESET_NVRAM; - - if (virSaveCookieParseString(data->cookie, (virObject **)&cookie, - virDomainXMLOptionGetSaveCookie(driver->x= mlopt)) < 0) - goto cleanup; =20 if ((header->version =3D=3D 2) && (header->compressed !=3D QEMU_SAVE_FORMAT_RAW)) { if (!(cmd =3D qemuSaveImageGetCompressionCommand(header->compresse= d))) - goto cleanup; + return -1; =20 intermediatefd =3D *fd; *fd =3D -1; @@ -613,7 +617,7 @@ qemuSaveImageStartVM(virConnectPtr conn, if (virCommandRunAsync(cmd, NULL) < 0) { *fd =3D intermediatefd; intermediatefd =3D -1; - goto cleanup; + return -1; } } =20 @@ -622,7 +626,7 @@ qemuSaveImageStartVM(virConnectPtr conn, */ if (cookie && qemuDomainFixupCPUs(vm, &cookie->cpu) < 0) - goto cleanup; + return -1; =20 if (cookie && !cookie->slirpHelper) priv->disableSlirp =3D true; @@ -631,12 +635,12 @@ qemuSaveImageStartVM(virConnectPtr conn, asyncJob, "stdio", *fd, path, NULL, VIR_NETDEV_VPORT_PROFILE_OP_RESTORE, start_flags) =3D=3D 0) - started =3D true; + *started =3D true; =20 if (intermediatefd !=3D -1) { virErrorPtr orig_err =3D NULL; =20 - if (!started) { + 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 @@ -656,15 +660,50 @@ qemuSaveImageStartVM(virConnectPtr conn, rc =3D -1; } =20 - virDomainAuditStart(vm, "restored", started); - if (!started || rc < 0) - goto cleanup; + virDomainAuditStart(vm, "restored", *started); + if (!*started || rc < 0) + return -1; =20 /* qemuProcessStart doesn't unset the qemu error reporting infrastruct= ure * in case of migration (which is used in this case) so we need to res= et it * so that the handle to virtlogd is not held open unnecessarily */ qemuMonitorSetDomainLog(qemuDomainGetMonitor(vm), NULL, NULL, NULL); =20 + return 0; +} + +int +qemuSaveImageStartVM(virConnectPtr conn, + virQEMUDriver *driver, + virDomainObj *vm, + int *fd, + virQEMUSaveData *data, + const char *path, + bool start_paused, + bool reset_nvram, + virDomainAsyncJob asyncJob) +{ + int ret =3D -1; + bool started =3D false; + virObjectEvent *event; + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + virQEMUSaveHeader *header =3D &data->header; + g_autoptr(qemuDomainSaveCookie) cookie =3D NULL; + unsigned int start_flags =3D VIR_QEMU_PROCESS_START_PAUSED | + VIR_QEMU_PROCESS_START_GEN_VMID; + + if (reset_nvram) + start_flags |=3D VIR_QEMU_PROCESS_START_RESET_NVRAM; + + if (virSaveCookieParseString(data->cookie, (virObject **)&cookie, + virDomainXMLOptionGetSaveCookie(driver->x= mlopt)) < 0) + goto cleanup; + + if (qemuSaveImageStartProcess(conn, driver, vm, fd, path, header, cook= ie, + asyncJob, start_flags, &started) < 0) { + goto cleanup; + } + event =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STARTED, VIR_DOMAIN_EVENT_STARTED_RESTORED); diff --git a/src/qemu/qemu_saveimage.h b/src/qemu/qemu_saveimage.h index 30cf4b1ee0..af30b7f2ec 100644 --- a/src/qemu/qemu_saveimage.h +++ b/src/qemu/qemu_saveimage.h @@ -57,6 +57,18 @@ qemuSaveImageUpdateDef(virQEMUDriver *driver, virDomainDef *def, const char *newxml); =20 +int +qemuSaveImageStartProcess(virConnectPtr conn, + virQEMUDriver *driver, + virDomainObj *vm, + int *fd, + const char *path, + virQEMUSaveHeader *header, + qemuDomainSaveCookie *cookie, + virDomainAsyncJob asyncJob, + unsigned int start_flags, + bool *started); + int qemuSaveImageStartVM(virConnectPtr conn, virQEMUDriver *driver, --=20 2.41.0 From nobody Fri May 17 06:07:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1693493774; cv=none; d=zohomail.com; s=zohoarc; b=Rf+XXvI2ntZ1HARMVnZeRehGT1aXfw1JB17bHlc4lnvHjl4MTHb9eWW3HZqmIHn8kT7FK0VB/GJC9x6AGVeon40pZzG3BTePhq8CUK2A385zKblcbuoLpA5/zNnYhwJpuxa9Shmyxb51MlRHbeEc0gvvEqamHDgCjXncxkgchfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693493774; 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=yJe301ST0IAPXQeRpZ5JEl+N9nmizbGqLOqIO5ldQrI=; b=K1UfUjdqREftejXA0HoK5O3jSMVFtkFS4t1VmdbV3S4s/jiN+3Rvm8VaiKjZOiUOKNwzbfLCuwX4+uc0s5z6FiEW+Posbnh3mFI1RHl+4lLdl1AIkuv0kOlRrh2psSBR+c92WLSBWldZ77YzVzLRnlypwL8lET/hmG7eya1ZptM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1693493774510838.1770028301919; Thu, 31 Aug 2023 07:56:14 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-523-dNgeEfjNP-GDbJ7axsQDOg-1; Thu, 31 Aug 2023 10:55:19 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8F5F438149D4; Thu, 31 Aug 2023 14:55:16 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4320540C2078; Thu, 31 Aug 2023 14:55:16 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 79476194658D; Thu, 31 Aug 2023 14:55:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C18451946587 for ; Thu, 31 Aug 2023 14:55:13 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B515540C2070; Thu, 31 Aug 2023 14:55:13 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.224.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55E7240C2063 for ; Thu, 31 Aug 2023 14:55:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693493773; 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=yJe301ST0IAPXQeRpZ5JEl+N9nmizbGqLOqIO5ldQrI=; b=R4/PSAgIpUCMCvwuqA8CHKGcZiMKaunOSsN/mbIffgQoTqmWZNCtCz2MWgZNoAt9H5BJyJ DIXb3TmaO1dW9x/tSS7N6ACOuPgVlc5gJzZkN8parIEOg5MRXl2b8QH9yILPoc/FcsjnJW ZV6PauCSIMYtgs2LuPLslmPmpgxI9zI= X-MC-Unique: dNgeEfjNP-GDbJ7axsQDOg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 2/7] qemuSaveImageStartProcess: allow setting reason for audit log Date: Thu, 31 Aug 2023 16:55:01 +0200 Message-ID: <5f4d86094cee70200838608e7f1f7dd945c2bb34.1693493289.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1693493775313100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When called by snapshot code we will need to use different reason. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_saveimage.c | 6 ++++-- src/qemu/qemu_saveimage.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index 86f31d1820..1eedc900b9 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -576,6 +576,7 @@ qemuSaveImageOpen(virQEMUDriver *driver, * @cookie: cookie from memory state file * @asyncJob: type of asynchronous job * @start_flags: flags to start QEMU process with + * @reason: audit log reason * @started: boolean to store if QEMU process was started * * Start VM with existing memory state. Make sure that the stored memory s= tate @@ -593,6 +594,7 @@ qemuSaveImageStartProcess(virConnectPtr conn, qemuDomainSaveCookie *cookie, virDomainAsyncJob asyncJob, unsigned int start_flags, + const char *reason, bool *started) { qemuDomainObjPrivate *priv =3D vm->privateData; @@ -660,7 +662,7 @@ qemuSaveImageStartProcess(virConnectPtr conn, rc =3D -1; } =20 - virDomainAuditStart(vm, "restored", *started); + virDomainAuditStart(vm, reason, started); if (!*started || rc < 0) return -1; =20 @@ -700,7 +702,7 @@ qemuSaveImageStartVM(virConnectPtr conn, goto cleanup; =20 if (qemuSaveImageStartProcess(conn, driver, vm, fd, path, header, cook= ie, - asyncJob, start_flags, &started) < 0) { + asyncJob, start_flags, "restored", &star= ted) < 0) { goto cleanup; } =20 diff --git a/src/qemu/qemu_saveimage.h b/src/qemu/qemu_saveimage.h index af30b7f2ec..c6a701dcf5 100644 --- a/src/qemu/qemu_saveimage.h +++ b/src/qemu/qemu_saveimage.h @@ -67,6 +67,7 @@ qemuSaveImageStartProcess(virConnectPtr conn, qemuDomainSaveCookie *cookie, virDomainAsyncJob asyncJob, unsigned int start_flags, + const char *reason, bool *started); =20 int --=20 2.41.0 From nobody Fri May 17 06:07:34 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=1693493732; cv=none; d=zohomail.com; s=zohoarc; b=ilkRSN2F2KsGvdIBKfOBDSJlHwL3zOOGOIFQeupYvOZJa6oNTJN/uMT2NukvZeB8CzZcNR+DeidFMYLs9HIFxZQ0j0CiEcdZTpnwK+tacbyNnlpw1zPodw+scGaxkzVv3RpcYk+5q2hdfUnmDTPWGH3Fp0uCYkSqAfS45j1hgS0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693493732; 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=henSYvdeYBkMBjOadHvd77CZGWC0+Iz6DLQUM9fW5wY=; b=D8BeVMFo6N6q0W3XZEYaNvGjUy4RgYrtLWEDo+pZqRuvNgSTrzCfWuwLVyNPYu0JvxNg9zeY+iFTTXcxacbHGDcW0WtD+M5C4SoYtxsGdVmTK1S7Yv0GSegG22N9m48OS/7YlqYe4lliqB4IGjKK6zZZ78CmNB+c+qpk9Z3eshQ= 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) 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 1693493732862192.34031697638; Thu, 31 Aug 2023 07:55:32 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-126-KS07_iycNWeP9hO5bmkyFA-1; Thu, 31 Aug 2023 10:55:27 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3C107101A528; Thu, 31 Aug 2023 14:55:24 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2567BC15BC0; Thu, 31 Aug 2023 14:55:24 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B272719451D0; Thu, 31 Aug 2023 14:55:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7D1A81946A71 for ; Thu, 31 Aug 2023 14:55:14 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5BCFE40C2070; Thu, 31 Aug 2023 14:55:14 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.224.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id F128640C2063 for ; Thu, 31 Aug 2023 14:55:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693493731; 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=henSYvdeYBkMBjOadHvd77CZGWC0+Iz6DLQUM9fW5wY=; b=ZEhGRBpPmiO4yq/xLw2ArqN10/gY/ydUEDe8KmoGtl+fVAF/epLekoLy8I1DVQIlUwIuy5 113yCHs0sOHr6O8CNsrB+6/BpOsb/ONLv3vXBy2qPqLW/Ht0YT5dzA8zTB1XbimrMS93qe 9PnO8QheuEy5/6S/908wBwPvFpI4etg= X-MC-Unique: KS07_iycNWeP9hO5bmkyFA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 3/7] qemuSaveImageStartProcess: add snapshot argument Date: Thu, 31 Aug 2023 16:55:02 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1693493734377100005 Content-Type: text/plain; charset="utf-8"; x-default="true" When called from snapshot code we will need to pass snapshot object in order to make internal snapshots work correctly. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_saveimage.c | 6 ++++-- src/qemu/qemu_saveimage.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index 1eedc900b9..73115af42d 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -572,6 +572,7 @@ qemuSaveImageOpen(virQEMUDriver *driver, * @vm: domain object * @fd: FD pointer of memory state file * @path: path to memory state file + * @snapshot: snapshot to load when starting QEMU process or NULL * @header: header from memory state file * @cookie: cookie from memory state file * @asyncJob: type of asynchronous job @@ -590,6 +591,7 @@ qemuSaveImageStartProcess(virConnectPtr conn, virDomainObj *vm, int *fd, const char *path, + virDomainMomentObj *snapshot, virQEMUSaveHeader *header, qemuDomainSaveCookie *cookie, virDomainAsyncJob asyncJob, @@ -634,7 +636,7 @@ qemuSaveImageStartProcess(virConnectPtr conn, priv->disableSlirp =3D true; =20 if (qemuProcessStart(conn, driver, vm, cookie ? cookie->cpu : NULL, - asyncJob, "stdio", *fd, path, NULL, + asyncJob, "stdio", *fd, path, snapshot, VIR_NETDEV_VPORT_PROFILE_OP_RESTORE, start_flags) =3D=3D 0) *started =3D true; @@ -701,7 +703,7 @@ qemuSaveImageStartVM(virConnectPtr conn, virDomainXMLOptionGetSaveCookie(driver->x= mlopt)) < 0) goto cleanup; =20 - if (qemuSaveImageStartProcess(conn, driver, vm, fd, path, header, cook= ie, + if (qemuSaveImageStartProcess(conn, driver, vm, fd, path, NULL, header= , cookie, asyncJob, start_flags, "restored", &star= ted) < 0) { goto cleanup; } diff --git a/src/qemu/qemu_saveimage.h b/src/qemu/qemu_saveimage.h index c6a701dcf5..c5ad50558e 100644 --- a/src/qemu/qemu_saveimage.h +++ b/src/qemu/qemu_saveimage.h @@ -63,6 +63,7 @@ qemuSaveImageStartProcess(virConnectPtr conn, virDomainObj *vm, int *fd, const char *path, + virDomainMomentObj *snapshot, virQEMUSaveHeader *header, qemuDomainSaveCookie *cookie, virDomainAsyncJob asyncJob, --=20 2.41.0 From nobody Fri May 17 06:07:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1693493726; cv=none; d=zohomail.com; s=zohoarc; b=DT7SYr8u5awnVkBoE0hIhWUqcP+4xOQ9XX/GGxfqvKwYo0hqedqaX778bD8USOE9arT2TIl04Qc+RRcG2LxmkFqKIRCsZ+0Uh5Qn/RPyKevjF4zcLfWxrACR9qJnGOadH7bi95TeNLgS4zjdjnR5qZQ6FKY/qS8sX797Ui5l/wk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693493726; 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=vKMIqG3sP1quCr/hjuMGI8PjmewLPAT89jUjlEQ2OjY=; b=GRKRJUEAPwAEX302a4e+BGpKA3CsJxEMuBsubwZg6nUQe/G5Y2TLWFmpZfUcE33wBEw331AFuFt4m13HY/MZN/NznYg1JQxX5DTcdvyQ+3Qpg4X2yqG/1mGgT3MK6osF6ZSWUpZokM7nnBcKRm+uWS+EfAAzlj1P4P5dX3/HiNY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1693493726154146.15897595848242; Thu, 31 Aug 2023 07:55:26 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-505-tZtDsQANPQCTi30_1xc2gg-1; Thu, 31 Aug 2023 10:55:21 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1AE13101A52E; Thu, 31 Aug 2023 14:55:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08C9E1121315; Thu, 31 Aug 2023 14:55:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8F104194658D; Thu, 31 Aug 2023 14:55:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2D59B1946587 for ; Thu, 31 Aug 2023 14:55:15 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id F39FD40C2073; Thu, 31 Aug 2023 14:55:14 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.224.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 95BEB40C2063 for ; Thu, 31 Aug 2023 14:55:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693493725; 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=vKMIqG3sP1quCr/hjuMGI8PjmewLPAT89jUjlEQ2OjY=; b=PBXScTBtTDouEjR3o8I3XabPpK/xFWm058VQUVy+qQff7wovd+Wp6KSxxeg9kMRWZnsoyP HLyCDkbW1UZPSPbsC9iPO9b94jXFhMQjaORsV2psfnG9lEu+8UqSPKfR1ZkxcJSy7hmNlN T/RenUpwd/YGZjts6hGzRDGS6TrERN4= X-MC-Unique: tZtDsQANPQCTi30_1xc2gg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 4/7] qemuSaveImageStartProcess: make it possible to use without header Date: Thu, 31 Aug 2023 16:55:03 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1693493728294100009 Content-Type: text/plain; charset="utf-8"; x-default="true" When used with internal snapshots there is no header to be used and no memory state to be decompressed. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_saveimage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index 73115af42d..2538732901 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -573,7 +573,7 @@ qemuSaveImageOpen(virQEMUDriver *driver, * @fd: FD pointer of memory state file * @path: path to memory state file * @snapshot: snapshot to load when starting QEMU process or NULL - * @header: header from memory state file + * @header: header from memory state file or NULL * @cookie: cookie from memory state file * @asyncJob: type of asynchronous job * @start_flags: flags to start QEMU process with @@ -605,7 +605,7 @@ qemuSaveImageStartProcess(virConnectPtr conn, g_autofree char *errbuf =3D NULL; int rc =3D 0; =20 - if ((header->version =3D=3D 2) && + if (header && (header->version =3D=3D 2) && (header->compressed !=3D QEMU_SAVE_FORMAT_RAW)) { if (!(cmd =3D qemuSaveImageGetCompressionCommand(header->compresse= d))) return -1; --=20 2.41.0 From nobody Fri May 17 06:07:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1693493731; cv=none; d=zohomail.com; s=zohoarc; b=lrt4LTIyw27nBbEAeSkVl5q9P/OyIQHe+y1op3q3k4N12FNuMZwElZROvZtzSHdagrGP6vDWWntcHxKLukfZpo0JDS3RN3oP5ZVtNLiG5e8wxmQ7IBgBW4Qg7p9EhBXRVCMTss/F+2Y4Qx7RhOPROL1VS+52PK6J+lrJZYW1CLE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693493731; 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=FHZnQuy0dwYJom25iTlkgE5yKc0Yw49dhF0V1witXEE=; b=cTX/CI4+sdq5P4E3VVr8tcQYWI1/o2XZXUXIOTCroR9u2se5e1WgBOcSiFM4vq90SvvB+m2RGi0xo5tcO2gvW7BylG1OwF11mcqP/RxXKpym1EBVMhXuPCtdpq/sqogND1Ycd+njeLZ6TwCnsoyAZQaxDWpYLXCDbW7sd9CIoWQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1693493731809774.664769557808; Thu, 31 Aug 2023 07:55:31 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-413-_TmhJ7Y-PNCl5jR7JvyFqQ-1; Thu, 31 Aug 2023 10:55:25 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5707180CC5E; Thu, 31 Aug 2023 14:55:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 318F6413738; Thu, 31 Aug 2023 14:55:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CED811946A4D; Thu, 31 Aug 2023 14:55:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BD4D319465BA for ; Thu, 31 Aug 2023 14:55:15 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id AA99440C2073; Thu, 31 Aug 2023 14:55:15 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.224.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3917B40C2063 for ; Thu, 31 Aug 2023 14:55:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693493730; 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=FHZnQuy0dwYJom25iTlkgE5yKc0Yw49dhF0V1witXEE=; b=fm/dmeRU7bOteUUIm/mg22A5hy9ytjwOwdAySNIeU1f9pJGrD8KzCzV3P2LEa9aQjz8qm/ 3XxBGFY71MukK2kJRKL1FFJQKsTFLYl50fMslTRC8Tu7lSOKTfICSRVhjkwkmwpOV2lofB 03BK+NMlDh/WYXqZXkl+dSqmxfpiYZ8= X-MC-Unique: _TmhJ7Y-PNCl5jR7JvyFqQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 5/7] qemu_snapshot: fix reverting external snapshot when not all disks are included Date: Thu, 31 Aug 2023 16:55:04 +0200 Message-ID: <4f6a4b5e8709e9ccccd85a2c85afc5757a578067.1693493289.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1693493733176100003 Content-Type: text/plain; charset="utf-8"; x-default="true" We need to skip all disks that have snapshot type other than 'external'. Signed-off-by: Pavel Hrdina --- src/qemu/qemu_snapshot.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index d943281e35..ff85d56572 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2058,6 +2058,9 @@ qemuSnapshotRevertExternalPrepare(virDomainObj *vm, virDomainSnapshotDiskDef *snapdisk =3D &tmpsnapdef->disks[i]; virDomainDiskDef *domdisk =3D domdef->disks[i]; =20 + if (snapdisk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) + continue; + if (qemuSnapshotPrepareDiskExternal(domdisk, snapdisk, active, fal= se) < 0) return -1; } @@ -2098,6 +2101,9 @@ qemuSnapshotRevertExternalActive(virDomainObj *vm, return -1; =20 for (i =3D 0; i < tmpsnapdef->ndisks; i++) { + if (tmpsnapdef->disks[i].snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATIO= N_EXTERNAL) + continue; + if (qemuSnapshotDiskPrepareOne(snapctxt, vm->def->disks[i], tmpsnapdef->disks + i, @@ -2188,6 +2194,9 @@ qemuSnapshotRevertExternalFinish(virDomainObj *vm, for (i =3D 0; i < curdef->nrevertdisks; i++) { virDomainSnapshotDiskDef *snapdisk =3D &(curdef->revertdisks[i= ]); =20 + if (snapdisk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTER= NAL) + continue; + if (virStorageSourceInit(snapdisk->src) < 0 || virStorageSourceUnlink(snapdisk->src) < 0) { VIR_WARN("Failed to remove snapshot image '%s'", @@ -2203,6 +2212,9 @@ qemuSnapshotRevertExternalFinish(virDomainObj *vm, for (i =3D 0; i < curdef->ndisks; i++) { virDomainSnapshotDiskDef *snapdisk =3D &(curdef->disks[i]); =20 + if (snapdisk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTER= NAL) + continue; + if (virStorageSourceInit(snapdisk->src) < 0 || virStorageSourceUnlink(snapdisk->src) < 0) { VIR_WARN("Failed to remove snapshot image '%s'", --=20 2.41.0 From nobody Fri May 17 06:07:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1693493732; cv=none; d=zohomail.com; s=zohoarc; b=QSQLNUwJJKpPWS18dZuKBsVm1k6UVEMyaNDCF/lHcG3o/rHTqugGYpfpQcbsNn8MXfzgRcMOuKDovmomyzPfSJPOom/XcYbmybJf7iJenPR2889m0Yrmcwg04spZJgtcVrExzXjolV9zANSjWHFmbewMhjKTZCV6GgYmzzZsN18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693493732; 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=rRA45HLrgB94eq6KFcH2EGxWkOmWy1b9wW2uzOy3EFo=; b=mgVwp9guhoDk3fXxfXus+JqtcF9SfXGiRjYqMVJ/c47Dq94eTqP7wTGpvGh8og98M5vxt5B6xj66T6hQMXLSYqREIXLnTYjqozudsJsRGlxBLqg6m6zKPHEwJi+D/YmTyE2AFgk4ApFsxBL9MGXKiFExO+xaHt4AhtvFGd/84fM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1693493732053546.4451824567473; Thu, 31 Aug 2023 07:55:32 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-131-Mpw9IMS-MRmZhWqK91kE3Q-1; Thu, 31 Aug 2023 10:55:28 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C043F2812956; Thu, 31 Aug 2023 14:55:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB60A40C2070; Thu, 31 Aug 2023 14:55:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 11FC719452C2; Thu, 31 Aug 2023 14:55:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5C1831946587 for ; Thu, 31 Aug 2023 14:55:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3C9A040C207C; Thu, 31 Aug 2023 14:55:16 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.224.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id D02EE40C2063 for ; Thu, 31 Aug 2023 14:55:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693493731; 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=rRA45HLrgB94eq6KFcH2EGxWkOmWy1b9wW2uzOy3EFo=; b=Hd+MMLI0R6BFfvs+FvOkSA0Vk50MgZ+vnPzT+wLY+MkGPYd5MMGjkSsYkMFT+yTATXERFg iYrNU2FkvvAORsTO+dgLGu64hfLfBBnIt7PRvwBmFR6rGGWvDQzJgZAP+yJnhDwq6SdHRs O7Sb0PXU96u+D4EZe8iQihLitkXuguc= X-MC-Unique: Mpw9IMS-MRmZhWqK91kE3Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 6/7] qemu_snapshot: correctly load the saved memory state file Date: Thu, 31 Aug 2023 16:55:05 +0200 Message-ID: <9fdb92119dea686b507b5b9aa5786260ba11dfed.1693493289.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1693493732543100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Original code assumed that the memory state file is only migration stream but it has additional metadata stored by libvirt. To correctly load the memory state file we need to reuse code that is used when restoring domain from saved image. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 78 ++++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 31 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index ff85d56572..869b46a9a8 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2004,6 +2004,21 @@ qemuSnapshotRevertWriteMetadata(virDomainObj *vm, } =20 =20 +typedef struct _qemuSnapshotRevertMemoryData { + int fd; + char *path; + virQEMUSaveData *data; +} qemuSnapshotRevertMemoryData; + +static void +qemuSnapshotClearRevertMemoryData(qemuSnapshotRevertMemoryData *memdata) +{ + VIR_FORCE_CLOSE(memdata->fd); + virQEMUSaveDataFree(memdata->data); +} +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(qemuSnapshotRevertMemoryData, qemuSnapsho= tClearRevertMemoryData); + + /** * qemuSnapshotRevertExternalPrepare: * @vm: domain object @@ -2011,15 +2026,13 @@ qemuSnapshotRevertWriteMetadata(virDomainObj *vm, * @snap: snapshot object we are reverting to * @config: live domain definition * @inactiveConfig: offline domain definition - * memsnapFD: pointer to store memory state file FD or NULL - * memsnapPath: pointer to store memory state file path or NULL + * @memdata: struct with data to load memory state * * Prepare new temporary snapshot definition @tmpsnapdef that will * be used while creating new overlay files after reverting to snapshot * @snap. In case we are reverting to snapshot with memory state it will - * open it and pass FD via @memsnapFD and path to the file via - * @memsnapPath, caller is responsible for freeing both @memsnapFD and - * memsnapPath. + * open it and store necessary data in @memdata. Caller is responsible + * to clear the data by using qemuSnapshotClearRevertMemoryData(). * * Returns 0 in success, -1 on error. */ @@ -2029,8 +2042,7 @@ qemuSnapshotRevertExternalPrepare(virDomainObj *vm, virDomainMomentObj *snap, virDomainDef *config, virDomainDef *inactiveConfig, - int *memsnapFD, - char **memsnapPath) + qemuSnapshotRevertMemoryData *memdata) { size_t i; bool active =3D virDomainObjIsActive(vm); @@ -2065,12 +2077,21 @@ qemuSnapshotRevertExternalPrepare(virDomainObj *vm, return -1; } =20 - if (memsnapFD && memsnapPath && snapdef->memorysnapshotfile) { + if (memdata && snapdef->memorysnapshotfile) { virQEMUDriver *driver =3D ((qemuDomainObjPrivate *) vm->privateDat= a)->driver; - g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driv= er); + g_autoptr(virDomainDef) savedef =3D NULL; =20 - *memsnapPath =3D snapdef->memorysnapshotfile; - *memsnapFD =3D qemuDomainOpenFile(cfg, NULL, *memsnapPath, O_RDONL= Y, NULL); + memdata->path =3D snapdef->memorysnapshotfile; + memdata->fd =3D qemuSaveImageOpen(driver, NULL, memdata->path, + &savedef, &memdata->data, + false, NULL, + false, false); + + if (memdata->fd < 0) + return -1; + + if (!virDomainDefCheckABIStability(savedef, domdef, driver->xmlopt= )) + return -1; } =20 return 0; @@ -2254,13 +2275,13 @@ qemuSnapshotRevertActive(virDomainObj *vm, virObjectEvent *event =3D NULL; virObjectEvent *event2 =3D NULL; virDomainMomentObj *loadSnap =3D NULL; - VIR_AUTOCLOSE memsnapFD =3D -1; - char *memsnapPath =3D NULL; int detail; bool defined =3D false; qemuDomainSaveCookie *cookie =3D (qemuDomainSaveCookie *) snapdef->coo= kie; int rc; g_autoptr(virDomainSnapshotDef) tmpsnapdef =3D NULL; + g_auto(qemuSnapshotRevertMemoryData) memdata =3D { -1, NULL, NULL }; + bool started =3D false; =20 start_flags |=3D VIR_QEMU_PROCESS_START_PAUSED; =20 @@ -2284,7 +2305,7 @@ qemuSnapshotRevertActive(virDomainObj *vm, =20 if (qemuSnapshotRevertExternalPrepare(vm, tmpsnapdef, snap, *config, *inactiveConfig, - &memsnapFD, &memsnapPath) < = 0) { + &memdata) < 0) { return -1; } } else { @@ -2298,28 +2319,24 @@ qemuSnapshotRevertActive(virDomainObj *vm, =20 virDomainObjAssignDef(vm, config, true, NULL); =20 - /* No cookie means libvirt which saved the domain was too old to - * mess up the CPU definitions. - */ - if (cookie && - qemuDomainFixupCPUs(vm, &cookie->cpu) < 0) + if (qemuSaveImageStartProcess(snapshot->domain->conn, driver, vm, + &memdata.fd, memdata.path, loadSnap, + memdata.data ? &memdata.data->header : N= ULL, + cookie, VIR_ASYNC_JOB_SNAPSHOT, start_fl= ags, + "from-snapshot", &started) < 0) { + if (started) { + qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, + VIR_ASYNC_JOB_SNAPSHOT, + VIR_QEMU_PROCESS_STOP_MIGRATED); + } return -1; + } =20 - rc =3D qemuProcessStart(snapshot->domain->conn, driver, vm, - cookie ? cookie->cpu : NULL, - VIR_ASYNC_JOB_SNAPSHOT, NULL, memsnapFD, - memsnapPath, loadSnap, - VIR_NETDEV_VPORT_PROFILE_OP_CREATE, - start_flags); - virDomainAuditStart(vm, "from-snapshot", rc >=3D 0); detail =3D VIR_DOMAIN_EVENT_STARTED_FROM_SNAPSHOT; event =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STARTED, detail); virObjectEventStateQueue(driver->domainEventState, event); - if (rc < 0) - return -1; - =20 if (virDomainSnapshotIsExternal(snap)) { if (qemuSnapshotRevertExternalActive(vm, tmpsnapdef) < 0) @@ -2427,8 +2444,7 @@ qemuSnapshotRevertInactive(virDomainObj *vm, return -1; =20 if (qemuSnapshotRevertExternalPrepare(vm, tmpsnapdef, snap, - NULL, *inactiveConfig, - NULL, NULL) < 0) { + NULL, *inactiveConfig, NULL)= < 0) { return -1; } =20 --=20 2.41.0 From nobody Fri May 17 06:07:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1693493770; cv=none; d=zohomail.com; s=zohoarc; b=h7jkdfnHFndLBcMEnE1cvsJZmut9jKXUiWUgOKHcpq3PUXWGn7UoJI3ndCUwqNSI414jamJcChpJRyzRJPDEEnTOcnH9PreLuLs9zQ7B0JLzrwGsg9gBY90YKLwkooi2ngGc5hHpaaO3DsPVZ7BB9FMd6Rs09BZnNpwpPv69ItE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693493770; 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=uwSPJbxPxDV84fa4Suxyu1kglScScmk40L2/t+LH0jo=; b=e0DjCHhlrJ9sB6t7W+iME6m3aZdCT54hq/yE8iHMWBCQ0Vjy9bafsP/pyODGcvo9T6bvegj0F4iF3kAnsG6hLm1lvqfsJWhi3JMitlBgOC/obZBFCPNYb4cqg3PmRmgKDn0yJQf7IkU5695LkBfg/MTWW+ehDB5zq5T4s9mA+kI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1693493770527898.6156442818711; Thu, 31 Aug 2023 07:56:10 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-605--LGmiEqCPJepL-BrZ5TSiQ-1; Thu, 31 Aug 2023 10:55:27 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ACAC5801CF3; Thu, 31 Aug 2023 14:55:23 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 959729A; Thu, 31 Aug 2023 14:55:23 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 674FF19452D3; Thu, 31 Aug 2023 14:55:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E17491946A61 for ; Thu, 31 Aug 2023 14:55:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D652A40C2063; Thu, 31 Aug 2023 14:55:16 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.224.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 783BC40C2070 for ; Thu, 31 Aug 2023 14:55:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693493769; 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=uwSPJbxPxDV84fa4Suxyu1kglScScmk40L2/t+LH0jo=; b=WekR6/nT0Vk5p+B6M7QF57SoFMhrbPq4BLriJsM6klYtBMWE3kRd7U5HlfFiSQcoaOAAQq Zk6nWkZ7r/N7NAE5vuUzs6NxolTaw64mtrwnQPY0zHcHO4XHJ/nLX2UXzYSuSpFcQIvMBC Y+ks3Gtws/RbJpzIdnnwGtID1m+LbfU= X-MC-Unique: -LGmiEqCPJepL-BrZ5TSiQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 7/7] NEWS: document support for reverting external snapshots Date: Thu, 31 Aug 2023 16:55:06 +0200 Message-ID: <657ea6b4011e59dc6f5011fba7721240fffdd93d.1693493289.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1693493772287100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Pavel Hrdina --- NEWS.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index e40c8ac259..a3be76d6cc 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -28,6 +28,14 @@ v9.7.0 (unreleased) 2) pre-binding the variant driver using the ``--driver`` option of ``virsh nodedev-detach``. =20 + * QEMU: implement reverting external snapshots + + Reverting external snapshots is now possible using the existing API + ``virDomainSnapshotRevert()``. Management application can check host + capabilities for ```` element within the list of + guest features to see if the current libvirt supports both deleting + and reverting external snapshots. + * **Improvements** =20 * **Bug fixes** --=20 2.41.0