From nobody Tue Jan 21 04:00:35 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1737196282287254.4848698320185; Sat, 18 Jan 2025 02:31:22 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 8A58018DA; Sat, 18 Jan 2025 05:31:21 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A86B918D6; Sat, 18 Jan 2025 05:30:36 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 22C4F18B5; Sat, 18 Jan 2025 05:30:34 -0500 (EST) 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 280EB18A7 for ; Sat, 18 Jan 2025 05:30:33 -0500 (EST) Received: from mx-prod-mc-01.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-241-4FmJpdWpMRmoRKdzgMJRpg-1; Sat, 18 Jan 2025 05:30:30 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EEFCA19560B0 for ; Sat, 18 Jan 2025 10:30:29 +0000 (UTC) Received: from ajulis-thinkpadt14gen4.remote.csb (unknown [10.45.224.33]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DC8053003E7F for ; Sat, 18 Jan 2025 10:30:28 +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.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,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=1737196232; 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=VRwl++trpMCqlffoFVy+bzz/dB1KFuRmerLOpGGM3yM=; b=Kd5gJkAGOJCh/PJGSQAwqblOmhTp7ZQw0FR+c93+mU8TZPiRjoCr23whhfwgQGZLsUS92K CqglBAn4QtWHb2pPswPQK+F2ADzo/8iEAIPPmlMVIoLIIwmXgYcMR95hLNqn5J24GoLodp O+dkq8vfQEyIgUMpwMM6ZC21M2R/bJo= X-MC-Unique: 4FmJpdWpMRmoRKdzgMJRpg-1 X-Mimecast-MFC-AGG-ID: 4FmJpdWpMRmoRKdzgMJRpg From: Adam Julis To: devel@lists.libvirt.org Subject: [PATCH v3] Support IDE/SATA disk 'product' parameter Date: Sat, 18 Jan 2025 11:30:20 +0100 Message-ID: <4590d7211527e6611250ff69a5b5ac0bb2a25a4a.1737195842.git.ajulis@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: eEcWWcTxtV54BGrkhwx1KuOWi5_30ri4rggq2C7PZA8_1737196230 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: IQVQE3VM6FUYRIYV2Z3ORTZQOB6ZBJGL X-Message-ID-Hash: IQVQE3VM6FUYRIYV2Z3ORTZQOB6ZBJGL X-MailFrom: ajulis@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: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1737196284810019000 Content-Type: text/plain; charset="utf-8"; x-default="true" Since we supported 'product' parameter for SCSI, just expanded existing solution makes IDE/SATA parameter works too. QEMU requires parameter 'model' in case of IDE/SATA (instead of 'product'), so the process of making JSON object is slightly modified. Length of the 'product' parameter is different in SCSI (16 chars) and ATA/SATA (40 chars). Resolves: https://gitlab.com/libvirt/libvirt/-/issues/697 Signed-off-by: Adam Julis --- Changes to v2: - doc (mainly mentioned the different length of SCSI and SATA/ATA) - modified schemas (for supporting longer string) - added tests - ..details in formatting docs/formatdomain.rst | 9 ++-- src/conf/domain_validate.c | 14 +++++-- src/conf/schemas/domaincommon.rng | 2 +- src/qemu/qemu_command.c | 9 +++- src/qemu/qemu_validate.c | 14 ++++++- .../disk-sata-product.x86_64-latest.args | 36 ++++++++++++++++ .../disk-sata-product.x86_64-latest.xml | 41 +++++++++++++++++++ tests/qemuxmlconfdata/disk-sata-product.xml | 28 +++++++++++++ ...csi-disk-vpd-build-error.x86_64-latest.err | 2 +- ...disk-scsi-product-length.x86_64-latest.err | 1 + .../disk-scsi-product-length.xml | 28 +++++++++++++ tests/qemuxmlconftest.c | 2 + 12 files changed, 173 insertions(+), 13 deletions(-) create mode 100644 tests/qemuxmlconfdata/disk-sata-product.x86_64-latest.a= rgs create mode 100644 tests/qemuxmlconfdata/disk-sata-product.x86_64-latest.x= ml create mode 100644 tests/qemuxmlconfdata/disk-sata-product.xml create mode 100644 tests/qemuxmlconfdata/disk-scsi-product-length.x86_64-l= atest.err create mode 100644 tests/qemuxmlconfdata/disk-scsi-product-length.xml diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 620daae9af..0544b11fb9 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -3562,12 +3562,13 @@ paravirtualized driver is specified via the ``disk`= ` element. :since:`Since 0.10.1` ``vendor`` If present, this element specifies the vendor of a virtual hard disk or - CD-ROM device. It must not be longer than 8 printable characters. - :since:`Since 1.0.1` + CD-ROM device. It must not be longer than 8 printable characters. Only = for + 'scsi' ``bus``.:since:`Since 1.0.1` ``product`` If present, this element specifies the product of a virtual hard disk or - CD-ROM device. It must not be longer than 16 printable characters. - :since:`Since 1.0.1` + CD-ROM device. It must not be longer than 16 printable characters for '= scsi' + (:since:`Since 1.0.1`). For 'sata' or 'ide' not longer than 40 printable + characters (:since:`Since 11.0.1`). Other ``bus`` is not supported. ``address`` If present, the ``address`` element ties the disk to a given slot of a controller (the actual ```` device can often be inferred by diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 6aed74dd8d..01dda3a278 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -603,8 +603,8 @@ virDomainDiskDefValidateSource(const virStorageSource *= src) =20 =20 #define VENDOR_LEN 8 -#define PRODUCT_LEN 16 - +#define PRODUCT_SCSI_LEN 16 +#define PRODUCT_ATA_SATA_LEN 40 =20 /** * virDomainDiskDefSourceLUNValidate: @@ -880,10 +880,16 @@ virDomainDiskDefValidate(const virDomainDef *def, return -1; } =20 - if (strlen(disk->product) > PRODUCT_LEN) { + if (disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_SCSI && + strlen(disk->product) > PRODUCT_SCSI_LEN) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("disk product is more than %1$d characters"), - PRODUCT_LEN); + PRODUCT_SCSI_LEN); + return -1; + } else if (strlen(disk->product) > PRODUCT_ATA_SATA_LEN) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk product is more than %1$d characters"), + PRODUCT_ATA_SATA_LEN); return -1; } } diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index 7121519ca3..0fb1050f1e 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -1669,7 +1669,7 @@ - [ -~]{0,16} + [ -~]{0,40} diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1f28de6194..b636079417 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1619,6 +1619,8 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, const char *biosCHSTrans =3D NULL; const char *wpolicy =3D NULL; const char *rpolicy =3D NULL; + const char *model =3D NULL; + const char *product =3D NULL; =20 switch (disk->bus) { case VIR_DOMAIN_DISK_BUS_IDE: @@ -1628,6 +1630,8 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, else driver =3D "ide-hd"; =20 + model =3D disk->product; + break; =20 case VIR_DOMAIN_DISK_BUS_SCSI: @@ -1654,6 +1658,8 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, } } =20 + product =3D disk->product; + break; =20 case VIR_DOMAIN_DISK_BUS_VIRTIO: { @@ -1803,7 +1809,8 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, "A:wwn", &wwn, "p:rotation_rate", disk->rotation_rate, "S:vendor", disk->vendor, - "S:product", disk->product, + "S:product", product, + "S:model", model, "T:removable", removable, "S:write-cache", qemuOnOffAuto(writeCache), "p:cyls", disk->geometry.cylinders, diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 086c66b602..1194c4743c 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2947,10 +2947,20 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDo= mainDiskDef *disk, } } =20 - if (disk->vendor || disk->product) { + if (disk->vendor) { if (disk->bus !=3D VIR_DOMAIN_DISK_BUS_SCSI) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Only scsi disk supports vendor and product")= ); + _("Only scsi disk supports 'vendor'")); + return -1; + } + } + + if (disk->product) { + if ((disk->bus !=3D VIR_DOMAIN_DISK_BUS_IDE) && + (disk->bus !=3D VIR_DOMAIN_DISK_BUS_SATA) && + (disk->bus !=3D VIR_DOMAIN_DISK_BUS_SCSI)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Only ide, sata and scsi disk supports 'produ= ct'")); return -1; } } diff --git a/tests/qemuxmlconfdata/disk-sata-product.x86_64-latest.args b/t= ests/qemuxmlconfdata/disk-sata-product.x86_64-latest.args new file mode 100644 index 0000000000..a171f5c447 --- /dev/null +++ b/tests/qemuxmlconfdata/disk-sata-product.x86_64-latest.args @@ -0,0 +1,36 @@ +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":"ahci","id":"sata0","bus":"pci.0","addr":"0x2"}' \ +-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUG uest1","n= ode-name":"libvirt-1-storage","read-only":false}' \ +-device '{"driver":"ide-hd","bus":"sata0.0","drive":"libvirt-1-storage","i= d":"sata0-0-0","bootindex":1,"model":"WD10EZEX-00BN5A0"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x3"}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxmlconfdata/disk-sata-product.x86_64-latest.xml b/te= sts/qemuxmlconfdata/disk-sata-product.x86_64-latest.xml new file mode 100644 index 0000000000..7a75731146 --- /dev/null +++ b/tests/qemuxmlconfdata/disk-sata-product.x86_64-latest.xml @@ -0,0 +1,41 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + + WD10EZEX-00BN5A0 +
+ + +
+ + +
+ + + + +