Re: [PATCH v2 2/5] qemu: Introduce shared_filesystems configuration option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 4/17/24 09:29, Andrea Bolognani wrote:
As explained in the comment, this can help in scenarios where
a shared filesystem can't be detected as such by libvirt, by
giving the admin the opportunity to provide this information
manually.

Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
---
  src/qemu/libvirtd_qemu.aug         |  3 +++
  src/qemu/qemu.conf.in              | 23 +++++++++++++++++++++++
  src/qemu/qemu_conf.c               | 17 +++++++++++++++++
  src/qemu/qemu_conf.h               |  2 ++
  src/qemu/test_libvirtd_qemu.aug.in |  5 +++++
  5 files changed, 50 insertions(+)

diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug
index 2b6526538f..1377fd89cc 100644
--- a/src/qemu/libvirtd_qemu.aug
+++ b/src/qemu/libvirtd_qemu.aug
@@ -143,6 +143,8 @@ module Libvirtd_qemu =
let storage_entry = bool_entry "storage_use_nbdkit" + let filesystem_entry = str_array_entry "shared_filesystems"
+
     (* Entries that used to exist in the config which are now
      * deleted. We keep on parsing them so we don't break
      * ability to parse old configs after upgrade
@@ -173,6 +175,7 @@ module Libvirtd_qemu =
               | swtpm_entry
               | capability_filters_entry
               | storage_entry
+             | filesystem_entry
               | obsolete_entry
let comment = [ label "#comment" . del /#[ \t]*/ "# " . store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ]
diff --git a/src/qemu/qemu.conf.in b/src/qemu/qemu.conf.in
index f406df8749..c543a0a55b 100644
--- a/src/qemu/qemu.conf.in
+++ b/src/qemu/qemu.conf.in
@@ -986,3 +986,26 @@
  # note that the default might change in future releases.
  #
  #storage_use_nbdkit = @USE_NBDKIT_DEFAULT@
+
+# libvirt will normally prevent migration if the storage backing the VM is not
+# on a shared filesystems. Sometimes, however, the storage *is* shared despite
+# not being detected as such: for example, this is the case when one of the
+# hosts involved in the migration is exporting its local storage to the other
+# one via NFS.
+#
+# Any directory listed here will be assumed to live on a shared filesystem,
+# making migration possible in scenarios such as the one described above.
+#
+# Due to how label remembering is implemented, it will generally be necessary
+# to set remember_owner=0 *on both sides of the migration* as well.
+#
+# NOTE: this option is intended to help in very specific scenarios that are
+# rarely encountered. If you find yourself reaching for this option, consider
+# reworking your environment so that it follows a more common architecture
+# rather than using it.
+#
+#shared_filesystems = [
+#  "/path/to/images",
+#  "/path/to/nvram",
+#  "/path/to/swtpm"
+#]

May be worth considering: Would it ever be useful or necessary for libvirt to know what type of filesystem is used for the sharing, so that users should write nfs:/path/to/swtpm for example? I don't have much experience with shared filesystems (other than NFS) but maybe sometimes behavior has to be adjusted depending on what type is being used.

Otherwise LGTM.

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 4050a82341..01c6bcc793 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -374,6 +374,8 @@ static void virQEMUDriverConfigDispose(void *obj)
g_strfreev(cfg->capabilityfilters); + g_strfreev(cfg->sharedFilesystems);
+
      g_free(cfg->deprecationBehavior);
  }
@@ -1084,6 +1086,18 @@ virQEMUDriverConfigLoadStorageEntry(virQEMUDriverConfig *cfg,
  }
+static int
+virQEMUDriverConfigLoadFilesystemEntry(virQEMUDriverConfig *cfg,
+                                       virConf *conf)
+{
+    if (virConfGetValueStringList(conf, "shared_filesystems", false,
+                                  &cfg->sharedFilesystems) < 0)
+        return -1;
+
+    return 0;
+}
+
+
  int virQEMUDriverConfigLoadFile(virQEMUDriverConfig *cfg,
                                  const char *filename,
                                  bool privileged)
@@ -1158,6 +1172,9 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfig *cfg,
      if (virQEMUDriverConfigLoadStorageEntry(cfg, conf) < 0)
          return -1;
+ if (virQEMUDriverConfigLoadFilesystemEntry(cfg, conf) < 0)
+        return -1;
+
      return 0;
  }
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 36049b4bfa..b53d56be02 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -233,6 +233,8 @@ struct _virQEMUDriverConfig {
      bool storageUseNbdkit;
virQEMUSchedCore schedCore;
+
+    char **sharedFilesystems;
  };
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virQEMUDriverConfig, virObjectUnref);
diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qemu.aug.in
index b97e6de11e..69fdae215a 100644
--- a/src/qemu/test_libvirtd_qemu.aug.in
+++ b/src/qemu/test_libvirtd_qemu.aug.in
@@ -119,3 +119,8 @@ module Test_libvirtd_qemu =
  { "deprecation_behavior" = "none" }
  { "sched_core" = "none" }
  { "storage_use_nbdkit" = "@USE_NBDKIT_DEFAULT@" }
+{ "shared_filesystems"
+    { "1" = "/path/to/images" }
+    { "2" = "/path/to/nvram" }
+    { "3" = "/path/to/swtpm" }
+}
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux