From nobody Fri Dec 19 20:18:27 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=1738954005; cv=none; d=zohomail.com; s=zohoarc; b=HB/a4pFAGztThhPhb2B9CLFjWkuT4N4KssRKxNmEUXvY+HEBmIi8GWPn/ZntXlCG87eRreud4oy/P6nci/ym/yxvJivrdBMUm1Eo9EfFn1SkoXlraHiBvnJ5+9pWF8mGBSz7kRVw6MdgH/b0lubWco85KR+D98ufX44VTqpA7IE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738954005; 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=NhpoeFVWiBqdBIU7ShXizpmc8Yjw9AYxL5k+fNs3XXk=; b=Iaef5gh/uCkXG5feAVzkl4E17/Vw9YDUAJbxAX4UTCc7pVbo5lN7AOn7E5DmkjUUPpaGJR+nvHlIN6aJL15k/1M2obxHLdiN8FxTSWIy4ZQs9wwKQSlZJkqKMKLXlIZN2dmcQ0loutbnouqcOMXE+FZSFDSvvKLBOWas4yTMLgc= 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 1738954005410300.6617815690894; Fri, 7 Feb 2025 10:46:45 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 5A5811646; Fri, 7 Feb 2025 13:46:44 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 0C4141888; Fri, 7 Feb 2025 13:38:43 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 579201596; Fri, 7 Feb 2025 13:38:38 -0500 (EST) Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 1F9F21612 for ; Fri, 7 Feb 2025 13:38:14 -0500 (EST) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-436345cc17bso17342835e9.0 for ; Fri, 07 Feb 2025 10:38:14 -0800 (PST) Received: from localhost (205-201-32-8.scinternet.net. [205.201.32.8]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2f9bf6f116fsm6014560a91.0.2025.02.07.10.38.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2025 10:38:12 -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=1738953493; x=1739558293; 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=lFEfnHKLxyaCwAh/Cc8PhcGMjmxdr0RtUeku/Xo+0RA=; b=SJ0gr1makc7FGS/e9Z4MH/NKgX5gDg2OfyeNkWwM1Hq44RGVO+tnnxx7ywrf0oZO60 96GBVlN/Ga1LMpgUQilPV4/SksadFpr+QprLYe1tsrseL9xKigIaOltZ4NsFGywpEhvc xY2mWL/aa+r7f87RlWH1lDE2NV/87YRgo1pisWafMuEmYO2nr6D93DwS0qDSWLzyiNIf VxJoRgDvz/Y0dkpRyfkQGhLzI5IjoluVI18GWQwPPlPV94ZXrBUYDO6BIC2y0U3QyPYW yjNEbFbR8s/IiqTtibJRo+CgFFC+4gEEykTvLMuRK/H5O7Mt5mxbKwsilH9dDLVAFIBm lWHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738953493; x=1739558293; 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=lFEfnHKLxyaCwAh/Cc8PhcGMjmxdr0RtUeku/Xo+0RA=; b=Gbs7+WUSeRUer1HudTro7oGeWDM8zTurumDXG2E0I4b1eTyqckdJYHT7Hyv+/xXh76 TXwyBOHD3DWgoW9TL0iE69Y0BpN/0J1QqBOkENy9fhm9LCh1f6b4yzTBuALEnsjDYBGH br8JdiXFviA+zKEqHlQQc977RCjO/3hAu7vvEAmgoHUmcjRFpn+Cd0zJZRK/ub7xdlqI dQj/KGQ5mZtc1o8MkoYth2dNyOBjeM7jwVbOxet1Aac4XODt3gyu2MhDU3C4aUEJ4JhZ 6zZeqsvaaCw6G3V50aWdwpr30TEfvxo60h8OvbjzdX1jq8WSBeots+5PtSLQuKLl5gmm HAMg== X-Gm-Message-State: AOJu0YwzowJLpjFak0/vTNWWDK1nbeKJgLmvtbHmgduXS7hKmUXCY2Ce KSAC1cv1DmE2aU2uowu5z7QGSyQw5Ig8+BuUlwqQ2+c8S01mFU/9a67StuMBo227Y/c5Kd4y305 9 X-Gm-Gg: ASbGncuCkJg2N3N/lhvYY2gYq12KOsgv/ZsMwGkiVkrMx5u+OlD/eazpCX9yiUuZInU Tu7UTurGN0HHhmTq/bwoi2nz0h0oJVwqa/lcrdb2epkTzO22mI80WWCD/6JA0iUeBp/FgQ3okIV zzJajNCizB3XwVYo2DzEroTHMLZv3ztwwi2Z3l753F6KpTGjbXviDUqeFtTfpXcQDEx+YmbL/4C vAe2XrfKeHzPocMZFDScd++7MuNrICH2dSLEm08shKQR/MtibYetLqT9afFJkC2FOFSTDmGOLfQ D+oRsDyJDhQVyictGH4sHnW5k0atlGwwRQ== X-Google-Smtp-Source: AGHT+IHQ3/lShGsOKjGUNnYCMzGacy5F0YY90hj+qjA1bI04Tpjlt4AL0J01jjGJ/Rnw7nhViB515Q== X-Received: by 2002:a05:6000:1f82:b0:386:459e:655d with SMTP id ffacd0b85a97d-38dc9137df4mr2585541f8f.20.1738953492920; Fri, 07 Feb 2025 10:38:12 -0800 (PST) To: devel@lists.libvirt.org Subject: [PATCH V3 18/19] tools: add parallel parameter to virsh save command Date: Fri, 7 Feb 2025 11:27:29 -0700 Message-ID: <20250207183730.21686-19-jfehlig@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250207183730.21686-1-jfehlig@suse.com> References: <20250207183730.21686-1-jfehlig@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: JBDVVC5LE6XIEPBRR3M46MFOPQVSLOBG X-Message-ID-Hash: JBDVVC5LE6XIEPBRR3M46MFOPQVSLOBG 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: 1738954006178019100 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 | 42 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 0eb1d6ea93..959393be13 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -3997,6 +3997,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 @@ -4004,8 +4005,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 @@ -4027,6 +4031,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 f3da2f903f..3b765a95b5 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 1; + int rv =3D -1; unsigned int flags =3D 0; const char *xmlfile =3D NULL; g_autofree char *xml =3D NULL; @@ -4188,15 +4201,30 @@ 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 (flags & VIR_DOMAIN_SAVE_PARALLEL) { + if ((rv =3D vshCommandOptInt(ctl, cmd, "parallel-channels", &nchan= nels)) < 0) + goto out; + + 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 +4237,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 +4256,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