From nobody Tue Sep 9 23:57:22 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=1737588742; cv=none; d=zohomail.com; s=zohoarc; b=AVp0cijdb+GRgC+zj3HPnWVynSDQ31P4OcfFmz1uLhqwQpV1nGCFZ5NwgTHmJdOL1x2b2ZspImx7jgIhl8d8X4wxEyaCIMP+YL7ErSk5jsnDvFVrSvMOdHbo7Kovdp76CKLBhMsMJEH6AXL1VNVklP7I47QzXLL1TNRSyNzUS0g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737588742; h=Content-Transfer-Encoding:Cc:Cc: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; bh=I6lzq0FxdVqmPWN7CqkFYhYfe48E6tELIcm6gSqfnXo=; b=D5PyBbswDQYaSIL1OhTjn1aZYIrHushMiqkHXaN9PgdtamL2mRIBguKBm11mb7Zen7nFSvHyDhmm5FTp1zjb9LXKIfkJBER+5n4gudCj24CeKB1rfl1PluwoSj9Hm36jCvaB72lUAJO4Bdi/yIkkJzrxoMAbwTuqHkuuBy5KC8k= 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 1737588742259855.4304502434612; Wed, 22 Jan 2025 15:32:22 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id D0B5413FB; Wed, 22 Jan 2025 18:32:21 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 7FF2A12C1; Wed, 22 Jan 2025 18:23:40 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 5E9F313AD; Wed, 22 Jan 2025 18:23:30 -0500 (EST) Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (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 D6A1913B0 for ; Wed, 22 Jan 2025 18:23:06 -0500 (EST) Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-5d3d0205bd5so491957a12.3 for ; Wed, 22 Jan 2025 15:23:06 -0800 (PST) Received: from localhost (75-169-8-111.slkc.qwest.net. [75.169.8.111]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21c2d3deb6csm101293965ad.175.2025.01.22.15.23.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2025 15:23:05 -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=1737588186; x=1738192986; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bdusarzrhB3IYH7ZUAjJPhUgLK6W7/TW4bbma/26O8s=; b=SS9Gb8oRqMabnpD5SkUAqBvAtQfhvePu71HhlMC6mByJwmIH3ghdNac3NaDYkmJw7U H/AeaH9orikYsYA3Iuk9UE6fGXdKxSjIcGFwHVGTsu1fu/BQ6YKEfCq8aKOTzqi+32EW 2s26FU5KB55XxUIcjgTEzE96GHuwjjpIu/XHvccOwf/9X9cmHA4PLhDIHoN6hAmtVESS z9hy6+RUrpIN9igCRhdPE3FDiu2hLYd1m8AlfrdkM6mgKlm4W9VLMHgB5gxjWFQFdsOK L237YtwgnJxITgkcqTc/AAloYWF+Ea56mchln+T6FPiFwux/a38l+BQC69oeRNXh3EKL l1Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737588186; x=1738192986; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bdusarzrhB3IYH7ZUAjJPhUgLK6W7/TW4bbma/26O8s=; b=OV2mcaPc+T1YtwGhBnTeQnPlqY0I0B619OsY+mdPDkNx19uOJzIK8qBvQnGrpixMsZ UTFUaHSg+E+6zx3/+0y7NIfY1Rbzz1MbXYudV1kykRn9z2ScbWfIdwVFTjt9LVWTHuQv S9Fsk3z1GwJYufEClm0gSwgUc14QemuYvWm9iDla6v3iaKFqmDOhSZO2asng21o8jg70 ANB3/LY50yWFdPrXKyz/+Q5LgIZ+lEZWrab9i3qn6HuR436ciKoYkouIdx4P7OWFPk6V hXhS/3axVPoIVRYQj8UL3q53ExsoNMMEFnGQPJXxzGBtm747CY0HnauS0Pf1r516HFem zcWw== X-Gm-Message-State: AOJu0YxMar0oVC8Gu3VudCyPdgBgvyo6/yRevDty5FFzIB0xUCLmbaX/ uJiRIhnvkdskH4JGfmsv4t8iUPHUQ11LozHPi43fBaY9dwUcuEK/1CIdcIw8ZN2woJIJM9+dbpR h X-Gm-Gg: ASbGncv8YVI+F7h6EBArhwPZW/SnHUy3etMBEt+6Njh4jm8EmZegtLVr0vcG7kaVM2w rOTNPmT1ub5+F06vBCHtigNMH35jfItsJarx57V5Xaa7/4fz1qAg4t0yOQ5WIV6Nitax0pCIIky 3eDv9qviWv3zml4BHocFEXy/3ZvzKAYDVIZb0nTdWc0FIy47In8lM10uYU8TJ68Jo1bXROEHCQN DJhumAplYbqk5ssMgT14W/JaiPEv3Y6HL0XD4aLD0cMnX5jaBPvtIuE11RPgTwrevNPsyhOq/l1 H04YYNwIcHZL X-Google-Smtp-Source: AGHT+IFwD47uJwdxculPd2IJyd0nnUWju9VEEGj8sCGr3hgDUlRnTmZk1BFqoi4Xr/4WqjvxEGHI8A== X-Received: by 2002:a17:907:3602:b0:aaf:74b3:80db with SMTP id a640c23a62f3a-ab38b0b90f1mr2283015866b.3.1737588185685; Wed, 22 Jan 2025 15:23:05 -0800 (PST) To: devel@lists.libvirt.org Subject: [PATCH V2 19/20] tools: add parallel parameter to virsh save command Date: Wed, 22 Jan 2025 16:16:53 -0700 Message-ID: <20250122232228.19306-20-jfehlig@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250122232228.19306-1-jfehlig@suse.com> References: <20250122232228.19306-1-jfehlig@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: NFYQ3WQ5Q2AP5SMYYHMRIMRMZEAPORTJ X-Message-ID-Hash: NFYQ3WQ5Q2AP5SMYYHMRIMRMZEAPORTJ 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 CC: farosas@suse.de, Claudio Fontana 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: 1737588742860019000 Content-Type: text/plain; charset="utf-8" From: Claudio Fontana Signed-off-by: Claudio Fontana Signed-off-by: Jim Fehlig --- docs/manpages/virsh.rst | 12 +++++++++++- tools/virsh-domain.c | 41 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index e801037c04..669f27d2a6 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -3984,6 +3984,7 @@ save :: =20 save domain state-file [--bypass-cache] [--xml file] + [--parallel] [--parallel-channels channels] [{--running | --paused}] [--verbose] =20 Saves a running domain (RAM, but not disk state) to a state file so that @@ -3991,8 +3992,11 @@ it can be restored later. Once saved, the domain will no longer be running on the system, thus the memory allocated for the domain will be free for other domains to use. ``virsh restore`` restores from this state file. + If *--bypass-cache* is specified, the save will avoid the file system -cache, although this may slow down the operation. +cache. Depending on the specific scenario this may slow down or speed up +the operation. + =20 The progress may be monitored using ``domjobinfo`` virsh command and cance= led with ``domjobabort`` command (sent by another virsh instance). Another opt= ion @@ -4014,6 +4018,12 @@ based on the state the domain was in when the save w= as done; passing either the *--running* or *--paused* flag will allow overriding which state the ``restore`` should use. =20 +*--parallel* option will cause the save data to be written to file +over multiple parallel IO channels. The number of channels can be +specified using *--parallel-channels*. Using parallel IO channels +requires the use of ``sparse`` image save format. Parallel save may +significantly reduce the time required to save large memory domains. + Domain saved state files assume that disk images will be unchanged between the creation and restore point. For a more complete system restore point, where the disk state is saved alongside the memory diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 546db955a9..99acb45079 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -4145,6 +4145,14 @@ static const vshCmdOptDef opts_save[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("avoid file system cache when saving") }, + {.name =3D "parallel", + .type =3D VSH_OT_BOOL, + .help =3D N_("enable parallel save") + }, + {.name =3D "parallel-channels", + .type =3D VSH_OT_INT, + .help =3D N_("number of extra IO channels to use for parallel save") + }, {.name =3D "xml", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, @@ -4175,6 +4183,11 @@ doSave(void *opaque) g_autoptr(virshDomain) dom =3D NULL; const char *name =3D NULL; const char *to =3D NULL; + virTypedParameterPtr params =3D NULL; + int nparams =3D 0; + int maxparams =3D 0; + int nchannels =3D 0; + int rv =3D -1; unsigned int flags =3D 0; const char *xmlfile =3D NULL; g_autofree char *xml =3D NULL; @@ -4188,15 +4201,29 @@ doSave(void *opaque) goto out_sig; #endif /* !WIN32 */ =20 - if (vshCommandOptString(ctl, cmd, "file", &to) < 0) - goto out; - if (vshCommandOptBool(cmd, "bypass-cache")) flags |=3D VIR_DOMAIN_SAVE_BYPASS_CACHE; if (vshCommandOptBool(cmd, "running")) flags |=3D VIR_DOMAIN_SAVE_RUNNING; if (vshCommandOptBool(cmd, "paused")) flags |=3D VIR_DOMAIN_SAVE_PAUSED; + if (vshCommandOptBool(cmd, "parallel")) + flags |=3D VIR_DOMAIN_SAVE_PARALLEL; + + if (vshCommandOptString(ctl, cmd, "file", &to) < 0) + goto out; + if (to && + virTypedParamsAddString(¶ms, &nparams, &maxparams, + VIR_DOMAIN_SAVE_PARAM_FILE, to) < 0) + goto out; + + if ((rv =3D vshCommandOptInt(ctl, cmd, "parallel-channels", &nchannels= )) < 0) { + goto out; + } else if (rv > 0) { + if (virTypedParamsAddInt(¶ms, &nparams, &maxparams, + VIR_DOMAIN_SAVE_PARAM_PARALLEL_CHANNELS, = nchannels) < 0) + goto out; + } =20 if (vshCommandOptString(ctl, cmd, "xml", &xmlfile) < 0) goto out; @@ -4209,9 +4236,13 @@ doSave(void *opaque) vshReportError(ctl); goto out; } + if (xml && + virTypedParamsAddString(¶ms, &nparams, &maxparams, + VIR_DOMAIN_SAVE_PARAM_DXML, xml) < 0) + goto out; =20 if (flags || xml) { - rc =3D virDomainSaveFlags(dom, to, xml, flags); + rc =3D virDomainSaveParams(dom, params, nparams, flags); } else { rc =3D virDomainSave(dom, to); } @@ -4224,6 +4255,8 @@ doSave(void *opaque) data->ret =3D 0; =20 out: + virTypedParamsFree(params, nparams); + #ifndef WIN32 pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL); out_sig: --=20 2.43.0