From nobody Tue Feb 10 12:57:40 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=fail(p=reject dis=none) header.from=major.onl ARC-Seal: i=1; a=rsa-sha256; t=1689712800; cv=none; d=zohomail.com; s=zohoarc; b=K526FtEf6ansCXRVaGO+yPiQeWO8MSF5hE+A5jhG9ADTx/NObjFli57RKMXCJTpFTFdc+YMlFJVcfSbiQMBQwkzVf1ewldgatRMkCRxkYEFVFb/IGXl1+tHPEInbET6LodO6hWYngw9uSe9stuLOHGAY+h9txvG/zvGUXvwvrog= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689712800; 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=0QQwP0IkqPxVP/v0qLVAZBWsrq6GTeoZmvqZJKs4/Lg=; b=MezVTP3euHZMX03baCgBTCqFccGKCIgfqdSH5sMEUB73W50v1Jx/raQworge8NXrhtniG4wtfURm1RBXzdFgHIBy4LRUJIFBr2aBk8SMofn1lLceE9eqMs2Yz5m8cvkYOl2vm4bozssD82KNRPdcmS+zG7OX5Q163HVKKvRd5xI= 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=fail header.from= (p=reject 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 1689712800261169.43178648998162; Tue, 18 Jul 2023 13:40:00 -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-29-lUQHeVH-PVqLnXETAEmc8w-1; Tue, 18 Jul 2023 16:39:55 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A58A88F1849; Tue, 18 Jul 2023 20:39:53 +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 1011AF6CCA; Tue, 18 Jul 2023 20:39:53 +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 0496E19465A4; Tue, 18 Jul 2023 20:39:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3E2591946594 for ; Tue, 18 Jul 2023 20:39:40 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 17FE040C2070; Tue, 18 Jul 2023 20:39:40 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1069140C206F for ; Tue, 18 Jul 2023 20:39:40 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (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 DFFAF3810D3B for ; Tue, 18 Jul 2023 20:39:39 +0000 (UTC) Received: from mailout02.t-online.de (mailout02.t-online.de [194.25.134.17]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-118-byZWX5RsOHaLAY-fB2mGZQ-1; Tue, 18 Jul 2023 16:39:37 -0400 Received: from fwd81.dcpf.telekom.de (fwd81.aul.t-online.de [10.223.144.107]) by mailout02.t-online.de (Postfix) with SMTP id 8B51C1E5EC; Tue, 18 Jul 2023 22:39:32 +0200 (CEST) Received: from major.onl ([79.208.248.137]) by fwd81.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1qLrTm-3jR85I0; Tue, 18 Jul 2023 22:39:30 +0200 Received: from benedek.fritz.box (benedek.fritz.box [192.168.0.27]) by major.onl (Postfix) with ESMTP id EA2A9400B2; Tue, 18 Jul 2023 22:39:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689712799; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=0QQwP0IkqPxVP/v0qLVAZBWsrq6GTeoZmvqZJKs4/Lg=; b=S7/ybHBfUZTG2B9/b6r0vWJ+KJ/7SDS9QuVNe1HuuIkXdDV2zzG3OLjwzhhehJIChVjhqF pyJy39zY39cJIReykQxNYoePDkxY2wn46xZBULu588iQmLqtyCEnWnxgKnbd9eYeIkKtVL NR9fkJBLed4TAsA3CjwbgmM3PCsLKAI= X-MC-Unique: lUQHeVH-PVqLnXETAEmc8w-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: byZWX5RsOHaLAY-fB2mGZQ-1 From: Benedek Major To: pkrempa@redhat.com Subject: [PATCH] Added support for disk model string for QEMU IDE and SATA devices Date: Tue, 18 Jul 2023 22:39:26 +0200 Message-ID: <20230718203926.25809-1-benedek@major.onl> In-Reply-To: References: MIME-Version: 1.0 X-TOI-EXPURGATEID: 150726::1689712770-42FFB2B7-A8C105C0/0/0 CLEAN NORMAL X-TOI-MSGID: 3d4d1065-9648-437b-9e1d-530cc2f46d34 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.1 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: libvir-list@redhat.com, Benedek Major Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: major.onl Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1689712803044100001 Content-Type: text/plain; charset="utf-8"; x-default="true" The QEMU drivers ide-hd and ide-cd used for IDE and SATA bus devices support adding a disk model that is returned on guest query by the IDE or SATA disk= to the guest. The already existing product tag got changed to allow for up to 40 characte= rs, which is the maximum allowed by the specification, if the controller is set= to SATA or IDE. If set, the product gets passed to QEMU using the -model parameter. The product represents the model until command creation, where it gets processed depending on the current type of disk controller. Dead code checking for QEMU version 1.2.0 got removed, since minimum is 4.2= .0. Signed-off-by: Benedek Major Reviewed-by: Peter Krempa --- src/conf/domain_validate.c | 18 +++++++++++++++--- src/qemu/qemu_command.c | 8 ++++++-- src/qemu/qemu_validate.c | 28 +++++++++++++--------------- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 16bf3b559f..60454f3745 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -585,7 +585,8 @@ virDomainDiskDefValidateSource(const virStorageSource *= src) =20 =20 #define VENDOR_LEN 8 -#define PRODUCT_LEN 16 +#define PRODUCT_LEN_SCSI 16 +#define PRODUCT_LEN_IDE 40 =20 =20 /** @@ -856,10 +857,21 @@ virDomainDiskDefValidate(const virDomainDef *def, return -1; } =20 - if (strlen(disk->product) > PRODUCT_LEN) { + if ((disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_SATA || + disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_IDE) && + strlen(disk->product) > PRODUCT_LEN_IDE) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("disk product is more than %1$d characters"), - PRODUCT_LEN); + PRODUCT_LEN_IDE); + return -1; + } + + if (disk->bus !=3D VIR_DOMAIN_DISK_BUS_SATA && + disk->bus !=3D VIR_DOMAIN_DISK_BUS_IDE && + strlen(disk->product) > PRODUCT_LEN_SCSI) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk product is more than %1$d characters"), + PRODUCT_LEN_SCSI); return -1; } } diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ad224571f3..a3b0380695 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1762,6 +1762,8 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, unsigned int physical_block_size =3D disk->blockio.physical_block_size; g_autoptr(virJSONValue) wwn =3D NULL; g_autofree char *serial =3D NULL; + const char *modelstr =3D NULL; + const char *product =3D disk->product; virTristateSwitch removable =3D VIR_TRISTATE_SWITCH_ABSENT; virTristateSwitch writeCache =3D VIR_TRISTATE_SWITCH_ABSENT; const char *biosCHSTrans =3D NULL; @@ -1775,7 +1777,8 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, driver =3D "ide-cd"; else driver =3D "ide-hd"; - + /* IDE disk product name for IDE is passed via 'model' property */ + modelstr =3D g_steal_pointer(&product); break; =20 case VIR_DOMAIN_DISK_BUS_SCSI: @@ -1944,7 +1947,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", modelstr, "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 7e09e2c52f..84f9af3f16 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2870,22 +2870,20 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDo= mainDiskDef *disk, } } =20 - if (disk->vendor || disk->product) { - if (disk->bus !=3D VIR_DOMAIN_DISK_BUS_SCSI) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Only scsi disk supports vendor and product")= ); - return -1; - } + if (disk->vendor && + disk->bus !=3D VIR_DOMAIN_DISK_BUS_SCSI) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Only scsi disk supports vendor and product")); + return -1; + } =20 - /* Properties wwn, vendor and product were introduced in the - * same QEMU release (1.2.0). - */ - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_DISK_WWN)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Setting vendor or product for scsi disk is n= ot " - "supported by this QEMU")); - return -1; - } + if (disk->product && + 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 scsi, ide, sata disk supports product")); + return -1; } =20 if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_LUN) { --=20 2.41.0