[PATCH] qemu: Expose disk serial in virDomainGetGuestInfo()

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> --- src/libvirt-domain.c | 1 + src/qemu/qemu_driver.c | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 83ff7df9fe..1c244da650 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -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" - 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, on Linux * this is a name assigned by device mapper diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 90b5477f00..88ee9e5d5e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -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); -- 2.26.3

On Wed, Apr 14, 2021 at 10:15:14 +0200, Michal Privoznik wrote:
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> --- src/libvirt-domain.c | 1 + src/qemu/qemu_driver.c | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 83ff7df9fe..1c244da650 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -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" - disk serial number
It's a string though, so s/number/string/ perhaps. Also it's optional.
* "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
Missing virsh manpage update.
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 90b5477f00..88ee9e5d5e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c

On 4/14/21 10:56 AM, Peter Krempa wrote:
On Wed, Apr 14, 2021 at 10:15:14 +0200, Michal Privoznik wrote:
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> --- src/libvirt-domain.c | 1 + src/qemu/qemu_driver.c | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 83ff7df9fe..1c244da650 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -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" - disk serial number
It's a string though, so s/number/string/ perhaps. Also it's optional.
Ah, good point.
* "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
Missing virsh manpage update.
I had feeling that I forgot something :-) Let me respin. Michal
participants (2)
-
Michal Privoznik
-
Peter Krempa