[PATCH] Added support for vendor and product for qemu ide-hd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 model number is built by
combining the vendor and the product fields with a single space as separator 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 product to it.
The tests got changed to incorporate the new error message which now contains that the ide and
sata bus also supports vendor and product. Also the xml to command line tests 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 the ide and sata bus.

Signed-off-by: Benedek Major <benedek@xxxxxxxxx>
---
 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 == 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 == VIR_DOMAIN_DISK_BUS_IDE || disk->bus == VIR_DOMAIN_DISK_BUS_SATA) {
+        /* Repurpose vendor and product, since IDE-Disk only supports model,
+         * 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, NULL),
+                NULL) < 0)
+        return NULL;
+    }
     return g_steal_pointer(&props);
 }
 
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 virDomainDiskDef *disk,
     }
 
     if (disk->vendor || disk->product) {
-        if (disk->bus != VIR_DOMAIN_DISK_BUS_SCSI) {
+        if (disk->bus != VIR_DOMAIN_DISK_BUS_SCSI
+            && disk->bus != VIR_DOMAIN_DISK_BUS_IDE
+            && disk->bus != 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;
         }
 
diff --git a/tests/qemuxml2argvdata/disk-sata-device.x86_64-latest.args b/tests/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=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
 -device '{"driver":"ahci","id":"sata0","bus":"pci.0","addr":"0x2"}' \
 -blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUG uest1","node-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","addr":"0x3"}' \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
diff --git a/tests/qemuxml2argvdata/disk-sata-device.xml b/tests/qemuxml2argvdata/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 @@
       <source dev='/dev/HostVG/QEMUG uest1'/>
       <target dev='sda' bus='sata'/>
       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+      <vendor>Seagate</vendor>
+      <product>ST3500418AS</product>
     </disk>
     <controller type='usb' index='0'/>
     <controller type='sata' index='0'/>
diff --git a/tests/qemuxml2argvdata/disk-scsi-disk-vpd-build-error.x86_64-latest.err b/tests/qemuxml2argvdata/disk-scsi-disk-vpd-build-error.x86_64-latest.err
index f70b7a774f..fd77b3feb0 100644
--- a/tests/qemuxml2argvdata/disk-scsi-disk-vpd-build-error.x86_64-latest.err
+++ b/tests/qemuxml2argvdata/disk-scsi-disk-vpd-build-error.x86_64-latest.err
@@ -1 +1 @@
-unsupported configuration: Only scsi disk supports vendor and product
+unsupported configuration: Only scsi, sata and ide disk supports vendor and 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 @@
       <driver name='qemu' type='raw'/>
       <source dev='/dev/HostVG/QEMUG uest1'/>
       <target dev='sda' bus='sata'/>
+      <vendor>Seagate</vendor>
+      <product>ST3500418AS</product>
       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
     </disk>
     <controller type='usb' index='0' model='piix3-uhci'>
-- 
2.41.0





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux