From nobody Wed May 1 23:01:01 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=1628263506; cv=none; d=zohomail.com; s=zohoarc; b=YKHaxO+s3ZLWKW4mxELn4LVMngWPDtl/SmCUr5e1ixyzmJNVPObJO7kF+NE1DX3rBobUsSjKL+8ivh1UMHQQY4bEo8PhXP4aDYuxtUGJD/OGjLh3r74QFieRTWGdon/dsgoLXVrUiV5g4AOzignzKQ5oGa5SLtr3BBWQ2AVwKDA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628263506; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rRE0uUysuSIEwsHnSM+KaCv5X5VvE/UgtIQKlbvLhho=; b=Ynuv5T56u02CahaRX4RNGsDXQ3iOFpkB2HLb2bk1gfmZ8zI8PHvbBLcHyw4WtgzPZ065jeGFFujUhxnl6//g/1H7lBNkzJdD/Zcz6mmsIrjgOu8NLp5rjXqOIsHqB06oQ2gvSDNutentbEUUBewD6GHBpqtHFExwvk9YsDV8ydU= 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) 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 1628263506507469.21809259031545; Fri, 6 Aug 2021 08:25:06 -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-484-EJ0SDtAHOPC7nb36HP5QEw-1; Fri, 06 Aug 2021 11:24:45 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 00F9B1006C83; Fri, 6 Aug 2021 15:24:41 +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 CD9C71001B2C; Fri, 6 Aug 2021 15:24:40 +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 9DDBC4A7CA; Fri, 6 Aug 2021 15:24:40 +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 176FMi4c017521 for ; Fri, 6 Aug 2021 11:22:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id E658919C87; Fri, 6 Aug 2021 15:22:44 +0000 (UTC) Received: from bart.redhat.com (unknown [10.43.2.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F2AF1346F for ; Fri, 6 Aug 2021 15:22:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628263505; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=rRE0uUysuSIEwsHnSM+KaCv5X5VvE/UgtIQKlbvLhho=; b=hu55u8JEKA+9TcW3SPaJRFZslUmYiMbxnaB4kf9uGi6Vyu8uSLY7WQBdrfwCTyaZPwXEdv WnmHAfyRG4iTibZZWohtbdl+aYUgBO5GwMR32vsfGB+hZ2a1JAp23Y9EYzo4HnrZ6FZ4B1 x+pq0BOsYWWtZPEJL15OVkQnLmAXlmg= X-MC-Unique: EJ0SDtAHOPC7nb36HP5QEw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/4] virDomainDefGetSecurityLabelDef: Fix const correctness Date: Fri, 6 Aug 2021 17:22:35 +0200 Message-Id: <75dee420d8978bb1fd3a8018ee6f638bc28f05d4.1628263276.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.84 on 10.5.11.22 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) X-ZM-MESSAGEID: 1628263507181100001 Content-Type: text/plain; charset="utf-8" The function doesn't write to domain definition really so make @def argument as const. This allows us to call it from functions where the domain definition is already const. Signed-off-by: Michal Privoznik Reviewed-by: Pavel Hrdina Tested-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 2 +- src/conf/domain_conf.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3415e28b95..14abd527b6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29483,7 +29483,7 @@ virDomainDeviceDefCopy(virDomainDeviceDef *src, =20 =20 virSecurityLabelDef * -virDomainDefGetSecurityLabelDef(virDomainDef *def, const char *model) +virDomainDefGetSecurityLabelDef(const virDomainDef *def, const char *model) { size_t i; virSecurityLabelDef *seclabel =3D NULL; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9f32bcf9cf..984939cc69 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3776,7 +3776,7 @@ virDomainObjGetState(virDomainObj *obj, int *reason) ATTRIBUTE_NONNULL(1); =20 virSecurityLabelDef * -virDomainDefGetSecurityLabelDef(virDomainDef *def, const char *model); +virDomainDefGetSecurityLabelDef(const virDomainDef *def, const char *model= ); =20 virSecurityDeviceLabelDef * virDomainChrSourceDefGetSecurityLabelDef(virDomainChrSourceDef *def, --=20 2.31.1 From nobody Wed May 1 23:01:01 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=1628263490; cv=none; d=zohomail.com; s=zohoarc; b=Ml1NdLGLLeB0aHPLeyi+Jz0CRW8MGb8/zMk1L+Uxq/wd2QA2cRYy5SOQ2Zn70cWNOL13TgFdKRHFZeVnjeobsY6k9pAJeLPhPUoLi4o5Yo4N23EwJyNbXJ9GTsV+pYzTt2qohY36VcF9b7dvlaPFCC54covQVN2IqlAW2USkhRY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628263490; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=w/KStEvmePiDU3PecZMKEWfd9oQs1/PhTiltCa0ctng=; b=LdbfR9yyhIcVh+eRaAQuEjX/EMEkXjelP6sCVkSS73WSWQ+/wxAqTYR2PnwihsbOuDHzwQ/H+ZbplkNsON7Pm+WGh0ONBRAwK/FOAF1lcehMxOSnipBOZDrCigA4lAkfxwRSJrznuFDk8rhGX9iYhsVom/Tq1APR2yXC9RiUW6g= 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) 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 1628263490948116.40375597421189; Fri, 6 Aug 2021 08:24:50 -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-320-z6glSQ1JMH6_tSCYH0cfBA-1; Fri, 06 Aug 2021 11:24:48 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 62984107ACF5; Fri, 6 Aug 2021 15:24:43 +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 481761981C; Fri, 6 Aug 2021 15:24:43 +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 1307F180BAB3; Fri, 6 Aug 2021 15:24:43 +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 176FMj3W017526 for ; Fri, 6 Aug 2021 11:22:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id B4B641346F; Fri, 6 Aug 2021 15:22:45 +0000 (UTC) Received: from bart.redhat.com (unknown [10.43.2.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3ECD219CBA for ; Fri, 6 Aug 2021 15:22:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628263489; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=w/KStEvmePiDU3PecZMKEWfd9oQs1/PhTiltCa0ctng=; b=KRN9HbXuKLxuWKcN6HjXSRGtAmtPik/N5nGlsdgz/7/M6yA0WRhrRTXeRMf5qcdUKpry5M iwQY0vn7wq+abqRS2qXsiTP0hqVK24i1nkDoQT63nz8+o1nR3YomAl5UFzDbtE12KeIBv1 bFwS2gDbBrcAxXcNOwcsR5eVohn6XX0= X-MC-Unique: z6glSQ1JMH6_tSCYH0cfBA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/4] qemuDomainOpenFile: Take virDomainDef instead of virDomainObj Date: Fri, 6 Aug 2021 17:22:36 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.11 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) X-ZM-MESSAGEID: 1628263491718100001 Content-Type: text/plain; charset="utf-8" The function doesn't really need domain object, but domain definition from which it takes seclabels. Signed-off-by: Michal Privoznik Reviewed-by: Pavel Hrdina Tested-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 8 ++++---- src/qemu/qemu_domain.h | 2 +- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_saveimage.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6f8c93ea0c..5a88e82856 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11503,7 +11503,7 @@ virQEMUFileOpenAs(uid_t fallback_uid, /** * qemuDomainOpenFile: * @driver: driver object - * @vm: domain object + * @def: domain definition * @path: path to file to open * @oflags: flags for opening/creation of the file * @needUnlink: set to true if file was created by this function @@ -11518,7 +11518,7 @@ virQEMUFileOpenAs(uid_t fallback_uid, **/ int qemuDomainOpenFile(virQEMUDriver *driver, - virDomainObj *vm, + const virDomainDef *def, const char *path, int oflags, bool *needUnlink) @@ -11530,8 +11530,8 @@ qemuDomainOpenFile(virQEMUDriver *driver, virSecurityLabelDef *seclabel; =20 /* TODO: Take imagelabel into account? */ - if (vm && - (seclabel =3D virDomainDefGetSecurityLabelDef(vm->def, "dac")) != =3D NULL && + if (def && + (seclabel =3D virDomainDefGetSecurityLabelDef(def, "dac")) !=3D NU= LL && seclabel->label !=3D NULL && (virParseOwnershipIds(seclabel->label, &user, &group) < 0)) return -EINVAL; diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index acf6ca5ab6..63f657fa49 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1046,7 +1046,7 @@ int virQEMUFileOpenAs(uid_t fallback_uid, =20 int qemuDomainOpenFile(virQEMUDriver *driver, - virDomainObj *vm, + const virDomainDef *def, const char *path, int oflags, bool *needUnlink); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a7d76dd00f..d432c69dae 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10820,7 +10820,7 @@ qemuDomainStorageOpenStat(virQEMUDriver *driver, if (skipInaccessible && !virFileExists(src->path)) return 0; =20 - if ((*ret_fd =3D qemuDomainOpenFile(driver, vm, src->path, O_RDONL= Y, + if ((*ret_fd =3D qemuDomainOpenFile(driver, vm->def, src->path, O_= RDONLY, NULL)) < 0) return -1; =20 diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index b4af80f942..f93454c761 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -313,7 +313,7 @@ qemuSaveImageCreate(virQEMUDriver *driver, if (qemuDomainFileWrapperFDClose(vm, wrapperFd) < 0) goto cleanup; =20 - if ((fd =3D qemuDomainOpenFile(driver, vm, path, O_WRONLY, NULL)) < 0 = || + if ((fd =3D qemuDomainOpenFile(driver, vm->def, path, O_WRONLY, NULL))= < 0 || virQEMUSaveDataFinish(data, &fd, path) < 0) goto cleanup; =20 --=20 2.31.1 From nobody Wed May 1 23:01:01 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=1628263494; cv=none; d=zohomail.com; s=zohoarc; b=I7abDeV/eBE1s3MvyPRSbbzlAZaXIbMq8YCsRfnQo2WIg7fdnkBFcldTWfcNsHSMFRtica7+Z6ftZnEp6Ev1Z5L6Ij8YqvAQkWPEXkJTTBT7O9Fe9gp6pnY+aoUYCsRmhCpdxhyM39VdCmkYA7Aqy9ThGZAYKdEWYHZSOIShiIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628263494; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=q/x4vy0EfeiX9de46WdJKnsIB6Qsy7dir4jh2IX/bEc=; b=awXZIzCm7aNiHKYKWRu2pcWiPjWY3Z33/rtto5D0sWwh2F1XA0xn5XKx96I3s+Uk9AzkrcrDRbCYesojRao6negJwzQCEgCUAB3+ydYFdH95Y4RpkvjJC6IqMfQXWoaa7eM3qdBe45A7LYDvZMH4Uyv2T/QRTSxIatGrbG5k7PU= 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) 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 1628263494323471.4611809005454; Fri, 6 Aug 2021 08:24:54 -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-278-kN_dVGOyMnWd9mGyPbYXPg-1; Fri, 06 Aug 2021 11:24:51 -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 8FA25185302C; Fri, 6 Aug 2021 15:24:46 +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 6A49F69321; Fri, 6 Aug 2021 15:24:46 +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 38C794A7CB; Fri, 6 Aug 2021 15:24:46 +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 176FMkp6017539 for ; Fri, 6 Aug 2021 11:22:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 844D519C87; Fri, 6 Aug 2021 15:22:46 +0000 (UTC) Received: from bart.redhat.com (unknown [10.43.2.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E3BC1346F for ; Fri, 6 Aug 2021 15:22:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628263493; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=q/x4vy0EfeiX9de46WdJKnsIB6Qsy7dir4jh2IX/bEc=; b=MGw/U0Z4J17XWDyphJ2o82OaeMq5To/ViqN5PUO0Ryp1SfbIQuzYMfXxkXyH46US5KqHLT q3OvXMIFfbXHk7ySWdiJMCIee6aBCB9fVCvCB4eZxaeFGXYh05Ivgml29bGB7M48Cat6Bk a2YnpZjcjr2G0AsbXMDojr6lXwF0vC4= X-MC-Unique: kN_dVGOyMnWd9mGyPbYXPg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/4] qemuDomainOpenFile: Take @cfg instead of driver Date: Fri, 6 Aug 2021 17:22:37 +0200 Message-Id: <440bad6b9d12daa9037d0aad9ea0165efd8639f7.1628263276.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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) X-ZM-MESSAGEID: 1628263496231100001 Content-Type: text/plain; charset="utf-8" Again, we don't need full driver, just its config. Signed-off-by: Michal Privoznik Reviewed-by: Pavel Hrdina Tested-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 5 ++--- src/qemu/qemu_domain.h | 2 +- src/qemu/qemu_driver.c | 4 ++-- src/qemu/qemu_saveimage.c | 5 +++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 5a88e82856..2aa346744d 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11502,7 +11502,7 @@ virQEMUFileOpenAs(uid_t fallback_uid, =20 /** * qemuDomainOpenFile: - * @driver: driver object + * @cfg: driver config object * @def: domain definition * @path: path to file to open * @oflags: flags for opening/creation of the file @@ -11517,13 +11517,12 @@ virQEMUFileOpenAs(uid_t fallback_uid, * qemuDomainStorageFileInit and storage driver APIs if possible. **/ int -qemuDomainOpenFile(virQEMUDriver *driver, +qemuDomainOpenFile(virQEMUDriverConfig *cfg, const virDomainDef *def, const char *path, int oflags, bool *needUnlink) { - g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); uid_t user =3D cfg->user; gid_t group =3D cfg->group; bool dynamicOwnership =3D cfg->dynamicOwnership; diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 63f657fa49..d470dc3822 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1045,7 +1045,7 @@ int virQEMUFileOpenAs(uid_t fallback_uid, bool *needUnlink); =20 int -qemuDomainOpenFile(virQEMUDriver *driver, +qemuDomainOpenFile(virQEMUDriverConfig *cfg, const virDomainDef *def, const char *path, int oflags, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d432c69dae..ed3af5a619 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10808,7 +10808,7 @@ qemuDomainMemoryPeek(virDomainPtr dom, * reported) or -1 otherwise (errors are reported). */ static int -qemuDomainStorageOpenStat(virQEMUDriver *driver, +qemuDomainStorageOpenStat(virQEMUDriver *driver G_GNUC_UNUSED, virQEMUDriverConfig *cfg, virDomainObj *vm, virStorageSource *src, @@ -10820,7 +10820,7 @@ qemuDomainStorageOpenStat(virQEMUDriver *driver, if (skipInaccessible && !virFileExists(src->path)) return 0; =20 - if ((*ret_fd =3D qemuDomainOpenFile(driver, vm->def, src->path, O_= RDONLY, + if ((*ret_fd =3D qemuDomainOpenFile(cfg, vm->def, src->path, O_RDO= NLY, NULL)) < 0) return -1; =20 diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index f93454c761..e14e2987f1 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -313,7 +313,7 @@ qemuSaveImageCreate(virQEMUDriver *driver, if (qemuDomainFileWrapperFDClose(vm, wrapperFd) < 0) goto cleanup; =20 - if ((fd =3D qemuDomainOpenFile(driver, vm->def, path, O_WRONLY, NULL))= < 0 || + if ((fd =3D qemuDomainOpenFile(cfg, vm->def, path, O_WRONLY, NULL)) < = 0 || virQEMUSaveDataFinish(data, &fd, path) < 0) goto cleanup; =20 @@ -440,6 +440,7 @@ qemuSaveImageOpen(virQEMUDriver *driver, bool open_write, bool unlink_corrupt) { + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); VIR_AUTOCLOSE fd =3D -1; int ret =3D -1; g_autoptr(virQEMUSaveData) data =3D NULL; @@ -459,7 +460,7 @@ qemuSaveImageOpen(virQEMUDriver *driver, oflags |=3D directFlag; } =20 - if ((fd =3D qemuDomainOpenFile(driver, NULL, path, oflags, NULL)) < 0) + if ((fd =3D qemuDomainOpenFile(cfg, NULL, path, oflags, NULL)) < 0) return -1; =20 if (bypass_cache && --=20 2.31.1 From nobody Wed May 1 23:01:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1628263478; cv=none; d=zohomail.com; s=zohoarc; b=VG2Z3BseOMdxH+4E2T7305EMRiya2b0Rl/fAfriAZ2GTW+i2m89SMY8f+4yD8UqV+S1MUV3wi6KStqw2HOTSwpePW+ST1M3lQUUwykW2OMge5R6DCwyAl/Om95UCm0BfMWj7iTwhsfBUuT3oVAo7aE1q+eHPL+Y3FQ/DkaJdByc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628263478; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ivjvGNDWTkLbLhuPmwcIfgJ4Bku4bv5dZkA9Ts9C5t4=; b=PSlltXQ9wxAUd6S+nTcA5NTKxDRAJICapHiLKgS+CDAmTmnRqAOnamxHuQF0/E5UkckNsE6t7dLl0OPK7Tqs92IOEE7Rd3mcLNtmmZkk66iFnwSYw8SLPr8fLr77RFsWelxwVPWB8D5bIJxQzWaAo9dZkft2kCCIQN4TDsKL2Pg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1628263478092162.55326704719187; Fri, 6 Aug 2021 08:24:38 -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-489-MuMpattkOvKw10v-bwOiuw-1; Fri, 06 Aug 2021 11:24:35 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 888071800D41; Fri, 6 Aug 2021 15:24:29 +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 1F940779D0; Fri, 6 Aug 2021 15:24:29 +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 3FB75180BAB1; Fri, 6 Aug 2021 15:24: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 176FMlJC017545 for ; Fri, 6 Aug 2021 11:22:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 52AD21981C; Fri, 6 Aug 2021 15:22:47 +0000 (UTC) Received: from bart.redhat.com (unknown [10.43.2.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0BF81346F for ; Fri, 6 Aug 2021 15:22:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628263477; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ivjvGNDWTkLbLhuPmwcIfgJ4Bku4bv5dZkA9Ts9C5t4=; b=T0IClNLzZsMqTY+BJt+MmJL8BoRnI+lGQXxd4i1eFkOaDSJodGOEDkKzKAwTcNHQbWZSpR 1OrAn3IZvxXBQoFHGKJPncO6ihay6v0TrwHE/DLlgePYhm55DwDQGf5YO13+J5L6vNHmeV WVOJ+VLn4bXbyDTeT+x0t2wFgitPYu8= X-MC-Unique: MuMpattkOvKw10v-bwOiuw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/4] qemu: Open chardev logfile on behalf of QEMU Date: Fri, 6 Aug 2021 17:22:38 +0200 Message-Id: <012fa15a219cb545674aba8028d7e21224171eef.1628263276.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.13 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) X-ZM-MESSAGEID: 1628263478470100001 Content-Type: text/plain; charset="utf-8" If the QEMU driver is configured to use the old "file" stdio handler (meaning virtlogd is out of the picture) and a chardev has a log file configured we rely on QEMU being able to create the file itself. This may not be always possible (e.g. if the logfile is set to a directory that QEMU process can't reach). In such case we should create the file and just pass its FD to QEMU. We could do that unconditionally and just either pass FD from virtlogd or the one we opened, because we bumped QEMU version and are now requiring new enough QEMU. However, I'm keeping the old style where logfile is appended on the cmd line for the tests sake. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1989457 Signed-off-by: Michal Privoznik Reviewed-by: Pavel Hrdina Tested-by: J=C3=A1n Tomko --- I don't like the typecast in qemuSecuritySetImageFDLabel() call, but fixing that turned out to be not trivial, so I left it as is. src/qemu/qemu_command.c | 68 ++++++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 4381ea7d8b..3aca2bb177 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4702,30 +4702,63 @@ qemuBuildSCSIHostdevDevStr(const virDomainDef *def, =20 static int qemuBuildChrChardevFileStr(virLogManager *logManager, - virCommand *cmd, + virSecurityManager *secManager, + virQEMUDriverConfig *cfg, + virQEMUCaps *qemuCaps, const virDomainDef *def, + virCommand *cmd, virBuffer *buf, const char *filearg, const char *fileval, const char *appendarg, int appendval) { - if (logManager) { + /* Technically, to pass an FD via /dev/fdset we don't need + * any capability check because X_QEMU_CAPS_ADD_FD is already + * assumed. But keeping the old style is still handy when + * building a standalone command line (e.g. for tests). */ + if (logManager || + virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS)) { g_autofree char *fdset =3D NULL; - int flags =3D 0; int logfd; size_t idx; =20 - if (appendval =3D=3D VIR_TRISTATE_SWITCH_ABSENT || - appendval =3D=3D VIR_TRISTATE_SWITCH_OFF) - flags |=3D VIR_LOG_MANAGER_PROTOCOL_DOMAIN_OPEN_LOG_FILE_TRUNC= ATE; - - if ((logfd =3D virLogManagerDomainOpenLogFile(logManager, - "qemu", - def->uuid, - def->name, - fileval, - flags, - NULL, NULL)) < 0) - return -1; + if (logManager) { + int flags =3D 0; + + if (appendval =3D=3D VIR_TRISTATE_SWITCH_ABSENT || + appendval =3D=3D VIR_TRISTATE_SWITCH_OFF) + flags |=3D VIR_LOG_MANAGER_PROTOCOL_DOMAIN_OPEN_LOG_FILE_T= RUNCATE; + + if ((logfd =3D virLogManagerDomainOpenLogFile(logManager, + "qemu", + def->uuid, + def->name, + fileval, + flags, + NULL, NULL)) < 0) + return -1; + } else { + int oflags =3D O_CREAT | O_WRONLY; + + switch (appendval) { + case VIR_TRISTATE_SWITCH_ABSENT: + case VIR_TRISTATE_SWITCH_OFF: + oflags |=3D O_TRUNC; + break; + case VIR_TRISTATE_SWITCH_ON: + oflags |=3D O_APPEND; + break; + case VIR_TRISTATE_SWITCH_LAST: + break; + } + + if ((logfd =3D qemuDomainOpenFile(cfg, def, fileval, oflags, N= ULL)) < 0) + return -1; + + if (qemuSecuritySetImageFDLabel(secManager, (virDomainDef*)def= , logfd) < 0) { + VIR_FORCE_CLOSE(logfd); + return -1; + } + } =20 virCommandPassFDIndex(cmd, logfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT= , &idx); fdset =3D qemuBuildFDSet(logfd, idx); @@ -4868,7 +4901,7 @@ qemuBuildChrChardevStr(virLogManager *logManager, =20 if (qemuBuildChrChardevFileStr(cdevflags & QEMU_BUILD_CHARDEV_FILE= _LOGD ? logManager : NULL, - cmd, def, &buf, + secManager, cfg, qemuCaps, def, cmd= , &buf, "path", dev->data.file.path, "append", dev->data.file.append) < = 0) return NULL; @@ -5004,7 +5037,8 @@ qemuBuildChrChardevStr(virLogManager *logManager, } =20 if (dev->logfile) { - if (qemuBuildChrChardevFileStr(logManager, cmd, def, &buf, + if (qemuBuildChrChardevFileStr(logManager, secManager, cfg, + qemuCaps, def, cmd, &buf, "logfile", dev->logfile, "logappend", dev->logappend) < 0) return NULL; --=20 2.31.1