8fced6
From 58688d868656e77f67ea915544b0bb3bb60f33d8 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:11 -0500
8fced6
Subject: [PATCH 10/14] qga: add command guest-get-disks
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-7-marcandre.lureau@redhat.com>
8fced6
Patchwork-id: 100475
8fced6
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH v2 06/10] qga: add command guest-get-disks
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: Tomáš Golembiovský <tgolembi@redhat.com>
8fced6
8fced6
Add API and stubs for new guest-get-disks command.
8fced6
8fced6
The command guest-get-fsinfo can be used to list information about disks
8fced6
and partitions but it is limited only to mounted disks with filesystem.
8fced6
This new command should allow listing information about disks of the VM
8fced6
regardles whether they are mounted or not. This can be usefull for
8fced6
management applications for mapping virtualized devices or pass-through
8fced6
devices to device names in the guest OS.
8fced6
8fced6
Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
8fced6
Reviewed-by: Philippe Mathieu-Daudé <philmd@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 c27ea3f9ef7c7f29e55bde91879f8514abce9c38)
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 |  6 ++++++
8fced6
 qga/commands-win32.c |  6 ++++++
8fced6
 qga/qapi-schema.json | 31 +++++++++++++++++++++++++++++++
8fced6
 3 files changed, 43 insertions(+)
8fced6
8fced6
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
8fced6
index c86c87ed522..5095104afc0 100644
8fced6
--- a/qga/commands-posix.c
8fced6
+++ b/qga/commands-posix.c
8fced6
@@ -3039,3 +3039,9 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp)
8fced6
 
8fced6
     return info;
8fced6
 }
8fced6
+
8fced6
+GuestDiskInfoList *qmp_guest_get_disks(Error **errp)
8fced6
+{
8fced6
+    error_setg(errp, QERR_UNSUPPORTED);
8fced6
+    return NULL;
8fced6
+}
8fced6
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
8fced6
index 55ba5b263af..be63fa2b208 100644
8fced6
--- a/qga/commands-win32.c
8fced6
+++ b/qga/commands-win32.c
8fced6
@@ -2234,3 +2234,9 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp)
8fced6
 
8fced6
     return info;
8fced6
 }
8fced6
+
8fced6
+GuestDiskInfoList *qmp_guest_get_disks(Error **errp)
8fced6
+{
8fced6
+    error_setg(errp, QERR_UNSUPPORTED);
8fced6
+    return NULL;
8fced6
+}
8fced6
diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
8fced6
index fb4605cc19c..22df375c92f 100644
8fced6
--- a/qga/qapi-schema.json
8fced6
+++ b/qga/qapi-schema.json
8fced6
@@ -852,6 +852,37 @@
8fced6
            'bus': 'int', 'target': 'int', 'unit': 'int',
8fced6
            '*serial': 'str', '*dev': 'str'} }
8fced6
 
8fced6
+##
8fced6
+# @GuestDiskInfo:
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
+# @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
+#
8fced6
+# Since 5.2
8fced6
+##
8fced6
+{ 'struct': 'GuestDiskInfo',
8fced6
+  'data': {'name': 'str', 'partition': 'bool', 'dependents': ['str'],
8fced6
+           '*address': 'GuestDiskAddress', '*alias': 'str'} }
8fced6
+
8fced6
+##
8fced6
+# @guest-get-disks:
8fced6
+#
8fced6
+# Returns: The list of disks in the guest. For Windows these are only the
8fced6
+#          physical disks. On Linux these are all root block devices of
8fced6
+#          non-zero size including e.g. removable devices, loop devices,
8fced6
+#          NBD, etc.
8fced6
+#
8fced6
+# Since: 5.2
8fced6
+##
8fced6
+{ 'command': 'guest-get-disks',
8fced6
+  'returns': ['GuestDiskInfo'] }
8fced6
+
8fced6
 ##
8fced6
 # @GuestFilesystemInfo:
8fced6
 #
8fced6
-- 
8fced6
2.27.0
8fced6