From nobody Sat Nov 23 15:03:18 2024 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=1723160394; cv=none; d=zohomail.com; s=zohoarc; b=AjDnbxc2qJGm6WIfDkAOkWkhJ0qY7C+Ok2Q8bWusp3HF0+nbhU71THP+jk28URskroJhtu8EG958f1qxtjGhc8/bgh3CZ3rv7lvtyvMUYF6xMtNK0LE6vErjQo9ARym6cs+100rd4lKD4h9fTjC16jw4l3U5SESzTKWY1VsP8Mg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723160394; 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=ihwWSk4NCV5MUVhDNFNKechDlxbV23x0wATjLOFUZ04=; b=h0BoyX2/iyFThR+pq7U+tZ20zFxz6wM41bP2Evr3M/t1Qd3vnhmNIG7WR/VjTeBUWA8qMi0vyQqqqhc9fIrUl787qzVIS+dj7YGmM2N0BWf7covrPEHOGpM/ixYocoXYOMOhLoAkZzb7AgdNUDL9ZdGoSak4o+12dDt0vLE5d5U= 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 1723160394156185.12098405556526; Thu, 8 Aug 2024 16:39:54 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 24BF914A6; Thu, 8 Aug 2024 19:39:53 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 3162E13BB; Thu, 8 Aug 2024 19:38:29 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id C50F912BD; Thu, 8 Aug 2024 19:38:23 -0400 (EDT) Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (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 1BAD412BD for ; Thu, 8 Aug 2024 19:38:19 -0400 (EDT) Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2f189a2a7f8so15434681fa.2 for ; Thu, 08 Aug 2024 16:38:19 -0700 (PDT) Received: from localhost ([69.51.98.127]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-39b38bcf37fsm44165755ab.62.2024.08.08.16.38.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 16:38:17 -0700 (PDT) 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,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=1723160298; x=1723765098; 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=mddwPjqHrLFHS2KFN7Yr08edmPUU+prUBiuMEKgL8ZQ=; b=OkDfJ/E7iR1TIrU7mOrQ0KREcyEeFbsi7WDIT8MdkILEjg252dFXC5NCb1bSi37W/V pl9sZY0gUDXE0JjE+W5Ho7as/oXW4o0u7ODV5gLRbDr0OEsLx/PDBP1Tg9iuSt1EH6nA g34q96eQddjx0q3qsZU/7dtjpi6ecmxjk4/nVxjRomhaH5qFwSfQWuqLGRyrb6TZ7Rql UXhlrYZxjKayCw/MN/VAuVjQnAHZWF30HcFMyudzh0r8YsWeALZQdCIzoWd8eOtqk6ru jDBYf1S7/k+l2bVfuLwTKCXfAioEpSq2MJN1OQufHuYTQQrCvNIWZE2fQEDU25AiatfB PUYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723160298; x=1723765098; 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=mddwPjqHrLFHS2KFN7Yr08edmPUU+prUBiuMEKgL8ZQ=; b=URxXGRrdhAsPTSFcRHxA0aWOAxAE2MahZj0p0f5uf4XQCjvUL613epOaTLtRzTdyvn 6cAgFT/JKS15UqOHClLI/pA4hrBSxjifGos5qPctlrFV0POK4kVNsOR4EMpiYxTVKjBL WEg3YJbxjnoiax9Hbj2dZsaaTngQ2r7EG6M6OOqct4yzor7qILe0y8tc+i/IzVvTP5tn SVoxzbsN5SxklofoNPogWFazMfTOMj7JnwWCllqTpXmA0BWnfDkYUiJ+69ArfNCGnFCc ODW917TnAbUAvkMCpygwqTGYldLhkRHmqD6GiURDBHcEmPaJeaPvsavrFAMY66eVJsay pg6A== X-Gm-Message-State: AOJu0YyOrafQzZQIFgDsgSaZRotu5UCFzQPMb+sBHj93ay/wVH5TNcMm +D2FRuL6VpqnYrqFyg4A3mLj9l80cTQMVfPxKmYAFgOf755DQxf9iHp0OB5GvqdIG/W1nojmnuB s X-Google-Smtp-Source: AGHT+IEUwGoHPANhEDnVx0ZHfbHRr0zPC4rqHZM0NZLoS+wXKSpC8UDf1qOfi1o6zoF/VBpZiuMYPQ== X-Received: by 2002:a2e:9596:0:b0:2ee:974c:596f with SMTP id 38308e7fff4ca-2f19de4927bmr22386321fa.28.1723160297549; Thu, 08 Aug 2024 16:38:17 -0700 (PDT) To: devel@lists.libvirt.org Subject: [PATCH 01/20] lib: virDomainSaveParams: Ensure absolute save path Date: Thu, 8 Aug 2024 17:37:54 -0600 Message-Id: <20240808233813.22905-2-jfehlig@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240808233813.22905-1-jfehlig@suse.com> References: <20240808233813.22905-1-jfehlig@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: P7CZUBUNW5PWUXAXXKEPTFKNCRHHKVGN X-Message-ID-Hash: P7CZUBUNW5PWUXAXXKEPTFKNCRHHKVGN 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 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: 1723160394510116600 Content-Type: text/plain; charset="utf-8" When invoking virDomainSaveParams with a relative path, the image is saved to the daemon's CWD, which in most cases is '/'. Ensure a relative path is converted to absolute before invoking the driver 'domainSaveParams' function. Signed-off-by: Jim Fehlig --- src/libvirt-domain.c | 46 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 7c6b93963c..5aedae1b49 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -1020,6 +1020,11 @@ virDomainSaveParams(virDomainPtr domain, unsigned int flags) { virConnectPtr conn; + virTypedParameterPtr params_copy =3D NULL; + int nparams_copy =3D 0; + const char *to =3D NULL; + g_autofree char *absolute_to =3D NULL; + int ret =3D -1; =20 VIR_DOMAIN_DEBUG(domain, "params=3D%p, nparams=3D%d, flags=3D0x%x", params, nparams, flags); @@ -1030,23 +1035,46 @@ virDomainSaveParams(virDomainPtr domain, virCheckDomainReturn(domain, -1); conn =3D domain->conn; =20 - virCheckReadOnlyGoto(conn->flags, error); + virCheckReadOnlyGoto(conn->flags, done); =20 VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_SAVE_RUNNING, VIR_DOMAIN_SAVE_PAUSED, - error); + done); + + /* We must absolutize the file path as the save is done out of process= */ + virTypedParamsCopy(¶ms_copy, params, nparams); + nparams_copy =3D nparams; + if (virTypedParamsGetString(params_copy, nparams_copy, + VIR_DOMAIN_SAVE_PARAM_FILE, &to) < 0) + goto done; + + if (to) { + if (!(absolute_to =3D g_canonicalize_filename(to, NULL))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not build absolute output file path")); + goto done; + } + + if (virTypedParamsReplaceString(¶ms_copy, &nparams_copy, + VIR_DOMAIN_SAVE_PARAM_FILE, + absolute_to) < 0) + goto done; + } =20 if (conn->driver->domainSaveParams) { - if (conn->driver->domainSaveParams(domain, params, nparams, flags)= < 0) - goto error; - return 0; + if (conn->driver->domainSaveParams(domain, params_copy, nparams_co= py, flags) < 0) + goto done; + ret =3D 0; + } else { + virReportUnsupportedError(); } =20 - virReportUnsupportedError(); + done: + if (ret < 0) + virDispatchError(domain->conn); + virTypedParamsFree(params_copy, nparams_copy); =20 - error: - virDispatchError(domain->conn); - return -1; + return ret; } =20 =20 --=20 2.35.3 From nobody Sat Nov 23 15:03:18 2024 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=1723160367; cv=none; d=zohomail.com; s=zohoarc; b=ar1lTQf13gxMjaJWM5bvBvf51I+Y4qScJztqdkEukF2xdB88/FtbgojZ5gKTWahB94TYTXAcQcJmGuC11XIf1mBRuuKXV+DrEOf/6ASM2IIrpxXmd7kmsKFJXzsx3sWvqtaMSwmiQIlZmM8bLv/2l7/9jc394EMKstoEhyVJ16o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723160367; 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=FTBy7sqesGTlhhgwEgNvelseUhc6GoVR86wh+79XwZ4=; b=YXC3btZVyewcqqvncgRhERj5BRSyXZSiSk06fHACl1k/K0HwmjN2fdQyZhrx5C0MTfWAa5fTdcUr+4Vfo7p0A3rDJyQMJxarXaiYTAeP3pLHfHCw57y/YrRiEpKs9jyfeT1ZaGWo4FVcgerzlJvGG7etvMVAqZiCvLK6JVjJi8I= 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 1723160367433813.6186064744194; Thu, 8 Aug 2024 16:39:27 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 63051148F; Thu, 8 Aug 2024 19:39:26 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 23B4A12EB; Thu, 8 Aug 2024 19:38:27 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 0FAC212E2; Thu, 8 Aug 2024 19:38:22 -0400 (EDT) Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (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 4EBCD12CA for ; Thu, 8 Aug 2024 19:38:21 -0400 (EDT) Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2eeb1ba0468so19135221fa.0 for ; Thu, 08 Aug 2024 16:38:21 -0700 (PDT) Received: from localhost ([69.51.98.127]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-81fd4d3a31esm418237639f.30.2024.08.08.16.38.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 16:38:19 -0700 (PDT) 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,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=1723160300; x=1723765100; 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=t/xvwSaY3jX8VHWwL2CY2MBTUQkNCC5tTcnoKyoUVQ0=; b=gy7luBISxmd8Zn3i8qyqYPYu+tQ8yaD9A7Bq9aAkAQyTwOn2u6w4wMMCO+gR6IV2kX JWbBOl61kaNQXWLRntEnbTzq52HorJD7RW5FS+336OclohFQmsfO3zA/QvPRvyi9/Y0b XVtkuSJ0FSA5cEljZXV/3kpj/zUOmeAnWCRV1fEN9ZlCju3uDpp6FNIy9byykSiY0ebK MQGrHi8+FjbPuoLLF719Wmg0zVNx9BjiNL+kwfvcupz+kiMWeqxESS8h5QpASjxyiDQi R9LfcD9jYhToFW2v4Nsqx8T2euTxFT2rxUtKnk0XkTZ88LRzyyrypp4m4a3AkWjdktA3 ND/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723160300; x=1723765100; 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=t/xvwSaY3jX8VHWwL2CY2MBTUQkNCC5tTcnoKyoUVQ0=; b=inLA+dhzsa5VW7TxtfUJDeTkie+aUo09vA7LVz9tig1CeXS0YNhlHC7Cl48Ek6nz80 /d+5HTnrr3xpHKS9K6mbuGzZBm8tDk+lp12Pzu93+yz4EU2fTVrd5Zb5oHiQIHN7uhcM 3QtGTcodxbHLx5O+qEHJ6g4ddVx4GyNw9HxYawaIF1Z6Zv/DdN+IfHMb47QN58BvBxMV y8/68W+Za5RebUYLj78ffVh88l9w+GDEaK4YLCHOutJx36Ig4dTGBFetlm8WTAThd8Q/ OhMSMNoP92Ahh8pmgv/YENLvjbbZD0OMSbIbtqrs3KQzNF6QEIz0zcEDcg2jl84RB/Gw AgYg== X-Gm-Message-State: AOJu0Yxlf1GQJybY8Buc+jmydEQhw6tTjjFuPUYDyc6ZwK9YHi6cftfb iLhmQ2NwZ+JWqnr2j6yzhoLGkADKoKvvS90ezX9qBEwzUtiZGMqLeO78m/r59Zs40RsExzary8R Z X-Google-Smtp-Source: AGHT+IGgfCLxsN23ToWPD3hcVh1hNnrMCzQoLGg6gUrGM+X7pZP1UdT87ib87pHycacjlZsEKOvRqg== X-Received: by 2002:a2e:a541:0:b0:2f0:20cd:35fc with SMTP id 38308e7fff4ca-2f19de1fed7mr28012111fa.7.1723160299939; Thu, 08 Aug 2024 16:38:19 -0700 (PDT) To: devel@lists.libvirt.org Subject: [PATCH 02/20] qemu_fd: Add function to retrieve fdset ID Date: Thu, 8 Aug 2024 17:37:55 -0600 Message-Id: <20240808233813.22905-3-jfehlig@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240808233813.22905-1-jfehlig@suse.com> References: <20240808233813.22905-1-jfehlig@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: N4JMKQYVWUNAY7BBNXUBCIB34M63EM3T X-Message-ID-Hash: N4JMKQYVWUNAY7BBNXUBCIB34M63EM3T 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 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: 1723160368402116600 Content-Type: text/plain; charset="utf-8" Add new function qemuFDPassGetId() for retrieving the fdset ID of provided qemuFDPass object. Signed-off-by: Jim Fehlig Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_fd.c | 18 ++++++++++++++++++ src/qemu/qemu_fd.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/src/qemu/qemu_fd.c b/src/qemu/qemu_fd.c index e847056573..3ae4a87a20 100644 --- a/src/qemu/qemu_fd.c +++ b/src/qemu/qemu_fd.c @@ -276,6 +276,24 @@ qemuFDPassGetPath(qemuFDPass *fdpass) } =20 =20 +/** + * qemuFDPassGetId: + * @fdpass: The fd passing helper struct + * @id: An out parameter for providing the fdset ID + * + * Returns 0 on success, -1 on error. + */ +int +qemuFDPassGetId(qemuFDPass *fdpass, unsigned int *id) +{ + if (!fdpass) + return -1; + + *id =3D fdpass->fdSetID; + return 0; +} + + struct _qemuFDPassDirect { int fd; char *name; diff --git a/src/qemu/qemu_fd.h b/src/qemu/qemu_fd.h index cd0ff2c690..dfcd5fb754 100644 --- a/src/qemu/qemu_fd.h +++ b/src/qemu/qemu_fd.h @@ -58,6 +58,9 @@ qemuFDPassTransferMonitorRollback(qemuFDPass *fdpass, const char * qemuFDPassGetPath(qemuFDPass *fdpass); =20 +int +qemuFDPassGetId(qemuFDPass *fdpass, unsigned int *id); + =20 typedef struct _qemuFDPassDirect qemuFDPassDirect; =20 --=20 2.35.3 From nobody Sat Nov 23 15:03:18 2024 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=1723160418; cv=none; d=zohomail.com; s=zohoarc; b=Nhd1hp53gbnIck7CzZ5/SKyRtjBreO9S2IFLMOT/Is7CDOwCnFFt2VDZ7YnZFz5A4MwhOa4ysFH7+/0yy5bNJigQteeEfJrPqNqGWsmlitoj4gNNACkHrZOnqv7JYiqy8i9fCVnJ/+PWOqoVugLKNxwGnZ3xIsjDfaG4aQEu/MU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723160418; 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=F7OjoIGScxOrkcXGELPavdiXzkMfTcKzjOq4WawwPnU=; b=JcCQ9L9QWx8SR/h9ijwOGc3nMuXvyaTAgLKzeixLLjEzECqtmFBPRfL1P7ND4H02/hKG19Hmp7Wmld2fCTbxrlj20meTj1IvvqTa2i4jB5H03eESu4EjKSG0Df4EJJecDKIJ6c+39svcUkmJZyPv1kzDx7qtGcLnaLJNOkW2c/g= 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 1723160418151462.52267223434853; Thu, 8 Aug 2024 16:40:18 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id F1AF1137A; Thu, 8 Aug 2024 19:40:16 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 44CCC14C1; Thu, 8 Aug 2024 19:38:30 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 5350A12CA; Thu, 8 Aug 2024 19:38:24 -0400 (EDT) Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (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 9335B12CA for ; Thu, 8 Aug 2024 19:38:23 -0400 (EDT) Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2eeb1ba0468so19135451fa.0 for ; Thu, 08 Aug 2024 16:38:23 -0700 (PDT) Received: from localhost ([69.51.98.127]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d6a273c5sm3795354173.100.2024.08.08.16.38.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 16:38:21 -0700 (PDT) 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,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=1723160302; x=1723765102; 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=CBLP3RLVKI8Z0qp59yitF9BIiaylGPi/8peHWDi8AFY=; b=ZXZRNdWdo8ruX71GZi751aJ9LLBd8myRUNrhHZI2S8RGJp2kdxPg3WNkVmBindl0Rb r8Khveoqk/qSX0TV/RUYKN9UGaIhxQG4M8cpIXBCz90yoVqewZt9M1bT3rswpb+pZsks Q4FGi3NGdAhKSsH9s3/x87a0rqvHOL3vPJXPiPghHHifI0IHap17O6Ic+9vFuNnmB0zv TI/Myvi4dOZGG+KSIl5ieVBj1HzGw2fbtHNvfp8zq5FZJMveE0dTwyHWeaN9QAvQMv08 pO5xhAecEoPzfqOqF9KjHmE9ViW0jMwNba2PbFwIc4nGYU6Lt4XMBtyGv5IOojeWxhqD rOEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723160302; x=1723765102; 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=CBLP3RLVKI8Z0qp59yitF9BIiaylGPi/8peHWDi8AFY=; b=Wnu6LRCnzC4v0KkA+zREXWRxSecei2yKO5aL1Mqfz7h2m5RE1xyIll5i4mHZYVMPWX 2wYgo1lLKk8W4I3WOjRAMFU3Ft8rjlplW6ka9FeTsjjGRo+mAM3dzES4OWTgl/FX1L1G jG6LQ+8IO/GJBlOAJAgx9gaDh1uAhTrvgnPoPX8Ee3OcyaVPsLqWshjduXdJo4pwKRgs DhoZUF/JdoGsn9Kck451Df+OLbQLhs15oL60p4fNYdmZ8S3K+jDQsm5Y20hme0ecDrX+ nHwbcgaobjr9T0iJSzqr05+joAXjrr2kUDyQSR/ATo0SgcP/eyinwQ4nVuIRmf91Gm7l 72Ug== X-Gm-Message-State: AOJu0Yzyj3c50w3F0YPd+2EvQH2PCgsnw/KirnJmLL3EhzsnJOAIEnAD t+1Ucoer//GkZbVgEoKHvKTsppewiFKX9nuZkc9/u+hXVC3kgM3Z9UHhFgWwQxEcXr4N+FGzrr3 q X-Google-Smtp-Source: AGHT+IHOPJuDsl0ZUmBTuzA8ZQ/qELXXH6kn4DUMMFE8D/1jnNMA01wNDBytbUEHQeGBObDACZpBbg== X-Received: by 2002:a2e:a7ca:0:b0:2f1:a594:c1c3 with SMTP id 38308e7fff4ca-2f1a594c497mr1136631fa.32.1723160302182; Thu, 08 Aug 2024 16:38:22 -0700 (PDT) To: devel@lists.libvirt.org Subject: [PATCH 03/20] qemu: Add function to check capability in migration params Date: Thu, 8 Aug 2024 17:37:56 -0600 Message-Id: <20240808233813.22905-4-jfehlig@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240808233813.22905-1-jfehlig@suse.com> References: <20240808233813.22905-1-jfehlig@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: BF77N63CRYHE4F3LHGEFOGYPUQNI6ZJL X-Message-ID-Hash: BF77N63CRYHE4F3LHGEFOGYPUQNI6ZJL 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 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: 1723160418596116600 Content-Type: text/plain; charset="utf-8" Add new function qemuMigrationParamsCapEnabled() to check if a capability is set in the caller-provided migration parameters. Signed-off-by: Jim Fehlig Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_migration_params.c | 16 ++++++++++++++++ src/qemu/qemu_migration_params.h | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index 98822012cc..c3c9120c22 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -1303,6 +1303,22 @@ qemuMigrationParamsGetULL(qemuMigrationParams *migPa= rams, } =20 =20 +/** + * Returns true if @cap is enabled in @migParams, false otherwise. + */ +bool +qemuMigrationParamsCapEnabled(qemuMigrationParams *migParams, + qemuMigrationCapability cap) +{ + bool enabled =3D false; + + if (migParams) + ignore_value(virBitmapGetBit(migParams->caps, cap, &enabled)); + + return enabled; +} + + /** * qemuMigrationParamsCheck: * diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_par= ams.h index df67f1fb92..020071e8ef 100644 --- a/src/qemu/qemu_migration_params.h +++ b/src/qemu/qemu_migration_params.h @@ -136,6 +136,10 @@ qemuMigrationParamsGetULL(qemuMigrationParams *migPara= ms, qemuMigrationParam param, unsigned long long *value); =20 +bool +qemuMigrationParamsCapEnabled(qemuMigrationParams *migParams, + qemuMigrationCapability cap); + void qemuMigrationParamsSetBlockDirtyBitmapMapping(qemuMigrationParams *migPara= ms, virJSONValue **params); --=20 2.35.3 From nobody Sat Nov 23 15:03:18 2024 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=1723160445; cv=none; d=zohomail.com; s=zohoarc; b=PoAzdZNVrfCYnad0HKB20HKXtLbFHdRI3ZtMoZqclYKzvXEjEs6QLrfkmZZrvM8gb/Zk1eaRqyIwuVdAD1djkwPSHtujnU9iVkM/9vdps0m4ewHEHygWxG1NEhNqQp+wg2hENhP8zVRfkoX4JEa4bdjp0nRWS95rcRsJX/1Skds= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723160445; 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=8YUXLyy9QkAAR+VlPr5pRzJcd55lieewD0Fzpqi1llE=; b=VIY812KaHBVJEGLTgIDxuae0rnmv2qSoJKPNnKd9uKN/DWI+FG6JCNyAzfB4R/iHMJu8lCETXv92PsdVfF5SCM05bXHdsqHAVGXlG1rcGRSX6vtvr86IrRv/LyakveJ6OZ2IZejveOZclxQa+4i1Hma62keVUsAxfpZGzxG2yXg= 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 172316044595695.84430787380734; Thu, 8 Aug 2024 16:40:45 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id DFA351436; Thu, 8 Aug 2024 19:40:44 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id D392C1379; Thu, 8 Aug 2024 19:38:44 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 935A21442; Thu, 8 Aug 2024 19:38:39 -0400 (EDT) Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.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 A574D146F for ; Thu, 8 Aug 2024 19:38:25 -0400 (EDT) Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-367963ea053so1173048f8f.2 for ; Thu, 08 Aug 2024 16:38:25 -0700 (PDT) Received: from localhost ([69.51.98.127]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d69a880fsm3758359173.61.2024.08.08.16.38.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 16:38:23 -0700 (PDT) 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,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=1723160304; x=1723765104; 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=nXAWIVV4z2a5pIRAEgHP3K9iM3jyvCqwo6umyIFT9uI=; b=Ua8IE+h/nA8rrpDuJ3QCr2MPoZvPlDRNb9fRwrxvIJrgsorp+0NpDsH/TJJuudG6y+ zeMalS2lbS0gaSH4oOHlw5Hf5neOn9TeGynODo0NRrzLmzE2LWukkThcxXzzLiyw+0c8 dcHtfVROKct+Xp0/j3H9Wghy16742K/CYFnhGcpKuTdHw6UvtOtCi52YEodlKucOAnHO p0REhEa++J0kZmiPbJUdjGAubmMYY4mgy+fmaA1TEy+LkCmgL6Wq9+0JO8BTLnwiN2Um xlNEqIy7xmQlnm6HHVa/pjN78E3YRFneOxPs1wkEmsguRy+gKb347SXJv8B0fUkDR/Hm kyrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723160304; x=1723765104; 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=nXAWIVV4z2a5pIRAEgHP3K9iM3jyvCqwo6umyIFT9uI=; b=bLAxAjH6yQaafERNXjIH88zh9ouPpyZbRmeX9Ok1Ze/JT8BKssrlQkWkTI+I1rE+wy hRn34un7sBwNo58JWRVQ7mHGiaMoebrXQ8AAPHyyvJhhSaZMw1xumoY69RWsivQFrx6Q D0SSLTiFm+sEodCyGWruJZq4j8kD7HC2Nw4+mZMiQqRd41LLaM2lnfoidXHwthmlOX7j 11EVLwIMnXVLvhLqvvdTy/2zDS2AyPHpCrVvGx5+WSJhECK3Oi5to/j5QV4JGcShWJjt Zjt3WWF8YaVjN7QVHADA2wou0hW7eAQbjLgOo4e2iu7wt8/eUhTeXjme1F9PDbF0MIX3 Z5FA== X-Gm-Message-State: AOJu0YzTElSJt2ZPkY33GqekII74qPFm/LVkvz6liofFO0G3FuUYG8Co Ef3N3gxog9DBeV5uxcvuQeljl2cJqi3cRokreU2o7pUqbixlirq2QZX/BrHockTp83WVlm33HWU E X-Google-Smtp-Source: AGHT+IEHsEQeuL6001FZr1hGENLQbyW9jW7o9DKM7PQjdg1Il5b4qHzb6Rgm1+v6Ckj5f2I5OByx7w== X-Received: by 2002:a05:6000:18a7:b0:368:420c:74ab with SMTP id ffacd0b85a97d-36d2751b275mr3061596f8f.28.1723160304245; Thu, 08 Aug 2024 16:38:24 -0700 (PDT) To: devel@lists.libvirt.org Subject: [PATCH 04/20] qemu: Add function to get bool value from migration params Date: Thu, 8 Aug 2024 17:37:57 -0600 Message-Id: <20240808233813.22905-5-jfehlig@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240808233813.22905-1-jfehlig@suse.com> References: <20240808233813.22905-1-jfehlig@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: QUYYVHEAJITEK7G67R6RFVMMRBMQD6D5 X-Message-ID-Hash: QUYYVHEAJITEK7G67R6RFVMMRBMQD6D5 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 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: 1723160446694116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jim Fehlig Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_migration_params.c | 18 ++++++++++++++++++ src/qemu/qemu_migration_params.h | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index c3c9120c22..daa52269f4 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -1303,6 +1303,24 @@ qemuMigrationParamsGetULL(qemuMigrationParams *migPa= rams, } =20 =20 +int +qemuMigrationParamsGetBool(qemuMigrationParams *migParams, + qemuMigrationParam param, + bool *value) +{ + if (!migParams || !value) + return 0; + + if (qemuMigrationParamsCheckType(param, QEMU_MIGRATION_PARAM_TYPE_BOOL= ) < 0) + return -1; + + *value =3D migParams->params[param].set ? + migParams->params[param].value.b : false; + + return 0; +} + + /** * Returns true if @cap is enabled in @migParams, false otherwise. */ diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_par= ams.h index 020071e8ef..64b2dde59b 100644 --- a/src/qemu/qemu_migration_params.h +++ b/src/qemu/qemu_migration_params.h @@ -136,6 +136,11 @@ qemuMigrationParamsGetULL(qemuMigrationParams *migPara= ms, qemuMigrationParam param, unsigned long long *value); =20 +int +qemuMigrationParamsGetBool(qemuMigrationParams *migParams, + qemuMigrationParam param, + bool *value); + bool qemuMigrationParamsCapEnabled(qemuMigrationParams *migParams, qemuMigrationCapability cap); --=20 2.35.3 From nobody Sat Nov 23 15:03:18 2024 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=1723160473; cv=none; d=zohomail.com; s=zohoarc; b=mLIEEoQT9R0IPmVZGE3I5IvJt9GR9U28JaAZF5Ypsla80BQKVYFGj/3Udps0Y2A42NLZvwuiNzCDy9dh15oiSi5FBBwnaTfpcEWVhT1er14ItYNqZk/vm4i15SaFQ13hPHKxeTab2prI3DyeOtTi6S5cepP3b/hBOJL28RaiYa8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723160473; 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=//EWhHnhiu2dTgOSjCTUNAp0UtFx3XJwEGgOTC0E/40=; b=d4hujjQPzQmjYe4uwCPhI0SVPSjeAYXalgD7+maSOePX59R0n9SonD+vnBoFxrvuZntgiortwMFZNTLlpCnwMN4HmErmo/TVFRBTzHBjVlCRGjAnWpVuE0pXOtZM4fwJKdsWmRA4+4YEm/PFD70ZuG/PprUSKl7aBLQTpCGIVos= 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 1723160473839921.4216326030286; Thu, 8 Aug 2024 16:41:13 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id C97A71446; Thu, 8 Aug 2024 19:41:12 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id ADA8714DB; Thu, 8 Aug 2024 19:38:54 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 0248F1401; Thu, 8 Aug 2024 19:38:48 -0400 (EDT) Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (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 B98A414AD for ; Thu, 8 Aug 2024 19:38:27 -0400 (EDT) Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-3683178b226so586799f8f.1 for ; Thu, 08 Aug 2024 16:38:27 -0700 (PDT) Received: from localhost ([69.51.98.127]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d69a7e57sm3743713173.56.2024.08.08.16.38.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 16:38:26 -0700 (PDT) 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,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=1723160306; x=1723765106; 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=PhCatc/TDLzX8fsygU4C9Udf81N0taVv7IQJ7D4vnp8=; b=M7VkAD0u3CARvDKesgHByEhjLZomty/ZFbOR8p4fuIX9sa4WQw1TQ7teDewYY9zica vbZR8hkhpOxkpYb74ekliMTdqxDf2fYdzwgU+z0GILvrLDOpwvAyg85brvx6vAM8rxZN gvpKxCiS/z/P3eZ3Q30ZVOTHGJEsYyx0jxfqlRHjetTT1tch8vAEAIvnFqMOeqW13faN Z6kB93UsOLQlHi0102NJ3I7uyn2BazQpha1pkxatZzk6E8IWLD5Ca13AIlFrV3Q9XMGA U9d29QVMW/7JuYZm7Np1TeSlYpTsM6bzupWUcxucEhQgtAWxfcVGbo4Ff8Q+9NQK/joM ujHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723160306; x=1723765106; 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=PhCatc/TDLzX8fsygU4C9Udf81N0taVv7IQJ7D4vnp8=; b=RiV/ngfwapIJNkKb+q7gs8CFjAwCKV5vbS6NQ1oxpPspwhSIIkwiAaiXoBFUXRhvnR B0RlbctmVYUJuo+qygc1fgMLaWJoRurs7PDpZeyQTKNpdstasHO9svoaLeqA/1hQD8k1 +Vx5NZ4zoy8rJExn9Cm6OjyMt/0DkieqPYdhTS4G1TNpaFV4aGucUixd73wDo2DhvaUC tCbWX/Xxyce/7BZ7gojIw4xJdn+CcCmIQMs9033A78rHi2JkgJzwNV2pJuiXm35e9J4R S5LdLBYgt2cqnq9MSqQANMw+Ebaf+dImRKpfhPUwyBCAYcVmvJAqj0jXOrXWFD1I5VRX ltkQ== X-Gm-Message-State: AOJu0Yx2U80Y3PFo5H0gHBsMG2zWN8EaGp9a2xq6jMJVkwmUbdc8rssv J017Xu/lWOIaNswYrjSdqCvQ5MPZY10urOJFlvPFnEv1gZLROqeBBq29I7c9f5aUjCfsPn0XYod k X-Google-Smtp-Source: AGHT+IEOariuKuuzlO21puoQi77xFuw2KNk+9EQSTDCmQDYT8PMqWqcjl6hsyDRZgFTl5dpYmnUZ4A== X-Received: by 2002:a5d:588c:0:b0:367:9881:7d5e with SMTP id ffacd0b85a97d-36d273c92c0mr3129835f8f.8.1723160306394; Thu, 08 Aug 2024 16:38:26 -0700 (PDT) To: devel@lists.libvirt.org Subject: [PATCH 05/20] qemu: Add mapped-ram migration capability Date: Thu, 8 Aug 2024 17:37:58 -0600 Message-Id: <20240808233813.22905-6-jfehlig@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240808233813.22905-1-jfehlig@suse.com> References: <20240808233813.22905-1-jfehlig@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ZPQW3EPR76RWVWUMFBO6TAQIKCL67WZ3 X-Message-ID-Hash: ZPQW3EPR76RWVWUMFBO6TAQIKCL67WZ3 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 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: 1723160474811116600 Content-Type: text/plain; charset="utf-8" Add the mapped-ram migration capability introduced in QEMU 9.0. Signed-off-by: Jim Fehlig Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_migration_params.c | 1 + src/qemu/qemu_migration_params.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index daa52269f4..03937df2d3 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -106,6 +106,7 @@ VIR_ENUM_IMPL(qemuMigrationCapability, "zero-copy-send", "postcopy-preempt", "switchover-ack", + "mapped-ram", ); =20 =20 diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_par= ams.h index 64b2dde59b..91a1965a74 100644 --- a/src/qemu/qemu_migration_params.h +++ b/src/qemu/qemu_migration_params.h @@ -42,6 +42,7 @@ typedef enum { QEMU_MIGRATION_CAP_ZERO_COPY_SEND, QEMU_MIGRATION_CAP_POSTCOPY_PREEMPT, QEMU_MIGRATION_CAP_SWITCHOVER_ACK, + QEMU_MIGRATION_CAP_MAPPED_RAM, =20 QEMU_MIGRATION_CAP_LAST } qemuMigrationCapability; --=20 2.35.3 From nobody Sat Nov 23 15:03:18 2024 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=1723160495; cv=none; d=zohomail.com; s=zohoarc; b=Ec3sEb5m0XGDr+0NDoieb8vz6WDnDtPCOKSRbKBNjqimdvyYhJxvmiyUWIBfUwhWKaketos9ZBCBTPfhmp4xxIhjiR2D/44nec5wgvFQyZBhquV8GtYfBEH8/zBGH71G0SErTcry0w4HNYDRMGq181aDBZXz9uozJCRQDDG7FX0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723160495; 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=lD2KHfHRcl8fCSyPgebLBrCpy+hZ4kPseJ8iTVkxWIQ=; b=mOMJK3zaeYrjsLenhCSrNjA98geTQBlZn+D6fPusZg98GlrXmRVkqs3P1scx5lDqCBSirTeW+3RYMO6JWgUpxpxebvxHosSMhBnyqFi911KPV/boQTPjxjxOXybgF1AHle0MrulQE0i3ulV/TIrLKubIFdIfhLF+Z8gogneMdgU= 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 1723160495180810.3965875668914; Thu, 8 Aug 2024 16:41:35 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1D48C14D1; Thu, 8 Aug 2024 19:41:34 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 690D01405; Thu, 8 Aug 2024 19:38:56 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E028813AA; Thu, 8 Aug 2024 19:38:49 -0400 (EDT) Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 C6CB614B5 for ; Thu, 8 Aug 2024 19:38:29 -0400 (EDT) Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-428f5c0833bso14721755e9.0 for ; Thu, 08 Aug 2024 16:38:29 -0700 (PDT) Received: from localhost ([69.51.98.127]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d6a29236sm3760240173.113.2024.08.08.16.38.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 16:38:28 -0700 (PDT) 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,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=1723160308; x=1723765108; 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=i46WZdZcA0BLPY2UCIYN0lEK9DYwBaU1czStBthu+VQ=; b=QpJtKgAWen3oXqvOLchcqCXXAzla+p/+iu2hx5oqHS2rPVqzqz+q9Vz8Pcersc/qyb hg60mc5xWFc4UNCwZVTqaO8TSdtphBtZS6nEPPMVVwUctuANsBmlbTZDjfCKD4WMRFuC 8t1d0DOFx5adenNMzEg0IrL8qirV+YPmpKWWzYfbkCDlVOt0JwrBF/Vb+eX7h4qQ2zjH pT2vBxhRWGs/J6q8BtoxUVeNdvoYBegjx7wV3DGuRYLjTBkPODB1nDbzRcj2NSmv4OXU cgZBF+RHbPF5jU34G8/9cjHHmh97hh+q8KCCSFRxVh4V68sBSzXqvO4gnr9FEHHuimcb M/Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723160308; x=1723765108; 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=i46WZdZcA0BLPY2UCIYN0lEK9DYwBaU1czStBthu+VQ=; b=iI0DEoqiZtkMFUTF9DMzfDVDP7zkZdHirAniFJ+vrSx26MFxjOskmb9B7g/TJcCdkc 83GgYZAuk782YeQ+mGqZD4Vgfw2JCvjHOAwn3Q3DtXtC+XROvU+puDyElv+QOcY3+j7q 2L9jQER01f6xccQqHGeRGKoprTf82Yt8VyLqNNNCR6/CShAbu6+24ALXnwNx3B9GfSmL I2KPW4aCOhaNDsHHjAguQwr+LxLKHAQdzBTsV8DscutCjRTHLMU0DNCYlU7wJWo1J/hy jTNXuwiasAKibB1jYMVWl8lC2F78+QTZ84axch4qrPAm9HDu1KlrtJ8XmnX1WeLqSJuq zN8A== X-Gm-Message-State: AOJu0YyMHf2zpkLETogiIWRu+1yw56j/pVsSe7FVcxhOJPexGYRvSOge NnasslkjUPMbPRllfofTRne7sf+vr+Q7tj+rusa5wHuQjZN2IGcauG2ZHw94mA1V8r4/qyG0l2S A X-Google-Smtp-Source: AGHT+IFaK2LaH419e9vvRIMhDCTNJnb1AyuV6vEXgncL71OAAGN1UkaVFrfEbPwriYnIoBY3c6Ub1Q== X-Received: by 2002:adf:efcc:0:b0:36b:5d86:d885 with SMTP id ffacd0b85a97d-36d281e5833mr2316470f8f.24.1723160308439; Thu, 08 Aug 2024 16:38:28 -0700 (PDT) To: devel@lists.libvirt.org Subject: [PATCH 06/20] qemu: Add function to get migration params for save Date: Thu, 8 Aug 2024 17:37:59 -0600 Message-Id: <20240808233813.22905-7-jfehlig@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240808233813.22905-1-jfehlig@suse.com> References: <20240808233813.22905-1-jfehlig@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: MPAS2YYQRVX4MEHNUMNMJSF2S62IQLPX X-Message-ID-Hash: MPAS2YYQRVX4MEHNUMNMJSF2S62IQLPX 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 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: 1723160496922116600 Content-Type: text/plain; charset="utf-8" Introduce qemuMigrationParamsForSave() to create a qemuMigrationParams object initialized with appropriate migration capabilities and parameters for a save operation. Note that mapped-ram capability also requires the multifd capability. For now, the number of multifd channels is set to 1. Future work to support parallel save/restore can set the number of channels to a user-specified value. Signed-off-by: Jim Fehlig Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_migration.c | 2 +- src/qemu/qemu_migration_params.c | 21 +++++++++++++++++++++ src/qemu/qemu_migration_params.h | 3 +++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 4fd7a0aafb..c1bdaa273b 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -6965,7 +6965,7 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDoma= inObj *vm, =20 /* Increase migration bandwidth to unlimited since target is a file. * Failure to change migration speed is not fatal. */ - if (!(migParams =3D qemuMigrationParamsNew())) + if (!(migParams =3D qemuMigrationParamsForSave(false))) return -1; =20 if (qemuMigrationParamsSetULL(migParams, diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index 03937df2d3..503d6165b0 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -783,6 +783,27 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr para= ms, } =20 =20 +qemuMigrationParams * +qemuMigrationParamsForSave(bool mappedRam) +{ + g_autoptr(qemuMigrationParams) saveParams =3D NULL; + + if (!(saveParams =3D qemuMigrationParamsNew())) + return NULL; + + if (mappedRam) { + if (virBitmapSetBit(saveParams->caps, QEMU_MIGRATION_CAP_MAPPED_RA= M) < 0) + return NULL; + if (virBitmapSetBit(saveParams->caps, QEMU_MIGRATION_CAP_MULTIFD) = < 0) + return NULL; + saveParams->params[QEMU_MIGRATION_PARAM_MULTIFD_CHANNELS].value.i = =3D 1; + saveParams->params[QEMU_MIGRATION_PARAM_MULTIFD_CHANNELS].set =3D = true; + } + + return g_steal_pointer(&saveParams); +} + + int qemuMigrationParamsDump(qemuMigrationParams *migParams, virTypedParameterPtr *params, diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_par= ams.h index 91a1965a74..fe239d9a8f 100644 --- a/src/qemu/qemu_migration_params.h +++ b/src/qemu/qemu_migration_params.h @@ -86,6 +86,9 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params, unsigned int flags, qemuMigrationParty party); =20 +qemuMigrationParams * +qemuMigrationParamsForSave(bool mappedRam); + int qemuMigrationParamsDump(qemuMigrationParams *migParams, virTypedParameterPtr *params, --=20 2.35.3 From nobody Sat Nov 23 15:03:18 2024 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=1723160518; cv=none; d=zohomail.com; s=zohoarc; b=IYynLLDfETDiVGOgLRdL+pb2XqogMDdTIHC4nU58a/KiaMcxOu6zxmBx7/SOu4Wk8E6Et866B3RUS7fYzuSG/lYAOc1uwAAKFawoddciaW8FY0zcdUVlDVRoq5FL/aLpMff6O40pgE6fWVwgbOX41jUoqWYzUy9RRscdhdBGAAo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723160518; 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=A3VCUM7VcFI0qv7WXYob0JOntboAhKK1LP2RmL2LV7w=; b=NJxdC0TGMDa964qNKNsnNRxbFIbAj1SoF+NXFTxd39+8FzWZ0hfYix1jjbpAdnfZUXduEyeY1C5vxiILbnXIHpInulmHCglT8wdSAVpb4Mn8BBZjdzLOO2ZO/ESYeWIjiOiQLCysQ840Xy0LuaGwEhTtiSjsJ7noBCJ8rUI9pCY= 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 1723160518708467.6805697187866; Thu, 8 Aug 2024 16:41:58 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 9494414F4; Thu, 8 Aug 2024 19:41:57 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 2E76512CA; Thu, 8 Aug 2024 19:38:59 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id C183F1434; Thu, 8 Aug 2024 19:38:50 -0400 (EDT) Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (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 20D6A13D3 for ; Thu, 8 Aug 2024 19:38:32 -0400 (EDT) Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2eeb1ba0481so19147201fa.2 for ; Thu, 08 Aug 2024 16:38:32 -0700 (PDT) Received: from localhost ([69.51.98.127]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-39b20af1672sm58621085ab.76.2024.08.08.16.38.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 16:38:30 -0700 (PDT) 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,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=1723160311; x=1723765111; 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=piPeXLtBsnMuLcuZKLa7/RkfvxC0tK/DgsCYKTUm6bY=; b=CbA75Q8EQsNzYG0U5B4SPha8tGkoBZrJ02Q3vXnF8NB5e2IYv36SudATVDWaaIcHa4 x+LJ0ctwbxkpqJHk6seZUcVNlmJCqMNfKLzNcx7BDZFUmnsgJWdGZgOb7uf9M7FLcltH mVa4lgXnAhxntq80VZCTL4+5xRLGaSdBUzz1vrtbH6ANLv2KJwsYSWIr1dSduOvuUi1/ j96UAPJqfLhOkrVgJQN21ctiDNi0o91cqhsjUSB2nwJCUIO5M954mW4A222RjNajSFTT cBeZIax9/b/e+4cyM/tyk+NrIY7kj+fGG2y7LU6fnVi778NN/+S8Pt3jPXzbNTZFsCJ+ yWiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723160311; x=1723765111; 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=piPeXLtBsnMuLcuZKLa7/RkfvxC0tK/DgsCYKTUm6bY=; b=oerLylK9f4YezpXXshQEiidvSpTmkrxSdaPk+InuCQL5Drggv4gVPDMFMo0SHg3GsA geEKu7RBCPyVrG80Gbg+guBIMFxNtYMhv30+22Vie/hM/0BB1U+u2M1oncSzrPzHWXsM lPO1/wlrfk+wY6l9Scq0J+1q37YF9B6IsG38182tydNRPxfv39/aZ3pEGFbCsQk4z9t4 GjJmmgfUndPd5aNIskTxf8+d8riDTpmB0G8kCVhLlba6AphN7ZMToaTqvNcQtqabp3lV GCGkCML/H4sKsDjCu5NrHmYZufFNDpoBIcxBqA+BdkLsZqTtgPc+p/XBU1MtliU1/Ye4 ZbTA== X-Gm-Message-State: AOJu0YzZpgyJJtrr2XpI854GxaaJHcp0Qm8EpYlyPpFSLsGB6WOt4DLb xEmb+ySabWeGXAr3E3WLrQtj4qNJjwPgfhgKb0Fxy6+dFHI3WfhYyQ3fT0VXsfbng2iOWJy4Mjy K X-Google-Smtp-Source: AGHT+IFSH0BcjSF9rUVU8pLdYVVIqrt9FcueFLiRzvgBEwuzd/7qclexn8x9phpwiauPYRAIBXS0fA== X-Received: by 2002:a2e:be20:0:b0:2f0:25dc:1894 with SMTP id 38308e7fff4ca-2f19de21fd8mr27038021fa.2.1723160310661; Thu, 08 Aug 2024 16:38:30 -0700 (PDT) To: devel@lists.libvirt.org Subject: [PATCH 07/20] qemu: QEMU_SAVE_VERSION: Bump to version 3 Date: Thu, 8 Aug 2024 17:38:00 -0600 Message-Id: <20240808233813.22905-8-jfehlig@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240808233813.22905-1-jfehlig@suse.com> References: <20240808233813.22905-1-jfehlig@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: XVG3GSAADA6MSPXMSXN4SK2K3SLXCQXU X-Message-ID-Hash: XVG3GSAADA6MSPXMSXN4SK2K3SLXCQXU 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 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: 1723160519008116600 Content-Type: text/plain; charset="utf-8" QEMU's new mapped-ram stream format [1] is incompatible with the existing sequential stream format. An older libvirt+QEMU that does not support mapped-ram must not attempt to restore a mapped-ram saved image. Currently the only way to achieve this is to bump QEMU_SAVE_VERSION. To avoid future version bumps, add a new 'features' element to the saved image header. The element is used now to indicate the use of mapped-ram feature, and provides a mechanism to support future save image features. [1] https://gitlab.com/qemu-project/qemu/-/blob/master/docs/devel/migration= /mapped-ram.rst?ref_type=3Dheads Signed-off-by: Jim Fehlig --- src/qemu/qemu_saveimage.c | 7 +++++++ src/qemu/qemu_saveimage.h | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index 018ab5a222..50fec33f54 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -74,6 +74,7 @@ qemuSaveImageBswapHeader(virQEMUSaveHeader *hdr) hdr->was_running =3D GUINT32_SWAP_LE_BE(hdr->was_running); hdr->compressed =3D GUINT32_SWAP_LE_BE(hdr->compressed); hdr->cookieOffset =3D GUINT32_SWAP_LE_BE(hdr->cookieOffset); + hdr->features =3D GUINT32_SWAP_LE_BE(hdr->features); } =20 =20 @@ -637,6 +638,12 @@ qemuSaveImageOpen(virQEMUDriver *driver, return -1; } =20 + if (header->features && header->features !=3D QEMU_SAVE_FEATURE_MAPPED= _RAM) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("image contains unsupported features)")); + return -1; + } + if (header->cookieOffset) xml_len =3D header->cookieOffset; else diff --git a/src/qemu/qemu_saveimage.h b/src/qemu/qemu_saveimage.h index e541792153..9dd7de292d 100644 --- a/src/qemu/qemu_saveimage.h +++ b/src/qemu/qemu_saveimage.h @@ -28,10 +28,14 @@ */ #define QEMU_SAVE_MAGIC "LibvirtQemudSave" #define QEMU_SAVE_PARTIAL "LibvirtQemudPart" -#define QEMU_SAVE_VERSION 2 +#define QEMU_SAVE_VERSION 3 =20 G_STATIC_ASSERT(sizeof(QEMU_SAVE_MAGIC) =3D=3D sizeof(QEMU_SAVE_PARTIAL)); =20 +typedef enum { + QEMU_SAVE_FEATURE_MAPPED_RAM =3D 1 << 0, +} qemuSaveFeatures; + typedef struct _virQEMUSaveHeader virQEMUSaveHeader; struct _virQEMUSaveHeader { char magic[sizeof(QEMU_SAVE_MAGIC)-1]; @@ -40,7 +44,8 @@ struct _virQEMUSaveHeader { uint32_t was_running; uint32_t compressed; uint32_t cookieOffset; - uint32_t unused[14]; + uint32_t features; + uint32_t unused[13]; }; =20 =20 --=20 2.35.3 From nobody Sat Nov 23 15:03:18 2024 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=1723160553; cv=none; d=zohomail.com; s=zohoarc; b=GfM+1jlGl/bGLI/pSWoB8jlODMUI7+sB46h/Q1A/b7sP2WpmAEky5RvKK/HQI2vM8ctKYa+l8P8y4BJDuCulyHzAO4ZaMHQVrOUfxAanv2A9yLuIKYCC1isGLpxpvfm/5QmIHVyIopV+YN37b4ciILohUbbclTgpbuKrSwSEK0Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723160553; 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=neWbj29NMhmly6qDeikSiC+QKWrdNyXULx2drkappSE=; b=Fs/kWufsXB1FTWd4nsWgUQk7N8Foq0/tRcokLe1CJ1egpIIs2eBWZwMUpv9TVcvhh+Lb1faFK7KJKuxu30sV7psTtc+WMu/jrKMpuYdXO0453cibrrpswiOpNFV/FHV75VqLDEn5fhXjY6aG/Sq+jYfIp+SbkTSTwp350B1hbok= 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 1723160553735993.7193436916152; Thu, 8 Aug 2024 16:42:33 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 91A7D1495; Thu, 8 Aug 2024 19:42:32 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 46E041506; Thu, 8 Aug 2024 19:39:01 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 7C72012E2; Thu, 8 Aug 2024 19:38:53 -0400 (EDT) Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (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 4EA811437 for ; Thu, 8 Aug 2024 19:38:34 -0400 (EDT) Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2f035ae1083so15621091fa.3 for ; Thu, 08 Aug 2024 16:38:34 -0700 (PDT) Received: from localhost ([69.51.98.127]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-39b20ae3542sm59106785ab.67.2024.08.08.16.38.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 16:38:32 -0700 (PDT) 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,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=1723160313; x=1723765113; 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=ZUWa+TIurjQqe1o8fjh/h2Pp+r55UOO/gfn+c6bbmzE=; b=Jj2O4ip2q5gyqV4z5kN59tqrKr5Aivl3sZDrpiLfetRN2U/wWbP3ubaDo/NVnDKgcp rSe9tVjYjTEFaeMf8X3WRwNUYs94OlYT3ndbji+DjD5Rhct0LVvt2ewvXZsEAOR2P9p5 Rw0k7Zfh0YGts7xzLSG6BdXnKPoJV0L6okDPDgxcZIzQUI/mhQfmiycQKH57oDs4wRlh lI7erpprayZyGfZBjZeU2L1bNJOj4frEDXrUJjMYnxwZ6xhp+2m7SJ7fUQaRN5eoQR8B oMLy6d7V8wE16YzE+QllIW2IqShC1eTEShMlSh89GSrR/moEXEo8WeNI6tn7Zko3civw erWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723160313; x=1723765113; 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=ZUWa+TIurjQqe1o8fjh/h2Pp+r55UOO/gfn+c6bbmzE=; b=qMlgZCl+9DDY+VNmXeJuzrtrZQM1ih6gAVY0sTKogjY9HxHf2xhnZSTXzpK9CWqX5B LOFb12zGX05FfK5ARKzGxau8QbeWi1XmVt86/f1eKOZL0yhUbqAveW9RWAwQq/MKGsUM 5yCwAEAggLARtFtd56TPJu44911kUHFw6rdWZlT/mExB8SasTHnGT2gp/Ls41RUevNhc vhQMeTVgwDkz0sD+IAHbWIOTuwjghqNAssfJXOzlWTgFiZ61TQ7PdMu31KpV+4Lw6W/B 8qN+/RDl/r2kDgRcVUxt59SuiFKbf2MVScqvRLVPjCgkWwo1M3MRCRlFOV2wC1b8wo3O uq9g== X-Gm-Message-State: AOJu0YyvVaHIT1dpvB79H+abOoxE3C0LWoOAMfiG4c3GOh6WBYcVIKb+ YTzla8U4yOXOykChbLFNUeOqjSxTGhD1ZKeACyU6nfDg3JDMloCBxCK2E01ZkXzCl7MJ54I72HY S X-Google-Smtp-Source: AGHT+IEDpFPmwwZa6C1WMsRIcx2n0XqiqDwbwZgnlEXnzFuBsFvY6fiqPcXsP97boMJonulti8viVw== X-Received: by 2002:a2e:9156:0:b0:2ef:24dd:8d86 with SMTP id 38308e7fff4ca-2f19de9148emr20612771fa.49.1723160312736; Thu, 08 Aug 2024 16:38:32 -0700 (PDT) To: devel@lists.libvirt.org Subject: [PATCH 08/20] qemu: conf: Add setting for save image version Date: Thu, 8 Aug 2024 17:38:01 -0600 Message-Id: <20240808233813.22905-9-jfehlig@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240808233813.22905-1-jfehlig@suse.com> References: <20240808233813.22905-1-jfehlig@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: EVHBIGIWWALJLMXQ76K4BBAQ45YBF6K4 X-Message-ID-Hash: EVHBIGIWWALJLMXQ76K4BBAQ45YBF6K4 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 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: 1723160555164116600 Content-Type: text/plain; charset="utf-8" Add a 'save_image_version' setting to qemu.conf to control the image version when saving a VM with 'virsh save' or 'virsh managedsave'. Default to the new version 3. Signed-off-by: Jim Fehlig --- src/qemu/libvirtd_qemu.aug | 1 + src/qemu/qemu.conf.in | 6 ++++++ src/qemu/qemu_conf.c | 16 ++++++++++++++++ src/qemu/qemu_conf.h | 5 +++++ src/qemu/qemu_driver.c | 3 +-- src/qemu/qemu_saveimage.c | 11 ++++++----- src/qemu/qemu_saveimage.h | 8 ++++---- src/qemu/qemu_snapshot.c | 4 ++-- src/qemu/test_libvirtd_qemu.aug.in | 1 + 9 files changed, 42 insertions(+), 13 deletions(-) diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug index 2b6526538f..acbfcd9fc3 100644 --- a/src/qemu/libvirtd_qemu.aug +++ b/src/qemu/libvirtd_qemu.aug @@ -92,6 +92,7 @@ module Libvirtd_qemu =3D | str_array_entry "namespaces" =20 let save_entry =3D str_entry "save_image_format" + | int_entry "save_image_version" | str_entry "dump_image_format" | str_entry "snapshot_image_format" | str_entry "auto_dump_path" diff --git a/src/qemu/qemu.conf.in b/src/qemu/qemu.conf.in index 6bc2140dcb..b5df8c1cc6 100644 --- a/src/qemu/qemu.conf.in +++ b/src/qemu/qemu.conf.in @@ -590,6 +590,11 @@ # at scheduled saving, and it is an error if the specified save_image_form= at # is not valid, or the requested compression program can't be found. # +# save_image_version is applicable when using 'virsh save' or 'virsh manag= ed-save'. +# Currently only versions 2 and 3 are supported, with version 3 being the = default. +# If saved images must be compatible with an older libvirt without this se= tting, +# then set save_image_format_version to 2. +# # dump_image_format is used when you use 'virsh dump' at emergency # crashdump, and if the specified dump_image_format is not valid, or # the requested compression program can't be found, this falls @@ -601,6 +606,7 @@ # or the requested compression program can't be found. # #save_image_format =3D "raw" +#save_image_version =3D 3 #dump_image_format =3D "raw" #snapshot_image_format =3D "raw" =20 diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index b36bede6c3..ab4122708c 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -66,6 +66,10 @@ VIR_LOG_INIT("qemu.qemu_conf"); #define QEMU_MIGRATION_PORT_MIN 49152 #define QEMU_MIGRATION_PORT_MAX 49215 =20 +/* Need to reconsile definition here and in qemu_saveimage.h */ +#define QEMU_SAVE_VERSION 3 + + VIR_ENUM_IMPL(virQEMUSchedCore, QEMU_SCHED_CORE_LAST, "none", @@ -246,6 +250,8 @@ virQEMUDriverConfig *virQEMUDriverConfigNew(bool privil= eged, cfg->migrationPortMin =3D QEMU_MIGRATION_PORT_MIN; cfg->migrationPortMax =3D QEMU_MIGRATION_PORT_MAX; =20 + cfg->saveImageVersion =3D QEMU_SAVE_IMAGE_VERSION; + /* For privileged driver, try and find hugetlbfs mounts automatically. * Non-privileged driver requires admin to create a dir for the * user, chown it, and then let user configure it manually. */ @@ -608,6 +614,16 @@ static int virQEMUDriverConfigLoadSaveEntry(virQEMUDriverConfig *cfg, virConf *conf) { + if (virConfGetValueUInt(conf, "save_image_version", &cfg->saveImageVer= sion) < 0) + return -1; + if (cfg->saveImageVersion < QEMU_SAVE_IMAGE_VERSION_MIN || + cfg->saveImageVersion > QEMU_SAVE_IMAGE_VERSION) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid save image version %1$u"), + cfg->saveImageVersion); + return -1; + } + if (virConfGetValueString(conf, "save_image_format", &cfg->saveImageFo= rmat) < 0) return -1; if (virConfGetValueString(conf, "dump_image_format", &cfg->dumpImageFo= rmat) < 0) diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index aa1e1a626c..55abede7e3 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -45,6 +45,10 @@ =20 #define QEMU_DRIVER_NAME "QEMU" =20 +#define QEMU_SAVE_IMAGE_VERSION_MIN 2 +#define QEMU_SAVE_IMAGE_VERSION 3 + + typedef enum { QEMU_SCHED_CORE_NONE =3D 0, QEMU_SCHED_CORE_VCPUS, @@ -193,6 +197,7 @@ struct _virQEMUDriverConfig { bool securityRequireConfined; =20 char *saveImageFormat; + unsigned int saveImageVersion; char *dumpImageFormat; char *snapshotImageFormat; =20 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 736602333e..6c0d3e097c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2683,8 +2683,7 @@ qemuDomainSaveInternal(virQEMUDriver *driver, if (!(cookie =3D qemuDomainSaveCookieNew(vm))) goto endjob; =20 - if (!(data =3D virQEMUSaveDataNew(xml, cookie, was_running, compressed, - driver->xmlopt))) + if (!(data =3D virQEMUSaveDataNew(driver, xml, cookie, was_running, co= mpressed))) goto endjob; xml =3D NULL; =20 diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index 50fec33f54..bffa0a3397 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -95,25 +95,26 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(virQEMUSaveData, virQEMUS= aveDataFree); * This function steals @domXML on success. */ virQEMUSaveData * -virQEMUSaveDataNew(char *domXML, +virQEMUSaveDataNew(virQEMUDriver *driver, + char *domXML, qemuDomainSaveCookie *cookieObj, bool running, - int compressed, - virDomainXMLOption *xmlopt) + int compressed) { virQEMUSaveData *data =3D NULL; virQEMUSaveHeader *header; + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); =20 data =3D g_new0(virQEMUSaveData, 1); =20 if (cookieObj && !(data->cookie =3D virSaveCookieFormat((virObject *) cookieObj, - virDomainXMLOptionGetSaveCook= ie(xmlopt)))) + virDomainXMLOptionGetSaveCook= ie(driver->xmlopt)))) goto error; =20 header =3D &data->header; memcpy(header->magic, QEMU_SAVE_PARTIAL, sizeof(header->magic)); - header->version =3D QEMU_SAVE_VERSION; + header->version =3D cfg->saveImageVersion; header->was_running =3D running ? 1 : 0; header->compressed =3D compressed; =20 diff --git a/src/qemu/qemu_saveimage.h b/src/qemu/qemu_saveimage.h index 9dd7de292d..3cee846f14 100644 --- a/src/qemu/qemu_saveimage.h +++ b/src/qemu/qemu_saveimage.h @@ -28,7 +28,7 @@ */ #define QEMU_SAVE_MAGIC "LibvirtQemudSave" #define QEMU_SAVE_PARTIAL "LibvirtQemudPart" -#define QEMU_SAVE_VERSION 3 +#define QEMU_SAVE_VERSION QEMU_SAVE_IMAGE_VERSION =20 G_STATIC_ASSERT(sizeof(QEMU_SAVE_MAGIC) =3D=3D sizeof(QEMU_SAVE_PARTIAL)); =20 @@ -123,11 +123,11 @@ virQEMUSaveDataWrite(virQEMUSaveData *data, const char *path); =20 virQEMUSaveData * -virQEMUSaveDataNew(char *domXML, +virQEMUSaveDataNew(virQEMUDriver *driver, + char *domXML, qemuDomainSaveCookie *cookieObj, bool running, - int compressed, - virDomainXMLOption *xmlopt); + int compressed); =20 void virQEMUSaveDataFree(virQEMUSaveData *data); diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index f5260c4a22..1d75208814 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1390,9 +1390,9 @@ qemuSnapshotCreateActiveExternal(virQEMUDriver *drive= r, !(snapdef->cookie =3D (virObject *) qemuDomainSaveCookieNew(vm= ))) goto cleanup; =20 - if (!(data =3D virQEMUSaveDataNew(xml, + if (!(data =3D virQEMUSaveDataNew(driver, xml, (qemuDomainSaveCookie *) snapdef->= cookie, - resume, compressed, driver->xmlopt= ))) + resume, compressed))) goto cleanup; xml =3D NULL; =20 diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qe= mu.aug.in index b97e6de11e..8bcb332020 100644 --- a/src/qemu/test_libvirtd_qemu.aug.in +++ b/src/qemu/test_libvirtd_qemu.aug.in @@ -70,6 +70,7 @@ module Test_libvirtd_qemu =3D { "8" =3D "/dev/userfaultfd" } } { "save_image_format" =3D "raw" } +{ "save_image_version" =3D "3" } { "dump_image_format" =3D "raw" } { "snapshot_image_format" =3D "raw" } { "auto_dump_path" =3D "/var/lib/libvirt/qemu/dump" } --=20 2.35.3 From nobody Sat Nov 23 15:03:18 2024 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=1723160576; cv=none; d=zohomail.com; s=zohoarc; b=jgDAMtNjPgXbcgb1RukaVkmqqBy9xg7CA55ecTw/8aSEeZyyqMdV5ZxDz0IT01hFuxklT+gtP56G6zUUVX7o2GnaHFxr8L7qQfJu8aOYUCMmY3Jm6OeERcjjGhev28Sawg3PxS+2WofJ6Qn4WIVHhQnSGlajOKkFcDkgQvjL8AY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723160576; 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=FUCuRG7CLAhDtvV/UG391msEWZyysfpKIacpg2gjxPg=; b=CiMxkLstWENoBgU0p42f143NQKVaqy6uKp45nq17c8nF+GNGN6h0228UwZ11OThTJtwJb2mAoKr5bh46dQABzpy2nuezuB37KO2QbdK1v5yBvi/iRvWthhgkJQ/YjPtXork3C9Ujg0qtCEtAtozknFBBxu1nqdiuMGOtdpAikYU= 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 1723160576066966.8648045621877; Thu, 8 Aug 2024 16:42:56 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id EEA221472; Thu, 8 Aug 2024 19:42:54 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 2186314A2; Thu, 8 Aug 2024 19:39:03 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 4F1B21452; Thu, 8 Aug 2024 19:38:56 -0400 (EDT) Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (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 3B3871452 for ; Thu, 8 Aug 2024 19:38:36 -0400 (EDT) Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2ef2cce8be8so15719411fa.1 for ; Thu, 08 Aug 2024 16:38:36 -0700 (PDT) Received: from localhost ([69.51.98.127]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d6a28fb4sm3668929173.89.2024.08.08.16.38.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 16:38:34 -0700 (PDT) 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,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=1723160315; x=1723765115; 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=j7V+++zVavcA6V2+JOuX3BoNhg30qB9vmQUT1jAh9aw=; b=CAXjzptGGQ6dC++MQ5qusYYuS2LTOiNdgOXrAWj07/R4R3WXN/FR40VHfI8stWY7TA 6RByQu1blx/b93f5fvGeM7X2IgjDfiCQEWbdyhl8alKBjyuewbZTsix30cHusXfFi08N 6Oeb8n5T2+IqiNJrTv2DCvI4tvM6eZxecjaB9KaNk2EoDlM2xjoJ028Pj81nEqwnNjQP cuBxxQJMt+bst7oqeYcepdF9sggjkEAbrxn+XXGQS/KspALddMQDHlSMTLW2iFSaSQxr eZ8kZH6KFwSgT20mRrAplfyLi8DUxE4xfOdUNn3Ky/gIKoG0ARogWLUucq8/rZxeQw7x 5OHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723160315; x=1723765115; 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=j7V+++zVavcA6V2+JOuX3BoNhg30qB9vmQUT1jAh9aw=; b=C+YWEUb0oYujZMu6MGFZ+pTD5vtNEG2c8CgjKwqLlfbFJW7SMthHYDEK/wicYzV96U Dd+BCkKsFyA6ED36D5Mti6BXi8CVmrtINKE38IDpqi/GJEv7Yo0sMMr0YAGSYd8+5J8O WWar/WtcuO047NjhA5OIDUDNaJpmm7BcVQLgI+INlhC+NVxF/Nyh/hj39pgrIXoSmYOA F83z+GUKshlngvDeTNSuS6PgKJUZvJ+VjQ2jjDUOYJgxB4FYMCpi1hOQWz4tzf7Qh0jA dQt68NqenPR36OspIzuvpdcinEBZf6qTkXP35BzjUEDG+D558KeH0e/u5ye0Exlqdjyt uf2w== X-Gm-Message-State: AOJu0YwnpuJc7scA7reKjVotLj2ywculbFNnlsgCHq7/hIn/vCUcnI69 7CRC0HQ1mEZQr6lUMeek62munis1wIuSfw6ND3vdvCpQK4/Dmi7zqGXjdUNgBIUktkQUabWPGTj 0 X-Google-Smtp-Source: AGHT+IH2MzsIKid98KzOjji1c0sltnErK6v/ku7J/IezqJ2eu379kSD5nQlaStIiF9u491rRduVxQw== X-Received: by 2002:a2e:be1f:0:b0:2ef:1d8d:21fd with SMTP id 38308e7fff4ca-2f19de1f94dmr28573181fa.2.1723160314760; Thu, 08 Aug 2024 16:38:34 -0700 (PDT) To: devel@lists.libvirt.org Subject: [PATCH 09/20] qemu: Add helper function for creating save image fd Date: Thu, 8 Aug 2024 17:38:02 -0600 Message-Id: <20240808233813.22905-10-jfehlig@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240808233813.22905-1-jfehlig@suse.com> References: <20240808233813.22905-1-jfehlig@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: MEQSK2YLCXKKGYPPVSPV2WX45CKE7TXI X-Message-ID-Hash: MEQSK2YLCXKKGYPPVSPV2WX45CKE7TXI 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 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: 1723160577249116600 Content-Type: text/plain; charset="utf-8" Move the code in qemuSaveImageCreate that opens, labels, and wraps the save image fd to a helper function, providing more flexibility for upcoming mapped-ram support. Signed-off-by: Jim Fehlig --- src/qemu/qemu_saveimage.c | 65 +++++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index bffa0a3397..6f2ce40124 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -361,6 +361,50 @@ qemuSaveImageDecompressionStop(virCommand *cmd, } =20 =20 +static int +qemuSaveImageCreateFd(virQEMUDriver *driver, + virDomainObj *vm, + const char *path, + virFileWrapperFd *wrapperFd, + bool *needUnlink, + unsigned int flags) +{ + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + int ret =3D -1; + VIR_AUTOCLOSE fd =3D -1; + int directFlag =3D 0; + unsigned int wrapperFlags =3D VIR_FILE_WRAPPER_NON_BLOCKING; + + if (flags & VIR_DOMAIN_SAVE_BYPASS_CACHE) { + wrapperFlags |=3D VIR_FILE_WRAPPER_BYPASS_CACHE; + directFlag =3D virFileDirectFdFlag(); + if (directFlag < 0) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("bypass cache unsupported by this system")); + return -1; + } + } + + fd =3D virQEMUFileOpenAs(cfg->user, cfg->group, false, path, + O_WRONLY | O_TRUNC | O_CREAT | directFlag, + needUnlink); + + if (fd < 0) + return -1; + + if (qemuSecuritySetImageFDLabel(driver->securityManager, vm->def, fd) = < 0) + return -1; + + if (!(wrapperFd =3D virFileWrapperFdNew(&fd, path, wrapperFlags))) + return -1; + + ret =3D fd; + fd =3D -1; + + return ret; +} + + /* 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 */ @@ -377,33 +421,14 @@ qemuSaveImageCreate(virQEMUDriver *driver, bool needUnlink =3D false; int ret =3D -1; int fd =3D -1; - int directFlag =3D 0; virFileWrapperFd *wrapperFd =3D NULL; - unsigned int wrapperFlags =3D VIR_FILE_WRAPPER_NON_BLOCKING; =20 /* Obtain the file handle. */ - if ((flags & VIR_DOMAIN_SAVE_BYPASS_CACHE)) { - wrapperFlags |=3D VIR_FILE_WRAPPER_BYPASS_CACHE; - directFlag =3D virFileDirectFdFlag(); - if (directFlag < 0) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("bypass cache unsupported by this system")); - goto cleanup; - } - } + fd =3D qemuSaveImageCreateFd(driver, vm, path, wrapperFd, &needUnlink,= flags); =20 - fd =3D virQEMUFileOpenAs(cfg->user, cfg->group, false, path, - O_WRONLY | O_TRUNC | O_CREAT | directFlag, - &needUnlink); if (fd < 0) goto cleanup; =20 - if (qemuSecuritySetImageFDLabel(driver->securityManager, vm->def, fd) = < 0) - goto cleanup; - - if (!(wrapperFd =3D virFileWrapperFdNew(&fd, path, wrapperFlags))) - goto cleanup; - if (virQEMUSaveDataWrite(data, fd, path) < 0) goto cleanup; =20 --=20 2.35.3 From nobody Sat Nov 23 15:03:18 2024 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=1723160637; cv=none; d=zohomail.com; s=zohoarc; b=mtJCC9GLB6BXv77a0jVDIoRROFvnJpz5LKaBn1ebty4+sBZGcdWj85JPGTH0GcwcusU7cFbgRlkBkTYHc4iBpvc4BFMaLdeclhrn0fYJmAMowR7q8KfaTJdmCmJkGmGFcjYmVzIOIzY2awgX7eDUKw5TSWhPjNz0w4NWRoJd0OM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723160637; 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=iMPB8GhNQ/oOqEr8v2DxQseFL9nakaKGcP+L2n5eH2Q=; b=PLrfOHu5o1DsV6IxaEZntpEIr6lS1urOH/Png1UChX84dr51CczbRyNPITsR+FNkr6BiZ5VhnPOIX1Xsek0k/XDIF5F4oaa+7eg65DfRotfKPHqMUi8Q/nDac9295tTcnU65XwFK65ZCq406k3kJnC+7XvwYzJTXap4EpRxWoE0= 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 1723160637660177.28050107983097; Thu, 8 Aug 2024 16:43:57 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 953581496; Thu, 8 Aug 2024 19:43:56 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 516FD151A; Thu, 8 Aug 2024 19:39:05 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1102012CA; Thu, 8 Aug 2024 19:38:59 -0400 (EDT) Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 333E112CA for ; Thu, 8 Aug 2024 19:38:38 -0400 (EDT) Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-369c609d0c7so1153029f8f.3 for ; Thu, 08 Aug 2024 16:38:38 -0700 (PDT) Received: from localhost ([69.51.98.127]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4ca46deacfbsm1623771173.46.2024.08.08.16.38.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 16:38:36 -0700 (PDT) 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,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=1723160317; x=1723765117; 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=ai8nXKrq+L8+8zpltGno9LGSLpBI1G7vvr0MGN7RcgY=; b=GFHdkM9bnSc1yaEXGNAcBCMJC0fgCNQ99DAF2sz59PWvEoUco9qlQl3wBeXjM/JySW SAdvOYMbeDRn/H9QI6X8az8SdRaiCV01k/CwoH3hb5YDvQWz3aPBnODDFRVW2OBfiCcZ +N9tQ816V6f6/3OWqnbz2YqoEYiL02Lg32gpmC2xXZ1cE0bB2FN/i2Pq5StPYCaUkyXo B0OYRcBVvlTYwfZeYbRIYJCjg3NcPy3QOeIHGVhs7oIOk076+QdClv/MW1VGSGY03KP9 ed3LUVzT31QxBzRP5BofVXC3P62mjYdop0waIOrZeOb/Rx1pTTb6NuUjlQ3piypyg+mF IgFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723160317; x=1723765117; 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=ai8nXKrq+L8+8zpltGno9LGSLpBI1G7vvr0MGN7RcgY=; b=fEBGJ/j3iJK4hvK9hjDh2vFtX7185chlzsDMpQLD+PnSCrwYalY3GbIAePqyUHllBp LvWKgGYDQ5F45NDO7e/WbsTL509hHXEY62EFYQuuEDOkDxvV+4hnPWk2R52a8zCKIGmr CJza/B/ABPwDncr80Q7nkwUR2fUinM+tN336FWgwy6itg11Z44RdIMGphLS2Qq0afqpn eZpdxBqD+xE/l4FLmm02HYBKQJAoHlKl5+HGXJW69JX/WWw4G0jP6IWzGyNvXrlgq/ml Aqs8YC2q4Jic0wtsfCb2+Y4bEnUSuwk126lU59KU1qISlkS0+w22yxF/WnwZ7RecESr8 jvoA== X-Gm-Message-State: AOJu0Yz8spgE49U+xrfkzuy5efa+EKCBgehxIoq5bZZP0PP4zW/Nlzbm 6+oTYHSd2oUU3qmwEBFDNFek9dIGnoWPDlbMgel/xrsztRi4jau1amnPFv4vuSCkaEWUf98Glxt K X-Google-Smtp-Source: AGHT+IFD+JN6okvTLEZYFAcePODNSK1rc7AsRT3pijRPjLPwVKF3TsygKZtdBXTbk8mxI70/cBXOrg== X-Received: by 2002:adf:fe8b:0:b0:368:7f8f:ca68 with SMTP id ffacd0b85a97d-36d2751ba90mr2808227f8f.30.1723160316826; Thu, 08 Aug 2024 16:38:36 -0700 (PDT) To: devel@lists.libvirt.org Subject: [PATCH 10/20] qemu: Add support for mapped-ram on save Date: Thu, 8 Aug 2024 17:38:03 -0600 Message-Id: <20240808233813.22905-11-jfehlig@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240808233813.22905-1-jfehlig@suse.com> References: <20240808233813.22905-1-jfehlig@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: APACYLQXGGQHASJMODIBA7SSRXAULMVL X-Message-ID-Hash: APACYLQXGGQHASJMODIBA7SSRXAULMVL 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 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: 1723160639521116600 Content-Type: text/plain; charset="utf-8" Introduce support for QEMU's new mapped-ram stream format [1]. mapped-ram is enabled by default if the underlying QEMU advertises the mapped-ram migration capability. It can be disabled by changing the 'save_image_version' setting in qemu.conf to version '2'. To use mapped-ram with QEMU: - The 'mapped-ram' migration capability must be set to true - The 'multifd' migration capability must be set to true and the 'multifd-channels' migration parameter must set to 1 - QEMU must be provided an fdset containing the migration fd - The 'migrate' qmp command is invoked with a URI referencing the fdset and an offset where to start writing the data stream, e.g. {"execute":"migrate", "arguments":{"detach":true,"resume":false, "uri":"file:/dev/fdset/0,offset=3D0x11921"}} The mapped-ram stream, in conjunction with direct IO and multifd support provided by subsequent patches, can significantly improve the time required to save VM memory state. The following tables compare mapped-ram with the existing, sequential save stream. In all cases, the save and restore operations are to/from a block device comprised of two NVMe disks in RAID0 configuration with xfs (~8600MiB/s). The values in the 'save time' and 'restore time' columns were scraped from the 'real' time reported by time(1). The 'Size' and 'Blocks' columns were provided by the corresponding outputs of stat(1). VM: 32G RAM, 1 vcpu, idle (shortly after boot) | save | restore | | time | time | Size | Blocks -----------------------+---------+---------+--------------+-------- legacy | 6.193s | 4.399s | 985744812 | 1925288 -----------------------+---------+---------+--------------+-------- mapped-ram | 5.109s | 1.176s | 34368554354 | 1774472 -----------------------+---------+---------+--------------+-------- legacy + direct IO | 5.725s | 4.512s | 985765251 | 1925328 -----------------------+---------+---------+--------------+-------- mapped-ram + direct IO | 4.627s | 1.490s | 34368554354 | 1774304 -----------------------+---------+---------+--------------+-------- mapped-ram + direct IO | | | | + multifd-channels=3D8 | 4.421s | 0.845s | 34368554318 | 1774312 ------------------------------------------------------------------- VM: 32G RAM, 30G dirty, 1 vcpu in tight loop dirtying memory | save | restore | | time | time | Size | Blocks -----------------------+---------+---------+--------------+--------- legacy | 25.800s | 14.332s | 33154309983 | 64754512 -----------------------+---------+---------+--------------+--------- mapped-ram | 18.742s | 15.027s | 34368559228 | 64617160 -----------------------+---------+---------+--------------+--------- legacy + direct IO | 13.115s | 18.050s | 33154310496 | 64754520 -----------------------+---------+---------+--------------+--------- mapped-ram + direct IO | 13.623s | 15.959s | 34368557392 | 64662040 -----------------------+-------- +---------+--------------+--------- mapped-ram + direct IO | | | | + multifd-channels=3D8 | 6.994s | 6.470s | 34368554980 | 64665776 -------------------------------------------------------------------- As can be seen from the tables, one caveat of mapped-ram is the logical file size of a saved image is basically equivalent to the VM memory size. Note however that mapped-ram typically uses fewer blocks on disk. Another caveat of mapped-ram is the requirement for a seekable file descriptor, which currently makes it incompatible with libvirt's support for save image compression. Also note the mapped-ram stream is incompatible with the existing stream format, hence mapped-ram cannot be used to restore an image saved with the existing format and vice versa. [1] https://gitlab.com/qemu-project/qemu/-/blob/master/docs/devel/migration= /mapped-ram.rst?ref_type=3Dheads Signed-off-by: Jim Fehlig --- src/qemu/qemu_driver.c | 20 ++++-- src/qemu/qemu_migration.c | 139 ++++++++++++++++++++++++++------------ src/qemu/qemu_migration.h | 4 +- src/qemu/qemu_monitor.c | 36 ++++++++++ src/qemu/qemu_monitor.h | 4 ++ src/qemu/qemu_saveimage.c | 43 +++++++++--- src/qemu/qemu_saveimage.h | 2 + src/qemu/qemu_snapshot.c | 9 ++- 8 files changed, 195 insertions(+), 62 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6c0d3e097c..977763e5d8 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2617,6 +2617,8 @@ qemuDomainSaveInternal(virQEMUDriver *driver, qemuDomainObjPrivate *priv =3D vm->privateData; virQEMUSaveData *data =3D NULL; g_autoptr(qemuDomainSaveCookie) cookie =3D NULL; + g_autoptr(qemuMigrationParams) saveParams =3D NULL; + bool mappedRam =3D false; =20 if (virDomainObjBeginAsyncJob(vm, VIR_ASYNC_JOB_SAVE, VIR_DOMAIN_JOB_OPERATION_SAVE, flags) < = 0) @@ -2683,12 +2685,17 @@ qemuDomainSaveInternal(virQEMUDriver *driver, if (!(cookie =3D qemuDomainSaveCookieNew(vm))) goto endjob; =20 - if (!(data =3D virQEMUSaveDataNew(driver, xml, cookie, was_running, co= mpressed))) + + if (!(data =3D virQEMUSaveDataNew(driver, vm, xml, cookie, was_running= , compressed))) goto endjob; xml =3D NULL; =20 + mappedRam =3D data->header.features & QEMU_SAVE_FEATURE_MAPPED_RAM; + if (!(saveParams =3D qemuMigrationParamsForSave(mappedRam))) + goto endjob; + ret =3D qemuSaveImageCreate(driver, vm, path, data, compressor, - flags, VIR_ASYNC_JOB_SAVE); + saveParams, flags, VIR_ASYNC_JOB_SAVE); if (ret < 0) goto endjob; =20 @@ -3122,6 +3129,8 @@ doCoreDump(virQEMUDriver *driver, memory_dump_format) < 0) goto cleanup; } else { + g_autoptr(qemuMigrationParams) dump_params =3D NULL; + if (dumpformat !=3D VIR_DOMAIN_CORE_DUMP_FORMAT_RAW) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("kdump-compressed format is only supported wi= th memory-only dump")); @@ -3131,8 +3140,11 @@ doCoreDump(virQEMUDriver *driver, if (!qemuMigrationSrcIsAllowed(vm, false, VIR_ASYNC_JOB_DUMP, 0)) goto cleanup; =20 - if (qemuMigrationSrcToFile(driver, vm, fd, compressor, - VIR_ASYNC_JOB_DUMP) < 0) + if (!(dump_params =3D qemuMigrationParamsNew())) + goto cleanup; + + if (qemuMigrationSrcToFile(driver, vm, &fd, compressor, + dump_params, dump_flags, VIR_ASYNC_JOB_= DUMP) < 0) goto cleanup; } =20 diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index c1bdaa273b..3ab5e2fa30 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -6944,46 +6944,17 @@ qemuMigrationProcessUnattended(virQEMUDriver *drive= r, } =20 =20 -/* Helper function called while vm is active. */ -int -qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm, - int fd, - virCommand *compressor, - virDomainAsyncJob asyncJob) +static int +qemuMigrationSrcToLegacyFile(virQEMUDriver *driver, + virDomainObj *vm, + int fd, + virCommand *compressor, + virDomainAsyncJob asyncJob) { qemuDomainObjPrivate *priv =3D vm->privateData; - int rc; int ret =3D -1; int pipeFD[2] =3D { -1, -1 }; - unsigned long saveMigBandwidth =3D priv->migMaxBandwidth; char *errbuf =3D NULL; - virErrorPtr orig_err =3D NULL; - g_autoptr(qemuMigrationParams) migParams =3D NULL; - - if (qemuMigrationSetDBusVMState(driver, vm) < 0) - return -1; - - /* Increase migration bandwidth to unlimited since target is a file. - * Failure to change migration speed is not fatal. */ - if (!(migParams =3D qemuMigrationParamsForSave(false))) - return -1; - - if (qemuMigrationParamsSetULL(migParams, - QEMU_MIGRATION_PARAM_MAX_BANDWIDTH, - QEMU_DOMAIN_MIG_BANDWIDTH_MAX * 1024 * 1= 024) < 0) - return -1; - - if (qemuMigrationParamsApply(vm, asyncJob, migParams, 0) < 0) - return -1; - - priv->migMaxBandwidth =3D QEMU_DOMAIN_MIG_BANDWIDTH_MAX; - - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("guest unexpectedly quit")); - /* nothing to tear down */ - return -1; - } =20 if (compressor && virPipe(pipeFD) < 0) return -1; @@ -7000,7 +6971,7 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDoma= inObj *vm, goto cleanup; =20 if (!compressor) { - rc =3D qemuMonitorMigrateToFd(priv->mon, 0, fd); + ret =3D qemuMonitorMigrateToFd(priv->mon, 0, fd); } else { virCommandSetInputFD(compressor, pipeFD[0]); virCommandSetOutputFD(compressor, &fd); @@ -7016,12 +6987,99 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDo= mainObj *vm, qemuDomainObjExitMonitor(vm); goto cleanup; } - rc =3D qemuMonitorMigrateToFd(priv->mon, 0, pipeFD[1]); + ret =3D qemuMonitorMigrateToFd(priv->mon, 0, pipeFD[1]); if (VIR_CLOSE(pipeFD[0]) < 0 || VIR_CLOSE(pipeFD[1]) < 0) VIR_WARN("failed to close intermediate pipe"); } qemuDomainObjExitMonitor(vm); + + cleanup: + VIR_FORCE_CLOSE(pipeFD[0]); + VIR_FORCE_CLOSE(pipeFD[1]); + + if (errbuf) { + VIR_DEBUG("Compression binary stderr: %s", NULLSTR(errbuf)); + VIR_FREE(errbuf); + } + + return ret; +} + + +static int +qemuMigrationSrcToMappedFile(virQEMUDriver *driver, + virDomainObj *vm, + int *fd, + unsigned int flags, + virDomainAsyncJob asyncJob) +{ + int ret; + + /* mapped-ram does not support directIO */ + if ((flags & VIR_DOMAIN_SAVE_BYPASS_CACHE)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("bypass cache unsupported by this system")); + return -1; + } + + if (qemuSecuritySetImageFDLabel(driver->securityManager, vm->def, *fd)= < 0) + return -1; + + if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0) + return -1; + + ret =3D qemuMonitorMigrateToFdSet(vm, 0, fd); + qemuDomainObjExitMonitor(vm); + return ret; +} + + +/* Helper function called while vm is active. */ +int +qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm, + int *fd, + virCommand *compressor, + qemuMigrationParams *migParams, + unsigned int flags, + virDomainAsyncJob asyncJob) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + int rc; + int ret =3D -1; + unsigned long saveMigBandwidth =3D priv->migMaxBandwidth; + virErrorPtr orig_err =3D NULL; + + if (qemuMigrationSetDBusVMState(driver, vm) < 0) + return -1; + + /* Increase migration bandwidth to unlimited since target is a file. + * Failure to change migration speed is not fatal. */ + if (migParams && + qemuMigrationParamsSetULL(migParams, + QEMU_MIGRATION_PARAM_MAX_BANDWIDTH, + QEMU_DOMAIN_MIG_BANDWIDTH_MAX * 1024 * 1= 024) < 0) + return -1; + + if (qemuMigrationParamsApply(vm, asyncJob, migParams, 0) < 0) + return -1; + + priv->migMaxBandwidth =3D QEMU_DOMAIN_MIG_BANDWIDTH_MAX; + + if (!virDomainObjIsActive(vm)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("guest unexpectedly quit")); + /* nothing to tear down */ + return -1; + } + + if (migParams && + qemuMigrationParamsCapEnabled(migParams, QEMU_MIGRATION_CAP_MAPPED= _RAM)) { + rc =3D qemuMigrationSrcToMappedFile(driver, vm, fd, flags, asyncJo= b); + } else { + rc =3D qemuMigrationSrcToLegacyFile(driver, vm, *fd, compressor, a= syncJob); + } + if (rc < 0) goto cleanup; =20 @@ -7057,13 +7115,6 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDom= ainObj *vm, priv->migMaxBandwidth =3D saveMigBandwidth; } =20 - VIR_FORCE_CLOSE(pipeFD[0]); - VIR_FORCE_CLOSE(pipeFD[1]); - if (errbuf) { - VIR_DEBUG("Compression binary stderr: %s", NULLSTR(errbuf)); - VIR_FREE(errbuf); - } - virErrorRestore(&orig_err); =20 return ret; diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index ed62fd4a91..039a926e69 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -236,8 +236,10 @@ qemuMigrationSrcIsAllowed(virDomainObj *vm, int qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm, - int fd, + int *fd, virCommand *compressor, + qemuMigrationParams *migParams, + unsigned int flags, virDomainAsyncJob asyncJob) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; =20 diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index b1c0c6a064..9a454a1d08 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2237,6 +2237,42 @@ qemuMonitorMigrateToFd(qemuMonitor *mon, } =20 =20 +int +qemuMonitorMigrateToFdSet(virDomainObj *vm, + unsigned int flags, + int *fd) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + qemuMonitor *mon =3D priv->mon; + off_t offset; + g_autoptr(qemuFDPass) fdPassMigrate =3D NULL; + unsigned int setId; + g_autofree char *uri =3D NULL; + int ret; + + VIR_DEBUG("fd=3D%d flags=3D0x%x", *fd, flags); + + QEMU_CHECK_MONITOR(mon); + + if ((offset =3D lseek(*fd, 0, SEEK_CUR)) =3D=3D -1) { + virReportSystemError(errno, + "%s", _("failed to seek on file descriptor")); + return -1; + } + + fdPassMigrate =3D qemuFDPassNew("migrate", priv); + qemuFDPassAddFD(fdPassMigrate, fd, "-buffered-fd"); + if (qemuFDPassTransferMonitor(fdPassMigrate, mon) < 0) + return -1; + + qemuFDPassGetId(fdPassMigrate, &setId); + uri =3D g_strdup_printf("file:/dev/fdset/%u,offset=3D%#lx", setId, off= set); + ret =3D qemuMonitorJSONMigrate(mon, flags, uri); + + return ret; +} + + int qemuMonitorMigrateToHost(qemuMonitor *mon, unsigned int flags, diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 76c859a888..ebacdf110e 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -844,6 +844,10 @@ int qemuMonitorMigrateToFd(qemuMonitor *mon, unsigned int flags, int fd); =20 +int qemuMonitorMigrateToFdSet(virDomainObj *vm, + unsigned int flags, + int *fd); + int qemuMonitorMigrateToHost(qemuMonitor *mon, unsigned int flags, const char *protocol, diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index 6f2ce40124..98a1ad638d 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -96,6 +96,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(virQEMUSaveData, virQEMUSav= eDataFree); */ virQEMUSaveData * virQEMUSaveDataNew(virQEMUDriver *driver, + virDomainObj *vm, char *domXML, qemuDomainSaveCookie *cookieObj, bool running, @@ -115,6 +116,19 @@ virQEMUSaveDataNew(virQEMUDriver *driver, header =3D &data->header; memcpy(header->magic, QEMU_SAVE_PARTIAL, sizeof(header->magic)); header->version =3D cfg->saveImageVersion; + + /* Enable mapped-ram feature if available and save version >=3D 3 */ + if (header->version >=3D QEMU_SAVE_VERSION && + qemuMigrationCapsGet(vm, QEMU_MIGRATION_CAP_MAPPED_RAM)) { + if (compressed !=3D QEMU_SAVE_FORMAT_RAW) { + virReportError(VIR_ERR_OPERATION_FAILED, + _("compression is not supported with save image= version %1$u"), + header->version); + goto error; + } + header->features |=3D QEMU_SAVE_FEATURE_MAPPED_RAM; + } + header->was_running =3D running ? 1 : 0; header->compressed =3D compressed; =20 @@ -366,6 +380,7 @@ qemuSaveImageCreateFd(virQEMUDriver *driver, virDomainObj *vm, const char *path, virFileWrapperFd *wrapperFd, + bool mappedRam, bool *needUnlink, unsigned int flags) { @@ -375,7 +390,7 @@ qemuSaveImageCreateFd(virQEMUDriver *driver, int directFlag =3D 0; unsigned int wrapperFlags =3D VIR_FILE_WRAPPER_NON_BLOCKING; =20 - if (flags & VIR_DOMAIN_SAVE_BYPASS_CACHE) { + if (!mappedRam && flags & VIR_DOMAIN_SAVE_BYPASS_CACHE) { wrapperFlags |=3D VIR_FILE_WRAPPER_BYPASS_CACHE; directFlag =3D virFileDirectFdFlag(); if (directFlag < 0) { @@ -395,7 +410,7 @@ qemuSaveImageCreateFd(virQEMUDriver *driver, if (qemuSecuritySetImageFDLabel(driver->securityManager, vm->def, fd) = < 0) return -1; =20 - if (!(wrapperFd =3D virFileWrapperFdNew(&fd, path, wrapperFlags))) + if (!mappedRam && !(wrapperFd =3D virFileWrapperFdNew(&fd, path, wrapp= erFlags))) return -1; =20 ret =3D fd; @@ -414,6 +429,7 @@ qemuSaveImageCreate(virQEMUDriver *driver, const char *path, virQEMUSaveData *data, virCommand *compressor, + qemuMigrationParams *saveParams, unsigned int flags, virDomainAsyncJob asyncJob) { @@ -422,9 +438,10 @@ qemuSaveImageCreate(virQEMUDriver *driver, int ret =3D -1; int fd =3D -1; virFileWrapperFd *wrapperFd =3D NULL; + bool mappedRam =3D data->header.features & QEMU_SAVE_FEATURE_MAPPED_RA= M; =20 /* Obtain the file handle. */ - fd =3D qemuSaveImageCreateFd(driver, vm, path, wrapperFd, &needUnlink,= flags); + fd =3D qemuSaveImageCreateFd(driver, vm, path, wrapperFd, mappedRam, &= needUnlink, flags); =20 if (fd < 0) goto cleanup; @@ -433,7 +450,7 @@ qemuSaveImageCreate(virQEMUDriver *driver, goto cleanup; =20 /* Perform the migration */ - if (qemuMigrationSrcToFile(driver, vm, fd, compressor, asyncJob) < 0) + if (qemuMigrationSrcToFile(driver, vm, &fd, compressor, saveParams, fl= ags, asyncJob) < 0) goto cleanup; =20 /* Touch up file header to mark image complete. */ @@ -441,14 +458,18 @@ qemuSaveImageCreate(virQEMUDriver *driver, /* Reopen the file to touch up the header, since we aren't set * up to seek backwards on wrapperFd. The reopened fd will * trigger a single page of file system cache pollution, but - * that's acceptable. */ - if (VIR_CLOSE(fd) < 0) { - virReportSystemError(errno, _("unable to close %1$s"), path); - goto cleanup; - } + * that's acceptable. + * If using mapped-ram, the fd was passed to qemu, so no need + * to close it. */ + if (!mappedRam) { + if (VIR_CLOSE(fd) < 0) { + virReportSystemError(errno, _("unable to close %1$s"), path); + goto cleanup; + } =20 - if (qemuDomainFileWrapperFDClose(vm, wrapperFd) < 0) - goto cleanup; + if (qemuDomainFileWrapperFDClose(vm, wrapperFd) < 0) + goto cleanup; + } =20 if ((fd =3D qemuDomainOpenFile(cfg, vm->def, path, O_WRONLY, NULL)) < = 0 || virQEMUSaveDataFinish(data, &fd, path) < 0) diff --git a/src/qemu/qemu_saveimage.h b/src/qemu/qemu_saveimage.h index 3cee846f14..eb2835f11b 100644 --- a/src/qemu/qemu_saveimage.h +++ b/src/qemu/qemu_saveimage.h @@ -114,6 +114,7 @@ qemuSaveImageCreate(virQEMUDriver *driver, const char *path, virQEMUSaveData *data, virCommand *compressor, + qemuMigrationParams *saveParams, unsigned int flags, virDomainAsyncJob asyncJob); =20 @@ -124,6 +125,7 @@ virQEMUSaveDataWrite(virQEMUSaveData *data, =20 virQEMUSaveData * virQEMUSaveDataNew(virQEMUDriver *driver, + virDomainObj *vm, char *domXML, qemuDomainSaveCookie *cookieObj, bool running, diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 1d75208814..9833fb6206 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1367,6 +1367,8 @@ qemuSnapshotCreateActiveExternal(virQEMUDriver *drive= r, =20 /* do the memory snapshot if necessary */ if (memory) { + g_autoptr(qemuMigrationParams) snap_params =3D NULL; + /* check if migration is possible */ if (!qemuMigrationSrcIsAllowed(vm, false, VIR_ASYNC_JOB_SNAPSHOT, = 0)) goto cleanup; @@ -1390,7 +1392,7 @@ qemuSnapshotCreateActiveExternal(virQEMUDriver *drive= r, !(snapdef->cookie =3D (virObject *) qemuDomainSaveCookieNew(vm= ))) goto cleanup; =20 - if (!(data =3D virQEMUSaveDataNew(driver, xml, + if (!(data =3D virQEMUSaveDataNew(driver, vm, xml, (qemuDomainSaveCookie *) snapdef->= cookie, resume, compressed))) goto cleanup; @@ -1398,8 +1400,11 @@ qemuSnapshotCreateActiveExternal(virQEMUDriver *driv= er, =20 memory_existing =3D virFileExists(snapdef->memorysnapshotfile); =20 + if (!(snap_params =3D qemuMigrationParamsNew())) + goto cleanup; + if ((ret =3D qemuSaveImageCreate(driver, vm, snapdef->memorysnapsh= otfile, - data, compressor, 0, + data, compressor, snap_params, 0, VIR_ASYNC_JOB_SNAPSHOT)) < 0) goto cleanup; =20 --=20 2.35.3 From nobody Sat Nov 23 15:03:18 2024 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=1723160683; cv=none; d=zohomail.com; s=zohoarc; b=Nv7iUt42ILR+AK6irr+3AIxQJS062+m46PNd+YysHJrZAq0RNu9eGO+4eYCkNsRjlkqnbJyPYKOv+76/CGIEfckYIhb3IWzr37wZvaHgeQzixHdCnb0kcj9APfLLGIzqRiCh0uMrsfWD3DLIOf+I036Em4omJgOlH1n5wQfcSac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723160683; 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=DTEfP8tsJvPX+qcIBcXwIcuXCtfbtE7Jg3m26+f3Uqc=; b=maMX6AcgMq85pwFiZhZR9kpmaDEjCk3oTyepm9j1UKXiaaRdQC62fLFtjs9lqt601AT5GDqeHGKCN2mt2tkkPrcMGcfBX7oaCkuvR/jSqdWuj1lujzwuZ1qZ2P7GVjouD61nnKEo/BfjN2wc5nEmdtu4WF3gIRSUZKJDcfLk6dI= 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 1723160683692697.1644213138644; Thu, 8 Aug 2024 16:44:43 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 9E97413D3; Thu, 8 Aug 2024 19:44:42 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 62FA41527; Thu, 8 Aug 2024 19:39:10 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E793B1475; Thu, 8 Aug 2024 19:39:06 -0400 (EDT) Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 274C5147A for ; Thu, 8 Aug 2024 19:38:40 -0400 (EDT) Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-368313809a4so1510649f8f.0 for ; Thu, 08 Aug 2024 16:38:40 -0700 (PDT) Received: from localhost ([69.51.98.127]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-39b20aaaf79sm58802025ab.26.2024.08.08.16.38.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 16:38:38 -0700 (PDT) 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,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=1723160319; x=1723765119; 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=pA2jBZ87jEYD7xXSq+W9qWaRlk4msPPdDhhMbzcmmdU=; b=L3TAlnTnTuOvBYrWwRFovjRv0OJWtd0pom6nFkw/JNizwnSBkFlsXKkZSM3zF7WdsN rYLmx/6LmokBSaKN66txUVJvmCgn2f3r+A51pC3oARlNrUrgHNot55i3TlifFLGC9IwX eZHWU4HgyjXpzCVLyZ04/J+13agcAK4ZBVxBDwO9SotQYAUY2BVdaYnpF1rDxvXzcLJW Lc4dODSGyb3eYEZ2ojuFBk/HSdAtlkXC488htqj4gkogFkeYCo/8AXElxvZ6oFGEE6qU 7R5isH1Zcx28hPYmlKuWpDExIE3/IY+bjaiL24Yvhf69A9DDiIfdp+w6D+9s8KpeAdw2 G9bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723160319; x=1723765119; 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=pA2jBZ87jEYD7xXSq+W9qWaRlk4msPPdDhhMbzcmmdU=; b=H7Cq5xmM7gGQ2XRUxc8bA5xNbje8Gn0zI1fbKo6SZ2VAGemr4HgYmnfg65BU5c7Y3m l3jH/o5crDh1bpZTa71yDBAHaoVEAw/JWUN1EQ5msuN9BBcoqOZubExJ80kdy+mZPibi DWTDVzgyEw5NVPWqP9zah7LHYPV/WWJTkMgJMT2ibWUstqAwrxLgyLgrdNgxOoSvHhzC tef2NEarE8qzdLG4htHnfbSVhsC+DfJRmu1YuYsDgNRpQnDpswViCvtbnSe68Xbfr8Q2 2RXDEiQWMLDGhnPGiheNCysY+ICaTyqDKxPcVlpA+tBSSMMh0sG12euhZ/3V5B31RsCU 0dew== X-Gm-Message-State: AOJu0YycMYRGvKCjUwPSDdO6kFW9loVr94crakN4Cq9igIFfUzjHvVmY OdbVHI1AL2Vr5/UFx7lahnwk1BMuT3wYze1gOgSlXv5Gfc5KMPNcsZE5rGuWII3sdsP+F3iHSQH r X-Google-Smtp-Source: AGHT+IEc6wWs05/3/gUFXAIvqilOQKtuxCNd/2srTD9lTzpYVbVeq95awAI2Y2RSdRWwJ6H5qMDizw== X-Received: by 2002:a5d:588a:0:b0:36b:b174:5256 with SMTP id ffacd0b85a97d-36d280bdb20mr3483639f8f.6.1723160318877; Thu, 08 Aug 2024 16:38:38 -0700 (PDT) To: devel@lists.libvirt.org Subject: [PATCH 11/20] qemu: Decompose qemuSaveImageOpen Date: Thu, 8 Aug 2024 17:38:04 -0600 Message-Id: <20240808233813.22905-12-jfehlig@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240808233813.22905-1-jfehlig@suse.com> References: <20240808233813.22905-1-jfehlig@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: WYZMIVCYKJIOJXOKZSODELIGXIDMJRGH X-Message-ID-Hash: WYZMIVCYKJIOJXOKZSODELIGXIDMJRGH 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 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: 1723160685825116600 Content-Type: text/plain; charset="utf-8" Split the reading of libvirt's save image metadata from the opening of the fd that will be passed to QEMU. This provides flexibility for an upcoming patch adding mapped-ram support for restore. Signed-off-by: Jim Fehlig --- src/qemu/qemu_driver.c | 37 ++++++++-------- src/qemu/qemu_saveimage.c | 89 ++++++++++++++++++++++++--------------- src/qemu/qemu_saveimage.h | 16 ++++--- src/qemu/qemu_snapshot.c | 9 ++-- 4 files changed, 89 insertions(+), 62 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 977763e5d8..87d75b6baa 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5783,9 +5783,12 @@ qemuDomainRestoreInternal(virConnectPtr conn, if (flags & VIR_DOMAIN_SAVE_RESET_NVRAM) reset_nvram =3D true; =20 - fd =3D qemuSaveImageOpen(driver, NULL, path, &def, &data, + if (qemuSaveImageGetMetadata(driver, NULL, path, &def, &data, false) <= 0) + goto cleanup; + + fd =3D qemuSaveImageOpen(driver, path, (flags & VIR_DOMAIN_SAVE_BYPASS_CACHE) !=3D 0, - &wrapperFd, false, false); + &wrapperFd, false); if (fd < 0) goto cleanup; =20 @@ -5914,15 +5917,11 @@ qemuDomainSaveImageGetXMLDesc(virConnectPtr conn, c= onst char *path, virQEMUDriver *driver =3D conn->privateData; char *ret =3D NULL; g_autoptr(virDomainDef) def =3D NULL; - int fd =3D -1; virQEMUSaveData *data =3D NULL; =20 virCheckFlags(VIR_DOMAIN_SAVE_IMAGE_XML_SECURE, NULL); =20 - fd =3D qemuSaveImageOpen(driver, NULL, path, &def, &data, - false, NULL, false, false); - - if (fd < 0) + if (qemuSaveImageGetMetadata(driver, NULL, path, &def, &data, false) <= 0) goto cleanup; =20 if (virDomainSaveImageGetXMLDescEnsureACL(conn, def) < 0) @@ -5932,7 +5931,6 @@ qemuDomainSaveImageGetXMLDesc(virConnectPtr conn, con= st char *path, =20 cleanup: virQEMUSaveDataFree(data); - VIR_FORCE_CLOSE(fd); return ret; } =20 @@ -5956,8 +5954,10 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, con= st char *path, else if (flags & VIR_DOMAIN_SAVE_PAUSED) state =3D 0; =20 - fd =3D qemuSaveImageOpen(driver, NULL, path, &def, &data, - false, NULL, true, false); + if (qemuSaveImageGetMetadata(driver, NULL, path, &def, &data, false) <= 0) + goto cleanup; + + fd =3D qemuSaveImageOpen(driver, path, 0, NULL, false); =20 if (fd < 0) goto cleanup; @@ -6015,7 +6015,6 @@ qemuDomainManagedSaveGetXMLDesc(virDomainPtr dom, uns= igned int flags) g_autofree char *path =3D NULL; char *ret =3D NULL; g_autoptr(virDomainDef) def =3D NULL; - int fd =3D -1; virQEMUSaveData *data =3D NULL; qemuDomainObjPrivate *priv; =20 @@ -6037,15 +6036,14 @@ qemuDomainManagedSaveGetXMLDesc(virDomainPtr dom, u= nsigned int flags) goto cleanup; } =20 - if ((fd =3D qemuSaveImageOpen(driver, priv->qemuCaps, path, &def, &dat= a, - false, NULL, false, false)) < 0) + if (qemuSaveImageGetMetadata(driver, priv->qemuCaps, path, + &def, &data, false) < 0) goto cleanup; =20 ret =3D qemuDomainDefFormatXML(driver, priv->qemuCaps, def, flags); =20 cleanup: virQEMUSaveDataFree(data); - VIR_FORCE_CLOSE(fd); virDomainObjEndAPI(&vm); return ret; } @@ -6101,14 +6099,17 @@ qemuDomainObjRestore(virConnectPtr conn, virQEMUSaveData *data =3D NULL; virFileWrapperFd *wrapperFd =3D NULL; =20 - fd =3D qemuSaveImageOpen(driver, NULL, path, &def, &data, - bypass_cache, &wrapperFd, false, true); - if (fd < 0) { - if (fd =3D=3D -3) + ret =3D qemuSaveImageGetMetadata(driver, NULL, path, &def, &data, true= ); + if (ret < 0) { + if (ret =3D=3D -3) ret =3D 1; goto cleanup; } =20 + fd =3D qemuSaveImageOpen(driver, path, bypass_cache, &wrapperFd, false= ); + if (fd < 0) + goto cleanup; + if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) { int hookret; =20 diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index 98a1ad638d..125064ab66 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -570,58 +570,35 @@ qemuSaveImageGetCompressionProgram(const char *imageF= ormat, =20 =20 /** - * qemuSaveImageOpen: + * qemuSaveImageGetMetadata: * @driver: qemu driver data * @qemuCaps: pointer to qemuCaps if the domain is running or NULL * @path: path of the save image * @ret_def: returns domain definition created from the XML stored in the = image * @ret_data: returns structure filled with data from the image header - * @bypass_cache: bypass cache when opening the file - * @wrapperFd: returns the file wrapper structure - * @open_write: open the file for writing (for updates) * @unlink_corrupt: remove the image file if it is corrupted * - * Returns the opened fd of the save image file and fills the appropriate = fields - * on success. On error returns -1 on most failures, -3 if corrupt image w= as - * unlinked (no error raised). + * Open the save image file, read libvirt's save image metadata, and popul= ate + * the @ret_def and @ret_data structures. Returns 0 on success and -1 on m= ost + * failures. Returns -3 if corrupt image was unlinked (no error raised). */ int -qemuSaveImageOpen(virQEMUDriver *driver, - virQEMUCaps *qemuCaps, - const char *path, - virDomainDef **ret_def, - virQEMUSaveData **ret_data, - bool bypass_cache, - virFileWrapperFd **wrapperFd, - bool open_write, - bool unlink_corrupt) +qemuSaveImageGetMetadata(virQEMUDriver *driver, + virQEMUCaps *qemuCaps, + const char *path, + virDomainDef **ret_def, + virQEMUSaveData **ret_data, + bool unlink_corrupt) { g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); VIR_AUTOCLOSE fd =3D -1; - int ret =3D -1; g_autoptr(virQEMUSaveData) data =3D NULL; virQEMUSaveHeader *header; g_autoptr(virDomainDef) def =3D NULL; - int oflags =3D open_write ? O_RDWR : O_RDONLY; size_t xml_len; size_t cookie_len; =20 - if (bypass_cache) { - int directFlag =3D virFileDirectFdFlag(); - if (directFlag < 0) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("bypass cache unsupported by this system")); - return -1; - } - oflags |=3D directFlag; - } - - if ((fd =3D qemuDomainOpenFile(cfg, NULL, path, oflags, NULL)) < 0) - return -1; - - if (bypass_cache && - !(*wrapperFd =3D virFileWrapperFdNew(&fd, path, - VIR_FILE_WRAPPER_BYPASS_CACHE))) + if ((fd =3D qemuDomainOpenFile(cfg, NULL, path, O_RDONLY, NULL)) < 0) return -1; =20 data =3D g_new0(virQEMUSaveData, 1); @@ -725,6 +702,50 @@ qemuSaveImageOpen(virQEMUDriver *driver, *ret_def =3D g_steal_pointer(&def); *ret_data =3D g_steal_pointer(&data); =20 + return 0; +} + + +/** + * qemuSaveImageOpen: + * @driver: qemu driver data + * @path: path of the save image + * @bypass_cache: bypass cache when opening the file + * @wrapperFd: returns the file wrapper structure + * @open_write: open the file for writing (for updates) + * + * Returns the opened fd of the save image file on success, -1 on failure. + */ +int +qemuSaveImageOpen(virQEMUDriver *driver, + const char *path, + bool bypass_cache, + virFileWrapperFd **wrapperFd, + bool open_write) +{ + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + VIR_AUTOCLOSE fd =3D -1; + int ret =3D -1; + int oflags =3D open_write ? O_RDWR : O_RDONLY; + + if (bypass_cache) { + int directFlag =3D virFileDirectFdFlag(); + if (directFlag < 0) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("bypass cache unsupported by this system")); + return -1; + } + oflags |=3D directFlag; + } + + if ((fd =3D qemuDomainOpenFile(cfg, NULL, path, oflags, NULL)) < 0) + return -1; + + if (bypass_cache && + !(*wrapperFd =3D virFileWrapperFdNew(&fd, path, + VIR_FILE_WRAPPER_BYPASS_CACHE))) + return -1; + ret =3D fd; fd =3D -1; =20 diff --git a/src/qemu/qemu_saveimage.h b/src/qemu/qemu_saveimage.h index eb2835f11b..e101fdba6e 100644 --- a/src/qemu/qemu_saveimage.h +++ b/src/qemu/qemu_saveimage.h @@ -74,17 +74,21 @@ qemuSaveImageStartVM(virConnectPtr conn, virDomainAsyncJob asyncJob) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5) ATTRIBUTE_NONNULL(6); =20 +int +qemuSaveImageGetMetadata(virQEMUDriver *driver, + virQEMUCaps *qemuCaps, + const char *path, + virDomainDef **ret_def, + virQEMUSaveData **ret_data, + bool unlink_corrupt) + ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5); + int qemuSaveImageOpen(virQEMUDriver *driver, - virQEMUCaps *qemuCaps, const char *path, - virDomainDef **ret_def, - virQEMUSaveData **ret_data, bool bypass_cache, virFileWrapperFd **wrapperFd, - bool open_write, - bool unlink_corrupt) - ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); + bool open_write); =20 int qemuSaveImageGetCompressionProgram(const char *imageFormat, diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 9833fb6206..7d05ce76f4 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2118,11 +2118,12 @@ qemuSnapshotRevertExternalPrepare(virDomainObj *vm, g_autoptr(virDomainDef) savedef =3D NULL; =20 memdata->path =3D snapdef->memorysnapshotfile; - memdata->fd =3D qemuSaveImageOpen(driver, NULL, memdata->path, - &savedef, &memdata->data, - false, NULL, - false, false); + if (qemuSaveImageGetMetadata(driver, NULL, memdata->path, &savedef, + &memdata->data, false) < 0) + return -1; =20 + memdata->fd =3D qemuSaveImageOpen(driver, memdata->path, + false, NULL, false); if (memdata->fd < 0) return -1; =20 --=20 2.35.3 From nobody Sat Nov 23 15:03:18 2024 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=1723160733; cv=none; d=zohomail.com; s=zohoarc; b=OCcsP41p7sasFd6vmHUmj9Wqi9XgQJQCwsnCRDp88ng+32DZKAHW1MlBtYcgBC1ExL9N8iKBAA9ENPZ7Qt3OpXAvgTB96uAloO+3qo3uLF2vhTZ6olHs9jTsh2CeAVM7hm/P2xABSJqrKgStLrZ01c3tBMTy4WhL+9WKlSDH8kY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723160733; 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=XWHneypQnGC9g1mKY75XLjNJcCaF2qK+b5/fATNhqZo=; b=hFRcbcUn8xFlstWLqDwftlU8b2+Rci4ud13fn510YuNFCuVppV+kopWs0iVWg7nOJ28C9TbEy7QQa8+BaOUw+BUcOoY7IVFI2c7/CJjM6xTNsQZs2IUtx6rA4uv0TSh/qoGzTWfW1WtavdGNhPnGLkkd+GQGeYwMf48cGu6SvJo= 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 1723160733077811.8489099500172; Thu, 8 Aug 2024 16:45:33 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E7F97A36; Thu, 8 Aug 2024 19:45:31 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 330F31479; Thu, 8 Aug 2024 19:39:15 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 7618214CE; Thu, 8 Aug 2024 19:39:07 -0400 (EDT) Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.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 E29531499 for ; Thu, 8 Aug 2024 19:38:42 -0400 (EDT) Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4281d812d3eso14524945e9.3 for ; Thu, 08 Aug 2024 16:38:42 -0700 (PDT) Received: from localhost ([69.51.98.127]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-39b33853f12sm47409795ab.75.2024.08.08.16.38.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 16:38:41 -0700 (PDT) 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,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=1723160322; x=1723765122; 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=6nCvd+qhiUX7j8rP/8ke8aEFVJ3Xf9sfodiXPG7nIB0=; b=MlWhiaD5QFWQfBwHd+NnLWxFYRuR1FhZ7ph1sl2dX+q3lO/TkA5dLXbVf26mshMN8I Z/zWGZPqlEsqQm4lpJ+cPmTaFZhDM5xTJRzuwYFD+/I77HHmgjAZmu2mEUdE9LhCkhyn bwNoqPFtw8AqmDbiz7CzlCUJCe1wgNsUMstRt8ea3EheaH1+TPkSuM4eGPyyuhoCPh7e DgfWbGFEp8iRFoAeEm4CCZW9zLh7IESWMuQ/9U9u47iP4tyh6BcBPHaGKuHZswDHv/Z8 FJtfcO8Zcig0ZIwqo4fhQW8jvmAcTc9ht7s0UgMTdw8OpfnIBVt7sl1eaKw8QtAHUc4E dLwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723160322; x=1723765122; 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=6nCvd+qhiUX7j8rP/8ke8aEFVJ3Xf9sfodiXPG7nIB0=; b=RuY/CTbjZqij2OVL9HBbaB48+SW8Nmue76jnKzjkXQPq+MbqF1V305b2ByjQKMFznW yrOk055ZXZk6DmiwV+iwc5X17F7eJTfxp0AcbRhsn8nNqeaG2hHh5Q/ztLVJNchJJXPn W+IvqAAF2pw5BCt3UNABxyaqyNiyNm6eJaQlCvhxAN5LuLcvWL3QbVP2Nb1N6fewEg05 A6cjMnI0SuDMXizh1t2B1r4ZZTn/yECLmoh0oUn39vfq2VLfIUKYUBDprrr4CpUVSHXu UNz67nBfIpIFzS6T5zQZIO/0UusAGFaKhG/35xjpJZJzxBZlCTZ9ujlMhEfoILbqvx0e hMVQ== X-Gm-Message-State: AOJu0Yw6AypUQPUe8qTqwMIAYGYBCk5sRFOWYVhxNzRkxovae5pKFSzY G/3CIpTjuJdBK06YU5/dWzuOMVzaSNjwIQcfaCUKuemJ9C0VFfQKv1vU4spZn1wfOxJFAP3JWeB d X-Google-Smtp-Source: AGHT+IFRQ3bvlb30VG5y2UyYwLYEhbZbuH9cvt+a7+3ftVwQv7aaYjvWQZpXJBosbkzBQoFSDGU3yA== X-Received: by 2002:a5d:4b07:0:b0:368:6337:4221 with SMTP id ffacd0b85a97d-36d27592be2mr2428221f8f.54.1723160321602; Thu, 08 Aug 2024 16:38:41 -0700 (PDT) To: devel@lists.libvirt.org Subject: [PATCH 12/20] qemu: Move creation of qemuProcessIncomingDef struct Date: Thu, 8 Aug 2024 17:38:05 -0600 Message-Id: <20240808233813.22905-13-jfehlig@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240808233813.22905-1-jfehlig@suse.com> References: <20240808233813.22905-1-jfehlig@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: N7JCNP2ENY4V5W7VZEPOMQYSGE6YYPJZ X-Message-ID-Hash: N7JCNP2ENY4V5W7VZEPOMQYSGE6YYPJZ 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 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: 1723160733892116600 Content-Type: text/plain; charset="utf-8" qemuProcessStartWithMemoryState() is the only caller of qemuProcessStart() that uses the qemuProcessIncomingDef struct. Move creation of the struct to qemuProcessStartWithMemoryState(). Signed-off-by: Jim Fehlig --- src/qemu/qemu_process.c | 44 ++++++++++++++++++++--------------------- src/qemu/qemu_process.h | 2 +- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index cec739c984..7eeb85062c 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8191,7 +8191,7 @@ qemuProcessStart(virConnectPtr conn, virDomainObj *vm, virCPUDef *updatedCPU, virDomainAsyncJob asyncJob, - const char *migrateFrom, + qemuProcessIncomingDef *incoming, int migrateFd, const char *migratePath, virDomainMomentObj *snapshot, @@ -8199,7 +8199,6 @@ qemuProcessStart(virConnectPtr conn, unsigned int flags) { qemuDomainObjPrivate *priv =3D vm->privateData; - qemuProcessIncomingDef *incoming =3D NULL; unsigned int stopFlags; bool relabel =3D false; bool relabelSavedState =3D false; @@ -8207,11 +8206,11 @@ qemuProcessStart(virConnectPtr conn, int rv; =20 VIR_DEBUG("conn=3D%p driver=3D%p vm=3D%p name=3D%s id=3D%d asyncJob=3D= %s " - "migrateFrom=3D%s migrateFd=3D%d migratePath=3D%s " + "incoming=3D%p migrateFd=3D%d migratePath=3D%s " "snapshot=3D%p vmop=3D%d flags=3D0x%x", conn, driver, vm, vm->def->name, vm->def->id, virDomainAsyncJobTypeToString(asyncJob), - NULLSTR(migrateFrom), migrateFd, NULLSTR(migratePath), + incoming, migrateFd, NULLSTR(migratePath), snapshot, vmop, flags); =20 virCheckFlagsGoto(VIR_QEMU_PROCESS_START_COLD | @@ -8220,20 +8219,13 @@ qemuProcessStart(virConnectPtr conn, VIR_QEMU_PROCESS_START_GEN_VMID | VIR_QEMU_PROCESS_START_RESET_NVRAM, cleanup); =20 - if (!migrateFrom && !snapshot) + if (!incoming && !snapshot) flags |=3D VIR_QEMU_PROCESS_START_NEW; =20 if (qemuProcessInit(driver, vm, updatedCPU, - asyncJob, !!migrateFrom, flags) < 0) + asyncJob, !!incoming, flags) < 0) goto cleanup; =20 - if (migrateFrom) { - incoming =3D qemuProcessIncomingDefNew(priv->qemuCaps, NULL, migra= teFrom, - migrateFd, migratePath); - if (!incoming) - goto stop; - } - if (qemuProcessPrepareDomain(driver, vm, flags) < 0) goto stop; =20 @@ -8286,14 +8278,13 @@ qemuProcessStart(virConnectPtr conn, qemuSecurityRestoreSavedStateLabel(driver->securityManager, vm->def, migratePath) < 0) VIR_WARN("failed to restore save state label on %s", migratePath); - qemuProcessIncomingDefFree(incoming); return ret; =20 stop: stopFlags =3D 0; if (!relabel) stopFlags |=3D VIR_QEMU_PROCESS_STOP_NO_RELABEL; - if (migrateFrom) + if (incoming) stopFlags |=3D VIR_QEMU_PROCESS_STOP_MIGRATED; if (priv->mon) qemuMonitorSetDomainLog(priv->mon, NULL, NULL, NULL); @@ -8347,20 +8338,24 @@ qemuProcessStartWithMemoryState(virConnectPtr conn, VIR_AUTOCLOSE intermediatefd =3D -1; g_autoptr(virCommand) cmd =3D NULL; g_autofree char *errbuf =3D NULL; - const char *migrateFrom =3D NULL; + qemuProcessIncomingDef *incoming =3D NULL; int rc =3D 0; + int ret =3D -1; + + incoming =3D qemuProcessIncomingDefNew(priv->qemuCaps, NULL, "stdio", + *fd, path); + if (!incoming) + return -1; =20 if (data) { if (virSaveCookieParseString(data->cookie, (virObject **)&cookie, virDomainXMLOptionGetSaveCookie(drive= r->xmlopt)) < 0) - return -1; + goto cleanup; =20 if (qemuSaveImageDecompressionStart(data, fd, &intermediatefd, &errbuf, &cmd) < 0) { - return -1; + goto cleanup; } - - migrateFrom =3D "stdio"; } =20 /* No cookie means libvirt which saved the domain was too old to mess = up @@ -8373,7 +8368,7 @@ qemuProcessStartWithMemoryState(virConnectPtr conn, priv->disableSlirp =3D true; =20 if (qemuProcessStart(conn, driver, vm, cookie ? cookie->cpu : NULL, - asyncJob, migrateFrom, *fd, path, snapshot, + asyncJob, incoming, *fd, path, snapshot, VIR_NETDEV_VPORT_PROFILE_OP_RESTORE, start_flags) =3D=3D 0) *started =3D true; @@ -8385,14 +8380,17 @@ qemuProcessStartWithMemoryState(virConnectPtr conn, =20 virDomainAuditStart(vm, reason, *started); if (!*started || rc < 0) - return -1; + goto cleanup; =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); + ret =3D 0; =20 - return 0; + cleanup: + qemuProcessIncomingDefFree(incoming); + return ret; } =20 =20 diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 2324aeb7bd..e48d53dc46 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -84,7 +84,7 @@ int qemuProcessStart(virConnectPtr conn, virDomainObj *vm, virCPUDef *updatedCPU, virDomainAsyncJob asyncJob, - const char *migrateFrom, + qemuProcessIncomingDef *incoming, int stdin_fd, const char *stdin_path, virDomainMomentObj *snapshot, --=20 2.35.3 From nobody Sat Nov 23 15:03:18 2024 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=1723160706; cv=none; d=zohomail.com; s=zohoarc; b=YEXbQtjp3igAUw1udt2j8yMhHMYqZzPiQxIfYCvN2d/Gl9F616gzg5mh6DUfetXNFQETOV5GJ7JnpsWMVLDWkpEPCaID0bqUdxjY5iTwu3rTjE760AWNQnb46/K8gLndQnYTAyh3t0LRm3II26Y4V6cOBX7sNexWvVCiBdjSpTU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723160706; 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=Ok+FUxTw6tZsmTVitpw4vtpH1fzwpe4GGRfeeVXMxAA=; b=E654HRR2VL/uMrspZVRn+G9FiMlsB2gIjAAsqGhQn7825xm5bZXxvVMS338vf5T5RC43lmr9RUqneOclvLbkI7qUSBlfHVF9HcllYzI9zVo0l/VPGw3PcdVQ/SWzSssu35EfngSlrLc8KdveBIdgfJJ36A8zCt7nH3r38zBM6u0= 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 1723160706886361.0829019050493; Thu, 8 Aug 2024 16:45:06 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 75139140C; Thu, 8 Aug 2024 19:45:05 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 5E05B1507; Thu, 8 Aug 2024 19:39:13 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 37A6F141E; Thu, 8 Aug 2024 19:39:07 -0400 (EDT) Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (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 9B93814A5 for ; Thu, 8 Aug 2024 19:38:45 -0400 (EDT) Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2f15dd0b489so18894681fa.3 for ; Thu, 08 Aug 2024 16:38:45 -0700 (PDT) Received: from localhost ([69.51.98.127]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-8223b10421dsm222801339f.12.2024.08.08.16.38.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 16:38:43 -0700 (PDT) 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,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=1723160324; x=1723765124; 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=Y9R/FCOn0fE1pvXFcvR3M6BWh/AnH1nQObE/+b3tKck=; b=Gkj6vZYpWofP/qdiyanjZ21AxisxvTqu8aUv272e/ShmzWEmqQjGkCxsvdEHN5SNiz zgV51YulH2S9a5ByQprVDCICe2pk3l7XdqB1FDUbBJW5aCupvm5DVRlx4qxAKsdKD5iY GNHWKBGg8adDDZc9nTEC1pLTqM7wIsYB2dnWQZfMef3I78u/wUgXXbL1itY6zRRfrIUx A3JZXVFnxle+71we/e0zrl5a0DZ9r7Won/84V6cOImVvetNewha4JdsmmUorlZiwQaZE 9FXi5enDYzM4PMgmjAWj8Oo0h8Es1jkmO4L/86NnuG0x+LPD4vtSGOPId/uzKNr4w2lI gmjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723160324; x=1723765124; 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=Y9R/FCOn0fE1pvXFcvR3M6BWh/AnH1nQObE/+b3tKck=; b=e6WVlJihkqKDdf0nToy9O0hx0MVV6QiDx74d1fWyfdkjKUCIX7cU9sPQxMzOinBEcl oNvpR7nYyHFXlSA5QsRMcvs1OQ1LzDIChAHQQPaBRa4h7FBJSfLy+18m+pvWlKr9m6So dJ7osZKztYgO1wSbfWRkk+1qBiMXiiVmk8ssYTv/opvhG1m61MBznB+DaS4ji6UB+v3U O/ANVdVjB4ChT8fUjy2qMxk0/7uwKt8Gjbx1Qao+92o9hgdMjNtpUxsns6PKN0zqmTPw 2khlKyHEaJemChGDXGgOT0plnpQIvk0jq88BNAscu4ski4GGy6JFHeXg/ClYuCvN3W7F JxPw== X-Gm-Message-State: AOJu0YxgS3oR/NP+t3QTWBf1OAlAIYT8ZbAZ6nGdozRknUX4NUHlA36s FtDrIaNTCvoq5PgjJ5VHz1DyYzohRE1NpB5/Sr42CtJ0qUyKQ4UzErngfDcNfcfG/Vnouwxn0zj 5 X-Google-Smtp-Source: AGHT+IFfd2yTs+k8n02tJL9+cL3oKx6zTlihB1ONa0lSh78EGb6nAIfknnADvbU40SI3JhAn7JKm+g== X-Received: by 2002:a2e:9b0c:0:b0:2f1:9248:c325 with SMTP id 38308e7fff4ca-2f19de603c0mr20370301fa.31.1723160324171; Thu, 08 Aug 2024 16:38:44 -0700 (PDT) To: devel@lists.libvirt.org Subject: [PATCH 13/20] qemu: Apply migration parameters in qemuMigrationDstRun Date: Thu, 8 Aug 2024 17:38:06 -0600 Message-Id: <20240808233813.22905-14-jfehlig@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240808233813.22905-1-jfehlig@suse.com> References: <20240808233813.22905-1-jfehlig@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: MPAXBZYWL2ICCUI5ACKZ6Q4MMNMW5RBN X-Message-ID-Hash: MPAXBZYWL2ICCUI5ACKZ6Q4MMNMW5RBN 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 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: 1723160707727116600 Content-Type: text/plain; charset="utf-8" Similar to qemuMigrationSrcRun, apply migration parameters in qemuMigrationDstRun. This allows callers to create customized migration parameters, but delegates their application to the function performing the migration. Signed-off-by: Jim Fehlig --- src/qemu/qemu_migration.c | 15 +++++++++------ src/qemu/qemu_migration.h | 4 +++- src/qemu/qemu_process.c | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 3ab5e2fa30..fd897b4ed1 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2285,13 +2285,19 @@ qemuMigrationDstGetURI(const char *migrateFrom, int qemuMigrationDstRun(virDomainObj *vm, const char *uri, - virDomainAsyncJob asyncJob) + virDomainAsyncJob asyncJob, + qemuMigrationParams *migParams, + unsigned int flags) { qemuDomainObjPrivate *priv =3D vm->privateData; int rv; =20 VIR_DEBUG("Setting up incoming migration with URI %s", uri); =20 + if (migParams && qemuMigrationParamsApply(vm, asyncJob, + migParams, flags) < 0) + return -1; + if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0) return -1; =20 @@ -3207,10 +3213,6 @@ qemuMigrationDstPrepareActive(virQEMUDriver *driver, goto error; } =20 - if (qemuMigrationParamsApply(vm, VIR_ASYNC_JOB_MIGRATION_IN, - migParams, flags) < 0) - goto error; - if (mig->nbd && flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARED_INC)= ) { const char *nbdTLSAlias =3D NULL; @@ -3242,7 +3244,8 @@ qemuMigrationDstPrepareActive(virQEMUDriver *driver, } =20 if (qemuMigrationDstRun(vm, incoming->uri, - VIR_ASYNC_JOB_MIGRATION_IN) < 0) + VIR_ASYNC_JOB_MIGRATION_IN, + migParams, flags) < 0) goto error; =20 if (qemuProcessFinishStartup(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN, diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index 039a926e69..5529f2ee21 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -281,7 +281,9 @@ qemuMigrationDstGetURI(const char *migrateFrom, int qemuMigrationDstRun(virDomainObj *vm, const char *uri, - virDomainAsyncJob asyncJob); + virDomainAsyncJob asyncJob, + qemuMigrationParams *migParams, + unsigned int flags); =20 void qemuMigrationSrcPostcopyFailed(virDomainObj *vm); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 7eeb85062c..1d7f214212 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8248,7 +8248,7 @@ qemuProcessStart(virConnectPtr conn, relabel =3D true; =20 if (incoming) { - if (qemuMigrationDstRun(vm, incoming->uri, asyncJob) < 0) + if (qemuMigrationDstRun(vm, incoming->uri, asyncJob, NULL, 0) < 0) goto stop; } else { /* Refresh state of devices from QEMU. During migration this happe= ns --=20 2.35.3 From nobody Sat Nov 23 15:03:18 2024 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=1723160778; cv=none; d=zohomail.com; s=zohoarc; b=P5CGrnYP8UlSkXdIE7SpFxNmGBlKBWeyxp8blnEi3K9wkOxkgultCmYdehqrQyT+RpODnKA5Vt+dCOVp1VUW6MzblMm2z/jEBx8KW4FN89BjrsxUnR8DoUGead/N99x99GbaM60hREiwkrc0VLUfsdKYwCzQa508jikWEmTUDeQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723160778; 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=Q1jPow6jUUr+ftMEeHQhtefQv/lw+dd8XC1RAQI+0ZI=; b=knMkZPn6ptF+dlDkXX2z0/HKMVxtc0mFz+s/QmE7lCu/eo1nkSp1zlVTQl2t9dFK/8Aj2K4eicn09XgTHmy6xPpzFKnOLBjzCPqjyRY3cc4oo1TOVBAODlALSuNdpKxDJ0gWuyH5SOYLOB4ALmy/fhPQu5/3AKGuKfyVcjiTSEc= 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 1723160778244158.47518820436494; Thu, 8 Aug 2024 16:46:18 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 27C90136; Thu, 8 Aug 2024 19:46:17 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 12F141518; Thu, 8 Aug 2024 19:39:18 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 7A0AD145D; Thu, 8 Aug 2024 19:39:12 -0400 (EDT) Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (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 A9305145D for ; Thu, 8 Aug 2024 19:38:47 -0400 (EDT) Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2f15790b472so18189891fa.0 for ; Thu, 08 Aug 2024 16:38:47 -0700 (PDT) Received: from localhost ([69.51.98.127]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-81fd4d82be5sm412714939f.49.2024.08.08.16.38.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 16:38:45 -0700 (PDT) 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,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=1723160326; x=1723765126; 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=mEuT9VLMxUCo0T//ZGuAvHDAROiO3GCaFRnR/EbdtKI=; b=DVa00ii9L/kq979cdeLh4YefTcn88x9kTvvSzpLBwQ+d1+uRgDbXg8x3vos8tMe11D aR8HsU52nBt9iOSh5RyvKBSuEO9uq6vA8+tjwfhS4cR7vnPZrCn4GhPHfGJia1WPLVzk JAmlVhWzqkeVcIYV4ZwMeV5yfTkK/olTz1UCB2N8cnhWVlioSTbg2chUnNtOhnQacr4S EB3T65pa4nvwNNCJf95YX2ffeuWh/GpazSV4ASu1oGGYMaVWlUF1bOzq/88xk2sMIFBi ivCJiQHohYvmUA4PlFPDUo53n0szxbnMJGLuaZ6K2XWYasMinxZuh+rrEvwJbxDwIGZf Xp5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723160326; x=1723765126; 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=mEuT9VLMxUCo0T//ZGuAvHDAROiO3GCaFRnR/EbdtKI=; b=psWahefBgOWHZBSq+JXm2k8NWqfitTimJSq4+SC5DxGIyDJDfniTB7b9+TDy/Af1U7 w/ScDdrxYCfIJ9JJMxuFuUjryxVA2ZvAdY5hN4p73PfjDcUCtBas0aYHk45Kyklz5r33 41BJvSCOnWDj3ko96ch9gLvFLywsceNT3X+Fb+4cPCcKPKuGd2Q4fCOyBO/epDTwLEdy G7h6n/oOAoJkDtUFtEDH9dXwcFJEhOXeypByxA0mDTiN+VbuI9LOJzp0hOrhJCoX6l7i 1j9Z2a5/71ztza2Kuig8/aPusfveR1d0fPDcG7DO4mshhMb1drDL4r1RKNJvOPyWIl2Z qqLg== X-Gm-Message-State: AOJu0YyVISvIqcmI7Toa4LdPln2t9RHMkmDIVeZ9vi5G3iIbGNdbpS0/ i4BNvYbdb32CzXLIqTq4LJ/ZRfijUoEEM7CSUTb7rFyx084wG6KplPYDRA9bcfUC6VtrFe9uYBf n X-Google-Smtp-Source: AGHT+IHV50xtBz2L4uf6FfZEV6lh25AWnij8VOmvYwj2crwB53P7ejfKnPXRIqJInV2DakyNPa+AZg== X-Received: by 2002:a05:651c:b26:b0:2f1:59ed:87b8 with SMTP id 38308e7fff4ca-2f19de21feemr29062141fa.3.1723160326197; Thu, 08 Aug 2024 16:38:46 -0700 (PDT) To: devel@lists.libvirt.org Subject: [PATCH 14/20] qemu: Add support for mapped-ram on restore Date: Thu, 8 Aug 2024 17:38:07 -0600 Message-Id: <20240808233813.22905-15-jfehlig@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240808233813.22905-1-jfehlig@suse.com> References: <20240808233813.22905-1-jfehlig@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: QFIQJE5PAEX32YW43BJLRTAFZLAO3HDZ X-Message-ID-Hash: QFIQJE5PAEX32YW43BJLRTAFZLAO3HDZ 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 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: 1723160780147116600 Content-Type: text/plain; charset="utf-8" Add support for the mapped-ram migration capability on restore. Using mapped-ram with QEMU to restore an image requires the same steps as saving: - The 'mapped-ram' migration capability must be set to true - The 'multifd' migration capability must be set to true and the 'multifd-channels' migration parameter must set to a value >=3D 1 - QEMU must be provided an fdset containing the migration fd(s) - The 'migrate-incoming' qmp command is invoked with a URI referencing the fdset and an offset where to start reading the data stream, e.g. {"execute":"migrate-incoming", "arguments":{"uri":"file:/dev/fdset/0,offset=3D0x119eb"}} Signed-off-by: Jim Fehlig --- src/qemu/qemu_driver.c | 26 +++++++++++++----- src/qemu/qemu_migration.c | 11 ++++---- src/qemu/qemu_process.c | 58 +++++++++++++++++++++++++++++++-------- src/qemu/qemu_process.h | 15 ++++++---- src/qemu/qemu_saveimage.c | 9 ++++-- src/qemu/qemu_saveimage.h | 2 ++ src/qemu/qemu_snapshot.c | 8 +++--- 7 files changed, 92 insertions(+), 37 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 87d75b6baa..6d0f52951c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1611,7 +1611,7 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr= conn, } =20 if (qemuProcessStart(conn, driver, vm, NULL, VIR_ASYNC_JOB_START, - NULL, -1, NULL, NULL, + NULL, -1, NULL, NULL, NULL, VIR_NETDEV_VPORT_PROFILE_OP_CREATE, start_flags) < 0) { virDomainAuditStart(vm, "booted", false); @@ -5774,6 +5774,8 @@ qemuDomainRestoreInternal(virConnectPtr conn, virFileWrapperFd *wrapperFd =3D NULL; bool hook_taint =3D false; bool reset_nvram =3D false; + bool mapped_ram =3D false; + g_autoptr(qemuMigrationParams) restoreParams =3D NULL; =20 virCheckFlags(VIR_DOMAIN_SAVE_BYPASS_CACHE | VIR_DOMAIN_SAVE_RUNNING | @@ -5786,9 +5788,13 @@ qemuDomainRestoreInternal(virConnectPtr conn, if (qemuSaveImageGetMetadata(driver, NULL, path, &def, &data, false) <= 0) goto cleanup; =20 + mapped_ram =3D data->header.features & QEMU_SAVE_FEATURE_MAPPED_RAM; + if (!(restoreParams =3D qemuMigrationParamsForSave(mapped_ram))) + return -1; + fd =3D qemuSaveImageOpen(driver, path, (flags & VIR_DOMAIN_SAVE_BYPASS_CACHE) !=3D 0, - &wrapperFd, false); + mapped_ram, &wrapperFd, false); if (fd < 0) goto cleanup; =20 @@ -5842,7 +5848,7 @@ qemuDomainRestoreInternal(virConnectPtr conn, if (qemuProcessBeginJob(vm, VIR_DOMAIN_JOB_OPERATION_RESTORE, flags) <= 0) goto cleanup; =20 - ret =3D qemuSaveImageStartVM(conn, driver, vm, &fd, data, path, + ret =3D qemuSaveImageStartVM(conn, driver, vm, &fd, data, path, restor= eParams, false, reset_nvram, VIR_ASYNC_JOB_START); =20 qemuProcessEndJob(vm); @@ -5957,7 +5963,7 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, cons= t char *path, if (qemuSaveImageGetMetadata(driver, NULL, path, &def, &data, false) <= 0) goto cleanup; =20 - fd =3D qemuSaveImageOpen(driver, path, 0, NULL, false); + fd =3D qemuSaveImageOpen(driver, path, 0, false, NULL, false); =20 if (fd < 0) goto cleanup; @@ -6098,6 +6104,8 @@ qemuDomainObjRestore(virConnectPtr conn, g_autofree char *xmlout =3D NULL; virQEMUSaveData *data =3D NULL; virFileWrapperFd *wrapperFd =3D NULL; + bool mapped_ram =3D false; + g_autoptr(qemuMigrationParams) restoreParams =3D NULL; =20 ret =3D qemuSaveImageGetMetadata(driver, NULL, path, &def, &data, true= ); if (ret < 0) { @@ -6106,7 +6114,11 @@ qemuDomainObjRestore(virConnectPtr conn, goto cleanup; } =20 - fd =3D qemuSaveImageOpen(driver, path, bypass_cache, &wrapperFd, false= ); + mapped_ram =3D data->header.features & QEMU_SAVE_FEATURE_MAPPED_RAM; + if (!(restoreParams =3D qemuMigrationParamsForSave(mapped_ram))) + return -1; + + fd =3D qemuSaveImageOpen(driver, path, bypass_cache, mapped_ram, &wrap= perFd, false); if (fd < 0) goto cleanup; =20 @@ -6148,7 +6160,7 @@ qemuDomainObjRestore(virConnectPtr conn, =20 virDomainObjAssignDef(vm, &def, true, NULL); =20 - ret =3D qemuSaveImageStartVM(conn, driver, vm, &fd, data, path, + ret =3D qemuSaveImageStartVM(conn, driver, vm, &fd, data, path, restor= eParams, start_paused, reset_nvram, asyncJob); =20 cleanup: @@ -6349,7 +6361,7 @@ qemuDomainObjStart(virConnectPtr conn, } =20 ret =3D qemuProcessStart(conn, driver, vm, NULL, asyncJob, - NULL, -1, NULL, NULL, + NULL, -1, NULL, NULL, NULL, VIR_NETDEV_VPORT_PROFILE_OP_CREATE, start_flags= ); virDomainAuditStart(vm, "booted", ret >=3D 0); if (ret >=3D 0) { diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index fd897b4ed1..35d3e26908 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2953,9 +2953,8 @@ qemuMigrationDstPrepare(virDomainObj *vm, const char *protocol, const char *listenAddress, unsigned short port, - int fd) + int *fd) { - qemuDomainObjPrivate *priv =3D vm->privateData; g_autofree char *migrateFrom =3D NULL; =20 if (tunnel) { @@ -3009,8 +3008,8 @@ qemuMigrationDstPrepare(virDomainObj *vm, migrateFrom =3D g_strdup_printf(incFormat, protocol, listenAddress= , port); } =20 - return qemuProcessIncomingDefNew(priv->qemuCaps, listenAddress, - migrateFrom, fd, NULL); + return qemuProcessIncomingDefNew(vm, listenAddress, + migrateFrom, fd, NULL, NULL); } =20 =20 @@ -3154,7 +3153,7 @@ qemuMigrationDstPrepareActive(virQEMUDriver *driver, =20 if (!(incoming =3D qemuMigrationDstPrepare(vm, tunnel, protocol, listenAddress, port, - dataFD[0]))) + &dataFD[0]))) goto error; =20 if (qemuProcessPrepareDomain(driver, vm, startFlags) < 0) @@ -3524,7 +3523,7 @@ qemuMigrationDstPrepareResume(virQEMUDriver *driver, priv->origname =3D g_strdup(origname); =20 if (!(incoming =3D qemuMigrationDstPrepare(vm, false, protocol, - listenAddress, port, -1))) + listenAddress, port, NULL))) goto cleanup; =20 if (qemuDomainObjEnterMonitorAsync(vm, VIR_ASYNC_JOB_MIGRATION_IN) < 0) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 1d7f214212..b02cd84aff 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4680,6 +4680,7 @@ qemuProcessIncomingDefFree(qemuProcessIncomingDef *in= c) =20 g_free(inc->address); g_free(inc->uri); + qemuFDPassFree(inc->fdPassMigrate); g_free(inc); } =20 @@ -4693,26 +4694,54 @@ qemuProcessIncomingDefFree(qemuProcessIncomingDef *= inc) * qemuProcessIncomingDefFree will NOT close it. */ qemuProcessIncomingDef * -qemuProcessIncomingDefNew(virQEMUCaps *qemuCaps, +qemuProcessIncomingDefNew(virDomainObj *vm, const char *listenAddress, const char *migrateFrom, - int fd, - const char *path) + int *fd, + const char *path, + virQEMUSaveData *data) { + qemuDomainObjPrivate *priv =3D vm->privateData; qemuProcessIncomingDef *inc =3D NULL; =20 - if (qemuMigrationDstCheckProtocol(qemuCaps, migrateFrom) < 0) + if (qemuMigrationDstCheckProtocol(priv->qemuCaps, migrateFrom) < 0) return NULL; =20 inc =3D g_new0(qemuProcessIncomingDef, 1); =20 inc->address =3D g_strdup(listenAddress); =20 - inc->uri =3D qemuMigrationDstGetURI(migrateFrom, fd); + if (data) { + size_t offset =3D sizeof(virQEMUSaveHeader) + data->header.data_le= n; + + if (data->header.features & QEMU_SAVE_FEATURE_MAPPED_RAM) { + unsigned int fdsetId; + + inc->fdPassMigrate =3D qemuFDPassNew("migrate", priv); + qemuFDPassAddFD(inc->fdPassMigrate, fd, "-buffered-fd"); + qemuFDPassGetId(inc->fdPassMigrate, &fdsetId); + inc->uri =3D g_strdup_printf("file:/dev/fdset/%u,offset=3D%#lx= ", fdsetId, offset); + } else { + g_autofree char *tmp =3D g_new(char, offset); + + /* HACK: + * We provide qemu the offset in case of mapped-ram, but must = set + * the file offset for the legacy save format. Unfortunately we + * can't lseek when the fd is wrapped by virFileWrapperFd, so + * we do a needless read instead. + */ + if (saferead(*fd, tmp, offset) !=3D offset) + VIR_DEBUG("failed to read from save file"); + inc->uri =3D qemuMigrationDstGetURI(migrateFrom, *fd); + } + } else { + inc->uri =3D qemuMigrationDstGetURI(migrateFrom, *fd); + } + if (!inc->uri) goto error; =20 - inc->fd =3D fd; + inc->fd =3D *fd; inc->path =3D path; =20 return inc; @@ -7782,8 +7811,11 @@ qemuProcessLaunch(virConnectPtr conn, &nnicindexes, &nicindexes))) goto cleanup; =20 - if (incoming && incoming->fd !=3D -1) - virCommandPassFD(cmd, incoming->fd, 0); + if (incoming) { + if (incoming->fd !=3D -1) + virCommandPassFD(cmd, incoming->fd, 0); + qemuFDPassTransferCommand(incoming->fdPassMigrate, cmd); + } =20 /* now that we know it is about to start call the hook if present */ if (qemuProcessStartHook(driver, vm, @@ -8195,6 +8227,7 @@ qemuProcessStart(virConnectPtr conn, int migrateFd, const char *migratePath, virDomainMomentObj *snapshot, + qemuMigrationParams *migParams, virNetDevVPortProfileOp vmop, unsigned int flags) { @@ -8248,7 +8281,7 @@ qemuProcessStart(virConnectPtr conn, relabel =3D true; =20 if (incoming) { - if (qemuMigrationDstRun(vm, incoming->uri, asyncJob, NULL, 0) < 0) + if (qemuMigrationDstRun(vm, incoming->uri, asyncJob, migParams, 0)= < 0) goto stop; } else { /* Refresh state of devices from QEMU. During migration this happe= ns @@ -8302,6 +8335,7 @@ qemuProcessStart(virConnectPtr conn, * @path: path to memory state file * @snapshot: internal snapshot to load when starting QEMU process or NULL * @data: data from memory state file or NULL + * @migParams: Migration params to use on restore or NULL * @asyncJob: type of asynchronous job * @start_flags: flags to start QEMU process with * @reason: audit log reason @@ -8328,6 +8362,7 @@ qemuProcessStartWithMemoryState(virConnectPtr conn, const char *path, virDomainMomentObj *snapshot, virQEMUSaveData *data, + qemuMigrationParams *migParams, virDomainAsyncJob asyncJob, unsigned int start_flags, const char *reason, @@ -8342,8 +8377,7 @@ qemuProcessStartWithMemoryState(virConnectPtr conn, int rc =3D 0; int ret =3D -1; =20 - incoming =3D qemuProcessIncomingDefNew(priv->qemuCaps, NULL, "stdio", - *fd, path); + incoming =3D qemuProcessIncomingDefNew(vm, NULL, "stdio", fd, path, da= ta); if (!incoming) return -1; =20 @@ -8369,7 +8403,7 @@ qemuProcessStartWithMemoryState(virConnectPtr conn, =20 if (qemuProcessStart(conn, driver, vm, cookie ? cookie->cpu : NULL, asyncJob, incoming, *fd, path, snapshot, - VIR_NETDEV_VPORT_PROFILE_OP_RESTORE, + migParams, VIR_NETDEV_VPORT_PROFILE_OP_RESTORE, start_flags) =3D=3D 0) *started =3D true; =20 diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index e48d53dc46..93699da8bd 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -54,14 +54,17 @@ struct _qemuProcessIncomingDef { char *address; /* address where QEMU is supposed to listen */ char *uri; /* used when calling migrate-incoming QMP command */ int fd; /* for fd:N URI */ + qemuFDPass *fdPassMigrate; /* for file:/dev/fdset/n,offset=3Dx URI */ const char *path; /* path associated with fd */ }; =20 -qemuProcessIncomingDef *qemuProcessIncomingDefNew(virQEMUCaps *qemuCaps, - const char *listenAddr= ess, - const char *migrateFro= m, - int fd, - const char *path); +qemuProcessIncomingDef *qemuProcessIncomingDefNew(virDomainObj *vm, + const char *listenAddres= s, + const char *migrateFrom, + int *fd, + const char *path, + virQEMUSaveData *data); + void qemuProcessIncomingDefFree(qemuProcessIncomingDef *inc); =20 int qemuProcessBeginJob(virDomainObj *vm, @@ -88,6 +91,7 @@ int qemuProcessStart(virConnectPtr conn, int stdin_fd, const char *stdin_path, virDomainMomentObj *snapshot, + qemuMigrationParams *migParams, virNetDevVPortProfileOp vmop, unsigned int flags); =20 @@ -98,6 +102,7 @@ int qemuProcessStartWithMemoryState(virConnectPtr conn, const char *path, virDomainMomentObj *snapshot, virQEMUSaveData *data, + qemuMigrationParams *migParams, virDomainAsyncJob asyncJob, unsigned int start_flags, const char *reason, diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index 125064ab66..b99e0de1ff 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -711,6 +711,7 @@ qemuSaveImageGetMetadata(virQEMUDriver *driver, * @driver: qemu driver data * @path: path of the save image * @bypass_cache: bypass cache when opening the file + * @mapped_ram: Image contains mapped-ram save format * @wrapperFd: returns the file wrapper structure * @open_write: open the file for writing (for updates) * @@ -720,6 +721,7 @@ int qemuSaveImageOpen(virQEMUDriver *driver, const char *path, bool bypass_cache, + bool mapped_ram, virFileWrapperFd **wrapperFd, bool open_write) { @@ -741,7 +743,7 @@ qemuSaveImageOpen(virQEMUDriver *driver, if ((fd =3D qemuDomainOpenFile(cfg, NULL, path, oflags, NULL)) < 0) return -1; =20 - if (bypass_cache && + if (!mapped_ram && bypass_cache && !(*wrapperFd =3D virFileWrapperFdNew(&fd, path, VIR_FILE_WRAPPER_BYPASS_CACHE))) return -1; @@ -760,6 +762,7 @@ qemuSaveImageStartVM(virConnectPtr conn, int *fd, virQEMUSaveData *data, const char *path, + qemuMigrationParams *restoreParams, bool start_paused, bool reset_nvram, virDomainAsyncJob asyncJob) @@ -776,8 +779,8 @@ qemuSaveImageStartVM(virConnectPtr conn, start_flags |=3D VIR_QEMU_PROCESS_START_RESET_NVRAM; =20 if (qemuProcessStartWithMemoryState(conn, driver, vm, fd, path, NULL, = data, - asyncJob, start_flags, "restored", - &started) < 0) { + restoreParams, asyncJob, start_fla= gs, + "restored", &started) < 0) { goto cleanup; } =20 diff --git a/src/qemu/qemu_saveimage.h b/src/qemu/qemu_saveimage.h index e101fdba6e..2007784e88 100644 --- a/src/qemu/qemu_saveimage.h +++ b/src/qemu/qemu_saveimage.h @@ -69,6 +69,7 @@ qemuSaveImageStartVM(virConnectPtr conn, int *fd, virQEMUSaveData *data, const char *path, + qemuMigrationParams *restoreParams, bool start_paused, bool reset_nvram, virDomainAsyncJob asyncJob) @@ -87,6 +88,7 @@ int qemuSaveImageOpen(virQEMUDriver *driver, const char *path, bool bypass_cache, + bool mapped_ram, virFileWrapperFd **wrapperFd, bool open_write); =20 diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 7d05ce76f4..79c20d48f4 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2123,7 +2123,7 @@ qemuSnapshotRevertExternalPrepare(virDomainObj *vm, return -1; =20 memdata->fd =3D qemuSaveImageOpen(driver, memdata->path, - false, NULL, false); + false, false, NULL, false); if (memdata->fd < 0) return -1; =20 @@ -2366,7 +2366,7 @@ qemuSnapshotRevertActive(virDomainObj *vm, =20 if (qemuProcessStartWithMemoryState(snapshot->domain->conn, driver, vm, &memdata.fd, memdata.path, loadSna= p, - memdata.data, VIR_ASYNC_JOB_SNAPSH= OT, + memdata.data, NULL, VIR_ASYNC_JOB_= SNAPSHOT, start_flags, "from-snapshot", &started) < 0) { if (started) { @@ -2520,7 +2520,7 @@ qemuSnapshotRevertInactive(virDomainObj *vm, =20 rc =3D qemuProcessStart(snapshot->domain->conn, driver, vm, NULL, VIR_ASYNC_JOB_SNAPSHOT, NULL, -1, NULL, NULL, - VIR_NETDEV_VPORT_PROFILE_OP_CREATE, + NULL, VIR_NETDEV_VPORT_PROFILE_OP_CREATE, start_flags); virDomainAuditStart(vm, "from-snapshot", rc >=3D 0); if (rc < 0) { @@ -2997,7 +2997,7 @@ qemuSnapshotDeleteExternalPrepare(virDomainObj *vm, =20 if (!virDomainObjIsActive(vm)) { if (qemuProcessStart(NULL, driver, vm, NULL, VIR_ASYNC_JOB_SNA= PSHOT, - NULL, -1, NULL, NULL, + NULL, -1, NULL, NULL, NULL, VIR_NETDEV_VPORT_PROFILE_OP_CREATE, VIR_QEMU_PROCESS_START_PAUSED) < 0) { return -1; --=20 2.35.3 From nobody Sat Nov 23 15:03:18 2024 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=1723160819; cv=none; d=zohomail.com; s=zohoarc; b=WAbP87KXpZ5ewz+TX3n85+8lAPyLHVitrzgqahQLAnP7gzZS/RxJR/LcRmYk/F/A3wYNjWVP2qUdN6uZv/tEhT0iOfwX2Sgv/PLiPUngmc8ZKrlemsFTLqeW/JRKO9FlMalF5q7s11Sr4z97QjrQmMY4A7ypZ+AnCiGFxd9vbcc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723160819; 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=GeEzbKA6On+WYVAmq0Poun0z2eBGHEr8alFmS83bmdc=; b=HI1PByS6XlL7AGEQ48XBiuwfQW/P0gzPn6sCzZlimt0j9YywBrip6XQ8C4CmdIKuqEoheNObLCD3wnJO09LWZsNXH12OqYNsFoyH4ejWn13iME0FAUbq0RHmwX3lH0As9nMaki5BNpxh3hob5PLesU4cLmdZWXrZ/O1j9csqFME= 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 1723160819480275.7243510871916; Thu, 8 Aug 2024 16:46:59 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 72724B65; Thu, 8 Aug 2024 19:46:58 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 630E21493; Thu, 8 Aug 2024 19:39:20 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 875201528; Thu, 8 Aug 2024 19:39:13 -0400 (EDT) Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (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 E346914C8 for ; Thu, 8 Aug 2024 19:38:49 -0400 (EDT) Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2eeb1ba040aso20130811fa.1 for ; Thu, 08 Aug 2024 16:38:49 -0700 (PDT) Received: from localhost ([69.51.98.127]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d69a6bbdsm3769049173.38.2024.08.08.16.38.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 16:38:47 -0700 (PDT) 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,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=1723160328; x=1723765128; 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=BHxZ9mbDeg3mWrmAkW80BpmFagGfEpKGjmqxXbuJItg=; b=Wgt6TGAn/a9iXyOwLiRYMBRzZ7djcDSXwEx0NI+UKmHM7u3uAc/bRdy9bjiPCBQa0K Hf5UvrErZ6yIH9n9le3MalNSg0EebELWHt/oBdiNBuOtRaN8rj9fwUApoqr5+A7vC8Ii CItRr6GNdbbgyfOmxSpL2r5utasogscOl9ByIoJ7118QNd+2YRPFLvGfmPE58r9kpbjz qDdoat4Bak3KgmwZM0IEiI7iIN0EtnTW3AfV+F1O5KxlRvtT81hlxU5G5D7L87z+qgV4 W4awtKjROoK9FQfAWrfxjBBrKITHLM5u93LPEhfl9pT3vpCxoYkSTsdoRhS0X6uWLzAS BRAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723160328; x=1723765128; 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=BHxZ9mbDeg3mWrmAkW80BpmFagGfEpKGjmqxXbuJItg=; b=HTex/e1bswiJ9WlXC5wDhW3t6pTZvJ/aHxC19Boo5rzbAkpZqGULqrlKoA3HCUzYBL Bm014HEZeb/fIy8HiL3yANp5YpNlmURNQ0dWZY2rvqmkiaP0wdN/dt85gqRbWWMZBLY0 WvKsAJvYFIsKkKJtWapeXLZSSwwqy8incNqGbqy2J/CzYdy7qPpLmEB5iM6DwVDjkaav G2eNhCNKHl8z4YqV0kkTEt0/KAX2Qjvvd5KaKqinGtQ3J2pX8zSZXMRRNM0MESF8fB2K rgjL7xwYDT+8zbfbNB1bvOLavtcX09WhxDhFK9Oiu7IuwhFxyp6CuVuaDisr0+5FxBcw 3imw== X-Gm-Message-State: AOJu0YzTgJtv3Z4TTF+eR6JBXILmoWEFALuqStyqW6zdgR/t9FGei8WV 8XDp3vQKzFySf3xaT7s/QQHR6cYCCFT6uoxvicLXCeVHvceZ+NgoinM3AyDSyXKEz21IfQfLBQ2 V X-Google-Smtp-Source: AGHT+IEUFf44e2sHxI18oZyeWPWHOg7pkx3HJ4Pxgpwne4mTriHeyQ3iSw+oPTf59Vluti3Hpu9UTA== X-Received: by 2002:a05:651c:1993:b0:2ef:259f:a569 with SMTP id 38308e7fff4ca-2f19ee80b06mr24839791fa.15.1723160328317; Thu, 08 Aug 2024 16:38:48 -0700 (PDT) To: devel@lists.libvirt.org Subject: [PATCH 15/20] qemu: Support O_DIRECT with mapped-ram on save Date: Thu, 8 Aug 2024 17:38:08 -0600 Message-Id: <20240808233813.22905-16-jfehlig@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240808233813.22905-1-jfehlig@suse.com> References: <20240808233813.22905-1-jfehlig@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: NZXES33XMN2TGCI7KMEQ5MV3277CNINN X-Message-ID-Hash: NZXES33XMN2TGCI7KMEQ5MV3277CNINN 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 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: 1723160820272116600 Content-Type: text/plain; charset="utf-8" When using the mapped-ram migration capability, direct IO is enabled by setting the "direct-io" migration parameter to "true" and passing QEMU an additional fd with O_DIRECT set. Signed-off-by: Jim Fehlig --- src/qemu/qemu_driver.c | 9 +++++---- src/qemu/qemu_migration.c | 32 ++++++++++++++++++++++++++------ src/qemu/qemu_migration.h | 1 + src/qemu/qemu_migration_params.c | 11 ++++++++++- src/qemu/qemu_migration_params.h | 3 ++- src/qemu/qemu_monitor.c | 7 +++++-- src/qemu/qemu_monitor.h | 3 ++- src/qemu/qemu_saveimage.c | 2 +- 8 files changed, 52 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6d0f52951c..0025bad6e7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2691,7 +2691,7 @@ qemuDomainSaveInternal(virQEMUDriver *driver, xml =3D NULL; =20 mappedRam =3D data->header.features & QEMU_SAVE_FEATURE_MAPPED_RAM; - if (!(saveParams =3D qemuMigrationParamsForSave(mappedRam))) + if (!(saveParams =3D qemuMigrationParamsForSave(mappedRam, flags))) goto endjob; =20 ret =3D qemuSaveImageCreate(driver, vm, path, data, compressor, @@ -3143,7 +3143,7 @@ doCoreDump(virQEMUDriver *driver, if (!(dump_params =3D qemuMigrationParamsNew())) goto cleanup; =20 - if (qemuMigrationSrcToFile(driver, vm, &fd, compressor, + if (qemuMigrationSrcToFile(driver, vm, path, &fd, compressor, dump_params, dump_flags, VIR_ASYNC_JOB_= DUMP) < 0) goto cleanup; } @@ -5789,7 +5789,7 @@ qemuDomainRestoreInternal(virConnectPtr conn, goto cleanup; =20 mapped_ram =3D data->header.features & QEMU_SAVE_FEATURE_MAPPED_RAM; - if (!(restoreParams =3D qemuMigrationParamsForSave(mapped_ram))) + if (!(restoreParams =3D qemuMigrationParamsForSave(mapped_ram, flags))) return -1; =20 fd =3D qemuSaveImageOpen(driver, path, @@ -6115,7 +6115,8 @@ qemuDomainObjRestore(virConnectPtr conn, } =20 mapped_ram =3D data->header.features & QEMU_SAVE_FEATURE_MAPPED_RAM; - if (!(restoreParams =3D qemuMigrationParamsForSave(mapped_ram))) + if (!(restoreParams =3D qemuMigrationParamsForSave(mapped_ram, + bypass_cache ? VIR_DO= MAIN_SAVE_BYPASS_CACHE : 0))) return -1; =20 fd =3D qemuSaveImageOpen(driver, path, bypass_cache, mapped_ram, &wrap= perFd, false); diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 35d3e26908..daa42bcfe4 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -7012,17 +7012,36 @@ qemuMigrationSrcToLegacyFile(virQEMUDriver *driver, static int qemuMigrationSrcToMappedFile(virQEMUDriver *driver, virDomainObj *vm, + const char *path, int *fd, unsigned int flags, virDomainAsyncJob asyncJob) { + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + VIR_AUTOCLOSE directFd =3D -1; + int directFlag =3D 0; + bool needUnlink =3D false; int ret; =20 - /* mapped-ram does not support directIO */ + /* When using directio with mapped-ram, qemu needs two fds. One with + * O_DIRECT set writing the memory, and another without it set for + * writing small bits of unaligned state. */ if ((flags & VIR_DOMAIN_SAVE_BYPASS_CACHE)) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("bypass cache unsupported by this system")); - return -1; + directFlag =3D virFileDirectFdFlag(); + if (directFlag < 0) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("bypass cache unsupported by this system")); + return -1; + } + directFd =3D virQEMUFileOpenAs(cfg->user, cfg->group, false, path, + O_WRONLY | directFlag, &needUnlink); + + if (directFd < 0) + return -1; + + if (qemuSecuritySetImageFDLabel(driver->securityManager, vm->def, = directFd) < 0) + return -1; + } =20 if (qemuSecuritySetImageFDLabel(driver->securityManager, vm->def, *fd)= < 0) @@ -7031,7 +7050,7 @@ qemuMigrationSrcToMappedFile(virQEMUDriver *driver, if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0) return -1; =20 - ret =3D qemuMonitorMigrateToFdSet(vm, 0, fd); + ret =3D qemuMonitorMigrateToFdSet(vm, 0, fd, &directFd); qemuDomainObjExitMonitor(vm); return ret; } @@ -7040,6 +7059,7 @@ qemuMigrationSrcToMappedFile(virQEMUDriver *driver, /* Helper function called while vm is active. */ int qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm, + const char *path, int *fd, virCommand *compressor, qemuMigrationParams *migParams, @@ -7077,7 +7097,7 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDoma= inObj *vm, =20 if (migParams && qemuMigrationParamsCapEnabled(migParams, QEMU_MIGRATION_CAP_MAPPED= _RAM)) { - rc =3D qemuMigrationSrcToMappedFile(driver, vm, fd, flags, asyncJo= b); + rc =3D qemuMigrationSrcToMappedFile(driver, vm, path, fd, flags, a= syncJob); } else { rc =3D qemuMigrationSrcToLegacyFile(driver, vm, *fd, compressor, a= syncJob); } diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index 5529f2ee21..51d5b680bc 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -236,6 +236,7 @@ qemuMigrationSrcIsAllowed(virDomainObj *vm, int qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm, + const char *path, int *fd, virCommand *compressor, qemuMigrationParams *migParams, diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index 503d6165b0..8f6003005c 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -129,6 +129,7 @@ VIR_ENUM_IMPL(qemuMigrationParam, "multifd-compression", "multifd-zlib-level", "multifd-zstd-level", + "direct-io", ); =20 typedef struct _qemuMigrationParamsAlwaysOnItem qemuMigrationParamsAlwaysO= nItem; @@ -319,6 +320,9 @@ static const qemuMigrationParamInfoItem qemuMigrationPa= ramInfo[] =3D { [QEMU_MIGRATION_PARAM_MULTIFD_ZSTD_LEVEL] =3D { .type =3D QEMU_MIGRATION_PARAM_TYPE_INT, }, + [QEMU_MIGRATION_PARAM_DIRECT_IO] =3D { + .type =3D QEMU_MIGRATION_PARAM_TYPE_BOOL, + }, }; G_STATIC_ASSERT(G_N_ELEMENTS(qemuMigrationParamInfo) =3D=3D QEMU_MIGRATION= _PARAM_LAST); =20 @@ -784,7 +788,7 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr param= s, =20 =20 qemuMigrationParams * -qemuMigrationParamsForSave(bool mappedRam) +qemuMigrationParamsForSave(bool mappedRam, unsigned int flags) { g_autoptr(qemuMigrationParams) saveParams =3D NULL; =20 @@ -798,6 +802,11 @@ qemuMigrationParamsForSave(bool mappedRam) return NULL; saveParams->params[QEMU_MIGRATION_PARAM_MULTIFD_CHANNELS].value.i = =3D 1; saveParams->params[QEMU_MIGRATION_PARAM_MULTIFD_CHANNELS].set =3D = true; + + if (flags & VIR_DOMAIN_SAVE_BYPASS_CACHE) { + saveParams->params[QEMU_MIGRATION_PARAM_DIRECT_IO].value.b =3D= true; + saveParams->params[QEMU_MIGRATION_PARAM_DIRECT_IO].set =3D tru= e; + } } =20 return g_steal_pointer(&saveParams); diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_par= ams.h index fe239d9a8f..9700469b5e 100644 --- a/src/qemu/qemu_migration_params.h +++ b/src/qemu/qemu_migration_params.h @@ -65,6 +65,7 @@ typedef enum { QEMU_MIGRATION_PARAM_MULTIFD_COMPRESSION, QEMU_MIGRATION_PARAM_MULTIFD_ZLIB_LEVEL, QEMU_MIGRATION_PARAM_MULTIFD_ZSTD_LEVEL, + QEMU_MIGRATION_PARAM_DIRECT_IO, =20 QEMU_MIGRATION_PARAM_LAST } qemuMigrationParam; @@ -87,7 +88,7 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params, qemuMigrationParty party); =20 qemuMigrationParams * -qemuMigrationParamsForSave(bool mappedRam); +qemuMigrationParamsForSave(bool mappedRam, unsigned int flags); =20 int qemuMigrationParamsDump(qemuMigrationParams *migParams, diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 9a454a1d08..832ede639e 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2240,7 +2240,8 @@ qemuMonitorMigrateToFd(qemuMonitor *mon, int qemuMonitorMigrateToFdSet(virDomainObj *vm, unsigned int flags, - int *fd) + int *fd, + int *directFd) { qemuDomainObjPrivate *priv =3D vm->privateData; qemuMonitor *mon =3D priv->mon; @@ -2250,7 +2251,7 @@ qemuMonitorMigrateToFdSet(virDomainObj *vm, g_autofree char *uri =3D NULL; int ret; =20 - VIR_DEBUG("fd=3D%d flags=3D0x%x", *fd, flags); + VIR_DEBUG("fd=3D%d directFd=3D%d flags=3D0x%x", *fd, *directFd, flags); =20 QEMU_CHECK_MONITOR(mon); =20 @@ -2262,6 +2263,8 @@ qemuMonitorMigrateToFdSet(virDomainObj *vm, =20 fdPassMigrate =3D qemuFDPassNew("migrate", priv); qemuFDPassAddFD(fdPassMigrate, fd, "-buffered-fd"); + if (*directFd !=3D -1) + qemuFDPassAddFD(fdPassMigrate, directFd, "-directio-fd"); if (qemuFDPassTransferMonitor(fdPassMigrate, mon) < 0) return -1; =20 diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index ebacdf110e..63385e93f3 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -846,7 +846,8 @@ int qemuMonitorMigrateToFd(qemuMonitor *mon, =20 int qemuMonitorMigrateToFdSet(virDomainObj *vm, unsigned int flags, - int *fd); + int *fd, + int *directFd); =20 int qemuMonitorMigrateToHost(qemuMonitor *mon, unsigned int flags, diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index b99e0de1ff..8ffd26d57a 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -450,7 +450,7 @@ qemuSaveImageCreate(virQEMUDriver *driver, goto cleanup; =20 /* Perform the migration */ - if (qemuMigrationSrcToFile(driver, vm, &fd, compressor, saveParams, fl= ags, asyncJob) < 0) + if (qemuMigrationSrcToFile(driver, vm, path, &fd, compressor, savePara= ms, flags, asyncJob) < 0) goto cleanup; =20 /* Touch up file header to mark image complete. */ --=20 2.35.3 From nobody Sat Nov 23 15:03:18 2024 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=1723160846; cv=none; d=zohomail.com; s=zohoarc; b=fgNpJwPX0od3NlWkTWsbP1gvbl4H7mnh6oPzp8RIELEF8SCE8MmQRxZe0MMTtMTf0qMCkQ+oFDTY7YAOa4EzI0IpEwpPAl82CScf4pOKFGLwfSXbHhqeB2WJLIPaL900vN8G+ZiYIb60UGAAYfFPFpf5P1GPTQb8t0ViGV7yGpA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723160846; 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=R0+4msEo++xML+ardIwyVe9dbF5DOiv2xD0zPLDQBP8=; b=eoOo5mQ/kxqzNAgnaM4B+uxgsK7dg35Ea2OU8MuQ9MSOnWOM9ocrjWjFrgjfKMm7CB+KYIiMjs3WUd4pXCqsw9qPKMJLgkgo0e92gYZOoKxPhtVUEuzO2R2mvj1/zTUMSfXFOOtfsmcQSmiB82yv35dOL0NGrmBq7RBv30Q55U8= 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 1723160846748281.84616303050643; Thu, 8 Aug 2024 16:47:26 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id A5DD614BE; Thu, 8 Aug 2024 19:47:25 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 379331530; Thu, 8 Aug 2024 19:39:22 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1F01B1454; Thu, 8 Aug 2024 19:39:15 -0400 (EDT) Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 17E9E14D1 for ; Thu, 8 Aug 2024 19:38:52 -0400 (EDT) Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-428163f7635so11086995e9.2 for ; Thu, 08 Aug 2024 16:38:52 -0700 (PDT) Received: from localhost ([69.51.98.127]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d69a7319sm3748658173.40.2024.08.08.16.38.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 16:38:50 -0700 (PDT) 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,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=1723160331; x=1723765131; 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=SGuin5jrSrFYl3uHlQC/yo3tboWqnHcgRyreGMDi94I=; b=A67Na/Aubd0O+Gt4M9kcu+hAZe6uMMYtRVxU+j34QQlXcXgmsaBf+6FPaaJ11Hs4Mv dLmeujDWAHhgzrGgXWFDU8nCojqYMmwliiij2OYc2vaov5b3odT1qnpbLPSylbsF9Uh2 Mh+Qh3dCifoQXbPddRiFBU28fkNd81oy0ZwplMlGHN2GlUiDjei9rZ+JL82+tGPDBMMH vVRIavYVgklRsn03O9l+QKmJ2l2rsqpGUrZoIO9R5SQjSbNkd1Ign9qCwWq6ixrmwJTV fAkaMNzpXtYCvZiJifl5iNGb64fywKBmCIHeFXGtgNLuNBAYdQ0Wo708FVqR6FYz6T8D 5w4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723160331; x=1723765131; 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=SGuin5jrSrFYl3uHlQC/yo3tboWqnHcgRyreGMDi94I=; b=hVy0/9WC+Azkqggb9kyQQ9kkB3QfTpmSAZOk4eTQOPZHfRd+tlp+CRT4u8JonBeTgw 9wGwYef76k0cICNVBz3v/vCoSJlK/H8XzYA1DhgSGT0XOD21p7Rs5dD0Dxx7Qw4aCk8f yzoEPQalYVbZsJQCej7NMtd3KdNUvwd0MNlKH6jSxleJl7tbZtMmaH6qhHOEcQvcJTsR orUt2HWw2joTr0RLh4nxsJDje4SZjaLGrEX27feMoANYyLppEyzdBr6ou8mkbar8Qzd+ K+iAC6uxT5KEI6QZiyjFysf5E0/2pTVNJQ0ZmKXrQMIx54a6L6gCEnQ9YZ6SNwFLRCzc OR0g== X-Gm-Message-State: AOJu0Yxl2RHGeUwzo2U9YRsLRsvWf8AZsZIc54e22ny8VCL0xGcF/iUH cbxfPOEXNenNs4ZVocVbZAGhBjarlm+YUzw2zbvp7CUPIP90hXuse8q+YIG8UmJcu7Nf8HvRE3z A X-Google-Smtp-Source: AGHT+IGfxGnyjjsFlIZtyCMS77lCgcyCotFhn5zVn0QHzgTq4CdM3fYebL2Fx8hdm4Tu24nKR8+Htg== X-Received: by 2002:a5d:4f8f:0:b0:368:3f74:f7dd with SMTP id ffacd0b85a97d-36d274db2c7mr2515718f8f.20.1723160330857; Thu, 08 Aug 2024 16:38:50 -0700 (PDT) To: devel@lists.libvirt.org Subject: [PATCH 16/20] qemu: Support O_DIRECT with mapped-ram on restore Date: Thu, 8 Aug 2024 17:38:09 -0600 Message-Id: <20240808233813.22905-17-jfehlig@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240808233813.22905-1-jfehlig@suse.com> References: <20240808233813.22905-1-jfehlig@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: RM3BWKAWXU35RMJBK4E3F6EN65UPAXBG X-Message-ID-Hash: RM3BWKAWXU35RMJBK4E3F6EN65UPAXBG 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 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: 1723160848386116600 Content-Type: text/plain; charset="utf-8" When using the mapped-ram migration capability, direct IO is enabled by setting the "direct-io" migration parameter to "true" and passing QEMU an additional fd with O_DIRECT set. Signed-off-by: Jim Fehlig --- src/qemu/qemu_migration.c | 11 ++++++----- src/qemu/qemu_process.c | 30 ++++++++++++++++++++++++++---- src/qemu/qemu_process.h | 6 ++++-- 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index daa42bcfe4..56199c616b 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2948,7 +2948,8 @@ qemuMigrationDstPrepareCleanup(virQEMUDriver *driver, } =20 static qemuProcessIncomingDef * -qemuMigrationDstPrepare(virDomainObj *vm, +qemuMigrationDstPrepare(virQEMUDriver *driver, + virDomainObj *vm, bool tunnel, const char *protocol, const char *listenAddress, @@ -3008,8 +3009,8 @@ qemuMigrationDstPrepare(virDomainObj *vm, migrateFrom =3D g_strdup_printf(incFormat, protocol, listenAddress= , port); } =20 - return qemuProcessIncomingDefNew(vm, listenAddress, - migrateFrom, fd, NULL, NULL); + return qemuProcessIncomingDefNew(driver, vm, listenAddress, + migrateFrom, fd, NULL, NULL, NULL); } =20 =20 @@ -3151,7 +3152,7 @@ qemuMigrationDstPrepareActive(virQEMUDriver *driver, goto error; stopProcess =3D true; =20 - if (!(incoming =3D qemuMigrationDstPrepare(vm, tunnel, protocol, + if (!(incoming =3D qemuMigrationDstPrepare(driver, vm, tunnel, protoco= l, listenAddress, port, &dataFD[0]))) goto error; @@ -3522,7 +3523,7 @@ qemuMigrationDstPrepareResume(virQEMUDriver *driver, =20 priv->origname =3D g_strdup(origname); =20 - if (!(incoming =3D qemuMigrationDstPrepare(vm, false, protocol, + if (!(incoming =3D qemuMigrationDstPrepare(driver, vm, false, protocol, listenAddress, port, NULL))) goto cleanup; =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b02cd84aff..e10894d0f9 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4694,13 +4694,16 @@ qemuProcessIncomingDefFree(qemuProcessIncomingDef *= inc) * qemuProcessIncomingDefFree will NOT close it. */ qemuProcessIncomingDef * -qemuProcessIncomingDefNew(virDomainObj *vm, +qemuProcessIncomingDefNew(virQEMUDriver *driver, + virDomainObj *vm, const char *listenAddress, const char *migrateFrom, int *fd, const char *path, - virQEMUSaveData *data) + virQEMUSaveData *data, + qemuMigrationParams *migParams) { + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); qemuDomainObjPrivate *priv =3D vm->privateData; qemuProcessIncomingDef *inc =3D NULL; =20 @@ -4715,10 +4718,28 @@ qemuProcessIncomingDefNew(virDomainObj *vm, size_t offset =3D sizeof(virQEMUSaveHeader) + data->header.data_le= n; =20 if (data->header.features & QEMU_SAVE_FEATURE_MAPPED_RAM) { + bool directio =3D false; unsigned int fdsetId; =20 inc->fdPassMigrate =3D qemuFDPassNew("migrate", priv); - qemuFDPassAddFD(inc->fdPassMigrate, fd, "-buffered-fd"); + /* When using directio with mapped-ram, qemu needs an fd witho= ut + * O_DIRECT set for reading small bits of unaligned state. */ + if (qemuMigrationParamsGetBool(migParams, + QEMU_MIGRATION_PARAM_DIRECT_IO, + &directio) < 0) + goto error; + + if (directio) { + VIR_AUTOCLOSE bufferedFd =3D -1; + + if ((bufferedFd =3D qemuDomainOpenFile(cfg, NULL, path, O_= RDONLY, NULL)) < 0) + goto error; + + qemuFDPassAddFD(inc->fdPassMigrate, &bufferedFd, "-buffere= d-fd"); + qemuFDPassAddFD(inc->fdPassMigrate, fd, "-directio-fd"); + } else { + qemuFDPassAddFD(inc->fdPassMigrate, fd, "-buffered-fd"); + } qemuFDPassGetId(inc->fdPassMigrate, &fdsetId); inc->uri =3D g_strdup_printf("file:/dev/fdset/%u,offset=3D%#lx= ", fdsetId, offset); } else { @@ -8377,7 +8398,8 @@ qemuProcessStartWithMemoryState(virConnectPtr conn, int rc =3D 0; int ret =3D -1; =20 - incoming =3D qemuProcessIncomingDefNew(vm, NULL, "stdio", fd, path, da= ta); + incoming =3D qemuProcessIncomingDefNew(driver, vm, NULL, "stdio", + fd, path, data, migParams); if (!incoming) return -1; =20 diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 93699da8bd..0e6aedf75d 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -58,12 +58,14 @@ struct _qemuProcessIncomingDef { const char *path; /* path associated with fd */ }; =20 -qemuProcessIncomingDef *qemuProcessIncomingDefNew(virDomainObj *vm, +qemuProcessIncomingDef *qemuProcessIncomingDefNew(virQEMUDriver *driver, + virDomainObj *vm, const char *listenAddres= s, const char *migrateFrom, int *fd, const char *path, - virQEMUSaveData *data); + virQEMUSaveData *data, + qemuMigrationParams *mig= Params); =20 void qemuProcessIncomingDefFree(qemuProcessIncomingDef *inc); =20 --=20 2.35.3 From nobody Sat Nov 23 15:03:18 2024 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=1723160879; cv=none; d=zohomail.com; s=zohoarc; b=nDjK65v1nvVLY44Tq8fZTcZxLDtO0OTvDuxwSpIqAKpE0vU/h11Q0IVRQuTAwW5wuW9i9I7JEFBnhDlwY3Q05E06+Vs3gplxjR741CwojSwC20x+S6B741QQ3LjnUANb0JJDKcouL3pPZc7vnR4fAaQSTzcbIuiSGso4VspGY7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723160879; 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=GUAJqWJHcb8RTjqH/VbT1h9/95GdQy01x/35e1eGOts=; b=AEnq1xZTjSR8V8Fap+1aX0Qik49YmPLOvxNvch9GIOzJchGjE1MPZaqVG+sV6LoCePUB82GZA3vG66zaUC0WUQ5MPxbrSD7N5XgpAVovBhNy6MRJPSf39vOz5Kc36yDS8UQNXL4vZxbSpkqH2OparB5z1mtRkf6NYBegRQ0lBNA= 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 1723160879129664.9291595309813; Thu, 8 Aug 2024 16:47:59 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 10C6914C5; Thu, 8 Aug 2024 19:47:58 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 7F3931428; Thu, 8 Aug 2024 19:39:25 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D10BA14B5; Thu, 8 Aug 2024 19:39:20 -0400 (EDT) Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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 4933D145C for ; Thu, 8 Aug 2024 19:38:54 -0400 (EDT) Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2ef1c12ae23so14724121fa.0 for ; Thu, 08 Aug 2024 16:38:54 -0700 (PDT) Received: from localhost ([69.51.98.127]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4ca6be646b5sm74717173.146.2024.08.08.16.38.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 16:38:52 -0700 (PDT) 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,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=1723160333; x=1723765133; 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=J1ySj5eOlzAYsT0uO6m7DkpPF81TpXINE7puuNkCK0U=; b=UmYUhOTO3vSMSzF52VxBJR9Ff6+shLyRYWSuD28rota4uVkhccgE7hUSLusFrSvrzr MtSkhrW+QuBAho9ByEngzPT9pD9cvYrE7+IyF27M05wsKXgSt6hqJta2B4q9i82mIOO6 PZbbePKELIIXXqnUX/jO8gTBUlmJvVrObPm2li6FpAmrVXhk4wbFsIka864qm2Xvnv7o bAWsQzAHG5BGQKFb8nl3H16V5MRtBbZcYQcXv9KtgkJ81Ju/fSOe+FTY0yJYSVVQ6MaY jHJakv5hWFKqu3sM0/jPfA4Fqj+fRehJZDGfjt68Q6pEo27pCmBMikgLb1d6Uh3XmRVm MRIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723160333; x=1723765133; 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=J1ySj5eOlzAYsT0uO6m7DkpPF81TpXINE7puuNkCK0U=; b=ecEj4DbRZOO+d/KJXvIyc4c6l3UlmEJSd1CkeuJCkMrwcAlTWcNTXLndI3FcgdKk2F VHFuE8vWYNa2dwAr13XxFdmxStCiEwcpurTHsFfWZxQCQ0j7pCjzjciAspY/i85TptdW deX0WCgonSLJ1SiqCQkrp5ij6y1SbWnTqo3gkCTkekl0jkePE8mTom5KMwuNmtBeZJS6 ao1797W9JUR2AwVoGla6LFA1i2y0/vYqjJsIoFw0+5sADJcgQde0zlcRGEW2fQ4roS3A bsXtNrQougHHbghNG8DHNs5SXF3j0Wr2/asDJ/XjeFjLpZLdTSKWiWC13a9NpyhVDfyZ SfRA== X-Gm-Message-State: AOJu0YzissOuPG6YS8+wQMMdAH7YqAsAIajqOD4RlzJsCk74tndmyjdB YXdj0+Isc3tDkK5WYUfw4RFJIBadOYabcpDJ3Hm09pQaORwbFSVHIdKBhfW0BznL+v+ngUAF4Vb l X-Google-Smtp-Source: AGHT+IFZ9Sy319CjhI45/V5IZKkOlNhH8U2rJ88uswsymdU6IatcsKesj+kb+i06BUYRJNfWCzBv3g== X-Received: by 2002:a2e:9e4f:0:b0:2f0:29e4:dc52 with SMTP id 38308e7fff4ca-2f19de48a8fmr22169031fa.27.1723160332807; Thu, 08 Aug 2024 16:38:52 -0700 (PDT) To: devel@lists.libvirt.org Subject: [PATCH 17/20] include: Define constants for parallel save/restore Date: Thu, 8 Aug 2024 17:38:10 -0600 Message-Id: <20240808233813.22905-18-jfehlig@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240808233813.22905-1-jfehlig@suse.com> References: <20240808233813.22905-1-jfehlig@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: J6RIILVTTWRUQCMGNBKVFK5BMT2Y6ONR X-Message-ID-Hash: J6RIILVTTWRUQCMGNBKVFK5BMT2Y6ONR 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: 1723160880474116600 Content-Type: text/plain; charset="utf-8" From: Claudio Fontana Add a new VIR_DOMAIN_SAVE_PARALLEL flag to the save and restore APIs, which can be used to specify the use of multiple, parallel channels for saving a domain. The number of parallel channels can be set using the VIR_DOMAIN_SAVE_PARAM_PARALLEL_CONNECTIONS typed parameter. Signed-off-by: Claudio Fontana Signed-off-by: Jim Fehlig --- include/libvirt/libvirt-domain.h | 13 +++++++++++++ src/libvirt-domain.c | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 4266237abe..f4bf9c3cdb 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -1596,6 +1596,7 @@ typedef enum { VIR_DOMAIN_SAVE_RUNNING =3D 1 << 1, /* Favor running over paused = (Since: 0.9.5) */ VIR_DOMAIN_SAVE_PAUSED =3D 1 << 2, /* Favor paused over running = (Since: 0.9.5) */ VIR_DOMAIN_SAVE_RESET_NVRAM =3D 1 << 3, /* Re-initialize NVRAM from t= emplate (Since: 8.1.0) */ + VIR_DOMAIN_SAVE_PARALLEL =3D 1 << 4, /* Save and restore using par= allel channels (Since: 10.6.0) */ } virDomainSaveRestoreFlags; =20 int virDomainSave (virDomainPtr domain, @@ -1641,6 +1642,18 @@ int virDomainRestoreParams (vir= ConnectPtr conn, */ # define VIR_DOMAIN_SAVE_PARAM_DXML "dxml" =20 +/** + * VIR_DOMAIN_SAVE_PARAM_PARALLEL_CONNECTIONS: + * + * this optional parameter mirrors the migration parameter + * VIR_MIGRATE_PARAM_PARALLEL_CONNECTIONS. + * + * It specifies the number of extra connections to use when transfering st= ate. + * + * Since: 10.6.0 + */ +# define VIR_DOMAIN_SAVE_PARAM_PARALLEL_CONNECTIONS "parallel.connecti= ons" + /* See below for virDomainSaveImageXMLFlags */ char * virDomainSaveImageGetXMLDesc (virConnectPtr conn, const char *file, diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 5aedae1b49..32508a4ede 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -1010,6 +1010,9 @@ virDomainSaveFlags(virDomainPtr domain, const char *t= o, * If VIR_DOMAIN_SAVE_PARAM_FILE is not provided then a managed save is * performed (see virDomainManagedSave). * + * See VIR_DOMAIN_SAVE_PARAM_* for detailed description of accepted save + * parameters. + * * Returns 0 in case of success and -1 in case of failure. * * Since: 8.4.0 @@ -1222,6 +1225,9 @@ virDomainRestoreFlags(virConnectPtr conn, const char = *from, const char *dxml, * now, VIR_DOMAIN_SAVE_PARAM_FILE is required but this requirement may * be lifted in the future. * + * See VIR_DOMAIN_SAVE_PARAM_* for detailed description of accepted + * restore parameters. + * * Returns 0 in case of success and -1 in case of failure. * * Since: 8.4.0 --=20 2.35.3 From nobody Sat Nov 23 15:03:18 2024 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=1723160908; cv=none; d=zohomail.com; s=zohoarc; b=JGJCvkm8S31gWLxRdlbkA+N99gVX022HsXE7FxGr6Mskh/3QbfbPbULj1/tFLp9uW2iKyvcf8r4mOMu0u+szM36stuOPkhxKtuD2p+bxAL3lu1NfYRdPO0GHvaxA91Cv+bSbS9S+L3ILzomXd0wbpPq/XCAdR07TDtjbalyctFw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723160908; 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=ve28TD90MLs4XnmBOSyWxRJ+a2pzUhnAGf4AUE+mLpM=; b=Av/m37z0fOaABcqJachtEOFeUKlnQIPFVkVRU85W1oWz6iYAAplMJSqtk9z0N+rrvhxDnNUQp25+6MFxAdcjcjkC2bVzs64RPahQp4pvSJ8AXoHMg+fRItCsy+vXOgviHhaGBR5PrujVE5txQC5aalnCn1w5DjjhPHivkrGWFV8= 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 1723160908709286.4495535592721; Thu, 8 Aug 2024 16:48:28 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 8612414F0; Thu, 8 Aug 2024 19:48:27 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 87CEA12EB; Thu, 8 Aug 2024 19:39:28 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 063B4146D; Thu, 8 Aug 2024 19:39:24 -0400 (EDT) Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.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 E9C7F1464 for ; Thu, 8 Aug 2024 19:38:55 -0400 (EDT) Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-368313809a4so1510702f8f.0 for ; Thu, 08 Aug 2024 16:38:55 -0700 (PDT) Received: from localhost ([69.51.98.127]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d69c4a86sm3702720173.76.2024.08.08.16.38.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 16:38:54 -0700 (PDT) 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,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=1723160335; x=1723765135; 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=7cKjANcb5c3TpSitae52WIPQcsI6UBqjfMy9Z4mdk6k=; b=TMep4jjZs41EvS+RhSdlB5yKDChvvvUHRhy0AirOvG66sQ9oOEhR0qtR9we1S1jlAp 3t/zfozx29pb0zwtdyfj0YnskQX43BN6tptE5JjIdZNmqnw8dJqs+yN7Gui0W7EHCyF4 bvXaUHfw+SVJGDFdOYyDgr/Dg3pJcclJL2ZBwBHndGfVeYDsrMf9AvgLvVsepFq8HKfi PoKQcLpyyKMLywUAidPqdfYhlAopCIa8+TcZ2emtDi1eg4hRWEgoGgUrYqcptdg7GMrG gZkuTtmH7C8lXIsIoaMgq69emnTTBK9y/wy4Lxr0Hvt5qj26opSABPmGhnUgEm/a500A jfsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723160335; x=1723765135; 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=7cKjANcb5c3TpSitae52WIPQcsI6UBqjfMy9Z4mdk6k=; b=LqKDSkXA2qrQoRvn4jwc8a4oQFI4GdJyXGdxgh3D7gw3K2h3VICy+aaqyqUbhdTO8m VU00LDQKATvHHlZctuFgc0JvuW2pV70yX+eaSyhd/wdTDlxRF5uoexb3MjkawRwxUgEz ecDaKvun9sAcATM4JV7vaV8CxFikw9ibhYRz+F7HUmJH450dkTnUwUsu0buii4OUJ21p jjJTK3g772ZvuzP+KncCJ5NbL2J64i7kzfakbB4J19OYf7TYjkimFTSngL1gYD18XGUD g9MH34GqvbjFGmZOILaum7rnVFurQ4/7bZXkuGYFqIL9muVcBkL+wTIoetVdB2Ccf8eQ /kkA== X-Gm-Message-State: AOJu0Yzcw/Md8WIdiU8Ufkx9QLghXd8dWKDaCgdfRHgCZV9dJHaQvUra TBwnw8iQrfwBaMSL/0ApIeEFPYj7yimI7eRTUeuORgjhTKSBOY8Xjq0xXat4QBgVDWnByvqE5V3 x X-Google-Smtp-Source: AGHT+IHPys8D/bGzjTHQpQBevN3AhsCtGWEeyDN2QexTDIWXR0nTBk5X4DfqIWPQYpjv7w/T+bmbRw== X-Received: by 2002:adf:cd8a:0:b0:36b:a5ac:7a with SMTP id ffacd0b85a97d-36d280ef138mr2673149f8f.7.1723160334843; Thu, 08 Aug 2024 16:38:54 -0700 (PDT) To: devel@lists.libvirt.org Subject: [PATCH 18/20] qemu: Add support for parallel save and restore Date: Thu, 8 Aug 2024 17:38:11 -0600 Message-Id: <20240808233813.22905-19-jfehlig@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240808233813.22905-1-jfehlig@suse.com> References: <20240808233813.22905-1-jfehlig@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: Z7TW2EKQY2HXTUNV2OHEEGLN75XHLIZW X-Message-ID-Hash: Z7TW2EKQY2HXTUNV2OHEEGLN75XHLIZW 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 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: 1723160910606116600 Content-Type: text/plain; charset="utf-8" Add support for parallel save and restore by mapping libvirt's "parallel-connections" parameter to QEMU's "multifd-channels" migration parameter. Signed-off-by: Jim Fehlig --- src/qemu/qemu_driver.c | 31 ++++++++++++++++++++----------- src/qemu/qemu_migration_params.c | 25 +++++++++++++++++++++++-- src/qemu/qemu_migration_params.h | 5 ++++- 3 files changed, 47 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0025bad6e7..fce599b321 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2608,6 +2608,8 @@ qemuDomainSaveInternal(virQEMUDriver *driver, int compressed, virCommand *compressor, const char *xmlin, + virTypedParameterPtr params, + int nparams, unsigned int flags) { g_autofree char *xml =3D NULL; @@ -2691,7 +2693,7 @@ qemuDomainSaveInternal(virQEMUDriver *driver, xml =3D NULL; =20 mappedRam =3D data->header.features & QEMU_SAVE_FEATURE_MAPPED_RAM; - if (!(saveParams =3D qemuMigrationParamsForSave(mappedRam, flags))) + if (!(saveParams =3D qemuMigrationParamsForSave(params, nparams, mappe= dRam, flags))) goto endjob; =20 ret =3D qemuSaveImageCreate(driver, vm, path, data, compressor, @@ -2777,7 +2779,7 @@ qemuDomainManagedSaveHelper(virQEMUDriver *driver, VIR_INFO("Saving state of domain '%s' to '%s'", vm->def->name, path); =20 if (qemuDomainSaveInternal(driver, vm, path, compressed, - compressor, dxml, flags) < 0) + compressor, dxml, NULL, 0, flags) < 0) return -1; =20 vm->hasManagedSave =3D true; @@ -2816,7 +2818,7 @@ qemuDomainSaveFlags(virDomainPtr dom, const char *pat= h, const char *dxml, goto cleanup; =20 ret =3D qemuDomainSaveInternal(driver, vm, path, compressed, - compressor, dxml, flags); + compressor, dxml, NULL, 0, flags); =20 cleanup: virDomainObjEndAPI(&vm); @@ -2846,13 +2848,16 @@ qemuDomainSaveParams(virDomainPtr dom, =20 virCheckFlags(VIR_DOMAIN_SAVE_BYPASS_CACHE | VIR_DOMAIN_SAVE_RUNNING | - VIR_DOMAIN_SAVE_PAUSED, -1); + VIR_DOMAIN_SAVE_PAUSED | + VIR_DOMAIN_SAVE_PARALLEL, -1); =20 if (virTypedParamsValidate(params, nparams, VIR_DOMAIN_SAVE_PARAM_FILE, VIR_TYPED_PARAM_STRING, VIR_DOMAIN_SAVE_PARAM_DXML, VIR_TYPED_PARAM_STRING, + VIR_DOMAIN_SAVE_PARAM_PARALLEL_CONNECTIONS, + VIR_TYPED_PARAM_INT, NULL) < 0) return -1; =20 @@ -2884,7 +2889,7 @@ qemuDomainSaveParams(virDomainPtr dom, goto cleanup; =20 ret =3D qemuDomainSaveInternal(driver, vm, to, compressed, - compressor, dxml, flags); + compressor, dxml, params, nparams, flags); =20 cleanup: virDomainObjEndAPI(&vm); @@ -5759,6 +5764,8 @@ static int qemuDomainRestoreInternal(virConnectPtr conn, const char *path, const char *dxml, + virTypedParameterPtr params, + int nparams, unsigned int flags, int (*ensureACL)(virConnectPtr, virDomainDef *)) { @@ -5780,7 +5787,8 @@ qemuDomainRestoreInternal(virConnectPtr conn, virCheckFlags(VIR_DOMAIN_SAVE_BYPASS_CACHE | VIR_DOMAIN_SAVE_RUNNING | VIR_DOMAIN_SAVE_PAUSED | - VIR_DOMAIN_SAVE_RESET_NVRAM, -1); + VIR_DOMAIN_SAVE_RESET_NVRAM | + VIR_DOMAIN_SAVE_PARALLEL, -1); =20 if (flags & VIR_DOMAIN_SAVE_RESET_NVRAM) reset_nvram =3D true; @@ -5789,7 +5797,7 @@ qemuDomainRestoreInternal(virConnectPtr conn, goto cleanup; =20 mapped_ram =3D data->header.features & QEMU_SAVE_FEATURE_MAPPED_RAM; - if (!(restoreParams =3D qemuMigrationParamsForSave(mapped_ram, flags))) + if (!(restoreParams =3D qemuMigrationParamsForSave(params, nparams, ma= pped_ram, flags))) return -1; =20 fd =3D qemuSaveImageOpen(driver, path, @@ -5871,7 +5879,7 @@ qemuDomainRestoreFlags(virConnectPtr conn, const char *dxml, unsigned int flags) { - return qemuDomainRestoreInternal(conn, path, dxml, flags, + return qemuDomainRestoreInternal(conn, path, dxml, NULL, 0, flags, virDomainRestoreFlagsEnsureACL); } =20 @@ -5879,7 +5887,7 @@ static int qemuDomainRestore(virConnectPtr conn, const char *path) { - return qemuDomainRestoreInternal(conn, path, NULL, 0, + return qemuDomainRestoreInternal(conn, path, NULL, NULL, 0, 0, virDomainRestoreEnsureACL); } =20 @@ -5895,6 +5903,7 @@ qemuDomainRestoreParams(virConnectPtr conn, if (virTypedParamsValidate(params, nparams, VIR_DOMAIN_SAVE_PARAM_FILE, VIR_TYPED_PARAM= _STRING, VIR_DOMAIN_SAVE_PARAM_DXML, VIR_TYPED_PARAM= _STRING, + VIR_DOMAIN_SAVE_PARAM_PARALLEL_CONNECTIONS,= VIR_TYPED_PARAM_INT, NULL) < 0) return -1; =20 @@ -5911,7 +5920,7 @@ qemuDomainRestoreParams(virConnectPtr conn, return -1; } =20 - ret =3D qemuDomainRestoreInternal(conn, path, dxml, flags, + ret =3D qemuDomainRestoreInternal(conn, path, dxml, params, nparams, f= lags, virDomainRestoreParamsEnsureACL); return ret; } @@ -6115,7 +6124,7 @@ qemuDomainObjRestore(virConnectPtr conn, } =20 mapped_ram =3D data->header.features & QEMU_SAVE_FEATURE_MAPPED_RAM; - if (!(restoreParams =3D qemuMigrationParamsForSave(mapped_ram, + if (!(restoreParams =3D qemuMigrationParamsForSave(NULL, 0, mapped_ram, bypass_cache ? VIR_DO= MAIN_SAVE_BYPASS_CACHE : 0))) return -1; =20 diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index 8f6003005c..8c656af163 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -788,7 +788,10 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr para= ms, =20 =20 qemuMigrationParams * -qemuMigrationParamsForSave(bool mappedRam, unsigned int flags) +qemuMigrationParamsForSave(virTypedParameterPtr params, + int nparams, + bool mappedRam, + unsigned int flags) { g_autoptr(qemuMigrationParams) saveParams =3D NULL; =20 @@ -800,7 +803,25 @@ qemuMigrationParamsForSave(bool mappedRam, unsigned in= t flags) return NULL; if (virBitmapSetBit(saveParams->caps, QEMU_MIGRATION_CAP_MULTIFD) = < 0) return NULL; - saveParams->params[QEMU_MIGRATION_PARAM_MULTIFD_CHANNELS].value.i = =3D 1; + + if (flags & VIR_DOMAIN_SAVE_PARALLEL) { + int nchannels; + + if (params && virTypedParamsGetInt(params, nparams, + VIR_DOMAIN_SAVE_PARAM_PARAL= LEL_CONNECTIONS, + &nchannels) < 0) + return NULL; + + if (nchannels < 1) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("number of parallel save channels cannot = be less than 1")); + return NULL; + } + + saveParams->params[QEMU_MIGRATION_PARAM_MULTIFD_CHANNELS].valu= e.i =3D nchannels; + } else { + saveParams->params[QEMU_MIGRATION_PARAM_MULTIFD_CHANNELS].valu= e.i =3D 1; + } saveParams->params[QEMU_MIGRATION_PARAM_MULTIFD_CHANNELS].set =3D = true; =20 if (flags & VIR_DOMAIN_SAVE_BYPASS_CACHE) { diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_par= ams.h index 9700469b5e..a672b3d875 100644 --- a/src/qemu/qemu_migration_params.h +++ b/src/qemu/qemu_migration_params.h @@ -88,7 +88,10 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params, qemuMigrationParty party); =20 qemuMigrationParams * -qemuMigrationParamsForSave(bool mappedRam, unsigned int flags); +qemuMigrationParamsForSave(virTypedParameterPtr params, + int nparams, + bool mappedRam, + unsigned int flags); =20 int qemuMigrationParamsDump(qemuMigrationParams *migParams, --=20 2.35.3 From nobody Sat Nov 23 15:03:18 2024 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=1723160929; cv=none; d=zohomail.com; s=zohoarc; b=KuSofjKMRMvyGANEsv3+yj/oFgZPf6u+L1YvkLAnzp3z8vHigygRzpbdfpIzHV9EYbqqnwqMFSM/LzMC/5UncwkSA5ubyRZMHCYd4g58H3iNfmdDDFgq2L7f0pO+NyFEdplLepKxWZuSEs56SSdl0abxQpqbavAN/xlHuiliwEg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723160929; 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=evtjX67EeddoP813DCdsqr3NnI8jpYp/AgCotAcq4Ys=; b=UeoMTdeLtLtj+DSRol6xt/Uizus3CL642s9N5vG0AFQI+cNLn9CeaKronILUYMqzEAK0da6/yDxzgkW4NiDqqSuJphm7/8gSG4ClnEmSEGFcbdVziFbr+3RRCtaNRbCflGRXdIq/Kuf51ZTKJlkDeTknGVf/jE8Rbjp8sSUAcj0= 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 1723160929236901.4226112986992; Thu, 8 Aug 2024 16:48:49 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 230E1147F; Thu, 8 Aug 2024 19:48:48 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 5C96E151C; Thu, 8 Aug 2024 19:39:31 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B3485137E; Thu, 8 Aug 2024 19:39:25 -0400 (EDT) Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (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 584461473 for ; Thu, 8 Aug 2024 19:38:58 -0400 (EDT) Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2ef27bfd15bso16071961fa.2 for ; Thu, 08 Aug 2024 16:38:58 -0700 (PDT) Received: from localhost ([69.51.98.127]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d69a7e2dsm3748490173.53.2024.08.08.16.38.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 16:38:56 -0700 (PDT) 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,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=1723160337; x=1723765137; 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=xpZXoDAxpngSu0KRBFGd+2Ezqi/Yy7j/LnIGwXRHiB4=; b=TqVnyjYpXJBlNXR+ZewxqcQTq78vVmgjSpt8talZ1Mjtm142a62nLUGtgsbsAwu1Lg dKpI28BckR6uz/T1x1okwwIguq/9lBE/ReY8IazwjfiNveuhiPLk7/FUeOAPCTPqiiyY j9qP13NovZJRpEZ+3V3pAKfFsovbRxg3PMDgCs+RgA6+m7R6sxChGa+jcRchQ0yriREO OmTcMVSec9Jr2DjZ2zomyN34IvXHVqM4lkEZP597yD0oIw5xeRCLq5njDh8U2gmzXM7f KEfsgaaPIZWZDEP9DwvXhbxfM5Iy2M7MA+X9geA/pESGE4WeLSF2Uw2yWpedOMNH7Zi7 jOxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723160337; x=1723765137; 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=xpZXoDAxpngSu0KRBFGd+2Ezqi/Yy7j/LnIGwXRHiB4=; b=t00YBJOVJYX31rPEJMfd97pQPSNDqI/IrX+n8+8dYiFGCSMboAq1+ubZhGG0wQqgpE bFQTxfCBmgm58ldTCCTAvrgRj+dy5aMuAxqNVs+UslKbvmJHsXNPXhazqaA49DLJebtm sR6RNimiqUQcElyk6U180nXgIgsJ6YX9ArD9M1Cz/faRE6HIMB0CrNQdVw4q5YzczZnp fAXnqd/syGDNjf0QVaVIXAyg7/j9Pt0dnOux6Q40gbNMiSd/wLcU6Q/LP83nN5W4uSIV FFzGGQ2/Fu3CetWmOHDfXHi47JWmFvsHgUh0gjB1qrHbYk0JdwGU6kGykz68eTvQ6FCq W1zA== X-Gm-Message-State: AOJu0YwCqDpWKpvqtcra5TOYMLA0Eid9vWZ1WixlyndOQOtLoiYl9cN/ onwk0F+1XNYgDLroZhqazjzWxqgNux+ij2D1SDaoNJKpbznW+nrbfjug8PApSHm9b5dHBD+/7cW I X-Google-Smtp-Source: AGHT+IEOHn5kIkNTwcFylPd6o5AdAStuNqV6qXx9PKgoVOXpFoANm+XkC9KtSsU8PsuIXDF1dbTI2Q== X-Received: by 2002:a2e:b046:0:b0:2ef:1c0f:d490 with SMTP id 38308e7fff4ca-2f19de63271mr23695061fa.39.1723160336949; Thu, 08 Aug 2024 16:38:56 -0700 (PDT) To: devel@lists.libvirt.org Subject: [PATCH 19/20] tools: add parallel parameter to virsh save command Date: Thu, 8 Aug 2024 17:38:12 -0600 Message-Id: <20240808233813.22905-20-jfehlig@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240808233813.22905-1-jfehlig@suse.com> References: <20240808233813.22905-1-jfehlig@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: NGXFZ34UIDH5UAGP4I4JQY7MRIQGCN24 X-Message-ID-Hash: NGXFZ34UIDH5UAGP4I4JQY7MRIQGCN24 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, Li Zhang , 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: 1723160930673116600 Content-Type: text/plain; charset="utf-8" From: Li Zhang Signed-off-by: Claudio Fontana Signed-off-by: Jim Fehlig --- tools/virsh-domain.c | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 50e80689a2..ec0e43ae7b 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-connections", + .type =3D VSH_OT_INT, + .help =3D N_("number of extra connections 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-connections", &nchann= els)) < 0) { + goto out; + } else if (rv > 0) { + if (virTypedParamsAddInt(¶ms, &nparams, &maxparams, + VIR_DOMAIN_SAVE_PARAM_PARALLEL_CONNECTION= S, 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.35.3 From nobody Sat Nov 23 15:03:18 2024 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=1723160960; cv=none; d=zohomail.com; s=zohoarc; b=mh4TmpjL6cyBrD3N2QcT3znHoBK30eKlHTochWgycot5LlVe3dD+z9mO1imtCUrTDmJTYfT3vCdsGnxMmXDEphbn3NrBFgJNDiXZJowV4ELti+fqW/GwltGq8mBGRkL8JT4lnRTSeP9gTfJ/tgE9ntRgz+4EUsvxYkaow361Btc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723160960; 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=p8Jv6LzaXPnaQAOPY2EmJMyuOSpeoXZl1Fv/wNF26PQ=; b=FLtYVUl20LQy1jLbLzXT8jMdwzAJpZriUyPrmWyEALbV3uYgfJuea37aHm5oJXRuud8StDkbtO/lmnseOHEM8vtZqezSRc4NGDA+byPPH3lqFN6HuKmUWgOsLBXpUqeg/BUxVm5+pRjfNuJTKicu4Ulw/KXwUdWGCQVv2LtfOVk= 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 1723160959792842.9670376376102; Thu, 8 Aug 2024 16:49:19 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B01E4146A; Thu, 8 Aug 2024 19:49:16 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 9B1DC1483; Thu, 8 Aug 2024 19:39:33 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 7AE4114F9; Thu, 8 Aug 2024 19:39:26 -0400 (EDT) Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (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 285B814FE for ; Thu, 8 Aug 2024 19:39:00 -0400 (EDT) Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-3684e8220f9so846519f8f.1 for ; Thu, 08 Aug 2024 16:39:00 -0700 (PDT) Received: from localhost ([69.51.98.127]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-81fd4d72184sm418908139f.38.2024.08.08.16.38.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 16:38:58 -0700 (PDT) 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,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=1723160339; x=1723765139; 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=gFlz5e9LowFMo7p8de01mnxKhFQ07EMfQt9MvmidvHs=; b=AIVt/jyaj4UKKKeD/l3n4XFtOWEnjjFty+V8YLRKrU3/ptS9Pv7xnZbisI2Vrga1/j K4omT1Kb5bghcOXCRoF7Ej6vfC6xj6VQwsQtA+grPhgnQ6nmZMOSRhCS27QNnQLIOCMy HQvPZ36Ts0D+2oLKrld5WLs8VD0NFMqN58NmZBtFl8fL+4eZBKv5gXQNwTSu3fLUcEQ0 DNANpSi/0LYEkPm0zwTf/c6CW4HuYecxqQKb9WF8eSh4QVYv6WRGgzDI3JWoAD38AHbY 1iDTEA563TkDfZHLO4d5a/DFnYcMGhyVduVSOY0PtAej+h9bWFtLtH1k/Mm+1vYhkF8s VsqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723160339; x=1723765139; 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=gFlz5e9LowFMo7p8de01mnxKhFQ07EMfQt9MvmidvHs=; b=W5phVuxDOqLr5hzLd6kXtt5drFvbqHydap6xtAdM832yWhPCoKwl1ZUNeGAhVU47pY eK2pAWVLtScELxNji71sMMVMlYKFvSphHTZbw7p6otwkZt+rMQVYlkn3azDXH0kHRwyX sgQdSQYTFU8Y0I9g9ZIKsWIXfBceExjHPv+IRdZnRhpvhdvXxmsfQciqiTKRTRcq6/+b t/GvoLQ0hZUrqojP04JL/OUA39MWvcFDjTf1ASVPzHfl4za2SABKGTIjAnAVmnALgm/e Iaat9BBNsHt/upOO0Fg6G5DfzY3tNIK8Lf7bcQsk1PZYBhBpmZYLT+WKY2gu9tvcRyCh agxA== X-Gm-Message-State: AOJu0Yw0EAAN28bhYEo9jH2I51XsKGyqDuMkpU64gxojLwy4dUUH9wNn VHBPCT3FKf7kRjQjZYYmbY1LZwjHvmUmANyeyc46jsjI1lAhuKdGD+nVV/BRsIdtdKyF6mKGum9 M X-Google-Smtp-Source: AGHT+IG2J+U7kikapiOcyTpY0GFujV0e/aoLZD/6aFVlr7BxGrtYdYR/ntT9QV7nM1+2uGtmHAhyNg== X-Received: by 2002:adf:e246:0:b0:368:6bb:f79e with SMTP id ffacd0b85a97d-36d280cd2bfmr2739734f8f.4.1723160339010; Thu, 08 Aug 2024 16:38:59 -0700 (PDT) To: devel@lists.libvirt.org Subject: [PATCH 20/20] tools: add parallel parameter to virsh restore command Date: Thu, 8 Aug 2024 17:38:13 -0600 Message-Id: <20240808233813.22905-21-jfehlig@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240808233813.22905-1-jfehlig@suse.com> References: <20240808233813.22905-1-jfehlig@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 3XS7GHT2F7VZEDVQDXJWHHMS5F4NODUA X-Message-ID-Hash: 3XS7GHT2F7VZEDVQDXJWHHMS5F4NODUA 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: 1723160960808116600 Content-Type: text/plain; charset="utf-8" From: Claudio Fontana Signed-off-by: Claudio Fontana Signed-off-by: Jim Fehlig --- docs/manpages/virsh.rst | 9 +++++++-- tools/virsh-domain.c | 38 ++++++++++++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index fa038e4547..2217728efd 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -3915,12 +3915,13 @@ restore :: =20 restore state-file [--bypass-cache] [--xml file] - [{--running | --paused}] [--reset-nvram] + [{--running | --paused}] [--reset-nvram] [--parallel] [--parallel-co= nnections] =20 Restores a domain from a ``virsh save`` state file. See *save* for more in= fo. =20 If *--bypass-cache* is specified, the restore 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 *--xml* ``file`` is usually omitted, but can be used to supply an alternative XML file for use on the restored guest with changes only @@ -3936,6 +3937,10 @@ domain should be started in. If *--reset-nvram* is specified, any existing NVRAM file will be deleted and re-initialized from its pristine template. =20 +*--parallel* option will cause the save data to be loaded using the number +of parallel connections specified with *--parallel-connections*. Parallel +connections will help speed up large restore operations. + ``Note``: To avoid corrupting file system contents within the domain, you should not reuse the saved state file for a second ``restore`` unless you have also reverted all storage volumes back to the same contents as when diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index ec0e43ae7b..73c04390cc 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -5265,6 +5265,14 @@ static const vshCmdOptDef opts_restore[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("avoid file system cache when restoring") }, + {.name =3D "parallel", + .type =3D VSH_OT_BOOL, + .help =3D N_("enable parallel restore") + }, + {.name =3D "parallel-connections", + .type =3D VSH_OT_INT, + .help =3D N_("number of connections to use for parallel restore") + }, {.name =3D "xml", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, @@ -5294,13 +5302,16 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd) const char *xmlfile =3D NULL; g_autofree char *xml =3D NULL; virshControl *priv =3D ctl->privData; + virTypedParameterPtr params =3D NULL; + int nparams =3D 0; + int maxparams =3D 0; + int nchannels =3D 0; int rc; =20 - if (vshCommandOptString(ctl, cmd, "file", &from) < 0) - return false; - if (vshCommandOptBool(cmd, "bypass-cache")) flags |=3D VIR_DOMAIN_SAVE_BYPASS_CACHE; + if (vshCommandOptBool(cmd, "parallel")) + flags |=3D VIR_DOMAIN_SAVE_PARALLEL; if (vshCommandOptBool(cmd, "running")) flags |=3D VIR_DOMAIN_SAVE_RUNNING; if (vshCommandOptBool(cmd, "paused")) @@ -5308,15 +5319,34 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "reset-nvram")) flags |=3D VIR_DOMAIN_SAVE_RESET_NVRAM; =20 + if (vshCommandOptString(ctl, cmd, "file", &from) < 0) + return false; + if (from && + virTypedParamsAddString(¶ms, &nparams, &maxparams, + VIR_DOMAIN_SAVE_PARAM_FILE, from) < 0) + return false; + if (vshCommandOptString(ctl, cmd, "xml", &xmlfile) < 0) return false; =20 if (xmlfile && virFileReadAll(xmlfile, VSH_MAX_XML_FILE, &xml) < 0) return false; + if (xml && + virTypedParamsAddString(¶ms, &nparams, &maxparams, + VIR_DOMAIN_SAVE_PARAM_DXML, xml) < 0) + return false; + + if ((rc =3D vshCommandOptInt(ctl, cmd, "parallel-connections", &nchann= els)) < 0) { + return false; + } else if (rc > 0) { + if (virTypedParamsAddInt(¶ms, &nparams, &maxparams, + VIR_DOMAIN_SAVE_PARAM_PARALLEL_CONNECTION= S, nchannels) < 0) + return false; + } =20 if (flags || xml) { - rc =3D virDomainRestoreFlags(priv->conn, from, xml, flags); + rc =3D virDomainRestoreParams(priv->conn, params, nparams, flags); } else { rc =3D virDomainRestore(priv->conn, from); } --=20 2.35.3