From nobody Sun Dec 14 08:05:17 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1750709076; cv=none; d=zohomail.com; s=zohoarc; b=f699oZso4+UjCMTbfdKpKbx4U7uChaKjHTBbP4f7OtNcdbb3YITPWnUt6vY96jrC4Ml0+8ffIwvFPGWb6yBLDYAG21f1YmdTPJ1sLVBsIQF6GHE/lkkcAcf6eJOhYLG/omH83tMr0RwV8RYGRfJMtxzvbEaTioTFklPtSRMSLQ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750709076; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=Oud3ahzLok/1oB8JapXJt1eYC5V/hDYRsknv7taZ4kk=; b=IMckhoIG3nuyGE0Em3lsJpHpbIFpWZttzYHHJornGVAwjBKtXsbK5ZLUr9lhpMDsu2nHVR8nerKzjNsaRLlGXFwHWjba06uJCX4PKWJ8jWXkGOqAcUMZNHrMC2AOMAqw5f85aRO2y4DcNzI/baYeR7NMG2yN3BfuSI+V6kGP4jQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1750709076215139.8667128879598; Mon, 23 Jun 2025 13:04:36 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 38F5B12D3; Mon, 23 Jun 2025 16:04:35 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id ACC5E1282; Mon, 23 Jun 2025 16:00:01 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E6A0DE7B; Mon, 23 Jun 2025 15:59:55 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 277CB1258 for ; Mon, 23 Jun 2025 15:59:34 -0400 (EDT) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-527-hbNzcAkfPTCIPNejwLHC-w-1; Mon, 23 Jun 2025 15:59:32 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9E5CE1956080 for ; Mon, 23 Jun 2025 19:59:31 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.5]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D76FB19560A3 for ; Mon, 23 Jun 2025 19:59:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750708773; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=XB938FghwI+TnaDBlWuEsyS186n21HDvZeKMFF/2dLQ=; b=KgBeM23np6TgZy0hAQXiYtDwLK72LNDb8i3qXPvWG7Nzc4eQ1n5Laqkb80fLkWUzMlz6cT jYz07enXA5A4iiOYgWEG4YttmJ3lz6YeqbstBrF0b69p/SJbqxtICNeOtJhKZP5Ip8XrwO tkFWxR7EIn9gOnmAzj+dLs7uClE3ObI= X-MC-Unique: hbNzcAkfPTCIPNejwLHC-w-1 X-Mimecast-MFC-AGG-ID: hbNzcAkfPTCIPNejwLHC-w_1750708771 To: devel@lists.libvirt.org Subject: [PATCH v2 08/13] conf: introduce usb disk models 'usb-storage' and 'usb-bot' Date: Mon, 23 Jun 2025 21:59:13 +0200 Message-ID: <94ff75348e47dcefba931979d9e220fc9611b7cb.1750705681.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Wja2FjDKjrG4zNq4IHPU07SIfAI2xgUaTW8Gurlu5J4_1750708771 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: O2PKVLK2RJTQMXJUGYP4D357O4DTNC3O X-Message-ID-Hash: O2PKVLK2RJTQMXJUGYP4D357O4DTNC3O X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1750709076982116600 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Historically libvirt specified 'usb-storage' as driver for USB disks. This though combined with '-blockdev' doesn't properly configure the device to look like CDROM for . 'usb-bot' acts like a controler and allows explicitly connecting a -device to it. In qemu the devices share implementation so they are effectively identical and can be used interchangably. There is though a slight difference in how the storage device itself (the SCSI bit) looks when CDROM as they were not declared as cdrom before. As this is effectively a bugfix we'll be fixing the behaviour for the default configuration. The possibility to explicitly set the model is added as a possibility for working around possible problems if they'd appear. Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- docs/formatdomain.rst | 23 +++++-- src/conf/domain_conf.c | 2 + src/conf/domain_conf.h | 3 + src/conf/schemas/domaincommon.rng | 2 + src/qemu/qemu_domain_address.c | 2 + .../disk-usb-device-model.x86_64-latest.args | 46 +++++++++++++ .../disk-usb-device-model.x86_64-latest.xml | 64 +++++++++++++++++++ .../qemuxmlconfdata/disk-usb-device-model.xml | 46 +++++++++++++ tests/qemuxmlconftest.c | 1 + 9 files changed, 185 insertions(+), 4 deletions(-) create mode 100644 tests/qemuxmlconfdata/disk-usb-device-model.x86_64-late= st.args create mode 100644 tests/qemuxmlconfdata/disk-usb-device-model.x86_64-late= st.xml create mode 100644 tests/qemuxmlconfdata/disk-usb-device-model.xml diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index ae054a52b3..e4ebf061c7 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -2862,10 +2862,25 @@ paravirtualized driver is specified via the ``disk`= ` element. ``model`` Indicates the emulated device model of the disk. Typically this is - indicated solely by the ``bus`` property but for ``bus`` "virtio" the - model can be specified further with "virtio", "virtio-transitional" = or - "virtio-non-transitional". See `virtio device models`_ - for more details. :since:`Since 5.2.0` + indicated solely by the ``bus`` property. + + For ``bus`` "virtio" the model can be specified further with "virtio= ", + "virtio-transitional" or "virtio-non-transitional". See `virtio devi= ce + models`_ for more details. :since:`Since 5.2.0` + + For ``bus`` "usb" the model can be specified further with ``usb-stor= age`` + or ``usb-bot``. There is no difference between the two models for + ```` is properly exposed as a cdrom device insi= de the + guest OS. Unfortunately this configuration is not ABI compatible and= thus + it can't be interchanged. + + The QEMU hypervisor driver will pick ``usb-bot`` for cold starts or + hotplug for cdrom devices to properly configure the devices. This is + not compatible for migration to older versions of libvirt and explic= it + configuration needs to be used. + :since:`Since 11.5.0`; relevant only for ``QEMU`` hypervisor. + ``rawio`` Indicates whether the disk needs rawio capability. Valid settings are "yes" or "no" (default is "no"). If any one disk in a domain has diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1a6c8afb1d..2882a7746b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1399,6 +1399,8 @@ VIR_ENUM_IMPL(virDomainDiskModel, "virtio", "virtio-transitional", "virtio-non-transitional", + "usb-storage", + "usb-bot", ); VIR_ENUM_IMPL(virDomainDiskMirrorState, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 3d380073cf..73e8a2fb99 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -439,6 +439,9 @@ typedef enum { VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL, VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL, + VIR_DOMAIN_DISK_MODEL_USB_STORAGE, + VIR_DOMAIN_DISK_MODEL_USB_BOT, + VIR_DOMAIN_DISK_MODEL_LAST } virDomainDiskModel; diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index b1fe51f519..a80005562a 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -1766,6 +1766,8 @@ virtio virtio-transitional virtio-non-transitional + usb-storage + usb-bot diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index bb86cfa0c3..3a23f70d39 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -729,6 +729,8 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDevic= eDef *dev, case VIR_DOMAIN_DISK_MODEL_DEFAULT: return virtioFlags; case VIR_DOMAIN_DISK_MODEL_LAST: + case VIR_DOMAIN_DISK_MODEL_USB_STORAGE: + case VIR_DOMAIN_DISK_MODEL_USB_BOT: break; } return 0; diff --git a/tests/qemuxmlconfdata/disk-usb-device-model.x86_64-latest.args= b/tests/qemuxmlconfdata/disk-usb-device-model.x86_64-latest.args new file mode 100644 index 0000000000..6d31319a49 --- /dev/null +++ b/tests/qemuxmlconfdata/disk-usb-device-model.x86_64-latest.args @@ -0,0 +1,46 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/va= r/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes"}' \ +-machine pc,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dpc.ram,acpi= =3Doff \ +-accel tcg \ +-cpu qemu64 \ +-m size=3D219136k \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}'= \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-boot strict=3Don \ +-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ +-device '{"driver":"usb-hub","id":"hub0","bus":"usb.0","port":"1"}' \ +-blockdev '{"driver":"file","filename":"/tmp/img1","node-name":"libvirt-6-= storage","read-only":false}' \ +-device '{"driver":"usb-storage","bus":"usb.0","port":"2","drive":"libvirt= -6-storage","id":"usb-disk0","bootindex":1,"removable":false}' \ +-blockdev '{"driver":"file","filename":"/tmp/img2","node-name":"libvirt-5-= storage","read-only":true}' \ +-device '{"driver":"usb-storage","bus":"usb.0","port":"1.1","drive":"libvi= rt-5-storage","id":"usb-disk1","removable":false}' \ +-blockdev '{"driver":"file","filename":"/tmp/img3","node-name":"libvirt-4-= storage","read-only":false}' \ +-device '{"driver":"usb-storage","bus":"usb.0","port":"1.2","drive":"libvi= rt-4-storage","id":"usb-disk2","removable":false}' \ +-blockdev '{"driver":"file","filename":"/tmp/img4","node-name":"libvirt-3-= storage","read-only":true}' \ +-device '{"driver":"usb-storage","bus":"usb.0","port":"1.3","drive":"libvi= rt-3-storage","id":"usb-disk3","removable":false}' \ +-blockdev '{"driver":"file","filename":"/tmp/img5","node-name":"libvirt-2-= storage","read-only":false}' \ +-device '{"driver":"usb-storage","bus":"usb.0","port":"1.4","drive":"libvi= rt-2-storage","id":"usb-disk4","removable":false}' \ +-blockdev '{"driver":"file","filename":"/tmp/img6","node-name":"libvirt-1-= storage","read-only":true}' \ +-device '{"driver":"usb-storage","bus":"usb.0","port":"1.5","drive":"libvi= rt-1-storage","id":"usb-disk5","removable":false}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x2"}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxmlconfdata/disk-usb-device-model.x86_64-latest.xml = b/tests/qemuxmlconfdata/disk-usb-device-model.x86_64-latest.xml new file mode 100644 index 0000000000..351257bc4a --- /dev/null +++ b/tests/qemuxmlconfdata/disk-usb-device-model.x86_64-latest.xml @@ -0,0 +1,64 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +