From nobody Fri Dec 19 20:17:05 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1739573493; cv=none; d=zohomail.com; s=zohoarc; b=ltx/hz6ZEJcQbju0ngLknaAtIPuKBCGP3Swh0oz3mEIrtqI4OYuDTRePC7+uXwxtHqo4Euc6gwZebCUm59kEi4NQJsIJQTUTGdc3Y0BKKIST7dfaZ5BpFHBVXTz0zDbLuDBosoSXzaSBBjfEXOn1KWTLoq3pFN5x9puCjRsmuiQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1739573493; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=UVGjSkzrTvbPIazxWVpd9hLyrwfNZEKwarxDC7c84S4=; b=ZTAIdwKgCJwAihvwSJfoN+4qhLAUOLcC5E4WH0fhZqLRwe1AK7oWqflSg3+d+FhUqOaZlg28hUmIeKqMEubqlPlv+2sFJ2N57iXj9BAhOxhiRiNXSxYgYp34j0FyYqxyuMxZ9rrvIPoeDoK+BUerRs9txpiKfYsklTL5I2X/rNk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1739573493583102.26456244652343; Fri, 14 Feb 2025 14:51:33 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 85D101B45; Fri, 14 Feb 2025 17:51:32 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id D89421BFF; Fri, 14 Feb 2025 17:50:23 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 034271C0E; Fri, 14 Feb 2025 17:50:18 -0500 (EST) Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 86AED1A08 for ; Fri, 14 Feb 2025 17:50:12 -0500 (EST) Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-38f1e8efe82so3002486f8f.0 for ; Fri, 14 Feb 2025 14:50:12 -0800 (PST) Received: from localhost (75-169-8-111.slkc.qwest.net. [75.169.8.111]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-220d537ca99sm33462205ad.106.2025.02.14.14.50.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Feb 2025 14:50:10 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1739573411; x=1740178211; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=MN981TTn8axKLUPpoAV+uTqD7ZKKK/9dBzGgBMRA8Wc=; b=ZJHLqC94I6lq5vuCf1qlRsiEaEW0rW/lU+23m/JMokPg7b7T3jou/r6vvSQl02N9bt hZub2s1E5dsRTPOeUmrfh3yqd+uWeJLQbl9O0sF8Q0GSP9HPQl1bG2dWJXXz3LSEiHyT 3n3Tm6dc7r/Hy/pDqWBamKlDA0/h/l7K1hnRESZtnUTNfvxMQGveiWcIekAeqZd1kH5l AV5aW11YAAR71N4NI9iEnU448FqlOPBNDavf3F2zjD/APJhUDGqOnNOjK5nF+7vXIUNi I48oQDwGf/5W9erWTiDfRjb5XOB/fK36BkqvsNrfjPNwkGvKBdY0i+HAmbVaRPUbehHr v+8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739573411; x=1740178211; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MN981TTn8axKLUPpoAV+uTqD7ZKKK/9dBzGgBMRA8Wc=; b=a9Yu64t0E/0RO5VCQyE+IrWwMIHQOV5V/MZzZjx7a8WVhwiqsFRFghBNgA2qI+FZZx EIplJrPmZudb4IJOgK+xgtvM6AgG+5kdgB6EOdfzAAKM/zMEnmPKQCLpqZ0IGAfJkjjg 0PHmlARtaCgTAiRfV1EdXJGIsTZRSdNM7UhJ2Ociu0pLh8fcf+z/ALeAr/G+ygjafheE 2kMl+MFBjXTsaGpYXuWbsTwIspAZ4tnUFxOZL8vNgazfUib1gIC112NdSaK5UE4/VWcV 9bKOAQbijnnxn4K2TiOdfH8qUqSzRqhPxepSjWT7x6RipsVZN5l9eqfoxg2cjodeTMyF bN8g== X-Gm-Message-State: AOJu0YzsNNUFnhHdA33hxgoBo9hHXx+CZIyNFkc8PrACTJjeoSv6WYUG GR2eh3v14B2HbbInhbSOXwQxPakykFfUMgZc5/SmMUyAdEoK3OguHiLUIJgZeXo2MrdJzw3i2E4 R X-Gm-Gg: ASbGncuOIpmwlr9L5jeNGC7wjbBMN5PMUEiPVyW/i9vRW2kIJ/rP66Dsk37RTmN2NeO QAUJLmz9+c0OJ7zkyju9Kd5uk+tgsWcbEtqEieb9ST7JuR0NHElhn72Bz9Y4eJbLNbMErc90ZW7 PDaMtkb9/WITPQ4gedlG7OoPPnnLwTZ0AyZKYzDqIZ2+j/EVWpuaegnxVJSTTn3HaFRynzZ9nm4 D3l0m5/3O/05KMpyvK2dX+skoFSrR7GPL8BARbJw40bFbEoJFJx0WIdYWz8mJHyD3tFbnUgxUW0 0d9giH0wUqVwKw/IlZFH3Zcgh0e8LmbM1A== X-Google-Smtp-Source: AGHT+IH2OUolKfcOAReVkwAVHCemdUhV6ks0Q2GgrVt1gQWtHHZ3Vlww4cW8Rca7PgyxUzvxABR/CA== X-Received: by 2002:a5d:50cd:0:b0:38c:5e03:5bb with SMTP id ffacd0b85a97d-38f33f51191mr924026f8f.41.1739573411341; Fri, 14 Feb 2025 14:50:11 -0800 (PST) To: devel@lists.libvirt.org Subject: [PATCH 2/3] qemu: Move special handling of invalid dump format to only caller Date: Fri, 14 Feb 2025 15:48:17 -0700 Message-ID: <20250214225005.29753-3-jfehlig@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250214225005.29753-1-jfehlig@suse.com> References: <20250214225005.29753-1-jfehlig@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ER3UAJGUNA45ZB4W2MACZ7Y33PZKPWO5 X-Message-ID-Hash: ER3UAJGUNA45ZB4W2MACZ7Y33PZKPWO5 X-MailFrom: jfehlig@suse.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Jim Fehlig via Devel Reply-To: Jim Fehlig X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1739573495338019100 Content-Type: text/plain; charset="utf-8" The 'use_raw_on_fail' logic in qemuSaveImageGetCompressionProgram is only used by doCoreDump in qemu_driver.c. Move the logic to the single call site and remove the parameter from qemuSaveImageGetCompressionProgram. Signed-off-by: Jim Fehlig --- src/qemu/qemu_driver.c | 29 ++++++++++++++++++++--------- src/qemu/qemu_saveimage.c | 38 ++++++++++---------------------------- src/qemu/qemu_saveimage.h | 3 +-- src/qemu/qemu_snapshot.c | 2 +- 4 files changed, 32 insertions(+), 40 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 78bfaa5b3a..0a1bcc0ed5 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2766,7 +2766,7 @@ qemuDomainManagedSaveHelper(virQEMUDriver *driver, cfg =3D virQEMUDriverGetConfig(driver); if ((format =3D qemuSaveImageGetCompressionProgram(cfg->saveImageForma= t, &compressor, - "save", false)) < 0) + "save")) < 0) return -1; =20 path =3D qemuDomainManagedSavePath(driver, vm); @@ -2800,7 +2800,7 @@ qemuDomainSaveFlags(virDomainPtr dom, const char *pat= h, const char *dxml, cfg =3D virQEMUDriverGetConfig(driver); if ((format =3D qemuSaveImageGetCompressionProgram(cfg->saveImageForma= t, &compressor, - "save", false)) < 0) + "save")) < 0) goto cleanup; =20 if (!(vm =3D qemuDomainObjFromDomain(dom))) @@ -2874,7 +2874,7 @@ qemuDomainSaveParams(virDomainPtr dom, cfg =3D virQEMUDriverGetConfig(driver); if ((format =3D qemuSaveImageGetCompressionProgram(cfg->saveImageForma= t, &compressor, - "save", false)) < 0) + "save")) < 0) goto cleanup; =20 if (virDomainObjCheckActive(vm) < 0) @@ -3077,6 +3077,7 @@ doCoreDump(virQEMUDriver *driver, { int fd =3D -1; int ret =3D -1; + int format =3D QEMU_SAVE_FORMAT_RAW; virFileWrapperFd *wrapperFd =3D NULL; int directFlag =3D 0; bool needUnlink =3D false; @@ -3085,13 +3086,23 @@ doCoreDump(virQEMUDriver *driver, g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); g_autoptr(virCommand) compressor =3D NULL; =20 + if (cfg->dumpImageFormat) { + if ((format =3D qemuSaveFormatTypeFromString(cfg->dumpImageFormat)= ) < 0) { + VIR_WARN("Invalid dump image format specified in configuration= file, using raw"); + format =3D QEMU_SAVE_FORMAT_RAW; + } + } + /* We reuse "save" flag for "dump" here. Then, we can support the same - * format in "save" and "dump". This path doesn't need the compression - * program to exist and can ignore the return value - it only cares to - * get the compressor */ - ignore_value(qemuSaveImageGetCompressionProgram(cfg->dumpImageFormat, - &compressor, - "dump", true)); + * format in "save" and "dump". If the compression program doesn't exi= st, + * reset any errors and continue on using the raw format. + */ + if (qemuSaveImageGetCompressionProgram(cfg->dumpImageFormat, + &compressor, "dump") < 0) { + virResetLastError(); + VIR_WARN("Compression program for dump image format in " + "configuration file isn't available, using raw"); + } =20 /* Create an empty file with appropriate ownership. */ if (dump_flags & VIR_DUMP_BYPASS_CACHE) { diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index 403e4c9679..eea35df175 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -513,10 +513,6 @@ qemuSaveImageCreate(virQEMUDriver *driver, * @compresspath: Pointer to a character string to store the fully qualifi= ed * path from virFindFileInPath. * @styleFormat: String representing the style of format (dump, save, snap= shot) - * @use_raw_on_fail: Boolean indicating how to handle the error path. For - * callers that are OK with invalid data or inability to - * find the compression program, just return a raw format - * and let the path remain as NULL. * * Returns: * virQEMUSaveFormat - Integer representation of the save image @@ -529,8 +525,7 @@ qemuSaveImageCreate(virQEMUDriver *driver, int qemuSaveImageGetCompressionProgram(const char *imageFormat, virCommand **compressor, - const char *styleFormat, - bool use_raw_on_fail) + const char *styleFormat) { int ret; const char *prog; @@ -549,6 +544,7 @@ qemuSaveImageGetCompressionProgram(const char *imageFor= mat, if (!(prog =3D virFindFileInPath(imageFormat))) goto error; =20 + *compressor =3D virCommandNew(prog); virCommandAddArg(*compressor, "-c"); if (ret =3D=3D QEMU_SAVE_FORMAT_XZ) @@ -558,31 +554,17 @@ qemuSaveImageGetCompressionProgram(const char *imageF= ormat, =20 error: if (ret < 0) { - if (use_raw_on_fail) - VIR_WARN("Invalid %s image format specified in " - "configuration file, using raw", - styleFormat); - else - virReportError(VIR_ERR_OPERATION_FAILED, - _("Invalid %1$s image format specified in confi= guration file"), - styleFormat); + ret =3D QEMU_SAVE_FORMAT_RAW; + virReportError(VIR_ERR_OPERATION_FAILED, + _("Invalid %1$s image format specified in configura= tion file"), + styleFormat); } else { - if (use_raw_on_fail) - VIR_WARN("Compression program for %s image format in " - "configuration file isn't available, using raw", - styleFormat); - else - virReportError(VIR_ERR_OPERATION_FAILED, - _("Compression program for %1$s image format in= configuration file isn't available"), - styleFormat); + virReportError(VIR_ERR_OPERATION_FAILED, + _("Compression program for %1$s image format in con= figuration file isn't available"), + styleFormat); } =20 - /* Use "raw" as the format if the specified format is not valid, - * or the compress program is not available. */ - if (use_raw_on_fail) - return QEMU_SAVE_FORMAT_RAW; - - return -1; + return ret; } =20 =20 diff --git a/src/qemu/qemu_saveimage.h b/src/qemu/qemu_saveimage.h index 8e755e1eb5..aa905768de 100644 --- a/src/qemu/qemu_saveimage.h +++ b/src/qemu/qemu_saveimage.h @@ -112,8 +112,7 @@ qemuSaveImageOpen(virQEMUDriver *driver, int qemuSaveImageGetCompressionProgram(const char *imageFormat, virCommand **compressor, - const char *styleFormat, - bool use_raw_on_fail) + const char *styleFormat) ATTRIBUTE_NONNULL(2); =20 int diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index ed140dd41c..4ff7e09bd4 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1658,7 +1658,7 @@ qemuSnapshotCreateActiveExternal(virQEMUDriver *drive= r, =20 if ((format =3D qemuSaveImageGetCompressionProgram(cfg->snapshotIm= ageFormat, &compressor, - "snapshot", false= )) < 0) + "snapshot")) < 0) goto cleanup; =20 if (!(xml =3D qemuDomainDefFormatLive(driver, priv->qemuCaps, --=20 2.43.0