From nobody Fri May 17 08:24:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1618393920; cv=none; d=zohomail.com; s=zohoarc; b=U3iDrvEGKGH0JkCjR60yoerZKWLdTQ//W8hyFmy/tDLkVST80kUkA2bTbRnMphsxn3/d5q8OabZ77WcEi0U6oniw06N1b6HOuQc7R/O9c8u/h6Z5qT/x+7S7vdd7kB6LaNOtJW7R2LRjanjK4RD/API95TY3htmrFihUIPmP0b0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618393920; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=RPiZ3KLjcxnLpNKjmBRVhR+98M4nOEdqhei3px2PY4c=; b=Qm83WqJthGrZSypw8ny/SjTUaVQhyFZG6rjgis4YGjco2SqpJpf3C4Rl6aLS60076gLuv3n/H5OzDWOZkbbUzHAXz5k3khD9eplxuhaVitoY6nsmgulIro2h005w0JEZgyZjNrHyUR0hAyfQZPVThcDpJr5aduh+hCq+u6UatUo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1618393920375284.91004004819774; Wed, 14 Apr 2021 02:52:00 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-464--bEGSL_5N_Gyry_an_C__g-1; Wed, 14 Apr 2021 05:51:56 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1453187A826; Wed, 14 Apr 2021 09:51:52 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 39CCA5D71D; Wed, 14 Apr 2021 09:51:49 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7B9691806D0F; Wed, 14 Apr 2021 09:51:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13E9pkOc025296 for ; Wed, 14 Apr 2021 05:51:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5B1E76F985; Wed, 14 Apr 2021 09:51:46 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.214]) by smtp.corp.redhat.com (Postfix) with ESMTP id D38A914106 for ; Wed, 14 Apr 2021 09:51:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618393919; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=RPiZ3KLjcxnLpNKjmBRVhR+98M4nOEdqhei3px2PY4c=; b=bkFOCw5/WEq2CGafNeY/hSZK7RasdJMCwreK7mN3mY0HedyR7Bhy1VDtDOEoJOSfqKor3p Hg5SzOqiOWo0iXOjsW3SMIitrhpxTASHf5omhQnGJ9f3oq0mGEWkTm/OTNXfrq2hC1IYy6 FwYlHOW/JnypvqAbgx4vRQ7ispuUwyI= X-MC-Unique: -bEGSL_5N_Gyry_an_C__g-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2] qemu: Expose disk serial in virDomainGetGuestInfo() Date: Wed, 14 Apr 2021 11:51:39 +0200 Message-Id: <4112bc6f6c53f2894c0a2d93f5f31e8dff7140ab.1618393840.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 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 Reviewed-By: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD Reviewed-by: Peter Krempa --- v2 of: https://listman.redhat.com/archives/libvir-list/2021-April/msg00552.html diff to v1: - Filled virsh documentation - Documented that the param is optional and type of string docs/manpages/virsh.rst | 1 + src/libvirt-domain.c | 1 + src/qemu/qemu_driver.c | 19 ++++++++++++++----- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 813fb0bd60..bccda292a2 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -2787,6 +2787,7 @@ returned: * ``disk..partition`` - whether this is a partition or disk * ``disk..dependency.count`` - the number of device dependencies * ``disk..dependency..name`` - a dependency name +* ``disk..serial`` - optional disk serial number * ``disk..alias`` - the device alias of the disk (e.g. sda) * ``disk..guest_alias`` - optional alias assigned to the disk =20 diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 83ff7df9fe..509b7a6d88 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 th= is will * contain the disk where the volume is placed. (Linu= x) * "disk..dependency..name" - a dependency + * "disk..serial" - optional disk serial number (as string) * "disk..alias" - the device alias of the disk (e.g. sda) * "disk..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, } =20 if (info[i]->address) { + qemuAgentDiskAddress *address =3D info[i]->address; virDomainDiskDef *diskdef =3D NULL; =20 + 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 =3D virDomainDiskByAddress(vmdef, - &info[i]->address->pci_contro= ller, - 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); --=20 2.26.3