From nobody Sat May 18 07:08:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1689586860; cv=none; d=zohomail.com; s=zohoarc; b=GVhKXY23O9Z4CA4cps7exLFitfZxaqePzi5YtqUMyrcd+kqBPM5vDb1nR+quDF6c7clr02BASELNscFGPYheZlYwacfKkkybkrEYf2tn2tqPnzgFAH8YbJp/eL4QW438P90uAqiPCSfLDb+/AX9UwM/CPykL0WR7gze2Au/OY30= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689586860; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=vLpxRTGOY8qiMpnjzz824X5IPt8tiwqcSHlmsdwrmic=; b=Uj0qV2Kas8BQSsKB3t9X0xiTS9+fLDlQ7KZtYdEAtDfOSPnzORlfNbA+eyKUpifXfVSa/nPYvwLv0Qqjp4FLe8jWyg78JAcAfRf/Zw6uuEjnvMN+zwpHx/A1XqR08MWu1DGkKnvKYL/xPPxS0jhC84N7ZFH7iaByD3WYnvrY91k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1689586860192607.3409849652214; Mon, 17 Jul 2023 02:41:00 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [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-108-1GDNY-gYPT60OeErRE5NNg-1; Mon, 17 Jul 2023 05:40:54 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AEA3529DD994; Mon, 17 Jul 2023 09:40:51 +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 F2AFF2166B25; Mon, 17 Jul 2023 09:40:49 +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 881CC194658C; Mon, 17 Jul 2023 09:40:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 95ACE1946586 for ; Sat, 15 Jul 2023 16:45:40 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 35287C2C863; Sat, 15 Jul 2023 16:45:40 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast07.extmail.prod.ext.rdu2.redhat.com [10.11.55.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2D440C2C862 for ; Sat, 15 Jul 2023 16:45:40 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (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 E92CC3C0C4B7 for ; Sat, 15 Jul 2023 16:45:39 +0000 (UTC) Received: from mailout01.t-online.de (mailout01.t-online.de [194.25.134.80]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-17-rhzrK5CON3CNNQNee8vc7A-1; Sat, 15 Jul 2023 12:45:37 -0400 Received: from fwd77.dcpf.telekom.de (fwd77.aul.t-online.de [10.223.144.103]) by mailout01.t-online.de (Postfix) with SMTP id 30B1E1DFE3 for ; Sat, 15 Jul 2023 18:37:28 +0200 (CEST) Received: from major.onl ([79.208.248.137]) by fwd77.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1qKiGu-0iYkN60; Sat, 15 Jul 2023 18:37:28 +0200 Received: from benedek.fritz.box (benedek.fritz.box [192.168.0.27]) by major.onl (Postfix) with ESMTP id B4DC8406C0; Sat, 15 Jul 2023 18:37:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689586859; 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=vLpxRTGOY8qiMpnjzz824X5IPt8tiwqcSHlmsdwrmic=; b=UdakIvKCZ+6aVPkNCl9EJYsHrQwkbUP2A0mu2QkExPPUmeQgPGwZY0HUPzkl1b2tHvX7IP FehwJOYu6UHLQZqY63H1iV0meMogSU6ytJRD6WFxqsdy7/viz9eKNWx8q3QuPam0T0VB6C LJyj3x26OSW+Fv+jUhB7iEbYrQ7der8= X-MC-Unique: 1GDNY-gYPT60OeErRE5NNg-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: rhzrK5CON3CNNQNee8vc7A-1 From: Benedek Major To: libvir-list@redhat.com Subject: [PATCH] Added support for vendor and product for qemu ide-hd Date: Sat, 15 Jul 2023 18:37:10 +0200 Message-ID: <20230715163713.59886-1-benedek@major.onl> MIME-Version: 1.0 X-TOI-EXPURGATEID: 150726::1689439048-1381E931-DF5D3FCC/0/0 CLEAN NORMAL X-TOI-MSGID: bed4fdbd-55af-4c71-a31d-696660535f2b 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.8 X-Mailman-Approved-At: Mon, 17 Jul 2023 09:40:47 +0000 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: Benedek Major Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: 1689586865161100001 Content-Type: text/plain; charset="utf-8"; x-default="true" The XML-Schema specifies two tags vendor and product for the disk type. But= they only apply to the SCSI bus, even though the QEMU driver ide-hd and ide-cd have support for the command = line argument -model. The model corresponds to words 27-46 of the IDENTIFY PACKET DEVICE response= from the ATAPI spec. Words 27-46 is a 40 Char space for the model number of the device. The mode= l number is built by combining the vendor and the product fields with a single space as separato= r in the middle. Therefore I would say, that vendor and product pretty much correlate to the= model field in QEMU, so the ide disk should also have the possibility of adding vendor and produ= ct to it. The tests got changed to incorporate the new error message which now contai= ns that the ide and sata bus also supports vendor and product. Also the xml to command line tes= ts got updated, to have both fields present for testing. The command generator reordered a bit too, to only include disk->vendor and= disk->product into the json generation, when the scsi bus is selected. The same logic applies to t= he ide and sata bus. Signed-off-by: Benedek Major --- src/qemu/qemu_command.c | 21 ++++++++++++++++--- src/qemu/qemu_validate.c | 6 ++++-- .../disk-sata-device.x86_64-latest.args | 2 +- tests/qemuxml2argvdata/disk-sata-device.xml | 2 ++ ...csi-disk-vpd-build-error.x86_64-latest.err | 2 +- .../disk-sata-device.x86_64-latest.xml | 2 ++ 6 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ad224571f3..903872091f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1943,8 +1943,6 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, "p:physical_block_size", physical_block_size, "A:wwn", &wwn, "p:rotation_rate", disk->rotation_rate, - "S:vendor", disk->vendor, - "S:product", disk->product, "T:removable", removable, "S:write-cache", qemuOnOffAuto(writeCache), "p:cyls", disk->geometry.cylinders, @@ -1956,7 +1954,24 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, "S:rerror", rpolicy, NULL) < 0) return NULL; - + if (disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_SCSI) { + /* add vendor and product in SCSI section, since only SCSI supports + * vendor and product tag*/ + if (virJSONValueObjectAdd(&props, + "S:vendor", disk->vendor, + "S:product", disk->product, + NULL) < 0) + return NULL; + } + if (disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_IDE || disk->bus =3D=3D VIR_D= OMAIN_DISK_BUS_SATA) { + /* Repurpose vendor and product, since IDE-Disk only supports mode= l, + * which per ATAPI spec is the combination of vendor and product + * separated by a single space*/ + if (virJSONValueObjectAdd(&props, + "S:model", g_strconcat(disk->vendor, " ", disk->product, N= ULL), + NULL) < 0) + return NULL; + } return g_steal_pointer(&props); } =20 diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 7e09e2c52f..e7312bf789 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2871,9 +2871,11 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDom= ainDiskDef *disk, } =20 if (disk->vendor || disk->product) { - if (disk->bus !=3D VIR_DOMAIN_DISK_BUS_SCSI) { + if (disk->bus !=3D VIR_DOMAIN_DISK_BUS_SCSI + && disk->bus !=3D VIR_DOMAIN_DISK_BUS_IDE + && disk->bus !=3D VIR_DOMAIN_DISK_BUS_SATA) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Only scsi disk supports vendor and product")= ); + _("Only scsi, sata and ide disk supports vendor= and product")); return -1; } =20 diff --git a/tests/qemuxml2argvdata/disk-sata-device.x86_64-latest.args b/t= ests/qemuxml2argvdata/disk-sata-device.x86_64-latest.args index b60d9b16d4..296f8f1ee0 100644 --- a/tests/qemuxml2argvdata/disk-sata-device.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-sata-device.x86_64-latest.args @@ -30,7 +30,7 @@ XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGue= st1/.config \ -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","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw= ","file":"libvirt-1-storage"}' \ --device '{"driver":"ide-hd","bus":"sata0.0","drive":"libvirt-1-format","id= ":"sata0-0-0","bootindex":1}' \ +-device '{"driver":"ide-hd","bus":"sata0.0","drive":"libvirt-1-format","id= ":"sata0-0-0","bootindex":1,"model":"Seagate ST3500418AS"}' \ -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 \ diff --git a/tests/qemuxml2argvdata/disk-sata-device.xml b/tests/qemuxml2ar= gvdata/disk-sata-device.xml index a9def2923e..51eb472dcc 100644 --- a/tests/qemuxml2argvdata/disk-sata-device.xml +++ b/tests/qemuxml2argvdata/disk-sata-device.xml @@ -19,6 +19,8 @@
+ Seagate + ST3500418AS diff --git a/tests/qemuxml2argvdata/disk-scsi-disk-vpd-build-error.x86_64-l= atest.err b/tests/qemuxml2argvdata/disk-scsi-disk-vpd-build-error.x86_64-la= test.err index f70b7a774f..fd77b3feb0 100644 --- a/tests/qemuxml2argvdata/disk-scsi-disk-vpd-build-error.x86_64-latest.e= rr +++ b/tests/qemuxml2argvdata/disk-scsi-disk-vpd-build-error.x86_64-latest.e= rr @@ -1 +1 @@ -unsupported configuration: Only scsi disk supports vendor and product +unsupported configuration: Only scsi, sata and ide disk supports vendor an= d product diff --git a/tests/qemuxml2xmloutdata/disk-sata-device.x86_64-latest.xml b/= tests/qemuxml2xmloutdata/disk-sata-device.x86_64-latest.xml index cd20f5185b..6caedf66a5 100644 --- a/tests/qemuxml2xmloutdata/disk-sata-device.x86_64-latest.xml +++ b/tests/qemuxml2xmloutdata/disk-sata-device.x86_64-latest.xml @@ -21,6 +21,8 @@ + Seagate + ST3500418AS
--=20 2.41.0