From nobody Sun May 12 23:43:20 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=1695043792; cv=none; d=zohomail.com; s=zohoarc; b=S795wdhKKp/BEtRBc7scMV7Bnc94iEHsO34RvMKcwlfeDOj0TmKpAIRfKR+1nMxvldnuhCoqr0KZofllYIWNkU6D/Lv59mz1R1xK80ErLpI8x6TQmh5g7eVAxIDwwwtsapP8nsCeHc4zhcAojAIviJFu8PITJPucD6ynlbN5BDQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695043792; 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=MK81YSKXyc2a4PJeHFVSO65hRT3fyunPoXKgu6hPt2U=; b=NrUWqXVkHg8GcJ2AKCdgdrwewjv6UPhu0XinuXxqEF/Sf1UMF02nPVNYJxuM+iQuSnmP5E/6Br8KBHq0WYhkTN0I8wiW1gkXFbukTDrCUXJUlyPFNuUBpkUOWIju4/q7aZH88XN1uJUlVuk214ko4FWx+eBxB+6dvTa/F51a2vk= 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 1695043792289246.3758916291946; Mon, 18 Sep 2023 06:29:52 -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-467-zqlJ1W5ENVCy5XX_pWhvqA-1; Mon, 18 Sep 2023 09:29:48 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CD7B429AA3BD; Mon, 18 Sep 2023 13:29:46 +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 B89251C554; Mon, 18 Sep 2023 13:29:46 +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 A46391946594; Mon, 18 Sep 2023 13:29:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 34876194658C for ; Mon, 18 Sep 2023 13:29:34 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 176971C554; Mon, 18 Sep 2023 13:29:34 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.226.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id ADEB0170EC for ; Mon, 18 Sep 2023 13:29:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695043791; 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=MK81YSKXyc2a4PJeHFVSO65hRT3fyunPoXKgu6hPt2U=; b=d1IS29Uz6oDD5gyj7xEJJ6NTWkP4Xcq8jvvvGbX79xmjG32Yf/s+BfxSpwVRc4RlI0FLl7 868wRDn2N+lDzOWFzr6W7wzCMf2YXNY/R3GDO98CaKJDKyNjvf3EMYNlMvEO3pTUlsx0LD WXVlU7S0dtCrYV/WXa1MFITzmtBLzhw= X-MC-Unique: zqlJ1W5ENVCy5XX_pWhvqA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 01/10] qemu_saveimage: extract starting process to qemuSaveImageStartProcess Date: Mon, 18 Sep 2023 15:29:18 +0200 Message-ID: <4cdec83aff0e3861364f2756099f616ac4fb2165.1695043512.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: 1695043793488100001 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 | 96 +++++++++++++++++++++++++++------------ src/qemu/qemu_saveimage.h | 11 +++++ 2 files changed, 78 insertions(+), 29 deletions(-) diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index 41310d6a9a..27b95b03ae 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -565,42 +565,50 @@ 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 + * @data: data 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, + virQEMUSaveData *data, + virDomainAsyncJob asyncJob, + unsigned int start_flags, + bool *started) { qemuDomainObjPrivate *priv =3D vm->privateData; - int ret =3D -1; - bool started =3D false; - virObjectEvent *event; + g_autoptr(qemuDomainSaveCookie) cookie =3D NULL; + virQEMUSaveHeader *header =3D &data->header; 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; =20 if (virSaveCookieParseString(data->cookie, (virObject **)&cookie, virDomainXMLOptionGetSaveCookie(driver->x= mlopt)) < 0) - goto cleanup; + return -1; =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 +621,7 @@ qemuSaveImageStartVM(virConnectPtr conn, if (virCommandRunAsync(cmd, NULL) < 0) { *fd =3D intermediatefd; intermediatefd =3D -1; - goto cleanup; + return -1; } } =20 @@ -622,7 +630,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 +639,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 +664,45 @@ 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; + 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 (qemuSaveImageStartProcess(conn, driver, vm, fd, path, data, + 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..24249ddf4c 100644 --- a/src/qemu/qemu_saveimage.h +++ b/src/qemu/qemu_saveimage.h @@ -57,6 +57,17 @@ qemuSaveImageUpdateDef(virQEMUDriver *driver, virDomainDef *def, const char *newxml); =20 +int +qemuSaveImageStartProcess(virConnectPtr conn, + virQEMUDriver *driver, + virDomainObj *vm, + int *fd, + const char *path, + virQEMUSaveData *data, + virDomainAsyncJob asyncJob, + unsigned int start_flags, + bool *started); + int qemuSaveImageStartVM(virConnectPtr conn, virQEMUDriver *driver, --=20 2.41.0 From nobody Sun May 12 23:43:20 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=1695043784; cv=none; d=zohomail.com; s=zohoarc; b=jnBny+p9V2SOUEMgzzkV45BQhBA5I1NlLYUDJFyP8z+iHsxvJtQO05k3t5nIUY7q2o5cAP+7CfOIdyQmlWmMZSxsvCNUOqjNSAer4esxgggF0x9Dw47KnPeRwLCmCk8U/YlxtRTVQQG3f3rJpUhGoCKH5KLdY0KjEtiJE/wOak4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695043784; 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=rF+zreg9l/KObQ93Dgii8/CJqUx2/gfVTVG1knBTOW8=; b=gSBZMcWIxfLUvTebQTQ5eqHYSiFr7iW9qVTGnweuiI6oYTTa4xTsyTwZHXbMBIfvHfUPKoLCeYTa2qMgqFIU7FcSms9+DuvNt67Y6Vw/Fc0cEiigMvxpVkV/2JgjelMNZI5vEmgv3J/dI7QdzNdVLPiefBt966vlq7KkQL6X1Qg= 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 1695043784306376.2928389217725; Mon, 18 Sep 2023 06:29:44 -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-642-T3pSwYzqOY6gBmfXSxcmpA-1; Mon, 18 Sep 2023 09:29:41 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CEB04380671D; Mon, 18 Sep 2023 13:29:38 +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 D249220268CB; Mon, 18 Sep 2023 13:29:35 +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 652EA194658D; Mon, 18 Sep 2023 13:29:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BE364194658C for ; Mon, 18 Sep 2023 13:29:34 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B2CC2170EC; Mon, 18 Sep 2023 13:29:34 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.226.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 54D571C5BB for ; Mon, 18 Sep 2023 13:29:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695043783; 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=rF+zreg9l/KObQ93Dgii8/CJqUx2/gfVTVG1knBTOW8=; b=K9BUq4VmFCIpPle8ehdDmSYAXwSmMHhpIgWvnzlUIom6PCYW8jF614HPMriWcB5w5irYVU 62yroZiYgkkE/3HKb1jb2QLkg/nXoICvk0fhHp6BQ42tJQXeC4/s89A1ap0B1SsH+DT4Wc BjYRNyrtAAcHOv2OFgJ2H7Ag50V8dzY= X-MC-Unique: T3pSwYzqOY6gBmfXSxcmpA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 02/10] qemu_saveimage: introduce helpers to decompress memory state file Date: Mon, 18 Sep 2023 15:29:19 +0200 Message-ID: <66bab038f8e738012056b192f976339388d5f20e.1695043512.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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.4 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: 1695043785359100001 Content-Type: text/plain; charset="utf-8"; x-default="true" These new helpers separates the code from the logic used to start new QEMU process with memory state and will make it easier to move qemuSaveImageStartProcess() into qemu_process.c file. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_saveimage.c | 155 +++++++++++++++++++++++++++----------- src/qemu/qemu_saveimage.h | 15 ++++ 2 files changed, 128 insertions(+), 42 deletions(-) diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index 27b95b03ae..95fabee907 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -247,6 +247,116 @@ qemuSaveImageGetCompressionCommand(virQEMUSaveFormat = compression) } =20 =20 +/** + * qemuSaveImageDecompressionStart: + * @data: data from memory state file + * @fd: pointer to FD of memory state file + * @intermediatefd: pointer to FD to store original @fd + * @errbuf: error buffer for @retcmd + * @retcmd: new virCommand pointer + * + * Start process to decompress VM memory state from @fd. If decompression + * is needed the original FD is stored to @intermediatefd and new FD after + * decompression is stored to @fd so caller can use the same variable + * in both cases. + * + * Function qemuSaveImageDecompressionStop() needs to be used to correctly + * stop the process and swap FD to the original state. + * + * Caller is responsible for freeing @retcmd. + * + * Returns -1 on error, 0 on success. + */ +int +qemuSaveImageDecompressionStart(virQEMUSaveData *data, + int *fd, + int *intermediatefd, + char **errbuf, + virCommand **retcmd) +{ + virQEMUSaveHeader *header =3D &data->header; + g_autoptr(virCommand) cmd =3D NULL; + + if (header->version !=3D 2) + return 0; + + if (header->compressed =3D=3D QEMU_SAVE_FORMAT_RAW) + return 0; + + if (!(cmd =3D qemuSaveImageGetCompressionCommand(header->compressed))) + return -1; + + *intermediatefd =3D *fd; + *fd =3D -1; + + virCommandSetInputFD(cmd, *intermediatefd); + virCommandSetOutputFD(cmd, fd); + virCommandSetErrorBuffer(cmd, errbuf); + virCommandDoAsyncIO(cmd); + + if (virCommandRunAsync(cmd, NULL) < 0) { + *fd =3D *intermediatefd; + *intermediatefd =3D -1; + return -1; + } + + *retcmd =3D g_steal_pointer(&cmd); + return 0; +} + + +/** + * qemuSaveImageDecompressionStop: + * @cmd: virCommand pointer + * @fd: pointer to FD of memory state file + * @intermediatefd: pointer to FD to store original @fd + * @errbuf: error buffer for @cmd + * @started: boolean to indicate if QEMU process was started + * @path: path to the memory state file + * + * Stop decompression process and close both @fd and @intermediatefd if + * necessary. + * + * Returns -1 on errro, 0 on success. + */ +int +qemuSaveImageDecompressionStop(virCommand *cmd, + int *fd, + int *intermediatefd, + char *errbuf, + bool started, + const char *path) +{ + int rc =3D 0; + virErrorPtr orig_err =3D NULL; + + if (*intermediatefd =3D=3D -1) + return rc; + + 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 + * the process + */ + virErrorPreserveLast(&orig_err); + VIR_FORCE_CLOSE(*intermediatefd); + VIR_FORCE_CLOSE(*fd); + } + + 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: %1$s"), path); + rc =3D -1; + } + + return rc; +} + + /* Helper function to execute a migration to file with a correct save head= er * the caller needs to make sure that the processors are stopped and do al= l other * actions besides saving memory */ @@ -595,7 +705,6 @@ qemuSaveImageStartProcess(virConnectPtr conn, { qemuDomainObjPrivate *priv =3D vm->privateData; g_autoptr(qemuDomainSaveCookie) cookie =3D NULL; - virQEMUSaveHeader *header =3D &data->header; VIR_AUTOCLOSE intermediatefd =3D -1; g_autoptr(virCommand) cmd =3D NULL; g_autofree char *errbuf =3D NULL; @@ -605,25 +714,8 @@ qemuSaveImageStartProcess(virConnectPtr conn, virDomainXMLOptionGetSaveCookie(driver->x= mlopt)) < 0) return -1; =20 - if ((header->version =3D=3D 2) && - (header->compressed !=3D QEMU_SAVE_FORMAT_RAW)) { - if (!(cmd =3D qemuSaveImageGetCompressionCommand(header->compresse= d))) - return -1; - - intermediatefd =3D *fd; - *fd =3D -1; - - virCommandSetInputFD(cmd, intermediatefd); - virCommandSetOutputFD(cmd, fd); - virCommandSetErrorBuffer(cmd, &errbuf); - virCommandDoAsyncIO(cmd); - - if (virCommandRunAsync(cmd, NULL) < 0) { - *fd =3D intermediatefd; - intermediatefd =3D -1; - return -1; - } - } + if (qemuSaveImageDecompressionStart(data, fd, &intermediatefd, &errbuf= , &cmd) < 0) + return -1; =20 /* No cookie means libvirt which saved the domain was too old to mess = up * the CPU definitions. @@ -641,28 +733,7 @@ qemuSaveImageStartProcess(virConnectPtr conn, start_flags) =3D=3D 0) *started =3D true; =20 - if (intermediatefd !=3D -1) { - virErrorPtr orig_err =3D NULL; - - 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 - * the process - */ - virErrorPreserveLast(&orig_err); - VIR_FORCE_CLOSE(intermediatefd); - VIR_FORCE_CLOSE(*fd); - } - - 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: %1$s"), path); - rc =3D -1; - } + rc =3D qemuSaveImageDecompressionStop(cmd, fd, &intermediatefd, errbuf= , *started, path); =20 virDomainAuditStart(vm, "restored", *started); if (!*started || rc < 0) diff --git a/src/qemu/qemu_saveimage.h b/src/qemu/qemu_saveimage.h index 24249ddf4c..dcee482066 100644 --- a/src/qemu/qemu_saveimage.h +++ b/src/qemu/qemu_saveimage.h @@ -99,6 +99,21 @@ qemuSaveImageGetCompressionProgram(const char *imageForm= at, bool use_raw_on_fail) ATTRIBUTE_NONNULL(2); =20 +int +qemuSaveImageDecompressionStart(virQEMUSaveData *data, + int *fd, + int *intermediatefd, + char **errbuf, + virCommand **retcmd); + +int +qemuSaveImageDecompressionStop(virCommand *cmd, + int *fd, + int *intermediatefd, + char *errbuf, + bool started, + const char *path); + int qemuSaveImageCreate(virQEMUDriver *driver, virDomainObj *vm, --=20 2.41.0 From nobody Sun May 12 23:43:20 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=1695043801; cv=none; d=zohomail.com; s=zohoarc; b=UULHKaY3KLOPVMOMCNBoako7iGMNaVN0RkzSLPVwLTu7u35YtW+oh4X1huUwQvPmH7JLy58a3PDaoMfwfz+K3M6C9EMfCN0+p4vQf6eYinpLNQzJ1NvxhD068baCsD10SXFfHrv12aSKuHhR3SsGw2IPJ4cIl9ZBKB6+vAzeYrM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695043801; 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=id7+JdSFFgj3CzqbC4TuSgpWVlsKIDC/MjqIFIMddkQ=; b=i96l7D1Rty1abXyo2P5IhPEKJEWuOd4sfyTyh8qoLa1RSbVnOxqu6zQhI30deNDz7ANWi1xtlQEGRc1q9VksaJeS5+wy/b+Yqkv5EEpGi0wBTmCZ6vgrazxc5hyytIzJF4oUs91OzBUuKjZ8RIWBtzyjlflDpel3NeXlX+6WMx0= 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 1695043801897721.7565121482365; Mon, 18 Sep 2023 06:30:01 -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-669-ftAwVpQMOW-zCvVzHoBPpQ-1; Mon, 18 Sep 2023 09:29:55 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2014C1C0515E; Mon, 18 Sep 2023 13:29:53 +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 099AAC03292; Mon, 18 Sep 2023 13:29:53 +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 D813219465A0; Mon, 18 Sep 2023 13:29:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 688FA194658F for ; Mon, 18 Sep 2023 13:29:35 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 571161C5BB; Mon, 18 Sep 2023 13:29:35 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.226.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED7A11C554 for ; Mon, 18 Sep 2023 13:29:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695043800; 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=id7+JdSFFgj3CzqbC4TuSgpWVlsKIDC/MjqIFIMddkQ=; b=bkWSRvlkqIfo/7Zr1wBD/nU9gIAEujM4ETv7O//itzknIb4f2pk2eQJZEaJWtPf77AT8lf LTw+s0Ep/ccjlPIGkeTV2QQfrBCbzMshLBINNDtA2k/AvRjBhYftYW2Czg/HfbhLf6j3hQ vA9geLhbNn+c7W4z5er+dAZya88XJi4= X-MC-Unique: ftAwVpQMOW-zCvVzHoBPpQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 03/10] qemu_saveimage: move qemuSaveImageStartProcess to qemu_process Date: Mon, 18 Sep 2023 15:29:20 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: 1695043803779100001 Content-Type: text/plain; charset="utf-8"; x-default="true" The function will no longer be used only when restoring VM as it will be used when reverting snapshot as well so move it to qemu_process and rename it accordingly. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_process.c | 73 +++++++++++++++++++++++++++++++++++++ src/qemu/qemu_process.h | 11 ++++++ src/qemu/qemu_saveimage.c | 75 ++------------------------------------- src/qemu/qemu_saveimage.h | 11 ------ 4 files changed, 86 insertions(+), 84 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 42837c4a8a..0de8ceb244 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8157,6 +8157,79 @@ qemuProcessStart(virConnectPtr conn, } =20 =20 +/** + * qemuProcessStartWithMemoryState: + * @conn: connection object + * @driver: qemu driver object + * @vm: domain object + * @fd: FD pointer of memory state file + * @path: path to memory state file + * @data: data 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 +qemuProcessStartWithMemoryState(virConnectPtr conn, + virQEMUDriver *driver, + virDomainObj *vm, + int *fd, + const char *path, + virQEMUSaveData *data, + virDomainAsyncJob asyncJob, + unsigned int start_flags, + bool *started) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + g_autoptr(qemuDomainSaveCookie) cookie =3D NULL; + VIR_AUTOCLOSE intermediatefd =3D -1; + g_autoptr(virCommand) cmd =3D NULL; + g_autofree char *errbuf =3D NULL; + int rc =3D 0; + + if (virSaveCookieParseString(data->cookie, (virObject **)&cookie, + virDomainXMLOptionGetSaveCookie(driver->x= mlopt)) < 0) + return -1; + + if (qemuSaveImageDecompressionStart(data, fd, &intermediatefd, &errbuf= , &cmd) < 0) + return -1; + + /* No cookie means libvirt which saved the domain was too old to mess = up + * the CPU definitions. + */ + if (cookie && + qemuDomainFixupCPUs(vm, &cookie->cpu) < 0) + return -1; + + if (cookie && !cookie->slirpHelper) + priv->disableSlirp =3D true; + + if (qemuProcessStart(conn, driver, vm, cookie ? cookie->cpu : NULL, + asyncJob, "stdio", *fd, path, NULL, + VIR_NETDEV_VPORT_PROFILE_OP_RESTORE, + start_flags) =3D=3D 0) + *started =3D true; + + rc =3D qemuSaveImageDecompressionStop(cmd, fd, &intermediatefd, errbuf= , *started, path); + + virDomainAuditStart(vm, "restored", *started); + if (!*started || rc < 0) + return -1; + + /* 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); + + return 0; +} + + int qemuProcessCreatePretendCmdPrepare(virQEMUDriver *driver, virDomainObj *vm, diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index cae1b49756..d758b4f51a 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -23,6 +23,7 @@ =20 #include "qemu_conf.h" #include "qemu_domain.h" +#include "qemu_saveimage.h" #include "vireventthread.h" =20 int qemuProcessPrepareMonitorChr(virDomainChrSourceDef *monConfig, @@ -90,6 +91,16 @@ int qemuProcessStart(virConnectPtr conn, virNetDevVPortProfileOp vmop, unsigned int flags); =20 +int qemuProcessStartWithMemoryState(virConnectPtr conn, + virQEMUDriver *driver, + virDomainObj *vm, + int *fd, + const char *path, + virQEMUSaveData *data, + virDomainAsyncJob asyncJob, + unsigned int start_flags, + bool *started); + int qemuProcessCreatePretendCmdPrepare(virQEMUDriver *driver, virDomainObj *vm, const char *migrateURI, diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index 95fabee907..1fbc7891b1 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -675,77 +675,6 @@ 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 - * @data: data 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 -qemuSaveImageStartProcess(virConnectPtr conn, - virQEMUDriver *driver, - virDomainObj *vm, - int *fd, - const char *path, - virQEMUSaveData *data, - virDomainAsyncJob asyncJob, - unsigned int start_flags, - bool *started) -{ - qemuDomainObjPrivate *priv =3D vm->privateData; - g_autoptr(qemuDomainSaveCookie) cookie =3D NULL; - VIR_AUTOCLOSE intermediatefd =3D -1; - g_autoptr(virCommand) cmd =3D NULL; - g_autofree char *errbuf =3D NULL; - int rc =3D 0; - - if (virSaveCookieParseString(data->cookie, (virObject **)&cookie, - virDomainXMLOptionGetSaveCookie(driver->x= mlopt)) < 0) - return -1; - - if (qemuSaveImageDecompressionStart(data, fd, &intermediatefd, &errbuf= , &cmd) < 0) - return -1; - - /* No cookie means libvirt which saved the domain was too old to mess = up - * the CPU definitions. - */ - if (cookie && - qemuDomainFixupCPUs(vm, &cookie->cpu) < 0) - return -1; - - if (cookie && !cookie->slirpHelper) - priv->disableSlirp =3D true; - - if (qemuProcessStart(conn, driver, vm, cookie ? cookie->cpu : NULL, - asyncJob, "stdio", *fd, path, NULL, - VIR_NETDEV_VPORT_PROFILE_OP_RESTORE, - start_flags) =3D=3D 0) - *started =3D true; - - rc =3D qemuSaveImageDecompressionStop(cmd, fd, &intermediatefd, errbuf= , *started, path); - - virDomainAuditStart(vm, "restored", *started); - if (!*started || rc < 0) - return -1; - - /* 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); - - return 0; -} =20 int qemuSaveImageStartVM(virConnectPtr conn, @@ -769,8 +698,8 @@ qemuSaveImageStartVM(virConnectPtr conn, if (reset_nvram) start_flags |=3D VIR_QEMU_PROCESS_START_RESET_NVRAM; =20 - if (qemuSaveImageStartProcess(conn, driver, vm, fd, path, data, - asyncJob, start_flags, &started) < 0) { + if (qemuProcessStartWithMemoryState(conn, driver, vm, fd, path, data, + asyncJob, start_flags, &started) <= 0) { goto cleanup; } =20 diff --git a/src/qemu/qemu_saveimage.h b/src/qemu/qemu_saveimage.h index dcee482066..e541792153 100644 --- a/src/qemu/qemu_saveimage.h +++ b/src/qemu/qemu_saveimage.h @@ -57,17 +57,6 @@ qemuSaveImageUpdateDef(virQEMUDriver *driver, virDomainDef *def, const char *newxml); =20 -int -qemuSaveImageStartProcess(virConnectPtr conn, - virQEMUDriver *driver, - virDomainObj *vm, - int *fd, - const char *path, - virQEMUSaveData *data, - virDomainAsyncJob asyncJob, - unsigned int start_flags, - bool *started); - int qemuSaveImageStartVM(virConnectPtr conn, virQEMUDriver *driver, --=20 2.41.0 From nobody Sun May 12 23:43:20 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=1695043803; cv=none; d=zohomail.com; s=zohoarc; b=NJn5HspnlsnO8Y2CqSq9D5rs9RDX3SVlengCMzJFlwGZaNQytIYHPnXuhI30n7WWkbx/0OBwLM73rL0Xzgwc3h08G96Kt7jP+NUxhC348cP5XLJTwLGhw6V4XNe8rbQm2QwZ0CtC18CSvpKFNXteh1OkKgQRIEIZnA0M6kKcCcQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695043803; 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=8kLlifyYg+BGo3jv8hD2njcsHLkn1lk0iuciKSpt9/w=; b=ddiEj7NMC1S9hOcu4oFM3cdT1UF2Q2BtqFJlmoy9L3pYtlLM5pd+T/V+6TutPzQUoO23J7zRzaOkINbgCqlfjWtxnF/sXt2dHo+/9a3ejEhaXQUInJnjFayFwVMqoAVALIqqoT2LCe3SFmXAap/D4jOWX4Q3Z7/kLfDdqG3fKyQ= 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 1695043803433509.8183529790417; Mon, 18 Sep 2023 06:30:03 -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-moQCjySuM7a7GYo78XuiFg-1; Mon, 18 Sep 2023 09:29:55 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C3786858F1C; Mon, 18 Sep 2023 13:29:52 +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 AFECBC0FE03; Mon, 18 Sep 2023 13:29:52 +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 D8BBD19465B8; Mon, 18 Sep 2023 13:29:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 068E519465B7 for ; Mon, 18 Sep 2023 13:29:36 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EF23C1C554; Mon, 18 Sep 2023 13:29:35 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.226.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91B981C5BB for ; Mon, 18 Sep 2023 13:29:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695043802; 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=8kLlifyYg+BGo3jv8hD2njcsHLkn1lk0iuciKSpt9/w=; b=jU8uuSjHAeZm+MBPSaQT9leGnDrkHcuqFsqBMUMyayJn7VeaA6sc6zZb5IrcZHuDt7jwJB r3pI49+tO/9tercs35nsT5GU0bsIyuTTx6d3Jikf3TzYGBafHv9FHEKp8Z+OrL4F7cyhNr egAKJ0xhX0oLpjQu0LGPEcrauEMVBGc= X-MC-Unique: moQCjySuM7a7GYo78XuiFg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 04/10] qemuProcessStartWithMemoryState: allow setting reason for audit log Date: Mon, 18 Sep 2023 15:29:21 +0200 Message-ID: <1888c6271153c43dcda244980c48c306773e92eb.1695043512.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: 1695043804053100003 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_process.c | 6 +++++- src/qemu/qemu_process.h | 1 + src/qemu/qemu_saveimage.c | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 0de8ceb244..d414a40fd5 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8167,11 +8167,14 @@ qemuProcessStart(virConnectPtr conn, * @data: data 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 * is correctly decompressed so it can be loaded by QEMU process. * + * For audit purposes the expected @reason is one of `restored` or `from-s= napshot`. + * * Returns 0 on success, -1 on error. */ int @@ -8183,6 +8186,7 @@ qemuProcessStartWithMemoryState(virConnectPtr conn, virQEMUSaveData *data, virDomainAsyncJob asyncJob, unsigned int start_flags, + const char *reason, bool *started) { qemuDomainObjPrivate *priv =3D vm->privateData; @@ -8217,7 +8221,7 @@ qemuProcessStartWithMemoryState(virConnectPtr conn, =20 rc =3D qemuSaveImageDecompressionStop(cmd, fd, &intermediatefd, errbuf= , *started, path); =20 - virDomainAuditStart(vm, "restored", *started); + virDomainAuditStart(vm, reason, *started); if (!*started || rc < 0) return -1; =20 diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index d758b4f51a..26c9a04969 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -99,6 +99,7 @@ int qemuProcessStartWithMemoryState(virConnectPtr conn, virQEMUSaveData *data, virDomainAsyncJob asyncJob, unsigned int start_flags, + const char *reason, bool *started); =20 int qemuProcessCreatePretendCmdPrepare(virQEMUDriver *driver, diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index 1fbc7891b1..92dcf4b616 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -699,7 +699,8 @@ qemuSaveImageStartVM(virConnectPtr conn, start_flags |=3D VIR_QEMU_PROCESS_START_RESET_NVRAM; =20 if (qemuProcessStartWithMemoryState(conn, driver, vm, fd, path, data, - asyncJob, start_flags, &started) <= 0) { + asyncJob, start_flags, "restored", + &started) < 0) { goto cleanup; } =20 --=20 2.41.0 From nobody Sun May 12 23:43:20 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=1695043815; cv=none; d=zohomail.com; s=zohoarc; b=ghseh6d5Vt/U/OH2toCUV5pbqUYwtzb1jXDSBi/U0Mrr+Z/rE0gXLVBE00Wd+zcMVSN2b+Umh56p+oG9WX0CYVDN7CuaBxDfDnWJKOHDLK6zGyqY1bmC18cSzNipHPKsPYDSAO1EBy19Zq5Oz1tlP0s7mmGJrh9SQAkIMFNNiqM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695043815; 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=FwNZ1prkImREJpZT8NUHOkJM5tcG85hCZ/Zeh6rKvZA=; b=DHbTjLXABz23xvH4YJgZcZivs/d4RKCyjMNj+K1LwECoaObTnZ2hmfa7fHlzJyJXDcbta+8pNNBgepZgLkR4Fy4PMdUXsQ+bFKkeyKDNpMZhf2TZXtDqj9ViY/0xJf7dCb/BSMqBcSRAm4s9iKxTg0Kvzx8A0YwcNfOmhD5NWTM= 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 1695043815699630.3067388402005; Mon, 18 Sep 2023 06:30:15 -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-640-lFLHpvuRNNSxfS-NejYBuQ-1; Mon, 18 Sep 2023 09:30:09 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B44931875057; Mon, 18 Sep 2023 13:30:05 +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 9E42F1C5BB; Mon, 18 Sep 2023 13:30:05 +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 35AC6194658F; Mon, 18 Sep 2023 13:29:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B1E2319465B7 for ; Mon, 18 Sep 2023 13:29:36 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 92CFD170EC; Mon, 18 Sep 2023 13:29:36 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.226.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 35A0A1C646 for ; Mon, 18 Sep 2023 13:29:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695043814; 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=FwNZ1prkImREJpZT8NUHOkJM5tcG85hCZ/Zeh6rKvZA=; b=VKv2VOho5GvGwC5k+soKvjiVrMSxPTq7sIL2ynl159lur+XipTdxcoxY8eHNhOF8QiFK8v t8k2xI3E2psYqnaKtS1NriNBPMUNXbDjkbMQTNz8Hp9jTMD+LOcNHuDfRyJTVMI8ZEtxjN eGNoLi6kw7MUIst2Luw7FVsmLp+OKxg= X-MC-Unique: lFLHpvuRNNSxfS-NejYBuQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 05/10] qemuProcessStartWithMemoryState: add snapshot argument Date: Mon, 18 Sep 2023 15:29:22 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: 1695043817789100001 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_process.c | 9 ++++++++- src/qemu/qemu_process.h | 1 + src/qemu/qemu_saveimage.c | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index d414a40fd5..c8430bf7b7 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8164,6 +8164,7 @@ qemuProcessStart(virConnectPtr conn, * @vm: domain object * @fd: FD pointer of memory state file * @path: path to memory state file + * @snapshot: internal snapshot to load when starting QEMU process or NULL * @data: data from memory state file * @asyncJob: type of asynchronous job * @start_flags: flags to start QEMU process with @@ -8173,6 +8174,11 @@ qemuProcessStart(virConnectPtr conn, * 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. * + * When reverting to internal snapshot callers needs to pass @snapshot as = well + * correctly start QEMU process. + * + * When restoring VM from saved image @snapshot needs to be NULL. + * * For audit purposes the expected @reason is one of `restored` or `from-s= napshot`. * * Returns 0 on success, -1 on error. @@ -8183,6 +8189,7 @@ qemuProcessStartWithMemoryState(virConnectPtr conn, virDomainObj *vm, int *fd, const char *path, + virDomainMomentObj *snapshot, virQEMUSaveData *data, virDomainAsyncJob asyncJob, unsigned int start_flags, @@ -8214,7 +8221,7 @@ qemuProcessStartWithMemoryState(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; diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 26c9a04969..ce2f25a2e7 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -96,6 +96,7 @@ int qemuProcessStartWithMemoryState(virConnectPtr conn, virDomainObj *vm, int *fd, const char *path, + virDomainMomentObj *snapshot, virQEMUSaveData *data, virDomainAsyncJob asyncJob, unsigned int start_flags, diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index 92dcf4b616..89112e3e44 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -698,7 +698,7 @@ qemuSaveImageStartVM(virConnectPtr conn, if (reset_nvram) start_flags |=3D VIR_QEMU_PROCESS_START_RESET_NVRAM; =20 - if (qemuProcessStartWithMemoryState(conn, driver, vm, fd, path, data, + if (qemuProcessStartWithMemoryState(conn, driver, vm, fd, path, NULL, = data, asyncJob, start_flags, "restored", &started) < 0) { goto cleanup; --=20 2.41.0 From nobody Sun May 12 23:43:20 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=1695043802; cv=none; d=zohomail.com; s=zohoarc; b=hMYEkkvSErt3kJK7K+JKytk+e+Yj/8rqrA5u+dPH9QthJBk5ypZrIGl57DdW1ANBIC6ZxxNoV8MWjKMGVw2SY31WrHMYi0dPhIGXXs/nNEWTBEWuESSsRq0Yb7wLjxAWUCtjrJzMOQ21bBPNeZQRh6uanNJ6hOVLazJwQTc4TLc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695043802; 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=jfHdAbCfdqnuNQTBFA47Y7QJ6m29Bs20nGl5PYZZdjM=; b=Y6izLVDzTqo4gkc+BbmmKaCibPVhK+xxzaHnPWeyuejGG4d1mTjNk5iJSBmujFwmyPJjuhmd2UMkWFPGOQojPsjSWc4b0oWJaXQWnvhujaxqubj9VogD9ZocavuCB/p3gDFrh4auDlh7jnjrkIQ83eaEtw9nqJxoHkOAg3EEXdQ= 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 1695043802682974.7095546298643; Mon, 18 Sep 2023 06:30:02 -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-307-fMsX6pcwMVuS3fnOT4H7GQ-1; Mon, 18 Sep 2023 09:29:59 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 20E798002B2; Mon, 18 Sep 2023 13:29:57 +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 0CB9F215670B; Mon, 18 Sep 2023 13:29:57 +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 199C91946A4D; Mon, 18 Sep 2023 13:29:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 42EC019465B7 for ; Mon, 18 Sep 2023 13:29:37 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 365E61C554; Mon, 18 Sep 2023 13:29:37 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.226.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD33F170EC for ; Mon, 18 Sep 2023 13:29:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695043801; 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=jfHdAbCfdqnuNQTBFA47Y7QJ6m29Bs20nGl5PYZZdjM=; b=fph6txGbdRNpZpim+63cnozr9wUWztRpYH2RZmYHvFnvOUZjaVVrbqt8ObRa4yGqMlIbp9 b4S3xET+RuS1+xq9f7E/mHpscXDzejiSBpGH+Lrk1J72PubZGQNRJQ8QBzGhenxg4fADBv c+/FRBiOFspeczp7UZ3Tu/tVg3UL3Jg= X-MC-Unique: fMsX6pcwMVuS3fnOT4H7GQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 06/10] qemuProcessStartWithMemoryState: make it possible to use without data Date: Mon, 18 Sep 2023 15:29:23 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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.6 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: 1695043804580100005 Content-Type: text/plain; charset="utf-8"; x-default="true" When used with internal snapshots there is no memory state file so we have no data to load and decompression is not needed. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_process.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index c8430bf7b7..f96918073f 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8165,7 +8165,7 @@ qemuProcessStart(virConnectPtr conn, * @fd: FD pointer of memory state file * @path: path to memory state file * @snapshot: internal snapshot to load when starting QEMU process or NULL - * @data: data from memory state file + * @data: data from memory state file or NULL * @asyncJob: type of asynchronous job * @start_flags: flags to start QEMU process with * @reason: audit log reason @@ -8175,7 +8175,8 @@ qemuProcessStart(virConnectPtr conn, * is correctly decompressed so it can be loaded by QEMU process. * * When reverting to internal snapshot callers needs to pass @snapshot as = well - * correctly start QEMU process. + * correctly start QEMU process. In addition there is no memory state file= so + * it's safe to pass NULL as @data. * * When restoring VM from saved image @snapshot needs to be NULL. * @@ -8203,9 +8204,16 @@ qemuProcessStartWithMemoryState(virConnectPtr conn, g_autofree char *errbuf =3D NULL; int rc =3D 0; =20 - if (virSaveCookieParseString(data->cookie, (virObject **)&cookie, - virDomainXMLOptionGetSaveCookie(driver->x= mlopt)) < 0) - return -1; + if (data) { + if (virSaveCookieParseString(data->cookie, (virObject **)&cookie, + virDomainXMLOptionGetSaveCookie(drive= r->xmlopt)) < 0) + return -1; + + if (qemuSaveImageDecompressionStart(data, fd, &intermediatefd, + &errbuf, &cmd) < 0) { + return -1; + } + } =20 if (qemuSaveImageDecompressionStart(data, fd, &intermediatefd, &errbuf= , &cmd) < 0) return -1; @@ -8226,7 +8234,10 @@ qemuProcessStartWithMemoryState(virConnectPtr conn, start_flags) =3D=3D 0) *started =3D true; =20 - rc =3D qemuSaveImageDecompressionStop(cmd, fd, &intermediatefd, errbuf= , *started, path); + if (data) { + rc =3D qemuSaveImageDecompressionStop(cmd, fd, &intermediatefd, er= rbuf, + *started, path); + } =20 virDomainAuditStart(vm, reason, *started); if (!*started || rc < 0) --=20 2.41.0 From nobody Sun May 12 23:43:20 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=1695043829; cv=none; d=zohomail.com; s=zohoarc; b=T6gLAaj4zBEv6bj48d4xYwGL1HEdJk3vZFNEarJZPaBKKvmeNCyo9TSQXGodkRooUcLURcYD5+aHefzL32adRY9c9d9WPmRF4N/V74aswnccpdGVac2l1mnbdt8W7YdjOmCS2g5m10wvIIy8PcG7cs9TbDN1Be5UGfPWeLVMg9w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695043829; 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=xIfmM5M+XIjz9LnrN93gT1YEcUde2KZsE2t/Lb+AL98=; b=Qn3gfBetxUuOhPjLErUv9mFRfGIwKlm4ohT4Q2TIo7UHltaFKxSk55DPIs7Kkdy2hGYdpmPAvc68gLd61maZ2V7e9i5IhYfEji9d9HISxTyYxkf1Hlx/uKpxGNOvafSWiNfx7W4vxNmSrno+e8WTerkqEaAQJPDck88ZLF3HmTg= 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 1695043829396688.8910573421588; Mon, 18 Sep 2023 06:30:29 -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-70-tMGMb4RCNOmFVXcndmwe1Q-1; Mon, 18 Sep 2023 09:30:23 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 22CEA1C0514C; Mon, 18 Sep 2023 13:30:17 +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 0C98E40C2070; Mon, 18 Sep 2023 13:30:17 +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 AF94B19465A4; Mon, 18 Sep 2023 13:29:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E3C0919465B2 for ; Mon, 18 Sep 2023 13:29:42 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id CF559170EC; Mon, 18 Sep 2023 13:29:37 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.226.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 70FA11C554 for ; Mon, 18 Sep 2023 13:29:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695043828; 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=xIfmM5M+XIjz9LnrN93gT1YEcUde2KZsE2t/Lb+AL98=; b=Ub+pFlFmy51trccecuXTS9LTbTBAJVr95OCcZeSFTcZewWoIJL+BP/Y3UHcvtPSoaHHye6 QjIG0QPiwzDuJtUTUdCWotp/nqgCqYfP7KXrnnIjOLT3xATbfi/LxJSdmVFB8jJ3bpm1lX 0BDaFZNLRRQl6Q2iMY0FfWYbHYxmmFc= X-MC-Unique: tMGMb4RCNOmFVXcndmwe1Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 07/10] qemu_snapshot: fix reverting external snapshot when not all disks are included Date: Mon, 18 Sep 2023 15:29:24 +0200 Message-ID: <890c3b2aeb7c6fd8f977b29147934247b2dcd80b.1695043512.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: 1695043830180100001 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 Reviewed-by: Peter Krempa --- 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 cdc8e12cff..44bd97e564 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2054,6 +2054,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; } @@ -2094,6 +2097,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, @@ -2184,6 +2190,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'", @@ -2199,6 +2208,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 Sun May 12 23:43:20 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=1695043812; cv=none; d=zohomail.com; s=zohoarc; b=atGKWD3If0sPP8l17lyifkc+4Q7QKaDUJCxayjwR2AWtsKLb+tYJ2w9L4me7zmwjTNPp2QqHUt3nzdQlmFf0cglcdCR6GZzpasm1CAk06QKDpRsQABn8T2v6URR/Ft41ppTeHymMCy2g0yQQ2eSglVORvV65EDWy86W0+iI8zRw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695043812; 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=Tt/HsJPBA8C6d19pDh4GV8o+7pttS9LWb0ctzpS5/EQ=; b=UZbD7mfQOzhfBK41Dg12w7k2Bb16KMT786h0B4vnMXieJHNxy6ZbXJxBEmkoA+C6Q31SMS9BVoGUEKpbAUpjkZF9IvY+HeIoRj7fX2eiHZvHQYQNYqdpuy05YGoToNecbZYant8DfMQZsZVgKc21tQDSTiTS3liJb2uidsbJZ0E= 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 1695043812469370.8096028110093; Mon, 18 Sep 2023 06:30:12 -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-435-mM6204tMNmuYU1I9jBhXRA-1; Mon, 18 Sep 2023 09:30:07 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AD7F4945935; Mon, 18 Sep 2023 13:30:04 +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 994F940C200B; Mon, 18 Sep 2023 13:30:04 +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 680ED1946A72; Mon, 18 Sep 2023 13:29:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 84BB619465B7 for ; Mon, 18 Sep 2023 13:29:38 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 731DB1C646; Mon, 18 Sep 2023 13:29:38 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.226.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 163411C554 for ; Mon, 18 Sep 2023 13:29:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695043811; 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=Tt/HsJPBA8C6d19pDh4GV8o+7pttS9LWb0ctzpS5/EQ=; b=I+4lu21CRXdo5o2mCTUWBrssaaxw9kpktF7dQk5XO5ZnS3PvlAE4VVak3Jp20d7UACnrXa BxtoVP5txoHR6IUPqEYn5CE4K2hnovpqDfnlhEcdPgYw/EGT+tlla1g7EZRgpKNR0SEata /nnCreQ1IxC/qLNXhruv0eVLZd730Wo= X-MC-Unique: mM6204tMNmuYU1I9jBhXRA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 08/10] qemu_snapshot: correctly load the saved memory state file Date: Mon, 18 Sep 2023 15:29:25 +0200 Message-ID: <1be2a537616735c3ea4261258d4ac07c1df715b2.1695043512.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: 1695043814008100001 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 | 79 ++++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 32 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 44bd97e564..e52d264826 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2000,6 +2000,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 @@ -2007,15 +2022,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. */ @@ -2025,8 +2038,7 @@ qemuSnapshotRevertExternalPrepare(virDomainObj *vm, virDomainMomentObj *snap, virDomainDef *config, virDomainDef *inactiveConfig, - int *memsnapFD, - char **memsnapPath) + qemuSnapshotRevertMemoryData *memdata) { size_t i; bool active =3D virDomainObjIsActive(vm); @@ -2061,12 +2073,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; @@ -2250,13 +2271,12 @@ 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 @@ -2280,7 +2300,7 @@ qemuSnapshotRevertActive(virDomainObj *vm, =20 if (qemuSnapshotRevertExternalPrepare(vm, tmpsnapdef, snap, *config, *inactiveConfig, - &memsnapFD, &memsnapPath) < = 0) { + &memdata) < 0) { return -1; } } else { @@ -2294,28 +2314,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 (qemuProcessStartWithMemoryState(snapshot->domain->conn, driver, vm, + &memdata.fd, memdata.path, loadSna= p, + memdata.data, VIR_ASYNC_JOB_SNAPSH= OT, + start_flags, "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) @@ -2423,8 +2439,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 Sun May 12 23:43:20 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=1695043818; cv=none; d=zohomail.com; s=zohoarc; b=YwrqX1BMIVtVfieS48Wp0eqW7QXCrLiFukUJl0KEIF+i/uf1X4oOLcvGzDitg3D0trJb15apOXKY6SwsR5JOIZKxX4PS8hjlO/6LlKldCg800dVVYC7XJThHbX52xFgX1jkrSPejtgFQES6++IhWrPGxScgotrqdiSybtgO4y44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695043818; 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=1SF6ufDjHCysFHDhUXbRIQFNqcPE/00mDEjAFrgOPD0=; b=ZjsjxpjAHJyboOMV4MhLCMDV85FNC5vCmYcJZX0V1ADRKPoqSRnUHQBLg0ew1oX/+ZqUUSJOlSTmXAQzHErStbeozUy5ySSo6ex+gglQesIRa1KBZxXZ9B9a1PS9witwvc/KZP8Jz+vCps23oLag29TQdigRvSa3ReuN0VrqL0g= 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 1695043818279232.4914258469064; Mon, 18 Sep 2023 06:30:18 -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-192-yS07cptFMvyg0KaxH2yVAQ-1; Mon, 18 Sep 2023 09:30:14 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0AFF4185A78E; Mon, 18 Sep 2023 13:30:09 +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 E3E1940C2011; Mon, 18 Sep 2023 13:30:08 +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 65EF319465B9; Mon, 18 Sep 2023 13:29:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 33240194658D for ; Mon, 18 Sep 2023 13:29:39 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 166081C5BB; Mon, 18 Sep 2023 13:29:39 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.226.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD9C21C554 for ; Mon, 18 Sep 2023 13:29:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695043817; 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=1SF6ufDjHCysFHDhUXbRIQFNqcPE/00mDEjAFrgOPD0=; b=Mj2GHH0UTPXRSbBxdD9mclb8yyc4UZdYedH9vDXDMbDAdY1sMbIRdGKYO1ZqadS73KzgBM HtRNR/i7Y2jv7+o1bLA68v+3PtvrQRk7/qEliqdW+6airqRw0DraU0uRDV73ufsvJ0XDrQ Tzf1Y7reR58qXL3hVFEL0TZFOT5saVM= X-MC-Unique: yS07cptFMvyg0KaxH2yVAQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 09/10] capabilities: report full external snapshot support Date: Mon, 18 Sep 2023 15:29:26 +0200 Message-ID: <5a29b5df570aa781e6b989bcdfa11f55b98da08b.1695043512.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: 1695043820303100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Now that deleting and reverting external snapshots is implemented we can report that in capabilities so management applications can use that information and start using external snapshots. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- docs/formatcaps.rst | 7 +++++++ src/conf/capabilities.c | 1 + src/conf/capabilities.h | 1 + src/conf/schemas/capability.rng | 5 +++++ src/qemu/qemu_capabilities.c | 1 + tests/qemucaps2xmloutdata/caps.aarch64+hvf.xml | 1 + tests/qemucaps2xmloutdata/caps.aarch64.xml | 1 + tests/qemucaps2xmloutdata/caps.ppc.xml | 1 + tests/qemucaps2xmloutdata/caps.ppc64.xml | 1 + tests/qemucaps2xmloutdata/caps.riscv64.xml | 1 + tests/qemucaps2xmloutdata/caps.s390x.xml | 1 + tests/qemucaps2xmloutdata/caps.sparc.xml | 1 + tests/qemucaps2xmloutdata/caps.x86_64+hvf.xml | 1 + tests/qemucaps2xmloutdata/caps.x86_64.xml | 1 + 14 files changed, 24 insertions(+) diff --git a/docs/formatcaps.rst b/docs/formatcaps.rst index bb8bc663d2..95502c511f 100644 --- a/docs/formatcaps.rst +++ b/docs/formatcaps.rst @@ -134,6 +134,12 @@ The ```` element will typically wrap up the fo= llowing elements: creating external disk snapshots is supported. If absent, creating e= xternal snapshots may still be supported, but it requires attempting the API= and checking for an error to find out for sure. :since:`Since 1.2.3` + ``externalSnapshot`` + If this element is present, the hypervisor supports deleting and + reverting external snapshots including memory state. Support for cre= ation + of external snapshots is reported via the ``disksnapshot`` feature f= lag. + Management applications can now switch from internal snapshots to ex= ternal + snapshots. :since:`Since 9.7.0` =20 Examples ~~~~~~~~ @@ -318,6 +324,7 @@ capabilities enabled in the chip and BIOS you will see: + =20 diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 56768ce6e0..34f04cb7d3 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -508,6 +508,7 @@ static const struct virCapsGuestFeatureInfo virCapsGues= tFeatureInfos[VIR_CAPS_GU [VIR_CAPS_GUEST_FEATURE_TYPE_DEVICEBOOT] =3D { "deviceboot", false }, [VIR_CAPS_GUEST_FEATURE_TYPE_DISKSNAPSHOT] =3D { "disksnapshot", true = }, [VIR_CAPS_GUEST_FEATURE_TYPE_HAP] =3D { "hap", true }, + [VIR_CAPS_GUEST_FEATURE_TYPE_EXTERNAL_SNAPSHOT] =3D { "externalSnapsho= t", false }, }; =20 =20 diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index c78e3e52fa..9eaf6e2807 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -40,6 +40,7 @@ typedef enum { VIR_CAPS_GUEST_FEATURE_TYPE_DEVICEBOOT, VIR_CAPS_GUEST_FEATURE_TYPE_DISKSNAPSHOT, VIR_CAPS_GUEST_FEATURE_TYPE_HAP, + VIR_CAPS_GUEST_FEATURE_TYPE_EXTERNAL_SNAPSHOT, =20 VIR_CAPS_GUEST_FEATURE_TYPE_LAST } virCapsGuestFeatureType; diff --git a/src/conf/schemas/capability.rng b/src/conf/schemas/capability.= rng index 83b414961a..b1968df258 100644 --- a/src/conf/schemas/capability.rng +++ b/src/conf/schemas/capability.rng @@ -493,6 +493,11 @@ + + + + + diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 3a1bfbf74d..83119e871a 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1122,6 +1122,7 @@ virQEMUCapsInitGuestFromBinary(virCaps *caps, virCapabilitiesAddGuestFeature(guest, VIR_CAPS_GUEST_FEATURE_TYPE_DEVI= CEBOOT); virCapabilitiesAddGuestFeatureWithToggle(guest, VIR_CAPS_GUEST_FEATURE= _TYPE_DISKSNAPSHOT, true, false); + virCapabilitiesAddGuestFeature(guest, VIR_CAPS_GUEST_FEATURE_TYPE_EXTE= RNAL_SNAPSHOT); =20 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_TCG)) { virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, diff --git a/tests/qemucaps2xmloutdata/caps.aarch64+hvf.xml b/tests/qemucap= s2xmloutdata/caps.aarch64+hvf.xml index b53a886b90..b9a5b5a1d6 100644 --- a/tests/qemucaps2xmloutdata/caps.aarch64+hvf.xml +++ b/tests/qemucaps2xmloutdata/caps.aarch64+hvf.xml @@ -21,6 +21,7 @@ + =20 diff --git a/tests/qemucaps2xmloutdata/caps.aarch64.xml b/tests/qemucaps2xm= loutdata/caps.aarch64.xml index 5dca6d3102..61512ed740 100644 --- a/tests/qemucaps2xmloutdata/caps.aarch64.xml +++ b/tests/qemucaps2xmloutdata/caps.aarch64.xml @@ -21,6 +21,7 @@ + =20 diff --git a/tests/qemucaps2xmloutdata/caps.ppc.xml b/tests/qemucaps2xmlout= data/caps.ppc.xml index e7ba391795..86d6b85ae0 100644 --- a/tests/qemucaps2xmloutdata/caps.ppc.xml +++ b/tests/qemucaps2xmloutdata/caps.ppc.xml @@ -19,6 +19,7 @@ + =20 diff --git a/tests/qemucaps2xmloutdata/caps.ppc64.xml b/tests/qemucaps2xmlo= utdata/caps.ppc64.xml index 85623f3980..90859f9594 100644 --- a/tests/qemucaps2xmloutdata/caps.ppc64.xml +++ b/tests/qemucaps2xmloutdata/caps.ppc64.xml @@ -20,6 +20,7 @@ + =20 diff --git a/tests/qemucaps2xmloutdata/caps.riscv64.xml b/tests/qemucaps2xm= loutdata/caps.riscv64.xml index 09b7eb7f2f..c6fa950211 100644 --- a/tests/qemucaps2xmloutdata/caps.riscv64.xml +++ b/tests/qemucaps2xmloutdata/caps.riscv64.xml @@ -19,6 +19,7 @@ + =20 diff --git a/tests/qemucaps2xmloutdata/caps.s390x.xml b/tests/qemucaps2xmlo= utdata/caps.s390x.xml index bb82a15040..6379ab73e6 100644 --- a/tests/qemucaps2xmloutdata/caps.s390x.xml +++ b/tests/qemucaps2xmloutdata/caps.s390x.xml @@ -20,6 +20,7 @@ + =20 diff --git a/tests/qemucaps2xmloutdata/caps.sparc.xml b/tests/qemucaps2xmlo= utdata/caps.sparc.xml index 9d977c4102..b5b158e430 100644 --- a/tests/qemucaps2xmloutdata/caps.sparc.xml +++ b/tests/qemucaps2xmloutdata/caps.sparc.xml @@ -19,6 +19,7 @@ + =20 diff --git a/tests/qemucaps2xmloutdata/caps.x86_64+hvf.xml b/tests/qemucaps= 2xmloutdata/caps.x86_64+hvf.xml index 356819a6c6..f5e49ba4db 100644 --- a/tests/qemucaps2xmloutdata/caps.x86_64+hvf.xml +++ b/tests/qemucaps2xmloutdata/caps.x86_64+hvf.xml @@ -22,6 +22,7 @@ + =20 diff --git a/tests/qemucaps2xmloutdata/caps.x86_64.xml b/tests/qemucaps2xml= outdata/caps.x86_64.xml index 35359780c4..8dd1439a80 100644 --- a/tests/qemucaps2xmloutdata/caps.x86_64.xml +++ b/tests/qemucaps2xmloutdata/caps.x86_64.xml @@ -22,6 +22,7 @@ + =20 --=20 2.41.0 From nobody Sun May 12 23:43:20 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=1695043865; cv=none; d=zohomail.com; s=zohoarc; b=IbvkVm+5MARByqDM0bkkK0AVYoniGf62dPjusWk4gd0doUWKA5xhPAWdmdB+On6n4w2y13xS5a5MaC0KDiJ8VScZOQSArb7JOoq2TzA8BIDP44SkZfWh/hNMwEZ+S4voxnksM6dPonNlOWUBYlim46d06apux4+NlLlxuuNfA2Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695043865; 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=KACri1YSBxI/70NJP/MfjrblQwUda6tvyvDX69A0hqo=; b=k7vR928xSeOcZBAgEJz6tnzyXY+9DZ9KgUpjcEoppmgZatigffUxXzRGdxOd3H93iK4oyvC5T8wUR/QdvnIMXU47XSZ5Wc58Kj8rnr/6sbdOked5E8dct9vCh+IN8zsKn0VZTStCxd0f5kDNtZofctcLPps+vjL5jfCBHAUzkpk= 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 1695043865384220.3850784330525; Mon, 18 Sep 2023 06:31:05 -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-391-qsKfsOi5PMuTqdlSkqiM2Q-1; Mon, 18 Sep 2023 09:30:17 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D5F2B1C05158; Mon, 18 Sep 2023 13:30:14 +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 BFA9D1005E27; Mon, 18 Sep 2023 13:30:14 +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 98AB719459E6; Mon, 18 Sep 2023 13:29:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B452919466DF for ; Mon, 18 Sep 2023 13:29:39 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id AFB281C5BB; Mon, 18 Sep 2023 13:29:39 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.226.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 524F61C554 for ; Mon, 18 Sep 2023 13:29:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695043864; 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=KACri1YSBxI/70NJP/MfjrblQwUda6tvyvDX69A0hqo=; b=dxB6+WEpcvUlTCLce52hql1+2uz61eROka+4JvwLwOZ3EdJTIOyO8lb6X4oa3JGk68d+s6 KDAGplW11PRfBfENQ3FhbWnIpr+G81ThNeV9k/5YRWYollotKgeqROqwEymLAbClLAP09V 5W108C9w3WFcn1H7nK8lRLoJU46tj14= X-MC-Unique: qsKfsOi5PMuTqdlSkqiM2Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 10/10] NEWS: document support for reverting external snapshots Date: Mon, 18 Sep 2023 15:29:27 +0200 Message-ID: <4d6d662c216dd6cf7849584f545341be539290eb.1695043512.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: 1695043867147100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- NEWS.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index 926620b03f..940e6e348a 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -23,6 +23,14 @@ v9.8.0 (unreleased) =20 * **New features** =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