From nobody Thu Dec 18 17:54:49 2025 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