From nobody Mon Feb 9 22:39:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1679491809; cv=none; d=zohomail.com; s=zohoarc; b=RkkIzDkhk/rxSXkobXSmoYAPYlnWhSToGAzEHExkIuP+88Fqd0kTTvGHEew6JuBTNn/MhWqczAfp9c2ZB3RfSEIanXBui4Rn5GGNeXcawc3Mf4Agvp6ZgACrLFEniVPa2smN/KFraPf3P1PTmxuKHT6vZaZSrmzKp8ASv5yynPU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679491809; 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=nCs0SUqsJNUzto9Rm0kuA1TIHwWnYAE7/AKJWWGvQUo=; b=g5ZU7a8w1TpJAluuOTEF8wQxyGYhyZyMAE+t9F4d40I+M9s/l696mCaEZaEBM84ZzV96SZ9ElnkMk9RZNS2Ja3fmV6zkfkVjCiM2c2oKATGDuDw7PEy0y+5Lc8H7ylg4uoL/ddLtJAxuuZLlbvTx573ZaN3vTwN1sECN3469S3E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1679491809098570.0460663186693; Wed, 22 Mar 2023 06:30:09 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-151-awlcBmnhMCOMJ6_MRi-Z0w-1; Wed, 22 Mar 2023 09:30:06 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ABC8E884EC8; Wed, 22 Mar 2023 13:29:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id DCF79140EBF4; Wed, 22 Mar 2023 13:29:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id ACA2319465BC; Wed, 22 Mar 2023 13:29:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5C0D719465BA for ; Wed, 22 Mar 2023 13:22:58 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3B7971731B; Wed, 22 Mar 2023 13:22:58 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5FF444037 for ; Wed, 22 Mar 2023 13:22:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679491808; 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=nCs0SUqsJNUzto9Rm0kuA1TIHwWnYAE7/AKJWWGvQUo=; b=A/NecBpne40r3J4ZO9dLnCDBSRkpG+A4WUfWNbNvMqSvldDUo7scI/qCaFEgczWt3t4pyL k0ieUjkA208RN5cUGaNB4YoiSgcIIxlh0UIaj24BnI5wiM6L0MNDb20Ywx2x/Fpyf06s83 qUaVivBUSayMbpKQA9am3YRsFDHUS+g= X-MC-Unique: awlcBmnhMCOMJ6_MRi-Z0w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] qemu_shim: Require absolute path for root directory Date: Wed, 22 Mar 2023 14:22:55 +0100 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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: 1679491809679100001 Content-Type: text/plain; charset="utf-8"; x-default="true" The virConnectOpen(), well virConnectOpenInternal() reports an error if embed root is not an absolute path. This is a fair requirement, but our qemu_shim doesn't check this requirement and instead mkdir()-s passed path only to fail later on, leaving the empty directory behind: $ ls -d asd ls: cannot access 'asd': No such file or directory $ virt-qemu-run -r asd whatever.xml virt-qemu-run: cannot open qemu:///embed?root=3Dasd: unsupported configur= ation: root path must be absolute $ ls -d asd asd Signed-off-by: Michal Privoznik Reviewed-by: Kristina Hanicova --- src/qemu/qemu_shim.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_shim.c b/src/qemu/qemu_shim.c index 7b58583074..33a6aa7d94 100644 --- a/src/qemu/qemu_shim.c +++ b/src/qemu/qemu_shim.c @@ -209,10 +209,18 @@ int main(int argc, char **argv) } tmproot =3D true; =20 - } else if (g_mkdir_with_parents(root, 0755) < 0) { - g_printerr("%s: cannot create dir: %s\n", - argv[0], g_strerror(errno)); - goto cleanup; + } else { + if (!g_path_is_absolute(root)) { + g_printerr("%s: the root directory must be an absolute path\n", + argv[0]); + goto cleanup; + } + + if (g_mkdir_with_parents(root, 0755) < 0) { + g_printerr("%s: cannot create dir: %s\n", + argv[0], g_strerror(errno)); + goto cleanup; + } } =20 if (chmod(root, 0755) < 0) { --=20 2.39.2