From nobody Sat Feb 7 07:38:07 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 ARC-Seal: i=1; a=rsa-sha256; t=1696666375; cv=none; d=zohomail.com; s=zohoarc; b=VELCN3UAs7MURSgJlTk1pOECieS6dUJNcxfCIACrjP+pF7D0La4fp49hjfDUob/1aJeZfEPE20iodA50o0Ak8Mt0RKLV2ZqJxMXSZqtGJsxTy30qxjVQdP+/Wbz8I97odKX/6cs33N5ydiza9EUQ3GrYxciTkNAZsK+JV9Gh2X8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696666375; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hbssHkflZ23ke798V3g2ka9JbpsZmtSxoZS5bx8q+/E=; b=dp5D7vkGCv1TYMJNZ9t3Aq6LHFGKQxcLM/rWB4PdlQf1Aw/5gJkYSDgam+nVI3ezXfFiLBbHidEeVhkDdl2K+qXUb0kKJROhYV358DiQ5J7hNNbmjPvRfbjlGPTdR4qcjC6PQ7UsC3Gdwc8KkwNmEcrK0OWamw087Vm2Au6vaf0= 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 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 1696666375101869.9996340829418; Sat, 7 Oct 2023 01:12:55 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-91-C1ErLMu-Og66MfofBztXCA-1; Sat, 07 Oct 2023 04:12:50 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B6B7329AB3EC; Sat, 7 Oct 2023 08:12:48 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 664611005B8E; Sat, 7 Oct 2023 08:12:46 +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 0A28E1946588; Sat, 7 Oct 2023 08:12:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 192841946587 for ; Sat, 7 Oct 2023 08:12:45 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 02317140E964; Sat, 7 Oct 2023 08:12:45 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EEAC3140E962 for ; Sat, 7 Oct 2023 08:12:44 +0000 (UTC) Received: from us-smtp-inbound-delivery-1.mimecast.com (us-smtp-inbound-delivery-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D0EE4185A790 for ; Sat, 7 Oct 2023 08:12:44 +0000 (UTC) Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-661-9a-WXGH1MX2q2uoEmAuDMw-1; Sat, 07 Oct 2023 04:12:42 -0400 Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-53fbf2c42bfso2301953a12.3 for ; Sat, 07 Oct 2023 01:12:41 -0700 (PDT) Received: from localhost.localdomain ([125.69.0.79]) by smtp.gmail.com with ESMTPSA id mp3-20020a17090b190300b00267d9f4d340sm6692077pjb.44.2023.10.07.01.12.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 07 Oct 2023 01:12:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696666374; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=hbssHkflZ23ke798V3g2ka9JbpsZmtSxoZS5bx8q+/E=; b=DNRxXBapyGhOvCsnxu9Kgxm6m2BWO5QM7743z2VB7lIXQMYVeYecMvJMaRunYNLtRAkTUP KDRfHcRCbdBdw4mE/K9ZTlIDkLYXg/rIQvI9QLBP3VhQLmYvnQQcZbsaWe1LFWyss4oX4w 4JP6uial/G/gJKnt55HzBJ/9IFwcgBY= X-MC-Unique: C1ErLMu-Og66MfofBztXCA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 9a-WXGH1MX2q2uoEmAuDMw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696666360; x=1697271160; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hbssHkflZ23ke798V3g2ka9JbpsZmtSxoZS5bx8q+/E=; b=fwOvrb1VA5p1emzWeaQ0Wl/0EpKEPmqnIUbPsWakS7gDkK5IBTh/0wwG2di10QhYHY uM+VwleLkR3IZwdAQbVrUFoDX5aZ1n0yeYIXiW1v6rkIXmku9Pf94yKIi8/s1raQdHyV RgOiv3XONzQQ5nJ/MrxLiWpEJPcnL/reQ/SW4gR54BiQaotC1+Iwh5IEYgYsWchSUFYJ 9L35uDPqxlsTuMLAPyecXnE3AfwfmspDuorfEE/u2Px2V969rRwMRSAvvTYPZdEvXkVE ICF+C7kbbOvbQ3CNdWYHE1HarwvPerXr9IS1ZlB8gC5uifsfXgKf1tYnOVmSWllJD4NL svpg== X-Gm-Message-State: AOJu0Yyy05TjKo05BISarCoKGAFX5DORy/1BnHVb/l4SMHZQ3l5e034Q r1Pl3OpQTbgcBYQHX9Dy2BcwRWF+/G/xBg7BsujfV4+1 X-Google-Smtp-Source: AGHT+IFTRM34An5gkTGJvO3EiztAsK/am3tt+N2QNvDh1O4s/zV8z7IfWodBm7RLOW/LgW8QvFpXHw== X-Received: by 2002:a05:6a20:7345:b0:16b:e2e5:fe55 with SMTP id v5-20020a056a20734500b0016be2e5fe55mr3898876pzc.51.1696666360149; Sat, 07 Oct 2023 01:12:40 -0700 (PDT) From: Minglei Liu To: libvir-list@redhat.com Subject: [PATCH] qemu: add 'media=cdrom' attribute for usb CDROM Date: Sat, 7 Oct 2023 16:12:09 +0800 Message-Id: <20231007081209.40305-1-minglei.liu@smartx.com> 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 3.1 on 10.11.54.7 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: , Cc: "minglei.liu" Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: smartx.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1696666376553100001 Content-Type: text/plain; charset="utf-8"; x-default="true" From: "minglei.liu" In commit 1328a83, the 'media=3Dcdrom' attribute was removed from -drive. However, this attribute is still essential for usb cdrom and is still supported in qemu 8.1.1. Therefore, we need to reintroduce this attribute for usb cdrom. --- src/qemu/qemu_command.c | 7 +++++++ .../disk-cdrom-bus-other.x86_64-latest.args | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 8a7b80719f..42f3f8f740 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1705,6 +1705,13 @@ qemuBuildDriveStr(virDomainDiskDef *disk) =20 virBufferAsprintf(&opt, "if=3Dsd,index=3D%d", virDiskNameToIndex(disk-= >dst)); =20 + /* While this is a frontend attribute, it only makes sense to be used = when + * legacy -drive is used. In modern qemu the 'ide-cd' or 'scsi-cd' are= used. + * currently only usb cdrom need this attribute */ + if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM && + disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_USB) + virBufferAddLit(&opt, ",media=3Dcdrom"); + if (disk->src->readonly) virBufferAddLit(&opt, ",readonly=3Don"); =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 de5fa083d8..38093423cf 100644 --- a/tests/qemuxml2argvdata/disk-cdrom-bus-other.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-cdrom-bus-other.x86_64-latest.args @@ -27,7 +27,7 @@ XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGue= st1/.config \ -no-shutdown \ -boot strict=3Don \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ --blockdev '{"driver":"file","filename":"/root/boot.iso","node-name":"libvi= rt-2-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"driver":"file","filename":"/root/boot.iso","node-name":"libvi= rt-2-storage","auto-read-only":true,"discard":"unmap","media":"cdrom"}' \ -blockdev '{"node-name":"libvirt-2-format","read-only":true,"driver":"raw"= ,"file":"libvirt-2-storage"}' \ -device '{"driver":"usb-storage","bus":"usb.0","port":"1","drive":"libvirt= -2-format","id":"usb-disk0","removable":false}' \ -device '{"driver":"usb-storage","bus":"usb.0","port":"2","id":"usb-disk1"= ,"removable":false}' \ --=20 2.41.0