From nobody Mon Feb 9 09:18:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1498224811084847.9086122283144; Fri, 23 Jun 2017 06:33:31 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D889C7F419; Fri, 23 Jun 2017 13:33:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B03153C61; Fri, 23 Jun 2017 13:33:27 +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 1BEFC4E987; Fri, 23 Jun 2017 13:33:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5NDXLq0025161 for ; Fri, 23 Jun 2017 09:33:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 698FC6C418; Fri, 23 Jun 2017 13:33:21 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id A91FD6C410; Fri, 23 Jun 2017 13:33:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D889C7F419 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D889C7F419 From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 23 Jun 2017 15:33:17 +0200 Message-Id: <160b4094429a525877b5a4768349c3528a8b3584.1498224715.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 5/6] qemu: Use storage driver APIs in qemuDomainBlockPeek 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 23 Jun 2017 13:33:28 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Refactor the access to storage driver usage along with qemuDomainStorageFileInit which ensures that we access the file with correct DAC uid/gid. Reviewed-by: John Ferlan --- src/qemu/qemu_driver.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4c4a6a036..115368d1d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -11309,9 +11309,9 @@ qemuDomainBlockPeek(virDomainPtr dom, unsigned int flags) { virQEMUDriverPtr driver =3D dom->conn->privateData; + virDomainDiskDefPtr disk =3D NULL; virDomainObjPtr vm; - int fd =3D -1, ret =3D -1; - const char *actual; + int ret =3D -1; virCheckFlags(0, -1); @@ -11322,32 +11322,23 @@ qemuDomainBlockPeek(virDomainPtr dom, goto cleanup; /* Check the path belongs to this domain. */ - if (!(actual =3D virDomainDiskPathByName(vm->def, path))) { + if (!(disk =3D virDomainDiskByName(vm->def, path, true))) { virReportError(VIR_ERR_INVALID_ARG, - _("invalid path '%s'"), path); + _("invalid disk or path '%s'"), path); goto cleanup; } - path =3D actual; - fd =3D qemuOpenFile(driver, vm, path, O_RDONLY, NULL, NULL); - if (fd < 0) + if (qemuDomainStorageFileInit(driver, vm, disk->src) < 0) goto cleanup; - /* Seek and read. */ - /* NB. Because we configure with AC_SYS_LARGEFILE, off_t should - * be 64 bits on all platforms. - */ - if (lseek(fd, offset, SEEK_SET) =3D=3D (off_t) -1 || - saferead(fd, buffer, size) =3D=3D (ssize_t) -1) { - virReportSystemError(errno, - _("%s: failed to seek or read"), path); + if (virStorageFileRead(disk->src, offset, size, buffer) < 0) goto cleanup; - } ret =3D 0; cleanup: - VIR_FORCE_CLOSE(fd); + if (disk) + virStorageFileDeinit(disk->src); virDomainObjEndAPI(&vm); return ret; } --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list