]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Expose disk serial in virDomainGetGuestInfo()
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 14 Apr 2021 08:09:35 +0000 (10:09 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 14 Apr 2021 11:56:09 +0000 (13:56 +0200)
When querying guest info via virDomainGetGuestInfo() the
'guest-get-disks' agent command is called. It may report disk
serial number which we parse, but never report nor use for
anything else.

As it turns out, it may help management application find matching
disk in their internals.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-By: Tomáš Golembiovský <tgolembi@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
docs/manpages/virsh.rst
src/libvirt-domain.c
src/qemu/qemu_driver.c

index 813fb0bd60dce684009337997ce66deecf6bd139..bccda292a2d8644b3747ffcc20a437c200a1b290 100644 (file)
@@ -2787,6 +2787,7 @@ returned:
 * ``disk.<num>.partition`` - whether this is a partition or disk
 * ``disk.<num>.dependency.count`` - the number of device dependencies
 * ``disk.<num>.dependency.<num>.name`` - a dependency name
+* ``disk.<num>.serial`` -  optional disk serial number
 * ``disk.<num>.alias`` - the device alias of the disk (e.g. sda)
 * ``disk.<num>.guest_alias`` - optional alias assigned to the disk
 
index 83ff7df9fe6c9f83fc1c0816c53a64a22a1991d5..509b7a6d8858721ac438ea442e656bbd31463185 100644 (file)
@@ -12561,6 +12561,7 @@ virDomainSetVcpu(virDomainPtr domain,
  *                      hold the list of PVs, for LUKS encrypted volume this will
  *                      contain the disk where the volume is placed. (Linux)
  *      "disk.<num>.dependency.<num>.name" - a dependency
+ *      "disk.<num>.serial" - optional disk serial number (as string)
  *      "disk.<num>.alias" - the device alias of the disk (e.g. sda)
  *      "disk.<num>.guest_alias" - optional alias assigned to the disk, on Linux
  *                      this is a name assigned by device mapper
index 90b5477f006330986cb188f4839451b19c01cf26..88ee9e5d5e6b6637b339f5e6c5c410576ab68565 100644 (file)
@@ -19951,15 +19951,24 @@ qemuAgentDiskInfoFormatParams(qemuAgentDiskInfo **info,
         }
 
         if (info[i]->address) {
+            qemuAgentDiskAddress *address = info[i]->address;
             virDomainDiskDef *diskdef = NULL;
 
+            if (address->serial) {
+                g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+                           "disk.%zu.serial", i);
+                if (virTypedParamsAddString(params, nparams, maxparams,
+                                            param_name, address->serial) < 0)
+                    return;
+            }
+
             /* match the disk to the target in the vm definition */
             diskdef = virDomainDiskByAddress(vmdef,
-                                             &info[i]->address->pci_controller,
-                                             info[i]->address->ccw_addr,
-                                             info[i]->address->bus,
-                                             info[i]->address->target,
-                                             info[i]->address->unit);
+                                             &address->pci_controller,
+                                             address->ccw_addr,
+                                             address->bus,
+                                             address->target,
+                                             address->unit);
             if (diskdef) {
                 g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
                            "disk.%zu.alias", i);