yeahuh / rpms / qemu-kvm

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