From nobody Mon Feb 9 07:43:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1487877994568376.0562347282373; Thu, 23 Feb 2017 11:26:34 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1NJMUqC008353; Thu, 23 Feb 2017 14:22:30 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1NJLH57001325 for ; Thu, 23 Feb 2017 14:21:17 -0500 Received: from angien.brq.redhat.com (dhcp129-47.brq.redhat.com [10.34.129.47]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1NJL8uZ028635; Thu, 23 Feb 2017 14:21:16 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 23 Feb 2017 20:21:59 +0100 Message-Id: <70fe08de4d2e605f3cc791a5b83d639aac9a2702.1487877253.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [RFC PATCH 06/12] qemu: domain: Add helper to generate indexed backing store names 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The code is currently simple, but if we later add node names, it will be necessary to generate the names based on the node name. Add a helper so that there's a central point to fix once we add self-generated node names. --- src/qemu/qemu_domain.c | 22 ++++++++++++++++++++++ src/qemu/qemu_domain.h | 4 ++++ 2 files changed, 26 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 4b446f1e8..b8a65cfd5 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8319,3 +8319,25 @@ qemuDomainDiskLookupByNodename(virDomainDefPtr def, return NULL; } + + +/** + * qemuDomainDiskBackingStoreGetName: + * + * Creates a name using the indexed syntax (vda[1])for the given backing s= tore + * entry for a disk. + */ +char * +qemuDomainDiskBackingStoreGetName(virDomainDiskDefPtr disk, + virStorageSourcePtr src ATTRIBUTE_UNUSED, + unsigned int idx) +{ + char *ret =3D NULL; + + if (idx) + ignore_value(virAsprintf(&ret, "%s[%d]", disk->dst, idx)); + else + ignore_value(VIR_STRDUP(ret, disk->dst)); + + return ret; +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 03377645f..6e847c7ae 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -855,4 +855,8 @@ virDomainDiskDefPtr qemuDomainDiskLookupByNodename(virD= omainDefPtr def, virStorageSourcePtr *sr= c, unsigned int *idx); +char *qemuDomainDiskBackingStoreGetName(virDomainDiskDefPtr disk, + virStorageSourcePtr src, + unsigned int idx); + #endif /* __QEMU_DOMAIN_H__ */ --=20 2.11.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list