yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-qga-update-schema-for-guest-get-disks-dependents-fie.patch

709dde
From 0829b1e0a9ca1a8270e138beb0c58b0b1ad67c9a Mon Sep 17 00:00:00 2001
709dde
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
709dde
Date: Fri, 8 Jan 2021 07:41:01 -0500
709dde
Subject: [PATCH 10/10] qga: update schema for guest-get-disks 'dependents'
709dde
 field
709dde
MIME-Version: 1.0
709dde
Content-Type: text/plain; charset=UTF-8
709dde
Content-Transfer-Encoding: 8bit
709dde
709dde
RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
709dde
Message-id: <20210108074101.290008-11-marcandre.lureau@redhat.com>
709dde
Patchwork-id: 100529
709dde
O-Subject: [RHEL-8.3.0.z qemu-kvm PATCH 10/10] qga: update schema for guest-get-disks 'dependents' field
709dde
Bugzilla: 1913818
709dde
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
709dde
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
709dde
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
709dde
709dde
From: Marc-André Lureau <marcandre.lureau@redhat.com>
709dde
709dde
From: Michael Roth <michael.roth@amd.com>
709dde
709dde
The recently-added 'guest-get-disk' command returns a list of
709dde
GuestDiskInfo entries, which in turn have a 'dependents' field which
709dde
lists devices these entries are dependent upon. Thus, 'dependencies'
709dde
is a better name for this field. Address this by renaming the field
709dde
accordingly.
709dde
709dde
Additionally, 'dependents' is specified as non-optional, even though
709dde
it's not implemented for w32. This is misleading, since it gives users
709dde
the impression that a particular disk might not have dependencies,
709dde
when in reality that information is simply not known to the guest
709dde
agent. Address this by making 'dependents' an optional field, and only
709dde
marking it as in-use when the facilities to obtain this information are
709dde
available to the guest agent.
709dde
709dde
Cc: Eric Blake <eblake@redhat.com>
709dde
Cc: Tomáš Golembiovský <tgolembi@redhat.com>
709dde
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
709dde
Reviewed-by: Eric Blake <eblake@redhat.com>
709dde
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
709dde
Signed-off-by: Michael Roth <michael.roth@amd.com>
709dde
709dde
(cherry-picked from commit a8aa94b5f8427cc2924d8cdd417c8014db1c86c0)
709dde
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
709dde
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
709dde
---
709dde
 qga/commands-posix.c | 10 ++++++----
709dde
 qga/qapi-schema.json |  8 ++++----
709dde
 2 files changed, 10 insertions(+), 8 deletions(-)
709dde
709dde
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
709dde
index 1a9c2cbc3e6..38bc9a229db 100644
709dde
--- a/qga/commands-posix.c
709dde
+++ b/qga/commands-posix.c
709dde
@@ -1226,6 +1226,7 @@ static void get_disk_deps(const char *disk_dir, GuestDiskInfo *disk)
709dde
         g_debug("failed to list entries in %s", deps_dir);
709dde
         return;
709dde
     }
709dde
+    disk->has_dependencies = true;
709dde
     while ((dep = g_dir_read_name(dp_deps)) != NULL) {
709dde
         g_autofree char *dep_dir = NULL;
709dde
         strList *dep_item = NULL;
709dde
@@ -1238,8 +1239,8 @@ static void get_disk_deps(const char *disk_dir, GuestDiskInfo *disk)
709dde
             g_debug("  adding dependent device: %s", dev_name);
709dde
             dep_item = g_new0(strList, 1);
709dde
             dep_item->value = dev_name;
709dde
-            dep_item->next = disk->dependents;
709dde
-            disk->dependents = dep_item;
709dde
+            dep_item->next = disk->dependencies;
709dde
+            disk->dependencies = dep_item;
709dde
         }
709dde
     }
709dde
     g_dir_close(dp_deps);
709dde
@@ -1292,8 +1293,9 @@ static GuestDiskInfoList *get_disk_partitions(
709dde
         partition->name = dev_name;
709dde
         partition->partition = true;
709dde
         /* Add parent disk as dependent for easier tracking of hierarchy */
709dde
-        partition->dependents = g_new0(strList, 1);
709dde
-        partition->dependents->value = g_strdup(disk_dev);
709dde
+        partition->dependencies = g_new0(strList, 1);
709dde
+        partition->dependencies->value = g_strdup(disk_dev);
709dde
+        partition->has_dependencies = true;
709dde
 
709dde
         item = g_new0(GuestDiskInfoList, 1);
709dde
         item->value = partition;
709dde
diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
709dde
index 22df375c92f..4222cb92d34 100644
709dde
--- a/qga/qapi-schema.json
709dde
+++ b/qga/qapi-schema.json
709dde
@@ -857,9 +857,9 @@
709dde
 #
709dde
 # @name: device node (Linux) or device UNC (Windows)
709dde
 # @partition: whether this is a partition or disk
709dde
-# @dependents: list of dependent devices; e.g. for LVs of the LVM this will
709dde
-#              hold the list of PVs, for LUKS encrypted volume this will
709dde
-#              contain the disk where the volume is placed.     (Linux)
709dde
+# @dependencies: list of device dependencies; e.g. for LVs of the LVM this will
709dde
+#                hold the list of PVs, for LUKS encrypted volume this will
709dde
+#                contain the disk where the volume is placed.     (Linux)
709dde
 # @address: disk address information (only for non-virtual devices)
709dde
 # @alias: optional alias assigned to the disk, on Linux this is a name assigned
709dde
 #         by device mapper
709dde
@@ -867,7 +867,7 @@
709dde
 # Since 5.2
709dde
 ##
709dde
 { 'struct': 'GuestDiskInfo',
709dde
-  'data': {'name': 'str', 'partition': 'bool', 'dependents': ['str'],
709dde
+  'data': {'name': 'str', 'partition': 'bool', '*dependencies': ['str'],
709dde
            '*address': 'GuestDiskAddress', '*alias': 'str'} }
709dde
 
709dde
 ##
709dde
-- 
709dde
2.27.0
709dde