qga: add implementation of guest-get-disks for Linux
commitfed3956429d560a06fc2d2fcf1a01efb58659f87
authorTomáš Golembiovský <tgolembi@redhat.com>
Mon, 12 Oct 2020 08:36:02 +0000 (12 10:36 +0200)
committerMichael Roth <michael.roth@amd.com>
Mon, 2 Nov 2020 17:32:15 +0000 (2 11:32 -0600)
tree66f334c566dadfc0f21f8503f758eadc2b897a60
parentc27ea3f9ef7c7f29e55bde91879f8514abce9c38
qga: add implementation of guest-get-disks for Linux

The command lists all disks (real and virtual) as well as disk
partitions. For each disk the list of dependent disks is also listed and
/dev path is used as a handle so it can be matched with "name" field of
other returned disk entries. For disk partitions the "dependents" list
is populated with the the parent device for easier tracking of
hierarchy.

Example output:
{
  "return": [
    ...
    {
      "name": "/dev/dm-0",
      "partition": false,
      "dependents": [
        "/dev/sda2"
      ],
      "alias": "luks-7062202e-5b9b-433e-81e8-6628c40da9f7"
    },
    {
      "name": "/dev/sda2",
      "partition": true,
      "dependents": [
        "/dev/sda"
      ]
    },
    {
      "name": "/dev/sda",
      "partition": false,
      "address": {
        "serial": "SAMSUNG_MZ7LN512HCHP-000L1_S1ZKNXAG822493",
        "bus-type": "sata",
        ...
        "dev": "/dev/sda",
        "target": 0
      },
      "dependents": []
    },
    ...
  ]
}

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
*add missing stub for !defined(CONFIG_FSFREEZE)
*remove unused deps_dir variable
Signed-off-by: Michael Roth <michael.roth@amd.com>
qga/commands-posix.c