diff mbox series

[v2,1/3] qga: add command guest-get-disks

Message ID d8573ee72572ba586c285472789243b37527e2b9.1599470071.git.tgolembi@redhat.com
State New
Headers show
Series qga: add command guest-get-disk | expand

Commit Message

Tomáš Golembiovský Sept. 7, 2020, 9:14 a.m. UTC
Add API and stubs for new guest-get-disks command.

The command guest-get-fsinfo can be used to list information about disks
and partitions but it is limited only to mounted disks with filesystem.
This new command should allow listing information about disks of the VM
regardles whether they are mounted or not. This can be usefull for
management applications for mapping virtualized devices or pass-through
devices to device names in the guest OS.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
---
 qga/commands-posix.c |  6 ++++++
 qga/commands-win32.c |  6 ++++++
 qga/qapi-schema.json | 29 +++++++++++++++++++++++++++++
 3 files changed, 41 insertions(+)

Comments

Philippe Mathieu-Daudé Sept. 7, 2020, 9:32 a.m. UTC | #1
On 9/7/20 11:14 AM, Tomáš Golembiovský wrote:
> Add API and stubs for new guest-get-disks command.
> 
> The command guest-get-fsinfo can be used to list information about disks
> and partitions but it is limited only to mounted disks with filesystem.
> This new command should allow listing information about disks of the VM
> regardles whether they are mounted or not. This can be usefull for
> management applications for mapping virtualized devices or pass-through
> devices to device names in the guest OS.
> 
> Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
> ---
>  qga/commands-posix.c |  6 ++++++
>  qga/commands-win32.c |  6 ++++++
>  qga/qapi-schema.json | 29 +++++++++++++++++++++++++++++
>  3 files changed, 41 insertions(+)

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Marc-André Lureau Sept. 29, 2020, 3:22 p.m. UTC | #2
On Mon, Sep 7, 2020 at 1:16 PM Tomáš Golembiovský <tgolembi@redhat.com>
wrote:

> Add API and stubs for new guest-get-disks command.
>
> The command guest-get-fsinfo can be used to list information about disks
> and partitions but it is limited only to mounted disks with filesystem.
> This new command should allow listing information about disks of the VM
> regardles whether they are mounted or not. This can be usefull for
> management applications for mapping virtualized devices or pass-through
> devices to device names in the guest OS.
>
> Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

---
>  qga/commands-posix.c |  6 ++++++
>  qga/commands-win32.c |  6 ++++++
>  qga/qapi-schema.json | 29 +++++++++++++++++++++++++++++
>  3 files changed, 41 insertions(+)
>
> diff --git a/qga/commands-posix.c b/qga/commands-posix.c
> index 744c2b5a5d..f99731af51 100644
> --- a/qga/commands-posix.c
> +++ b/qga/commands-posix.c
> @@ -3042,3 +3042,9 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp)
>
>      return info;
>  }
> +
> +GuestDiskInfoList *qmp_guest_get_disks(Error **errp)
> +{
> +    error_setg(errp, QERR_UNSUPPORTED);
> +    return NULL;
> +}
> diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> index aaa71f147b..e9976a0c46 100644
> --- a/qga/commands-win32.c
> +++ b/qga/commands-win32.c
> @@ -2229,3 +2229,9 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp)
>
>      return info;
>  }
> +
> +GuestDiskInfoList *qmp_guest_get_disks(Error **errp)
> +{
> +    error_setg(errp, QERR_UNSUPPORTED);
> +    return NULL;
> +}
> diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
> index 408a662ea5..70b54e0d07 100644
> --- a/qga/qapi-schema.json
> +++ b/qga/qapi-schema.json
> @@ -862,6 +862,35 @@
>             'bus': 'int', 'target': 'int', 'unit': 'int',
>             '*serial': 'str', '*dev': 'str'} }
>
> +##
> +# @GuestDiskInfo:
> +#
> +# @name: device node (Linux) or device UNC (Windows)
> +# @partition: whether this is a partition or disk
> +# @slaves: list of slave devices (Linux)
> +# @address: disk address information (only for non-virtual devices)
> +# @alias: optional alias assigned to the disk, on Linux this is a name
> assigned
> +#         by device mapper
> +#
> +# Since 5.2
> +##
> +{ 'struct': 'GuestDiskInfo',
> +  'data': {'name': 'str', 'partition': 'bool', 'slaves': ['str'],
> +           '*address': 'GuestDiskAddress', '*alias': 'str'} }
> +
> +##
> +# @guest-get-disks:
> +#
> +# Returns: The list of disks in the guest. For Windows these are only the
> +#          physical disks. On Linux these are all root block devices of
> +#          non-zero size including e.g. removable devices, loop devices,
> +#          NBD, etc.
> +#
> +# Since: 5.2
> +##
> +{ 'command': 'guest-get-disks',
> +  'returns': ['GuestDiskInfo'] }
> +
>  ##
>  # @GuestFilesystemInfo:
>  #
> --
> 2.25.0
>
>
>
Daniel P. Berrangé Oct. 6, 2020, 8:36 a.m. UTC | #3
On Mon, Sep 07, 2020 at 11:14:40AM +0200, Tomáš Golembiovský wrote:
> Add API and stubs for new guest-get-disks command.

> 

> The command guest-get-fsinfo can be used to list information about disks

> and partitions but it is limited only to mounted disks with filesystem.

> This new command should allow listing information about disks of the VM

> regardles whether they are mounted or not. This can be usefull for

> management applications for mapping virtualized devices or pass-through

> devices to device names in the guest OS.

> 

> Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>

> ---

>  qga/commands-posix.c |  6 ++++++

>  qga/commands-win32.c |  6 ++++++

>  qga/qapi-schema.json | 29 +++++++++++++++++++++++++++++

>  3 files changed, 41 insertions(+)

> 

> diff --git a/qga/commands-posix.c b/qga/commands-posix.c

> index 744c2b5a5d..f99731af51 100644

> --- a/qga/commands-posix.c

> +++ b/qga/commands-posix.c

> @@ -3042,3 +3042,9 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp)

>  

>      return info;

>  }

> +

> +GuestDiskInfoList *qmp_guest_get_disks(Error **errp)

> +{

> +    error_setg(errp, QERR_UNSUPPORTED);

> +    return NULL;

> +}

> diff --git a/qga/commands-win32.c b/qga/commands-win32.c

> index aaa71f147b..e9976a0c46 100644

> --- a/qga/commands-win32.c

> +++ b/qga/commands-win32.c

> @@ -2229,3 +2229,9 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp)

>  

>      return info;

>  }

> +

> +GuestDiskInfoList *qmp_guest_get_disks(Error **errp)

> +{

> +    error_setg(errp, QERR_UNSUPPORTED);

> +    return NULL;

> +}

> diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json

> index 408a662ea5..70b54e0d07 100644

> --- a/qga/qapi-schema.json

> +++ b/qga/qapi-schema.json

> @@ -862,6 +862,35 @@

>             'bus': 'int', 'target': 'int', 'unit': 'int',

>             '*serial': 'str', '*dev': 'str'} }

>  

> +##

> +# @GuestDiskInfo:

> +#

> +# @name: device node (Linux) or device UNC (Windows)

> +# @partition: whether this is a partition or disk

> +# @slaves: list of slave devices (Linux)


What are "slave devices" ?

For that matter, please don't use the term "slaves" at all in any
new code.

> +# @address: disk address information (only for non-virtual devices)

> +# @alias: optional alias assigned to the disk, on Linux this is a name assigned

> +#         by device mapper

> +#

> +# Since 5.2

> +##

> +{ 'struct': 'GuestDiskInfo',

> +  'data': {'name': 'str', 'partition': 'bool', 'slaves': ['str'],

> +           '*address': 'GuestDiskAddress', '*alias': 'str'} }


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
Tomáš Golembiovský Oct. 6, 2020, 1:53 p.m. UTC | #4
On Tue, Oct 06, 2020 at 09:36:32AM +0100, Daniel P. Berrangé wrote:
> On Mon, Sep 07, 2020 at 11:14:40AM +0200, Tomáš Golembiovský wrote:
> > Add API and stubs for new guest-get-disks command.
> > 
> > The command guest-get-fsinfo can be used to list information about disks
> > and partitions but it is limited only to mounted disks with filesystem.
> > This new command should allow listing information about disks of the VM
> > regardles whether they are mounted or not. This can be usefull for
> > management applications for mapping virtualized devices or pass-through
> > devices to device names in the guest OS.
> > 
> > Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
> > ---
> >  qga/commands-posix.c |  6 ++++++
> >  qga/commands-win32.c |  6 ++++++
> >  qga/qapi-schema.json | 29 +++++++++++++++++++++++++++++
> >  3 files changed, 41 insertions(+)
> > 
> > diff --git a/qga/commands-posix.c b/qga/commands-posix.c
> > index 744c2b5a5d..f99731af51 100644
> > --- a/qga/commands-posix.c
> > +++ b/qga/commands-posix.c
> > @@ -3042,3 +3042,9 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp)
> >  
> >      return info;
> >  }
> > +
> > +GuestDiskInfoList *qmp_guest_get_disks(Error **errp)
> > +{
> > +    error_setg(errp, QERR_UNSUPPORTED);
> > +    return NULL;
> > +}
> > diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> > index aaa71f147b..e9976a0c46 100644
> > --- a/qga/commands-win32.c
> > +++ b/qga/commands-win32.c
> > @@ -2229,3 +2229,9 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp)
> >  
> >      return info;
> >  }
> > +
> > +GuestDiskInfoList *qmp_guest_get_disks(Error **errp)
> > +{
> > +    error_setg(errp, QERR_UNSUPPORTED);
> > +    return NULL;
> > +}
> > diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
> > index 408a662ea5..70b54e0d07 100644
> > --- a/qga/qapi-schema.json
> > +++ b/qga/qapi-schema.json
> > @@ -862,6 +862,35 @@
> >             'bus': 'int', 'target': 'int', 'unit': 'int',
> >             '*serial': 'str', '*dev': 'str'} }
> >  
> > +##
> > +# @GuestDiskInfo:
> > +#
> > +# @name: device node (Linux) or device UNC (Windows)
> > +# @partition: whether this is a partition or disk
> > +# @slaves: list of slave devices (Linux)
> 
> What are "slave devices" ?

That is how Linux calls dependent devices. E.g. PVs in your LVM setup
are considered "slaves" to your LVs. Or if you have LUKS volume called
"foo" on your "bar" drive then "bar" would be listed as a "slave" for
"foo".

The dependency is in the opposite direction then I have always pictured
it in my had, but I guess that there are reasons for that.

> For that matter, please don't use the term "slaves" at all in any
> new code.

Fair enough... so how shall we call those devices? Dependents,
dependencies, parents... ? Ideas welcome.

    Tomas

> 
> > +# @address: disk address information (only for non-virtual devices)
> > +# @alias: optional alias assigned to the disk, on Linux this is a name assigned
> > +#         by device mapper
> > +#
> > +# Since 5.2
> > +##
> > +{ 'struct': 'GuestDiskInfo',
> > +  'data': {'name': 'str', 'partition': 'bool', 'slaves': ['str'],
> > +           '*address': 'GuestDiskAddress', '*alias': 'str'} }
> 
> Regards,
> Daniel
> -- 
> |: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org         -o-            https://fstop138.berrange.com :|
> |: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
> 
>
Daniel P. Berrangé Oct. 6, 2020, 1:56 p.m. UTC | #5
On Tue, Oct 06, 2020 at 03:53:08PM +0200, Tomáš Golembiovský wrote:
> On Tue, Oct 06, 2020 at 09:36:32AM +0100, Daniel P. Berrangé wrote:
> > On Mon, Sep 07, 2020 at 11:14:40AM +0200, Tomáš Golembiovský wrote:
> > > Add API and stubs for new guest-get-disks command.
> > > 
> > > The command guest-get-fsinfo can be used to list information about disks
> > > and partitions but it is limited only to mounted disks with filesystem.
> > > This new command should allow listing information about disks of the VM
> > > regardles whether they are mounted or not. This can be usefull for
> > > management applications for mapping virtualized devices or pass-through
> > > devices to device names in the guest OS.
> > > 
> > > Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
> > > ---
> > >  qga/commands-posix.c |  6 ++++++
> > >  qga/commands-win32.c |  6 ++++++
> > >  qga/qapi-schema.json | 29 +++++++++++++++++++++++++++++
> > >  3 files changed, 41 insertions(+)
> > > 
> > > diff --git a/qga/commands-posix.c b/qga/commands-posix.c
> > > index 744c2b5a5d..f99731af51 100644
> > > --- a/qga/commands-posix.c
> > > +++ b/qga/commands-posix.c
> > > @@ -3042,3 +3042,9 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp)
> > >  
> > >      return info;
> > >  }
> > > +
> > > +GuestDiskInfoList *qmp_guest_get_disks(Error **errp)
> > > +{
> > > +    error_setg(errp, QERR_UNSUPPORTED);
> > > +    return NULL;
> > > +}
> > > diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> > > index aaa71f147b..e9976a0c46 100644
> > > --- a/qga/commands-win32.c
> > > +++ b/qga/commands-win32.c
> > > @@ -2229,3 +2229,9 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp)
> > >  
> > >      return info;
> > >  }
> > > +
> > > +GuestDiskInfoList *qmp_guest_get_disks(Error **errp)
> > > +{
> > > +    error_setg(errp, QERR_UNSUPPORTED);
> > > +    return NULL;
> > > +}
> > > diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
> > > index 408a662ea5..70b54e0d07 100644
> > > --- a/qga/qapi-schema.json
> > > +++ b/qga/qapi-schema.json
> > > @@ -862,6 +862,35 @@
> > >             'bus': 'int', 'target': 'int', 'unit': 'int',
> > >             '*serial': 'str', '*dev': 'str'} }
> > >  
> > > +##
> > > +# @GuestDiskInfo:
> > > +#
> > > +# @name: device node (Linux) or device UNC (Windows)
> > > +# @partition: whether this is a partition or disk
> > > +# @slaves: list of slave devices (Linux)
> > 
> > What are "slave devices" ?
> 
> That is how Linux calls dependent devices. E.g. PVs in your LVM setup
> are considered "slaves" to your LVs. Or if you have LUKS volume called
> "foo" on your "bar" drive then "bar" would be listed as a "slave" for
> "foo".
> 
> The dependency is in the opposite direction then I have always pictured
> it in my had, but I guess that there are reasons for that.
> 
> > For that matter, please don't use the term "slaves" at all in any
> > new code.
> 
> Fair enough... so how shall we call those devices? Dependents,
> dependencies, parents... ? Ideas welcome.

Sounds like "dependents" sounds like a reasonable term for what
this is expressing.

Giving the LVM VG/PV and LUKS examples in the QAPI docs would be
useful.

Regards,
Daniel
diff mbox series

Patch

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 744c2b5a5d..f99731af51 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -3042,3 +3042,9 @@  GuestOSInfo *qmp_guest_get_osinfo(Error **errp)
 
     return info;
 }
+
+GuestDiskInfoList *qmp_guest_get_disks(Error **errp)
+{
+    error_setg(errp, QERR_UNSUPPORTED);
+    return NULL;
+}
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index aaa71f147b..e9976a0c46 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -2229,3 +2229,9 @@  GuestOSInfo *qmp_guest_get_osinfo(Error **errp)
 
     return info;
 }
+
+GuestDiskInfoList *qmp_guest_get_disks(Error **errp)
+{
+    error_setg(errp, QERR_UNSUPPORTED);
+    return NULL;
+}
diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
index 408a662ea5..70b54e0d07 100644
--- a/qga/qapi-schema.json
+++ b/qga/qapi-schema.json
@@ -862,6 +862,35 @@ 
            'bus': 'int', 'target': 'int', 'unit': 'int',
            '*serial': 'str', '*dev': 'str'} }
 
+##
+# @GuestDiskInfo:
+#
+# @name: device node (Linux) or device UNC (Windows)
+# @partition: whether this is a partition or disk
+# @slaves: list of slave devices (Linux)
+# @address: disk address information (only for non-virtual devices)
+# @alias: optional alias assigned to the disk, on Linux this is a name assigned
+#         by device mapper
+#
+# Since 5.2
+##
+{ 'struct': 'GuestDiskInfo',
+  'data': {'name': 'str', 'partition': 'bool', 'slaves': ['str'],
+           '*address': 'GuestDiskAddress', '*alias': 'str'} }
+
+##
+# @guest-get-disks:
+#
+# Returns: The list of disks in the guest. For Windows these are only the
+#          physical disks. On Linux these are all root block devices of
+#          non-zero size including e.g. removable devices, loop devices,
+#          NBD, etc.
+#
+# Since: 5.2
+##
+{ 'command': 'guest-get-disks',
+  'returns': ['GuestDiskInfo'] }
+
 ##
 # @GuestFilesystemInfo:
 #