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

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