From nobody Mon May 6 06:49:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599403644; cv=none; d=zohomail.com; s=zohoarc; b=E/2Aq5E4+5fRFI7lidZ+xHMkzOiF6yWT1BUc+V0seL01mq7HGmN6+nANQ5OtqgaP06MXTg4MYhq8+7pGnWK2rUyR0qjeefdzHEUoWxmVA2Z5iJjdw3R136BYDAlt5a+HAsYwz1hCQwvSdAAhasxs9xhFt+pmKh3vhPi9DQr7VC0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599403644; h=Content-Type:Content-Transfer-Encoding:Cc: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=2mXOFsEuRvO2D2plCq803n0PtvsJLSAnY7LYq1MoUWQ=; b=eiPLhDHu9pq734Ixo7Bomm11Es+u0nAWuKbdpp8ctg7ND2ruPHyr35iznnmUdgd+cof5PBgPeXqGaWTW603yGwnpTt4wM9o87Nw0aoOVZ8GGqxMybIvmUVZJndekiqqGIbfrAh4J0q3DCPmBNlvY3zYz8rQKaPd5UdDEDKs+d+g= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 15994036442621008.2243510279596; Sun, 6 Sep 2020 07:47:24 -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-352-lAF0Z_TzO8ytHKO190FypQ-1; Sun, 06 Sep 2020 10:47:20 -0400 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 93B461DDF0; Sun, 6 Sep 2020 14:47:15 +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 3209C5C5DE; Sun, 6 Sep 2020 14:47:15 +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 DE17A183D021; Sun, 6 Sep 2020 14:47:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 086El8S6002033 for ; Sun, 6 Sep 2020 10:47:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id B27AE2156A2D; Sun, 6 Sep 2020 14:47:08 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AE87B2156A23 for ; Sun, 6 Sep 2020 14:47:06 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8C3BD811E76 for ; Sun, 6 Sep 2020 14:47:06 +0000 (UTC) Received: from ironboyv.h-da.de (ironboyv.h-da.de [141.100.10.230]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-353-decLN202NDWbK9CPgQSN8w-2; Sun, 06 Sep 2020 10:47:04 -0400 Received: from unknown (HELO mail.fbihome.de) ([141.100.40.107]) by ironboyv.h-da.de with ESMTP; 06 Sep 2020 16:36:57 +0200 Received: from debian.fritz.box (x4d044b12.dyn.telefonica.de [77.4.75.18]) by mail.fbihome.de (Postfix) with ESMTPSA id 2DED6424CC; Sun, 6 Sep 2020 16:36:55 +0200 (CEST) X-MC-Unique: lAF0Z_TzO8ytHKO190FypQ-1 X-MC-Unique: decLN202NDWbK9CPgQSN8w-2 IronPort-SDR: TOK3S6cGbOA43jow8zK2ubcn8hlJ8fNWMOZa3BNdc7s39SLj5ays1FFlaHYe0WjEiSW0UXAlFJ pItiCXf4GJ2jGCx4JMXUMumulO6PKkYIU2A7nBUbOtLTnhhqvmv1SStJnJ0/EuTOxugX/AhLlg l0jqcrdJiLWy/Ikw2h0ZBwldMYhBUnoTLAv7kBvSRLU5nCmdTQspSR3XbfWcOXuVh+ijyhJVV4 c5gwHQPd8KPVh02Q2PTd37322TfxzQoeusp2VwdpunNGAPx0gNpiPcPW1/8VwsNuJQUIM03UQ9 zWA= X-IPAS-Result: =?us-ascii?q?A2FtBQCY8lRf/2soZI1fHgEBCxIMR4U4Xo06hnABAQEBA?= =?us-ascii?q?QEGgjybGgsBAQEhGgIEAQGESwKCOAEkOBMCAwEBAQMCAwEBAQEGAQEBAQEBB?= =?us-ascii?q?QQCAoYMRYZMBicLAUYQGCcSSQENGYMmglgpsmIzGgKFN4RtgTiILIR+G3mBB?= =?us-ascii?q?4ERgltzhCeGDQSPdYoynEOBZIELmiMwgwmOdBoDEo4qtDuBe00kFIMkUBmcd?= =?us-ascii?q?T8zNwIGCgEBAwlPDI0JgkUBAQ?= X-IronPort-Anti-Spam-Filtered: true From: Jan-Marek Glogowski To: libvir-list@redhat.com Subject: [PATCH 1/1] QEMU: support USB cdrom devices Date: Sun, 6 Sep 2020 16:36:15 +0200 Message-Id: <20200906143615.30816-2-glogow@fbihome.de> In-Reply-To: <20200906143615.30816-1-glogow@fbihome.de> References: <20200906143615.30816-1-glogow@fbihome.de> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false; X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Jan-Marek Glogowski 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If a USB cdrom is configured, the media type is silently ignored, when generating the QEMU command, so libvirt actually generates USB disks. The main problem is, that -blockdev mechanism relies on the device type to handle the media type, like ide-cd and ide-hd. But there is just usb-storage. As a result the Windows 10 Arm64 installer won't find the virtio ISO or even its own install media. You can actually turn them into USB sticks, by setting them removable, so they show up in the installer, but then it doesn't expect joliet or UDF filesystems, so can't access these either. So this generates the old driver+device commandline arguments in the case of USB cdrom devices to make the installer happy. Signed-off-by: Jan-Marek Glogowski --- src/qemu/qemu_command.c | 21 ++++++++++++++++++- src/qemu/qemu_command.h | 1 + src/qemu/qemu_domain.c | 2 +- .../disk-cdrom-bus-other.x86_64-latest.args | 12 +++++------ 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index bd98b0a97c..f98af612de 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1121,6 +1121,22 @@ qemuDiskBusIsSD(int bus) } =20 =20 +/** + * qemuDiskIsUSBCD + * @disk: the disk + * + * Returns true, if the disk is an USB cdrom, which can't be currently + * represented by using -blockdev entries (other frontends have extra + * '-hd' and '-cd' devices to distinguish the media). + */ +bool +qemuDiskIsUSBCD(virDomainDiskDefPtr disk) +{ + return ((virDomainDiskBus)disk->bus) =3D=3D VIR_DOMAIN_DISK_BUS_USB + && disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM; +} + + /** * qemuDiskSourceNeedsProps: * @src: disk source @@ -1425,6 +1441,9 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_STORAGE_WERROR)) qemuBuildDiskFrontendAttributeErrorPolicy(disk, &opt); =20 + if (qemuDiskIsUSBCD(disk)) + virBufferAddLit(&opt, ",media=3Dcdrom"); + if (disk->src->readonly) virBufferAddLit(&opt, ",readonly=3Don"); =20 @@ -2075,7 +2094,7 @@ qemuBuildDiskSourceCommandLine(virCommandPtr cmd, size_t i; =20 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV) && - !qemuDiskBusIsSD(disk->bus)) { + !qemuDiskBusIsSD(disk->bus) && !qemuDiskIsUSBCD(disk)) { if (virStorageSourceIsEmpty(disk->src)) return 0; =20 diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 89d99b111f..54093b388e 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -110,6 +110,7 @@ char *qemuBuildNicDevStr(virDomainDefPtr def, =20 char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk); bool qemuDiskBusIsSD(int bus); +bool qemuDiskIsUSBCD(virDomainDiskDefPtr disk); =20 qemuBlockStorageSourceAttachDataPtr qemuBuildStorageSourceAttachPrepareDrive(virDomainDiskDefPtr disk, diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index b1884b6c84..27d8bd6cc2 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7282,7 +7282,7 @@ qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr dis= k, *backendAlias =3D NULL; =20 if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV) || - qemuDiskBusIsSD(disk->bus)) { + qemuDiskBusIsSD(disk->bus) || qemuDiskIsUSBCD(disk)) { if (!(*backendAlias =3D qemuAliasDiskDriveFromDisk(disk))) return -1; =20 diff --git a/tests/qemuxml2argvdata/disk-cdrom-bus-other.x86_64-latest.args= b/tests/qemuxml2argvdata/disk-cdrom-bus-other.x86_64-latest.args index be091f150f..64e6fe1f42 100644 --- a/tests/qemuxml2argvdata/disk-cdrom-bus-other.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-cdrom-bus-other.x86_64-latest.args @@ -28,13 +28,13 @@ file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -no-acpi \ -boot strict=3Don \ -device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ --blockdev '{"driver":"file","filename":"/root/boot.iso",\ -"node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \ --blockdev '{"node-name":"libvirt-2-format","read-only":true,"driver":"raw"= ,\ -"file":"libvirt-2-storage"}' \ --device usb-storage,bus=3Dusb.0,port=3D1,drive=3Dlibvirt-2-format,id=3Dusb= -disk0,\ +-drive file=3D/root/boot.iso,format=3Draw,if=3Dnone,id=3Ddrive-usb-disk0,m= edia=3Dcdrom,\ +readonly=3Don \ +-device usb-storage,bus=3Dusb.0,port=3D1,drive=3Ddrive-usb-disk0,id=3Dusb-= disk0,\ +removable=3Doff \ +-drive if=3Dnone,id=3Ddrive-usb-disk1,media=3Dcdrom,readonly=3Don \ +-device usb-storage,bus=3Dusb.0,port=3D2,drive=3Ddrive-usb-disk1,id=3Dusb-= disk1,\ removable=3Doff \ --device usb-storage,bus=3Dusb.0,port=3D2,id=3Dusb-disk1,removable=3Doff \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ resourcecontrol=3Ddeny \ -msg timestamp=3Don --=20 2.20.1