From nobody Sat Nov 23 18:14:21 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