a19a21
From 58688d868656e77f67ea915544b0bb3bb60f33d8 Mon Sep 17 00:00:00 2001
709dde
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
a19a21
Date: Wed, 16 Dec 2020 16:06:11 -0500
a19a21
Subject: [PATCH 10/14] 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>
a19a21
Message-id: <20201216160615.324213-7-marcandre.lureau@redhat.com>
a19a21
Patchwork-id: 100475
a19a21
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH v2 06/10] qga: add command guest-get-disks
a19a21
Bugzilla: 1859494
a19a21
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
a19a21
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
a19a21
RH-Acked-by: Stefan Hajnoczi <stefanha@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
a19a21
index c86c87ed522..5095104afc0 100644
709dde
--- a/qga/commands-posix.c
709dde
+++ b/qga/commands-posix.c
a19a21
@@ -3039,3 +3039,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