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