From nobody Thu May 2 17:10:46 2024 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.zohomail.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 1499791363626302.00067920647234; Tue, 11 Jul 2017 09:42:43 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 26D5788E60; Tue, 11 Jul 2017 16:42:39 +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 3696060657; Tue, 11 Jul 2017 16:42:38 +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 EF1DE41F76; Tue, 11 Jul 2017 16:42:35 +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 v6BGgYWx016571 for ; Tue, 11 Jul 2017 12:42:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 483F019157; Tue, 11 Jul 2017 16:42:34 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id C51BC18A8E for ; Tue, 11 Jul 2017 16:42:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 26D5788E60 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 26D5788E60 From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 11 Jul 2017 18:42:29 +0200 Message-Id: <1c36719340eaef63b497e7289d8967b8fbd4f178.1499791349.git.mprivozn@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemu: Provide non-linux stub for qemuDomainAttachDeviceMknodRecursive 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 11 Jul 2017 16:42:40 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The way we create devices under /dev is highly linux specific. For instance we do mknod(), mount(), umount(), etc. Some platforms are even missing some of these functions. Then again, as declared in qemuDomainNamespaceAvailable(): namespaces are linux only. Therefore, to avoid obfuscating the code by trying to make it compile on weird platforms, just provide a non-linux stub for qemuDomainAttachDeviceMknodRecursive(). At the same time, qemuDomainAttachDeviceMknodHelper() which actually calls the non-existent functions is moved under ifdef __linux__ block since its only caller is in that block too. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrange --- src/qemu/qemu_domain.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 080ff336e..eb1a9794b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8541,6 +8541,8 @@ struct qemuDomainAttachDeviceMknodData { }; =20 =20 +/* Our way of creating devices is highly linux specific */ +#if defined(__linux__) static int qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE_UNUSED, void *opaque) @@ -8638,7 +8640,7 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE= _UNUSED, goto cleanup; } =20 -#ifdef WITH_SELINUX +# ifdef WITH_SELINUX if (data->tcon && lsetfilecon_raw(data->file, (VIR_SELINUX_CTX_CONST char *) data->t= con) < 0) { VIR_WARNINGS_NO_WLOGICALOP_EQUAL_EXPR @@ -8650,7 +8652,7 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE= _UNUSED, goto cleanup; } } -#endif +# endif =20 /* Finish mount process started earlier. */ if (isReg && @@ -8661,9 +8663,9 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE= _UNUSED, cleanup: if (ret < 0 && delDevice) unlink(data->file); -#ifdef WITH_SELINUX +# ifdef WITH_SELINUX freecon(data->tcon); -#endif +# endif virFileFreeACLs(&data->acl); return ret; } @@ -8754,14 +8756,14 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverP= tr driver, goto cleanup; } =20 -#ifdef WITH_SELINUX +# ifdef WITH_SELINUX if (lgetfilecon_raw(file, &data.tcon) < 0 && (errno !=3D ENOTSUP && errno !=3D ENODATA)) { virReportSystemError(errno, _("Unable to get SELinux label from %s"), fil= e); goto cleanup; } -#endif +# endif =20 if (STRPREFIX(file, DEVPREFIX)) { size_t i; @@ -8798,9 +8800,9 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr= driver, =20 ret =3D 0; cleanup: -#ifdef WITH_SELINUX +# ifdef WITH_SELINUX freecon(data.tcon); -#endif +# endif virFileFreeACLs(&data.acl); if (isReg && target) umount(target); @@ -8810,6 +8812,26 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPt= r driver, } =20 =20 +#else /* !defined(__linux__) */ + + +static int +qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver ATTRIBUTE_UNU= SED, + virDomainObjPtr vm ATTRIBUTE_UNUSED, + const char *file ATTRIBUTE_UNUSED, + char * const *devMountsPath ATTRIBUTE= _UNUSED, + size_t ndevMountsPath ATTRIBUTE_UNUSE= D, + unsigned int ttl ATTRIBUTE_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", + _("Namespaces are not supported on this platform.= ")); + return -1; +} + + +#endif /* !defined(__linux__) */ + + static int qemuDomainAttachDeviceMknod(virQEMUDriverPtr driver, virDomainObjPtr vm, --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list