From nobody Mon Apr 29 15:22:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 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=1574243531; cv=none; d=zoho.com; s=zohoarc; b=l0kBAb9NVYq5BUIcYE/a5GuCDtolnw6eXuwMJFTgYkFwTl7+qol+Ky10XNaugoKvN6B5W1/gfP1VNlk0pvO4bcBTMrLRgjrUPnh5ZWBCaXby1MfpWrigZBUFuk7MOMLMvtfhW2m+dLHxE3GnTdWLCbD0gYmzT+vIa14b0fx2ssU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574243531; 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=C8NSU1Qjm9cxMcYPRtpO4qJ/GPFm0RVCVztq/kTtdlk=; b=Gd0o9dZixnpxRiESaEeucP3w3Fzz3WvvWEN94t89gKB3XgzSrsfc1TK+dAr/h+1zmljEtXzrxg0KWR/baN3IJpZ02PFMzDrBo4H2yGqp77lxV49g6Ju7qKrjutsxTDZJf3c0P8hpUf4hgkOlCXx89xC/YgiSDOtilclkmM1VNwc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 157424353129099.29471319465063; Wed, 20 Nov 2019 01:52:11 -0800 (PST) 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-251-Cd0Jz3iHMzqNkPULJ0MObg-1; Wed, 20 Nov 2019 04:52:07 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6C4CA801E6A; Wed, 20 Nov 2019 09:51:59 +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 443A94D9F7; Wed, 20 Nov 2019 09:51:58 +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 6F89D4BB65; Wed, 20 Nov 2019 09:51:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xAK9prkm025626 for ; Wed, 20 Nov 2019 04:51:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id 87AA65F790; Wed, 20 Nov 2019 09:51:53 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1124763BCB for ; Wed, 20 Nov 2019 09:51:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574243530; 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=C8NSU1Qjm9cxMcYPRtpO4qJ/GPFm0RVCVztq/kTtdlk=; b=L7e5Hepd9+loBg7Iv5e0Wk2/Jw3qjHh1pMjtIUmTGCJ6hplPzB6cAZhzhnkYwYh7tcpRDa 8e+PLzl7rFgQaC4kpiuRoa8sDLW5Z6p20X9Nzq95EO2mNMmhFM6EitahDeQ6Ac9PMfLitd h0rQiizSpahM5cpv15wWTlzcbjbCZZ0= From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 20 Nov 2019 10:51:47 +0100 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemu: Forcibly mknod() even if it exists 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.16 X-MC-Unique: Cd0Jz3iHMzqNkPULJ0MObg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Another weird bug appeared concerning qemu namespaces. Basically the problem is as follows: 1) Issue an API that causes libvirt to create a node in domain's namespace, say /dev/sda with 8:0 as major:minor (the API can be attach-disk for instance). Or simply create the node from a console by hand. 2) Detach the disk from qemu. 3) Do something that makes /dev/sda change it's minor number. 4) Try to attach the disk again. The problem is, in a few cases - like disk-detach - we don't remove the corresponding /dev node from the mount namespace (because it may be used by some other disk's backing chain). But this creates a problem, because if the node changes its MAJ:MIN numbers we don't propagate the change into the domain's namespace. We do plain mknod() and ignore EEXIST which obviously is not enough because it doesn't guarantee that the node has updated MAJ:MIN pair. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1752978 Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_domain.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 262b74d1ab..f54b9b21ff 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -13203,16 +13203,14 @@ qemuDomainCreateDeviceRecursive(const char *devic= e, allow_noent, ttl - 1) < 0) goto cleanup; } else if (isDev) { - if (create && - mknod(devicePath, sb.st_mode, sb.st_rdev) < 0) { - if (errno =3D=3D EEXIST) { - ret =3D 0; - } else { + if (create) { + unlink(devicePath); + if (mknod(devicePath, sb.st_mode, sb.st_rdev) < 0) { virReportSystemError(errno, _("Failed to make device %s"), devicePath); + goto cleanup; } - goto cleanup; } } else if (isReg) { if (create && @@ -13996,17 +13994,12 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid G_GNU= C_UNUSED, } else if (isDev) { VIR_DEBUG("Creating dev %s (%d,%d)", data->file, major(data->sb.st_rdev), minor(data->sb.st_r= dev)); + unlink(data->file); if (mknod(data->file, data->sb.st_mode, data->sb.st_rdev) < 0) { - /* Because we are not removing devices on hotunplug, or - * we might be creating part of backing chain that - * already exist due to a different disk plugged to - * domain, accept EEXIST. */ - if (errno !=3D EEXIST) { - virReportSystemError(errno, - _("Unable to create device %s"), - data->file); - goto cleanup; - } + virReportSystemError(errno, + _("Unable to create device %s"), + data->file); + goto cleanup; } else { delDevice =3D true; } --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list