From nobody Sun Dec 22 06:11:11 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1727092145869413.8228249162986; Mon, 23 Sep 2024 04:49:05 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id C34281485; Mon, 23 Sep 2024 07:49:04 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 4E93116C2; Mon, 23 Sep 2024 07:48:10 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 971B012F2; Mon, 23 Sep 2024 07:48:05 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 02F2E12F2 for ; Mon, 23 Sep 2024 07:48:04 -0400 (EDT) Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-278-ANTQGy1RP7WQiQ-OaMFLqg-1; Mon, 23 Sep 2024 07:48:03 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a8a8308cceaso543440166b.0 for ; Mon, 23 Sep 2024 04:48:03 -0700 (PDT) Received: from wheatley.localdomain (37-188-137-5.red.o2.cz. [37.188.137.5]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90612e5731sm1213369466b.183.2024.09.23.04.48.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2024 04:48:01 -0700 (PDT) Received: from wheatley.pinto-pinecone.ts.net (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id 7829B26732E9 for ; Mon, 23 Sep 2024 13:48:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727092084; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m1ghKEy9uYpTvCovAoaZcIIr4TFMK2dugFQyzODzn6g=; b=ERKmZ0SN/g8WMdXoS532PEpDOE4j1WtsKTv3oL/HanSaske+XjOy2GBNAlmu4GSILaJvm4 RMqMoX7sLBMUszM+jE78Q6088CmvJESYSZhkdMqze82bGvW/2fIX7nKWMZzxsCDm0LIg71 eFWvYN6hVba6Ver59WiiTj5IgS/8NsI= X-MC-Unique: ANTQGy1RP7WQiQ-OaMFLqg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727092082; x=1727696882; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m1ghKEy9uYpTvCovAoaZcIIr4TFMK2dugFQyzODzn6g=; b=tf8u9xmLvQf4jK9HHJb42U1+HhKgODJ5JCUhIDFLOrpw6GdEofmMqD0pNVXsBLduj3 ExG4NIK3fYbnXnKqd5qOUTUxabEEI668+LAZj/R+xCGlZ9kOKRTfeR5PW+fPDQGOx2dx bzqrKtbfFplzp8Gu7AAF35lfMaQns6SVveJKeCMVTWF0yw+Jb9MRwnEZ3AjeH3SvWJC7 zU+QGKD4uJwlJFaGsQ1/fYUWpqu3K8trHVsmR13B4AU5K9reX8D4gjX7eC3y29NdbKol 74wyUkKQEJAIa877yDSfUERsAY184kSbBU88FI+0UfEUvlLrv0MjwT+vTTMEuWjZWRfB ZnGg== X-Gm-Message-State: AOJu0Ywky8GUuyVn5Cn9GyXlWD6mb9mjt9fk3GrBOn3pt9f2hk2tO5jg 8fFim3Sme89hAuyxOxOm1XDpXd6k3bfTE7dqL0APQnWTed+DcPfFvrXQyxIo6NxRmb0Y/XUKgrt 26bdby0ZG7L8oBu2zinERHa2HAdDD0zkrD4TSEJDnZIWR7Fb6f6BWJ/XSwxzbgV6Cpq5R5sZv4A 8JfFTWE5heClqRYLzEjM59fcogQR4ZiY45XjT5M4A= X-Received: by 2002:a17:906:f58e:b0:a8d:481a:563a with SMTP id a640c23a62f3a-a90c1d6e848mr1591828166b.25.1727092082311; Mon, 23 Sep 2024 04:48:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEIPs1qOkWUmgSLvk096vzlZtOjOQjFJRcWi/mhSeV0WnFievZIeKWvoaAgbTMsxHLhZ7z/5A== X-Received: by 2002:a17:906:f58e:b0:a8d:481a:563a with SMTP id a640c23a62f3a-a90c1d6e848mr1591825766b.25.1727092081868; Mon, 23 Sep 2024 04:48:01 -0700 (PDT) From: Martin Kletzander To: devel@lists.libvirt.org Subject: [PATCH v2 1/8] qemu: Move domain-related functions to qemu_domain Date: Mon, 23 Sep 2024 13:47:51 +0200 Message-ID: X-Mailer: git-send-email 2.46.1 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: QHYABSHZ2URB7OBQMXZBRWS7KMBBXH7B X-Message-ID-Hash: QHYABSHZ2URB7OBQMXZBRWS7KMBBXH7B X-MailFrom: mkletzan@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1727092146297116600 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Martin Kletzander Reviewed-by: Michal Privoznik --- src/qemu/qemu_conf.c | 58 ------------------------------------------ src/qemu/qemu_conf.h | 8 ------ src/qemu/qemu_domain.c | 58 ++++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 9 +++++++ 4 files changed, 67 insertions(+), 66 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index b36bede6c3c6..0d90a8739202 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1603,64 +1603,6 @@ qemuGetDomainHupageMemPath(virQEMUDriver *driver, } =20 =20 -int -qemuGetMemoryBackingDomainPath(virQEMUDriver *driver, - const virDomainDef *def, - char **path) -{ - g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - const char *root =3D driver->embeddedRoot; - g_autofree char *shortName =3D NULL; - - if (!(shortName =3D virDomainDefGetShortName(def))) - return -1; - - if (root && !STRPREFIX(cfg->memoryBackingDir, root)) { - g_autofree char * hash =3D virDomainDriverGenerateRootHash("qemu",= root); - *path =3D g_strdup_printf("%s/%s-%s", cfg->memoryBackingDir, hash,= shortName); - } else { - *path =3D g_strdup_printf("%s/%s", cfg->memoryBackingDir, shortNam= e); - } - - return 0; -} - - -/** - * qemuGetMemoryBackingPath: - * @driver: the qemu driver - * @def: domain definition - * @alias: memory object alias - * @memPath: constructed path - * - * Constructs path to memory backing dir and stores it at @memPath. - * - * Returns: 0 on success, - * -1 otherwise (with error reported). - */ -int -qemuGetMemoryBackingPath(virQEMUDriver *driver, - const virDomainDef *def, - const char *alias, - char **memPath) -{ - g_autofree char *domainPath =3D NULL; - - if (!alias) { - /* This should never happen (TM) */ - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("memory device alias is not assigned")); - return -1; - } - - if (qemuGetMemoryBackingDomainPath(driver, def, &domainPath) < 0) - return -1; - - *memPath =3D g_strdup_printf("%s/%s", domainPath, alias); - return 0; -} - - int qemuHugepageMakeBasedir(virQEMUDriver *driver, virHugeTLBFS *hugepage) diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index aa1e1a626c1a..c98b6137c1fd 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -368,14 +368,6 @@ int qemuGetDomainHupageMemPath(virQEMUDriver *driver, unsigned long long pagesize, char **memPath); =20 -int qemuGetMemoryBackingDomainPath(virQEMUDriver *driver, - const virDomainDef *def, - char **path); -int qemuGetMemoryBackingPath(virQEMUDriver *driver, - const virDomainDef *def, - const char *alias, - char **memPath); - int qemuHugepageMakeBasedir(virQEMUDriver *driver, virHugeTLBFS *hugepage); =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ed305d9427f5..cd891fd58f52 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1735,6 +1735,64 @@ qemuDomainSecretPrepare(virQEMUDriver *driver, } =20 =20 +int +qemuGetMemoryBackingDomainPath(virQEMUDriver *driver, + const virDomainDef *def, + char **path) +{ + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + const char *root =3D driver->embeddedRoot; + g_autofree char *shortName =3D NULL; + + if (!(shortName =3D virDomainDefGetShortName(def))) + return -1; + + if (root && !STRPREFIX(cfg->memoryBackingDir, root)) { + g_autofree char * hash =3D virDomainDriverGenerateRootHash("qemu",= root); + *path =3D g_strdup_printf("%s/%s-%s", cfg->memoryBackingDir, hash,= shortName); + } else { + *path =3D g_strdup_printf("%s/%s", cfg->memoryBackingDir, shortNam= e); + } + + return 0; +} + + +/** + * qemuGetMemoryBackingPath: + * @driver: the qemu driver + * @def: domain definition + * @alias: memory object alias + * @memPath: constructed path + * + * Constructs path to memory backing dir and stores it at @memPath. + * + * Returns: 0 on success, + * -1 otherwise (with error reported). + */ +int +qemuGetMemoryBackingPath(virQEMUDriver *driver, + const virDomainDef *def, + const char *alias, + char **memPath) +{ + g_autofree char *domainPath =3D NULL; + + if (!alias) { + /* This should never happen (TM) */ + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("memory device alias is not assigned")); + return -1; + } + + if (qemuGetMemoryBackingDomainPath(driver, def, &domainPath) < 0) + return -1; + + *memPath =3D g_strdup_printf("%s/%s", domainPath, alias); + return 0; +} + + /* This is the old way of setting up per-domain directories */ static void qemuDomainSetPrivatePathsOld(virQEMUDriver *driver, diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index d799f6c08676..9d897b761e3a 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -936,6 +936,15 @@ void qemuDomainCleanupStorageSourceFD(virStorageSource= *src); =20 void qemuDomainStartupCleanup(virDomainObj *vm); =20 +int qemuGetMemoryBackingDomainPath(virQEMUDriver *driver, + const virDomainDef *def, + char **path); + +int qemuGetMemoryBackingPath(virQEMUDriver *driver, + const virDomainDef *def, + const char *alias, + char **memPath); + int qemuDomainSecretPrepare(virQEMUDriver *driver, virDomainObj *vm) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); --=20 2.46.1 From nobody Sun Dec 22 06:11:11 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1727092236676144.6081952049101; Mon, 23 Sep 2024 04:50:36 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id A6349161E; Mon, 23 Sep 2024 07:50:35 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 431441632; Mon, 23 Sep 2024 07:48:17 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 6A4381419; Mon, 23 Sep 2024 07:48:06 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 C98DE13F3 for ; Mon, 23 Sep 2024 07:48:05 -0400 (EDT) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-455-nOyehsyJMju2xM4utQCTcw-1; Mon, 23 Sep 2024 07:48:03 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a8a80667ad8so354028566b.2 for ; Mon, 23 Sep 2024 04:48:03 -0700 (PDT) Received: from wheatley.localdomain (37-188-137-5.red.o2.cz. [37.188.137.5]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90612b3ba7sm1206847366b.119.2024.09.23.04.48.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2024 04:48:01 -0700 (PDT) Received: from wheatley.pinto-pinecone.ts.net (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id 8383B26732EA for ; Mon, 23 Sep 2024 13:48:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727092085; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ot5KoT87GkH9qB0ECKDJKngmR0ppesU/7cl50BIdiFU=; b=Q+dJ9RsNbHqE7y0BuPICa47HzqcMmq8ISuc5pM8rIjs0xK9xCZg5WTjq1QUTBsm0lrZ69F 1e1tS3oG1XV3Zc4vpAKRsprv/c0Z81BiKS+X4esgCTDBACJvImcSGcfY/cO5Ye5O5RhNIm MAbAilSMSdwKx5fGW2Ti9BQnv6hK+8A= X-MC-Unique: nOyehsyJMju2xM4utQCTcw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727092082; x=1727696882; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ot5KoT87GkH9qB0ECKDJKngmR0ppesU/7cl50BIdiFU=; b=TzmmHtrb5nsQzCXbwtOdOE2TJbpCeqEF2L0mdoS9goW8+TGSJ1BlT5Q0pXFtGCzXv8 woZjK4zNmRYUA0EYm/4HwP5NTud/EoWzCFJ3JfG4hbq/O4HDEaOhXo3xJ6/ISvUDV2/z 9D2bltRrcjdSmE9iwvXYtjIyMOeeB5xBo7NlGKlKCd9DJSIlfOMrafujPUBAXpAAheKM TBTr7LAYnLcgWaI/Ly68+rbfsqCTvYhxDF8XzcjW/WmWGrkkyGtwXolLTqblj50aUcmc zamTuNLyZzmokoNGHr8Bdu8Ee90BoFJMd7VZirRN2EW/pj3jSRxxkwYxZPXGYuFfOuq4 2cxQ== X-Gm-Message-State: AOJu0YywAluEw7e3vrENlyB1phMn4YibZtc2Cjro3NkbGxS0xdTqazq1 ecKilkGtzC3Iq8UEnSP5dcLTnFF+xZkhu9oErKE6mR8Mwbmg1ydqjcT8n2PVd+kfYnf91i0aADj w/Nf/JO9kVvY6lPY1U9W3igGxmdMK8VZEU1Hc8Eo18xOBzCIlMw8JhqZLcugXD0rcsB9xmk+Ki4 u3L6IB7t5RnBXvfPnWd7+zAOuqNrBUEZe+JmFfeAU= X-Received: by 2002:a17:907:f783:b0:a90:419f:d8c3 with SMTP id a640c23a62f3a-a90d50d0b18mr1168466066b.49.1727092082256; Mon, 23 Sep 2024 04:48:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFmpiifgu3NSU/P51mPKj2jvIgYtoyrC34oSag65QqtnqjKVqb59b/Eip9WwxIU5+KIHM9K1A== X-Received: by 2002:a17:907:f783:b0:a90:419f:d8c3 with SMTP id a640c23a62f3a-a90d50d0b18mr1168463766b.49.1727092081677; Mon, 23 Sep 2024 04:48:01 -0700 (PDT) From: Martin Kletzander To: devel@lists.libvirt.org Subject: [PATCH v2 2/8] qemu: Change parameters of qemuGetMemoryBackingDomainPath() Date: Mon, 23 Sep 2024 13:47:52 +0200 Message-ID: <28aa7abffd077a520b110b436884f481474e1457.1727092045.git.mkletzan@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: IF654ZUDODJNAADLSTG6LACTMC7JM3MB X-Message-ID-Hash: IF654ZUDODJNAADLSTG6LACTMC7JM3MB X-MailFrom: mkletzan@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1727092239018116600 Content-Type: text/plain; charset="utf-8"; x-default="true" This way it does not use driver, since it will be later reworked and the following patches cleaner, hopefully. Signed-off-by: Martin Kletzander Reviewed-by: Michal Privoznik --- src/qemu/qemu_command.c | 4 ++-- src/qemu/qemu_domain.c | 9 +++++---- src/qemu/qemu_domain.h | 5 +++-- src/qemu/qemu_hotplug.c | 4 ++-- src/qemu/qemu_process.c | 7 +++---- src/qemu/qemu_process.h | 3 +-- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c20d033aea5a..f36b02b76b35 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3222,7 +3222,7 @@ qemuBuildMemoryBackendProps(virJSONValue **backendPro= ps, } else { /* We can have both pagesize and mem source. If that's the cas= e, * prefer hugepages as those are more specific. */ - if (qemuGetMemoryBackingPath(priv->driver, def, mem->info.alia= s, &memPath) < 0) + if (qemuGetMemoryBackingPath(priv, def, mem->info.alias, &memP= ath) < 0) return -1; } =20 @@ -7116,7 +7116,7 @@ qemuBuildMemPathStr(const virDomainDef *def, return -1; prealloc =3D true; } else if (def->mem.source =3D=3D VIR_DOMAIN_MEMORY_SOURCE_FILE) { - if (qemuGetMemoryBackingPath(priv->driver, def, "ram", &mem_path) = < 0) + if (qemuGetMemoryBackingPath(priv, def, "ram", &mem_path) < 0) return -1; } =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index cd891fd58f52..9a2ce910a5c8 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1736,10 +1736,11 @@ qemuDomainSecretPrepare(virQEMUDriver *driver, =20 =20 int -qemuGetMemoryBackingDomainPath(virQEMUDriver *driver, +qemuGetMemoryBackingDomainPath(qemuDomainObjPrivate *priv, const virDomainDef *def, char **path) { + virQEMUDriver *driver =3D priv->driver; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); const char *root =3D driver->embeddedRoot; g_autofree char *shortName =3D NULL; @@ -1760,7 +1761,7 @@ qemuGetMemoryBackingDomainPath(virQEMUDriver *driver, =20 /** * qemuGetMemoryBackingPath: - * @driver: the qemu driver + * @priv: domain private data * @def: domain definition * @alias: memory object alias * @memPath: constructed path @@ -1771,7 +1772,7 @@ qemuGetMemoryBackingDomainPath(virQEMUDriver *driver, * -1 otherwise (with error reported). */ int -qemuGetMemoryBackingPath(virQEMUDriver *driver, +qemuGetMemoryBackingPath(qemuDomainObjPrivate *priv, const virDomainDef *def, const char *alias, char **memPath) @@ -1785,7 +1786,7 @@ qemuGetMemoryBackingPath(virQEMUDriver *driver, return -1; } =20 - if (qemuGetMemoryBackingDomainPath(driver, def, &domainPath) < 0) + if (qemuGetMemoryBackingDomainPath(priv, def, &domainPath) < 0) return -1; =20 *memPath =3D g_strdup_printf("%s/%s", domainPath, alias); diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 9d897b761e3a..355a9e1cb21e 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -936,11 +936,12 @@ void qemuDomainCleanupStorageSourceFD(virStorageSourc= e *src); =20 void qemuDomainStartupCleanup(virDomainObj *vm); =20 -int qemuGetMemoryBackingDomainPath(virQEMUDriver *driver, + +int qemuGetMemoryBackingDomainPath(qemuDomainObjPrivate *priv, const virDomainDef *def, char **path); =20 -int qemuGetMemoryBackingPath(virQEMUDriver *driver, +int qemuGetMemoryBackingPath(qemuDomainObjPrivate *priv, const virDomainDef *def, const char *alias, char **memPath); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 2dcb627dbdc0..09a37caf85c3 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2404,7 +2404,7 @@ qemuDomainAttachMemory(virQEMUDriver *driver, qemuDomainObjExitMonitor(vm); =20 if (objAdded && mem) - ignore_value(qemuProcessDestroyMemoryBackingPath(driver, vm, mem)); + ignore_value(qemuProcessDestroyMemoryBackingPath(vm, mem)); =20 virErrorRestore(&orig_err); if (!mem) @@ -4761,7 +4761,7 @@ qemuDomainRemoveMemoryDevice(virQEMUDriver *driver, if (qemuDomainNamespaceTeardownMemory(vm, mem) < 0) VIR_WARN("Unable to remove memory device from /dev"); =20 - if (qemuProcessDestroyMemoryBackingPath(driver, vm, mem) < 0) + if (qemuProcessDestroyMemoryBackingPath(vm, mem) < 0) VIR_WARN("Unable to destroy memory backing path"); =20 qemuDomainReleaseMemoryDeviceSlot(vm, mem); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 2e4ee9e30502..1d3a905dd854 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4095,7 +4095,7 @@ qemuProcessBuildDestroyMemoryPaths(virQEMUDriver *dri= ver, =20 if (!build || shouldBuildMB) { g_autofree char *path =3D NULL; - if (qemuGetMemoryBackingDomainPath(driver, vm->def, &path) < 0) + if (qemuGetMemoryBackingDomainPath(QEMU_DOMAIN_PRIVATE(vm), vm->de= f, &path) < 0) return -1; =20 if (qemuProcessBuildDestroyMemoryPathsImpl(driver, vm, @@ -4108,13 +4108,12 @@ qemuProcessBuildDestroyMemoryPaths(virQEMUDriver *d= river, =20 =20 int -qemuProcessDestroyMemoryBackingPath(virQEMUDriver *driver, - virDomainObj *vm, +qemuProcessDestroyMemoryBackingPath(virDomainObj *vm, virDomainMemoryDef *mem) { g_autofree char *path =3D NULL; =20 - if (qemuGetMemoryBackingPath(driver, vm->def, mem->info.alias, &path) = < 0) + if (qemuGetMemoryBackingPath(QEMU_DOMAIN_PRIVATE(vm), vm->def, mem->in= fo.alias, &path) < 0) return -1; =20 if (unlink(path) < 0 && diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 2324aeb7bdff..878c522d8255 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -43,8 +43,7 @@ int qemuProcessBuildDestroyMemoryPaths(virQEMUDriver *dri= ver, virDomainMemoryDef *mem, bool build); =20 -int qemuProcessDestroyMemoryBackingPath(virQEMUDriver *driver, - virDomainObj *vm, +int qemuProcessDestroyMemoryBackingPath(virDomainObj *vm, virDomainMemoryDef *mem); =20 void qemuProcessReconnectAll(virQEMUDriver *driver); --=20 2.46.1 From nobody Sun Dec 22 06:11:11 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1727092203230889.3301926869516; Mon, 23 Sep 2024 04:50:03 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 97A8116EA; Mon, 23 Sep 2024 07:50:00 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 6C55215EE; Mon, 23 Sep 2024 07:48:14 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1FCC113F1; Mon, 23 Sep 2024 07:48:06 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 1F5251414 for ; Mon, 23 Sep 2024 07:48:05 -0400 (EDT) Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-614-xx6sd7JmMRWZM27TvR-uGQ-1; Mon, 23 Sep 2024 07:48:03 -0400 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a8d2f475416so317176266b.0 for ; Mon, 23 Sep 2024 04:48:03 -0700 (PDT) Received: from wheatley.localdomain (37-188-137-5.red.o2.cz. [37.188.137.5]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90610966aasm1210538466b.26.2024.09.23.04.48.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2024 04:48:01 -0700 (PDT) Received: from wheatley.pinto-pinecone.ts.net (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id 8EDFC26732EB for ; Mon, 23 Sep 2024 13:48:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727092084; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D6Yioyqm2+SutVO7we4SQAFKzM+YbLDmj9sEvAzPmr4=; b=Mpe8Pu4SD29br0SxHFPa0dUN7kmqGiY5/QenMBaV/PtDTFPkD4bPAVPES7woq0lrD69pOq aI907x8t5YitJJxafC5C22gy87lSedqBz4hQSpGehF4slOAun5y7qOlv80DsAYcjKoTAaP B6/ZgxdkrtQGDb/xIGzIW/sRmflfsN0= X-MC-Unique: xx6sd7JmMRWZM27TvR-uGQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727092082; x=1727696882; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D6Yioyqm2+SutVO7we4SQAFKzM+YbLDmj9sEvAzPmr4=; b=eTBgCQ6MLq7K+uYga9FYPUKN1/2iP06s7qLm+Rl7bDrKuUj87hC5ImHT/NZM6hRMGj ylk45AmnnJaaO8Ags0+LpuURLc/X+sNGPYEM/zzZ7ysmM6bbifenJD3aVY9xlX84T1TZ FrkztU0A1uFBcZ0rnQnM9mFzTulRt7bTM4fTRFQ70xFPTpumpmvMT0WGCQkaiOhN1j2w BEJ4kOz6uAyOpKSKviegsekTH/8VoIviYCaxKJXS7ms9a7FNTGjNYXtvN1EjclBTYMvv l/fkkO5kJaHdiDTtcaGOchCb9d5fBOE6S8QqYIaJkksvd1Lo8oHEsLAQ4ohvUjr91o6A cOcw== X-Gm-Message-State: AOJu0Yyv7GgdrML1VY5ijokop6PigZE8kv6oz6gX/SADNDbK1hw5s6Ot 9I57jmOcNBSaIWtf5PNCe9FVadrAjreg0qzzmGLsuBiDZ6H7zA5cMiYY+CyFaJB43MhbzxXkHIS GcAB1lPpXaFICyUpTt1EK3rAToCE8wOYPYCfTHg8rdrXoAgAP2Ex3FLeHuG8d1l7Bq+UyfNNoyi xyf54dU7mbhlSvmeiJixseba/AqeEP8icsgDmO4Gc= X-Received: by 2002:a17:907:6095:b0:a86:842a:104a with SMTP id a640c23a62f3a-a90d515b2bcmr1268437966b.57.1727092082549; Mon, 23 Sep 2024 04:48:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFzCl2Vk2Kw1ls/jIfbfFxzWYDyigHlcgNQDgu1ocXUDDoNU5Qj8b0h6sCCOdlq7wkD/ksWWQ== X-Received: by 2002:a17:907:6095:b0:a86:842a:104a with SMTP id a640c23a62f3a-a90d515b2bcmr1268435966b.57.1727092082112; Mon, 23 Sep 2024 04:48:02 -0700 (PDT) From: Martin Kletzander To: devel@lists.libvirt.org Subject: [PATCH v2 3/8] qemu: Add memoryBackingDir to qemuDomainObjPrivate Date: Mon, 23 Sep 2024 13:47:53 +0200 Message-ID: <00e6e68d53c6d6d2eb4eb595d209ce6f970c6441.1727092045.git.mkletzan@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 7CIWLHX2F56TIDWYLS474DB3TIWT54YH X-Message-ID-Hash: 7CIWLHX2F56TIDWYLS474DB3TIWT54YH X-MailFrom: mkletzan@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1727092204602116600 Content-Type: text/plain; charset="utf-8"; x-default="true" This way we _can_ (but do not, yet) remember the memory backing path for running domains even after configuration change and daemon restart. Signed-off-by: Martin Kletzander Reviewed-by: Michal Privoznik --- src/qemu/qemu_domain.c | 5 ++ src/qemu/qemu_domain.h | 2 + .../memory-backing-dir-in.xml | 61 +++++++++++++++++++ .../memory-backing-dir-out.xml | 1 + tests/qemuxmlactivetest.c | 2 + 5 files changed, 71 insertions(+) create mode 100644 tests/qemustatusxml2xmldata/memory-backing-dir-in.xml create mode 120000 tests/qemustatusxml2xmldata/memory-backing-dir-out.xml diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 9a2ce910a5c8..76bcb70a5699 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1934,6 +1934,8 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivate *p= riv) g_slist_free_full(g_steal_pointer(&priv->threadContextAliases), g_free= ); =20 priv->migrationRecoverSetup =3D false; + + g_clear_pointer(&priv->memoryBackingDir, g_free); } =20 =20 @@ -2708,6 +2710,7 @@ qemuDomainObjPrivateXMLFormat(virBuffer *buf, virBufferEscapeString(buf, "\n", priv->libDir); virBufferEscapeString(buf, "\n", priv->channelTargetDir); + virBufferEscapeString(buf, "\n", priv->= memoryBackingDir); =20 virCPUDefFormatBufFull(buf, priv->origCPU, NULL); =20 @@ -3429,6 +3432,8 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, priv->channelTargetDir =3D tmp; tmp =3D NULL; =20 + priv->memoryBackingDir =3D virXPathString("string(./memoryBackingDir/@= path)", ctxt); + qemuDomainSetPrivatePathsOld(driver, vm); =20 if (virCPUDefParseXML(ctxt, "./cpu", VIR_CPU_TYPE_GUEST, &priv->origCP= U, diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 355a9e1cb21e..8f41c4af81c0 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -261,6 +261,8 @@ struct _qemuDomainObjPrivate { =20 /* named file descriptor groups associated with the VM */ GHashTable *fds; + + char *memoryBackingDir; }; =20 #define QEMU_DOMAIN_PRIVATE(vm) \ diff --git a/tests/qemustatusxml2xmldata/memory-backing-dir-in.xml b/tests/= qemustatusxml2xmldata/memory-backing-dir-in.xml new file mode 100644 index 000000000000..eea671a41c0d --- /dev/null +++ b/tests/qemustatusxml2xmldata/memory-backing-dir-in.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + testtest + + + + + + + + + + + + + + + + -2 + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i386 + +
+ + +
+ + + + +