thebeanogamer / rpms / qemu-kvm

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